blob: 49caaf7ba3155f81ef4d9d872951f69fd27c2f3b [file] [edit]
<!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.",
async test() {
let sessionStartedEvent = WI.consoleManager.awaitEvent(WI.ConsoleManager.Event.SessionStarted) // , {timestamp, wasReloaded}
let consoleClearedEvent = WI.consoleManager.awaitEvent(WI.ConsoleManager.Event.Cleared);
InspectorTest.reloadPage();
let sessionStartedEventData = (await sessionStartedEvent).data;
InspectorTest.log("Received `WI.ConsoleManager.Event.SessionStarted` event.");
InspectorTest.expectTrue(sessionStartedEventData.wasReloaded, "Expected `WI.ConsoleManager.Event.SessionStarted` to be a reload-based session start.");
await consoleClearedEvent;
InspectorTest.log("Received `WI.ConsoleManager.Event.Cleared` event.");
}
});
suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="runTest()">
<p>Test for the Console.messagesCleared event.</p>
</body>
</html>