blob: 6d4283a3172c33eda10f62ff20bf30e5e82b0fb2 [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(`Test that console.log() would linkify its location in respect with ignore-listing.\n`);
await TestRunner.loadModule('console_test_runner');
await TestRunner.showPanel('console');
await TestRunner.evaluateInPagePromise(`
function foo()
{
console.trace(239);
}
//# sourceURL=foo.js
`);
await TestRunner.evaluateInPagePromise(`
function boo()
{
foo();
}
//# sourceURL=boo.js
`);
TestRunner.evaluateInPage('boo()', step1);
async function step1() {
await dumpConsoleMessageURLs();
TestRunner.addSniffer(Bindings.IgnoreListManager.prototype, '_patternChangeFinishedForTests', step2);
var frameworkRegexString = 'foo\\.js';
Common.settingForTest('skipStackFramesPattern').set(frameworkRegexString);
}
async function step2() {
await dumpConsoleMessageURLs();
TestRunner.addSniffer(Bindings.IgnoreListManager.prototype, '_patternChangeFinishedForTests', step3);
var frameworkRegexString = 'foo\\.js|boo\\.js';
Common.settingForTest('skipStackFramesPattern').set(frameworkRegexString);
}
async function step3() {
await dumpConsoleMessageURLs();
TestRunner.addSniffer(Bindings.IgnoreListManager.prototype, '_patternChangeFinishedForTests', step4);
var frameworkRegexString = '';
Common.settingForTest('skipStackFramesPattern').set(frameworkRegexString);
}
async function step4() {
await dumpConsoleMessageURLs();
TestRunner.completeTest();
}
async function dumpConsoleMessageURLs() {
var messages = Console.ConsoleView.instance()._visibleViewMessages;
for (var i = 0; i < messages.length; ++i) {
// Ordering is important here. Retrieveing the message element the first time triggers
// live location creation and updates, which we need to await for correct locations.
var element = messages[i].element();
await TestRunner.waitForPendingLiveLocationUpdates();
var anchor = element.querySelector('.console-message-anchor');
TestRunner.addResult(anchor.textContent.replace(/VM\d+/g, 'VM'));
}
}
})();