blob: 29d937e0d53f38c22097f31bfda56135bbae7ea7 [file] [log] [blame]
<!doctype html>
<html>
<head>
<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
<script>
function test()
{
let suite = InspectorTest.createAsyncSuite("Console.messagesCleared");
suite.addTestCase({
name: "ClearViaConsoleClearMessagesAPI",
description: "Calling Console.clearMessages should trigger Console.messagesCleared.",
test(resolve, reject) {
WI.consoleManager.awaitEvent(WI.ConsoleManager.Event.Cleared)
.then((event) => {
InspectorTest.expectThat(event, "Cleared event should fire.");
})
.then(resolve, reject);
ConsoleAgent.clearMessages();
}
});
suite.addTestCase({
name: "ClearViaConsoleAPI",
description: "Calling console.clear() should trigger Console.messagesCleared.",
test(resolve, reject) {
WI.consoleManager.awaitEvent(WI.ConsoleManager.Event.Cleared)
.then((event) => {
InspectorTest.expectThat(event, "Cleared event should fire.");
})
.then(resolve, reject);
InspectorTest.evaluateInPage("console.clear()");
}
});
suite.addTestCase({
name: "ClearViaCommandLineAPI",
description: "Calling `clear()` in the command line API should trigger Console.messagesCleared.",
test(resolve, reject) {
WI.consoleManager.awaitEvent(WI.ConsoleManager.Event.Cleared)
.then((event) => {
InspectorTest.expectThat(event, "Cleared event should fire.");
})
.then(resolve, reject);
WI.runtimeManager.evaluateInInspectedWindow("clear()", {objectGroup: "test", includeCommandLineAPI: true}, function(){});
}
});
suite.addTestCase({
name: "ClearViaPageReload",
description: "Reloading the page should trigger Console.messagesCleared.",
test(resolve, reject) {
WI.consoleManager.awaitEvent(WI.ConsoleManager.Event.Cleared)
.then((event) => {
InspectorTest.expectThat(event, "Cleared event should fire.");
})
.then(resolve, reject);
InspectorTest.reloadPage();
}
});
suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="runTest()">
<p>Test for the Console.messagesCleared event.</p>
</body>
</html>