blob: cfbb24eb1ae2ee82ec2684952f0086a4c46ef463 [file] [log] [blame]
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(async function() {
TestRunner.addResult(`Tests that console is cleared via console.clear() method\n`);
await TestRunner.loadModule('console_test_runner');
await TestRunner.showPanel('console');
await TestRunner.evaluateInPagePromise(`
function log()
{
// Fill console.
console.log("one");
console.log("two");
console.log("three");
}
function clearConsoleFromPage()
{
console.clear();
}
`);
TestRunner.runTestSuite([
async function clearFromConsoleAPI(next) {
await TestRunner.RuntimeAgent.evaluate('log();');
TestRunner.addResult('=== Before clear ===');
await ConsoleTestRunner.dumpConsoleMessages();
await TestRunner.RuntimeAgent.evaluate('clearConsoleFromPage();');
TestRunner.addResult('=== After clear ===');
await ConsoleTestRunner.dumpConsoleMessages();
next();
},
async function shouldNotClearWithPreserveLog(next) {
await TestRunner.RuntimeAgent.evaluate('log();');
TestRunner.addResult('=== Before clear ===');
await ConsoleTestRunner.dumpConsoleMessages();
Common.moduleSetting('preserveConsoleLog').set(true);
await TestRunner.RuntimeAgent.evaluate('clearConsoleFromPage();');
TestRunner.addResult('=== After clear ===');
await ConsoleTestRunner.dumpConsoleMessages();
Common.moduleSetting('preserveConsoleLog').set(false);
next();
}
]);
})();