Commit 89b99696 authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

Prepare remaining console web tests for asynchronous source mapping

This CL adds async/await to the remaining web tests in
http/tests/devtools/console for the upcoming source map asyncification.

The CL also adds a few live location sync points where necessary. This
generally happens right after console message rendering is triggered.
Before the console message is logged, all pending live location
updates need to be {await}ed, as these will happen asynchronous in
the future.

Note: console-uncaught-promise.js is re-baselined as the test output
contains a stack trace with a frame from the test script itself.
As the test moves around some code, we also require a new baseline
reflecting those changes.

Bug: chromium:1032016
Change-Id: I57e5708038f4978b903080e5699afcab4e3f5b05
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2066856
Commit-Queue: Simon Zünd <szuend@chromium.org>
Reviewed-by: default avatarMathias Bynens <mathias@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743914}
parent 445d777b
...@@ -20,11 +20,13 @@ ...@@ -20,11 +20,13 @@
var consoleView = Console.ConsoleView.instance(); var consoleView = Console.ConsoleView.instance();
var viewport = consoleView._viewport; var viewport = consoleView._viewport;
TestRunner.runTestSuite([function testSelectAll(next) { TestRunner.runTestSuite([async function testSelectAll(next) {
viewport.forceScrollItemToBeFirst(0); viewport.forceScrollItemToBeFirst(0);
// Set some initial selection in console. // Set some initial selection in console.
var base = consoleView.itemElement(0).element(); var base = consoleView.itemElement(0).element();
// Console messages contain live locations.
await TestRunner.waitForPendingLiveLocationUpdates();
window.getSelection().setBaseAndExtent(base, 0, base, 1); window.getSelection().setBaseAndExtent(base, 0, base, 1);
// Try to select all messages. // Try to select all messages.
......
...@@ -34,67 +34,67 @@ ...@@ -34,67 +34,67 @@
var secondLongUrlIndexInMixedUrl; var secondLongUrlIndexInMixedUrl;
var tests = [ var tests = [
function testSelectWithinTruncatedUrl(next) { async function testSelectWithinTruncatedUrl(next) {
makeSelectionAndDump(1, 0, 1, halfMaxLength); await makeSelectionAndDump(1, 0, 1, halfMaxLength);
makeSelectionAndDump(1, 0, 1, halfMaxLength + 1); await makeSelectionAndDump(1, 0, 1, halfMaxLength + 1);
makeSelectionAndDump(1, 0, 1, maxLength); await makeSelectionAndDump(1, 0, 1, maxLength);
makeSelectionAndDump(1, halfMaxLength, 1, halfMaxLength + 1); await makeSelectionAndDump(1, halfMaxLength, 1, halfMaxLength + 1);
makeSelectionAndDump(1, halfMaxLength, 1, maxLength); await makeSelectionAndDump(1, halfMaxLength, 1, maxLength);
makeSelectionAndDump(1, halfMaxLength + 1, 1, maxLength); await makeSelectionAndDump(1, halfMaxLength + 1, 1, maxLength);
next(); next();
}, },
function testSelectAcrossMultipleMessages(next) { async function testSelectAcrossMultipleMessages(next) {
makeSelectionAndDump(1, 0, 2, shortUrl.length); await makeSelectionAndDump(1, 0, 2, shortUrl.length);
makeSelectionAndDump(1, halfMaxLength, 2, shortUrl.length); await makeSelectionAndDump(1, halfMaxLength, 2, shortUrl.length);
makeSelectionAndDump(1, halfMaxLength + 1, 2, shortUrl.length); await makeSelectionAndDump(1, halfMaxLength + 1, 2, shortUrl.length);
next(); next();
}, },
function testSelectAcrossMultipleMessagesWithTruncatedUrls(next) { async function testSelectAcrossMultipleMessagesWithTruncatedUrls(next) {
makeSelectionAndDump(1, 0, 3, halfMaxLength); await makeSelectionAndDump(1, 0, 3, halfMaxLength);
makeSelectionAndDump(1, 0, 3, halfMaxLength + 1); await makeSelectionAndDump(1, 0, 3, halfMaxLength + 1);
makeSelectionAndDump(1, 0, 3, maxLength); await makeSelectionAndDump(1, 0, 3, maxLength);
next(); next();
}, },
function testSelectWithinMessageWithMultipleTruncatedUrls(next) { async function testSelectWithinMessageWithMultipleTruncatedUrls(next) {
makeSelectionAndDump(4, 0, 4, halfMaxLength); await makeSelectionAndDump(4, 0, 4, halfMaxLength);
makeSelectionAndDump(4, 0, 4, halfMaxLength + 1); await makeSelectionAndDump(4, 0, 4, halfMaxLength + 1);
makeSelectionAndDump(4, 0, 4, secondLongUrlIndexInMixedUrl); await makeSelectionAndDump(4, 0, 4, secondLongUrlIndexInMixedUrl);
makeSelectionAndDump(4, 0, 4, secondLongUrlIndexInMixedUrl + halfMaxLength); await makeSelectionAndDump(4, 0, 4, secondLongUrlIndexInMixedUrl + halfMaxLength);
makeSelectionAndDump(4, 0, 4, secondLongUrlIndexInMixedUrl + halfMaxLength + 1); await makeSelectionAndDump(4, 0, 4, secondLongUrlIndexInMixedUrl + halfMaxLength + 1);
makeSelectionAndDump(4, 0, 4, secondLongUrlIndexInMixedUrl + maxLength); await makeSelectionAndDump(4, 0, 4, secondLongUrlIndexInMixedUrl + maxLength);
makeSelectionAndDump(4, halfMaxLength, 4, halfMaxLength + 1); await makeSelectionAndDump(4, halfMaxLength, 4, halfMaxLength + 1);
makeSelectionAndDump(4, halfMaxLength, 4, secondLongUrlIndexInMixedUrl); await makeSelectionAndDump(4, halfMaxLength, 4, secondLongUrlIndexInMixedUrl);
makeSelectionAndDump(4, halfMaxLength, 4, secondLongUrlIndexInMixedUrl + halfMaxLength); await makeSelectionAndDump(4, halfMaxLength, 4, secondLongUrlIndexInMixedUrl + halfMaxLength);
makeSelectionAndDump(4, halfMaxLength, 4, secondLongUrlIndexInMixedUrl + halfMaxLength + 1); await makeSelectionAndDump(4, halfMaxLength, 4, secondLongUrlIndexInMixedUrl + halfMaxLength + 1);
makeSelectionAndDump(4, halfMaxLength, 4, secondLongUrlIndexInMixedUrl + maxLength); await makeSelectionAndDump(4, halfMaxLength, 4, secondLongUrlIndexInMixedUrl + maxLength);
makeSelectionAndDump(4, halfMaxLength + 1, 4, secondLongUrlIndexInMixedUrl); await makeSelectionAndDump(4, halfMaxLength + 1, 4, secondLongUrlIndexInMixedUrl);
makeSelectionAndDump(4, halfMaxLength + 1, 4, secondLongUrlIndexInMixedUrl + halfMaxLength); await makeSelectionAndDump(4, halfMaxLength + 1, 4, secondLongUrlIndexInMixedUrl + halfMaxLength);
makeSelectionAndDump(4, halfMaxLength + 1, 4, secondLongUrlIndexInMixedUrl + halfMaxLength + 1); await makeSelectionAndDump(4, halfMaxLength + 1, 4, secondLongUrlIndexInMixedUrl + halfMaxLength + 1);
makeSelectionAndDump(4, halfMaxLength + 1, 4, secondLongUrlIndexInMixedUrl + maxLength); await makeSelectionAndDump(4, halfMaxLength + 1, 4, secondLongUrlIndexInMixedUrl + maxLength);
makeSelectionAndDump(4, secondLongUrlIndexInMixedUrl, 4, secondLongUrlIndexInMixedUrl + halfMaxLength); await makeSelectionAndDump(4, secondLongUrlIndexInMixedUrl, 4, secondLongUrlIndexInMixedUrl + halfMaxLength);
makeSelectionAndDump(4, secondLongUrlIndexInMixedUrl, 4, secondLongUrlIndexInMixedUrl + halfMaxLength + 1); await makeSelectionAndDump(4, secondLongUrlIndexInMixedUrl, 4, secondLongUrlIndexInMixedUrl + halfMaxLength + 1);
makeSelectionAndDump(4, secondLongUrlIndexInMixedUrl, 4, secondLongUrlIndexInMixedUrl + maxLength); await makeSelectionAndDump(4, secondLongUrlIndexInMixedUrl, 4, secondLongUrlIndexInMixedUrl + maxLength);
makeSelectionAndDump( await makeSelectionAndDump(
4, 4,
secondLongUrlIndexInMixedUrl + halfMaxLength, secondLongUrlIndexInMixedUrl + halfMaxLength,
4, 4,
secondLongUrlIndexInMixedUrl + halfMaxLength + 1 secondLongUrlIndexInMixedUrl + halfMaxLength + 1
); );
makeSelectionAndDump( await makeSelectionAndDump(
4, 4,
secondLongUrlIndexInMixedUrl + halfMaxLength, secondLongUrlIndexInMixedUrl + halfMaxLength,
4, 4,
secondLongUrlIndexInMixedUrl + maxLength secondLongUrlIndexInMixedUrl + maxLength
); );
makeSelectionAndDump( await makeSelectionAndDump(
4, 4,
secondLongUrlIndexInMixedUrl + halfMaxLength + 1, secondLongUrlIndexInMixedUrl + halfMaxLength + 1,
4, 4,
...@@ -103,24 +103,24 @@ ...@@ -103,24 +103,24 @@
next(); next();
}, },
function testSelectWithinShortUrlWithHashes(next) { async function testSelectWithinShortUrlWithHashes(next) {
var hashedUrlMaxLength = consoleMessageText(5).length; var hashedUrlMaxLength = consoleMessageText(5).length;
var hashedUrlHalfMaxLength = Math.ceil(hashedUrlMaxLength / 2); var hashedUrlHalfMaxLength = Math.ceil(hashedUrlMaxLength / 2);
makeSelectionAndDump(5, 0, 5, hashedUrlHalfMaxLength); await makeSelectionAndDump(5, 0, 5, hashedUrlHalfMaxLength);
makeSelectionAndDump(5, 0, 5, hashedUrlMaxLength); await makeSelectionAndDump(5, 0, 5, hashedUrlMaxLength);
makeSelectionAndDump(5, hashedUrlHalfMaxLength, 5, hashedUrlMaxLength); await makeSelectionAndDump(5, hashedUrlHalfMaxLength, 5, hashedUrlMaxLength);
next(); next();
}, },
function testSelectWithinUrlWithHashes(next) { async function testSelectWithinUrlWithHashes(next) {
var hashedUrlMaxLength = consoleMessageText(6).length; var hashedUrlMaxLength = consoleMessageText(6).length;
var hashedUrlHalfMaxLength = Math.ceil(hashedUrlMaxLength / 2); var hashedUrlHalfMaxLength = Math.ceil(hashedUrlMaxLength / 2);
makeSelectionAndDump(6, 0, 6, hashedUrlHalfMaxLength); await makeSelectionAndDump(6, 0, 6, hashedUrlHalfMaxLength);
makeSelectionAndDump(6, 0, 6, hashedUrlHalfMaxLength + 1); await makeSelectionAndDump(6, 0, 6, hashedUrlHalfMaxLength + 1);
makeSelectionAndDump(6, 0, 6, hashedUrlMaxLength); await makeSelectionAndDump(6, 0, 6, hashedUrlMaxLength);
makeSelectionAndDump(6, hashedUrlHalfMaxLength, 6, hashedUrlHalfMaxLength + 1); await makeSelectionAndDump(6, hashedUrlHalfMaxLength, 6, hashedUrlHalfMaxLength + 1);
makeSelectionAndDump(6, hashedUrlHalfMaxLength, 6, hashedUrlMaxLength); await makeSelectionAndDump(6, hashedUrlHalfMaxLength, 6, hashedUrlMaxLength);
makeSelectionAndDump(6, hashedUrlHalfMaxLength + 1, 6, hashedUrlMaxLength); await makeSelectionAndDump(6, hashedUrlHalfMaxLength + 1, 6, hashedUrlMaxLength);
next(); next();
}, },
...@@ -137,12 +137,12 @@ ...@@ -137,12 +137,12 @@
} }
]; ];
ConsoleTestRunner.waitForConsoleMessages(expectedMessageCount, () => { ConsoleTestRunner.waitForConsoleMessages(expectedMessageCount, async () => {
viewport.invalidate(); viewport.invalidate();
// Get the max truncated length from the first longUrl logged. // Get the max truncated length from the first longUrl logged.
try { try {
var longUrlMessageText = consoleMessageText(1); var longUrlMessageText = await consoleMessageText(1);
maxLength = longUrlMessageText.length; maxLength = longUrlMessageText.length;
halfMaxLength = Math.ceil(maxLength / 2); halfMaxLength = Math.ceil(maxLength / 2);
secondLongUrlIndexInMixedUrl = maxLength + 1 + shortUrl.length + 1; secondLongUrlIndexInMixedUrl = maxLength + 1 + shortUrl.length + 1;
...@@ -161,17 +161,21 @@ ...@@ -161,17 +161,21 @@
return messageElement.querySelector('.console-message-text').deepTextContent(); return messageElement.querySelector('.console-message-text').deepTextContent();
} }
function makeSelectionAndDump(fromMessage, fromTextOffset, toMessage, toTextOffset) { async function makeSelectionAndDump(fromMessage, fromTextOffset, toMessage, toTextOffset) {
TestRunner.addResult( TestRunner.addResult(
'\nMaking selection: ' + fromMessage + ', ' + fromTextOffset + ', ' + toMessage + ', ' + toTextOffset '\nMaking selection: ' + fromMessage + ', ' + fromTextOffset + ', ' + toMessage + ', ' + toTextOffset
); );
// Ignore the anchor text on the start/end message, just use their contents. // Ignore the anchor text on the start/end message, just use their contents.
var fromAnchor = consoleView.itemElement(fromMessage).element().querySelector('.console-message-anchor'); const fromElement = consoleView.itemElement(fromMessage).element();
var toAnchor = consoleView.itemElement(toMessage).element().querySelector('.console-message-anchor'); const toElement = consoleView.itemElement(toMessage).element();
// Console message elements contain live locations.
await TestRunner.waitForPendingLiveLocationUpdates();
var fromAnchor = fromElement.querySelector('.console-message-anchor');
var toAnchor = toElement.querySelector('.console-message-anchor');
fromTextOffset += fromAnchor ? fromAnchor.deepTextContent().length : 0; fromTextOffset += fromAnchor ? fromAnchor.deepTextContent().length : 0;
toTextOffset += toAnchor ? toAnchor.deepTextContent().length : 0; toTextOffset += toAnchor ? toAnchor.deepTextContent().length : 0;
ConsoleTestRunner.selectConsoleMessages(fromMessage, fromTextOffset, toMessage, toTextOffset); await ConsoleTestRunner.selectConsoleMessages(fromMessage, fromTextOffset, toMessage, toTextOffset);
var selectedText = viewport._selectedText(); var selectedText = viewport._selectedText();
if (selectedText) { if (selectedText) {
selectedText = selectedText.replace(/\bVM\d+/g, 'VM'); selectedText = selectedText.replace(/\bVM\d+/g, 'VM');
...@@ -189,7 +193,7 @@ ...@@ -189,7 +193,7 @@
consoleView._searchableView.showSearchField(); consoleView._searchableView.showSearchField();
TestRunner.addResult('Searching for text: ' + query); TestRunner.addResult('Searching for text: ' + query);
function onSearch() { async function onSearch() {
var matches = consoleView.element var matches = consoleView.element
.childTextNodes() .childTextNodes()
.filter(node => node.parentElement.classList.contains('highlighted-search-result')) .filter(node => node.parentElement.classList.contains('highlighted-search-result'))
...@@ -197,12 +201,12 @@ ...@@ -197,12 +201,12 @@
TestRunner.addResult('Highlighted ' + matches.length + ' matches'); TestRunner.addResult('Highlighted ' + matches.length + ' matches');
// Use TextNodes for containers to get inside the highlighted match element. // Use TextNodes for containers to get inside the highlighted match element.
makeSelectionAndDump(7, 0, 7, halfMaxLength); await makeSelectionAndDump(7, 0, 7, halfMaxLength);
makeSelectionAndDump(7, 0, 7, halfMaxLength + 1); await makeSelectionAndDump(7, 0, 7, halfMaxLength + 1);
makeSelectionAndDump(7, 0, 7, maxLength); await makeSelectionAndDump(7, 0, 7, maxLength);
makeSelectionAndDump(7, halfMaxLength, 7, halfMaxLength + 1); await makeSelectionAndDump(7, halfMaxLength, 7, halfMaxLength + 1);
makeSelectionAndDump(7, halfMaxLength, 7, maxLength); await makeSelectionAndDump(7, halfMaxLength, 7, maxLength);
makeSelectionAndDump(7, halfMaxLength + 1, 7, maxLength); await makeSelectionAndDump(7, halfMaxLength + 1, 7, maxLength);
next(); next();
} }
} }
......
...@@ -26,13 +26,18 @@ ...@@ -26,13 +26,18 @@
if (consoleView._isSidebarOpen) if (consoleView._isSidebarOpen)
consoleView._splitWidget._showHideSidebarButton.element.click(); consoleView._splitWidget._showHideSidebarButton.element.click();
function dumpVisibleMessages() { async function dumpVisibleMessages() {
var menuText = Console.ConsoleView.instance()._filter._levelMenuButton._text; var menuText = Console.ConsoleView.instance()._filter._levelMenuButton._text;
TestRunner.addResult('Level menu: ' + menuText); TestRunner.addResult('Level menu: ' + menuText);
var messages = Console.ConsoleView.instance()._visibleViewMessages; var messages = Console.ConsoleView.instance()._visibleViewMessages;
for (var i = 0; i < messages.length; i++) for (var i = 0; i < messages.length; i++) {
TestRunner.addResult('>' + messages[i].toMessageElement().deepTextContent()); // Ordering is important here, as accessing the element the first time around
// triggers live location creation and updates which we need to await properly.
const element = messages[i].toMessageElement();
await TestRunner.waitForPendingLiveLocationUpdates();
TestRunner.addResult('>' + element.deepTextContent());
}
} }
var testSuite = [ var testSuite = [
...@@ -46,59 +51,50 @@ ...@@ -46,59 +51,50 @@
function beforeFilter(next) { function beforeFilter(next) {
TestRunner.addResult('beforeFilter'); TestRunner.addResult('beforeFilter');
dumpVisibleMessages(); dumpVisibleMessages().then(next);
next();
}, },
function allLevels(next) { function allLevels(next) {
Console.ConsoleViewFilter.levelFilterSetting().set(Console.ConsoleFilter.allLevelsFilterValue()); Console.ConsoleViewFilter.levelFilterSetting().set(Console.ConsoleFilter.allLevelsFilterValue());
dumpVisibleMessages(); dumpVisibleMessages().then(next);
next();
}, },
function defaultLevels(next) { function defaultLevels(next) {
Console.ConsoleViewFilter.levelFilterSetting().set(Console.ConsoleFilter.defaultLevelsFilterValue()); Console.ConsoleViewFilter.levelFilterSetting().set(Console.ConsoleFilter.defaultLevelsFilterValue());
dumpVisibleMessages(); dumpVisibleMessages().then(next);
next();
}, },
function verbose(next) { function verbose(next) {
Console.ConsoleViewFilter.levelFilterSetting().set({ verbose: true }); Console.ConsoleViewFilter.levelFilterSetting().set({ verbose: true });
dumpVisibleMessages(); dumpVisibleMessages().then(next);
next();
}, },
function info(next) { function info(next) {
Console.ConsoleViewFilter.levelFilterSetting().set({ info: true }); Console.ConsoleViewFilter.levelFilterSetting().set({ info: true });
dumpVisibleMessages(); dumpVisibleMessages().then(next);
next();
}, },
function warningsAndErrors(next) { function warningsAndErrors(next) {
Console.ConsoleViewFilter.levelFilterSetting().set({ warning: true, error: true }); Console.ConsoleViewFilter.levelFilterSetting().set({ warning: true, error: true });
dumpVisibleMessages(); dumpVisibleMessages().then(next);
next();
}, },
function abcMessagePlain(next) { function abcMessagePlain(next) {
Console.ConsoleViewFilter.levelFilterSetting().set({ verbose: true }); Console.ConsoleViewFilter.levelFilterSetting().set({ verbose: true });
Console.ConsoleView.instance()._filter._textFilterUI.setValue('abc'); Console.ConsoleView.instance()._filter._textFilterUI.setValue('abc');
Console.ConsoleView.instance()._filter._onFilterChanged(); Console.ConsoleView.instance()._filter._onFilterChanged();
dumpVisibleMessages(); dumpVisibleMessages().then(next);
next();
}, },
function abcMessageRegex(next) { function abcMessageRegex(next) {
Console.ConsoleView.instance()._filter._textFilterUI.setValue('/ab[a-z]/'); Console.ConsoleView.instance()._filter._textFilterUI.setValue('/ab[a-z]/');
Console.ConsoleView.instance()._filter._onFilterChanged(); Console.ConsoleView.instance()._filter._onFilterChanged();
dumpVisibleMessages(); dumpVisibleMessages().then(next);
next();
}, },
function abcMessageRegexWarning(next) { function abcMessageRegexWarning(next) {
Console.ConsoleViewFilter.levelFilterSetting().set({ warning: true }); Console.ConsoleViewFilter.levelFilterSetting().set({ warning: true });
dumpVisibleMessages(); dumpVisibleMessages().then(next);
next();
} }
]; ];
......
...@@ -60,14 +60,19 @@ ...@@ -60,14 +60,19 @@
var messages = Console.ConsoleView.instance()._visibleViewMessages; var messages = Console.ConsoleView.instance()._visibleViewMessages;
function dumpVisibleMessages() { async function dumpVisibleMessages() {
var messages = Console.ConsoleView.instance()._visibleViewMessages; var messages = Console.ConsoleView.instance()._visibleViewMessages;
for (var i = 0; i < messages.length; ++i) { for (var i = 0; i < messages.length; ++i) {
var viewMessage = messages[i]; var viewMessage = messages[i];
var delimeter = viewMessage.consoleMessage().isGroupStartMessage() ? '>' : ''; var delimeter = viewMessage.consoleMessage().isGroupStartMessage() ? '>' : '';
var indent = ''; var indent = '';
for (var j = 0; j < viewMessage.nestingLevel(); ++j) indent += ' '; for (var j = 0; j < viewMessage.nestingLevel(); ++j) indent += ' ';
TestRunner.addResult(indent + delimeter + viewMessage.toMessageElement().deepTextContent());
// Ordering is important here, as accessing the element the first time around
// triggers live location creation and updates which we need to await properly.
const element = viewMessage.toMessageElement();
await TestRunner.waitForPendingLiveLocationUpdates();
TestRunner.addResult(indent + delimeter + element.deepTextContent());
} }
} }
...@@ -77,84 +82,70 @@ ...@@ -77,84 +82,70 @@
TestRunner.runTestSuite([ TestRunner.runTestSuite([
function beforeFilter(next) { function beforeFilter(next) {
TestRunner.addResult('beforeFilter'); TestRunner.addResult('beforeFilter');
dumpVisibleMessages(); dumpVisibleMessages().then(next);
next();
}, },
function allLevelsFilter(next) { function allLevelsFilter(next) {
Console.ConsoleViewFilter.levelFilterSetting().set(Console.ConsoleFilter.allLevelsFilterValue()); Console.ConsoleViewFilter.levelFilterSetting().set(Console.ConsoleFilter.allLevelsFilterValue());
dumpVisibleMessages(); dumpVisibleMessages().then(next);
next();
}, },
function addURL1Filter(next) { function addURL1Filter(next) {
TestRunner.addResult('Blocking messages from ' + url1); TestRunner.addResult('Blocking messages from ' + url1);
Console.ConsoleView.instance()._filter.addMessageURLFilter(url1); Console.ConsoleView.instance()._filter.addMessageURLFilter(url1);
dumpVisibleMessages(); dumpVisibleMessages().then(next);
next();
}, },
function addURL2Filter(next) { function addURL2Filter(next) {
TestRunner.addResult('Blocking messages from ' + url2); TestRunner.addResult('Blocking messages from ' + url2);
Console.ConsoleView.instance()._filter.addMessageURLFilter(url2); Console.ConsoleView.instance()._filter.addMessageURLFilter(url2);
dumpVisibleMessages(); dumpVisibleMessages().then(next);
next();
}, },
function removeAllFilters(next) { function removeAllFilters(next) {
Console.ConsoleView.instance()._filter._textFilterUI.setValue(''); Console.ConsoleView.instance()._filter._textFilterUI.setValue('');
Console.ConsoleView.instance()._filter._onFilterChanged(); Console.ConsoleView.instance()._filter._onFilterChanged();
dumpVisibleMessages(); dumpVisibleMessages().then(next);
next();
}, },
function checkTextFilter(next) { function checkTextFilter(next) {
Console.ConsoleView.instance()._filter._textFilterUI.setValue('outer'); Console.ConsoleView.instance()._filter._textFilterUI.setValue('outer');
Console.ConsoleView.instance()._filter._onFilterChanged(); Console.ConsoleView.instance()._filter._onFilterChanged();
dumpVisibleMessages(); dumpVisibleMessages().then(next);
next();
}, },
function checkMultiTextFilter(next) { function checkMultiTextFilter(next) {
Console.ConsoleView.instance()._filter._textFilterUI.setValue("Group /[2-3]top/"); Console.ConsoleView.instance()._filter._textFilterUI.setValue("Group /[2-3]top/");
Console.ConsoleView.instance()._filter._onFilterChanged(); Console.ConsoleView.instance()._filter._onFilterChanged();
dumpVisibleMessages(); dumpVisibleMessages().then(next);
next();
}, },
function checkTextUrlFilter(next) { function checkTextUrlFilter(next) {
Console.ConsoleView.instance()._filter._textFilterUI.setValue("url:log-source"); Console.ConsoleView.instance()._filter._textFilterUI.setValue("url:log-source");
Console.ConsoleView.instance()._filter._onFilterChanged(); Console.ConsoleView.instance()._filter._onFilterChanged();
dumpVisibleMessages(); dumpVisibleMessages().then(next);
next();
}, },
function checkNegativeTextUrlFilter(next) { function checkNegativeTextUrlFilter(next) {
Console.ConsoleView.instance()._filter._textFilterUI.setValue("-url:log-source"); Console.ConsoleView.instance()._filter._textFilterUI.setValue("-url:log-source");
Console.ConsoleView.instance()._filter._onFilterChanged(); Console.ConsoleView.instance()._filter._onFilterChanged();
dumpVisibleMessages(); dumpVisibleMessages().then(next);
next();
}, },
function checkSourceFilter(next) { function checkSourceFilter(next) {
Console.ConsoleView.instance()._filter._textFilterUI.setValue("source:violation"); Console.ConsoleView.instance()._filter._textFilterUI.setValue("source:violation");
Console.ConsoleView.instance()._filter._onFilterChanged(); Console.ConsoleView.instance()._filter._onFilterChanged();
dumpVisibleMessages(); dumpVisibleMessages().then(next);
next();
}, },
function checkContextTextFilter(next) { function checkContextTextFilter(next) {
Console.ConsoleView.instance()._filter._textFilterUI.setValue("context:context"); Console.ConsoleView.instance()._filter._textFilterUI.setValue("context:context");
Console.ConsoleView.instance()._filter._onFilterChanged(); Console.ConsoleView.instance()._filter._onFilterChanged();
dumpVisibleMessages(); dumpVisibleMessages().then(next);
next();
}, },
function checkStartEndLineRegex(next) { function checkStartEndLineRegex(next) {
Console.ConsoleView.instance()._filter._textFilterUI.setValue("/^Hello\\s\\d$/"); Console.ConsoleView.instance()._filter._textFilterUI.setValue("/^Hello\\s\\d$/");
Console.ConsoleView.instance()._filter._onFilterChanged(); Console.ConsoleView.instance()._filter._onFilterChanged();
dumpVisibleMessages(); dumpVisibleMessages().then(next);
next();
}, },
function checkStartEndLineRegexForAnchor(next) { function checkStartEndLineRegexForAnchor(next) {
Console.ConsoleView.instance()._filter._textFilterUI.setValue("/^log-source\\.js:\\d+$/"); Console.ConsoleView.instance()._filter._textFilterUI.setValue("/^log-source\\.js:\\d+$/");
Console.ConsoleView.instance()._filter._onFilterChanged(); Console.ConsoleView.instance()._filter._onFilterChanged();
dumpVisibleMessages(); dumpVisibleMessages().then(next);
next();
}, },
function checkResetFilter(next) { function checkResetFilter(next) {
Console.ConsoleView.instance()._filter.reset(); Console.ConsoleView.instance()._filter.reset();
dumpVisibleMessages(); dumpVisibleMessages().then(next);
next();
} }
]); ]);
})(); })();
...@@ -24,37 +24,40 @@ ...@@ -24,37 +24,40 @@
TestRunner.evaluateInPage('boo()', step1); TestRunner.evaluateInPage('boo()', step1);
function step1() { async function step1() {
dumpConsoleMessageURLs(); await dumpConsoleMessageURLs();
TestRunner.addSniffer(Bindings.BlackboxManager.prototype, '_patternChangeFinishedForTests', step2); TestRunner.addSniffer(Bindings.BlackboxManager.prototype, '_patternChangeFinishedForTests', step2);
var frameworkRegexString = 'foo\\.js'; var frameworkRegexString = 'foo\\.js';
Common.settingForTest('skipStackFramesPattern').set(frameworkRegexString); Common.settingForTest('skipStackFramesPattern').set(frameworkRegexString);
} }
function step2() { async function step2() {
dumpConsoleMessageURLs(); await dumpConsoleMessageURLs();
TestRunner.addSniffer(Bindings.BlackboxManager.prototype, '_patternChangeFinishedForTests', step3); TestRunner.addSniffer(Bindings.BlackboxManager.prototype, '_patternChangeFinishedForTests', step3);
var frameworkRegexString = 'foo\\.js|boo\\.js'; var frameworkRegexString = 'foo\\.js|boo\\.js';
Common.settingForTest('skipStackFramesPattern').set(frameworkRegexString); Common.settingForTest('skipStackFramesPattern').set(frameworkRegexString);
} }
function step3() { async function step3() {
dumpConsoleMessageURLs(); await dumpConsoleMessageURLs();
TestRunner.addSniffer(Bindings.BlackboxManager.prototype, '_patternChangeFinishedForTests', step4); TestRunner.addSniffer(Bindings.BlackboxManager.prototype, '_patternChangeFinishedForTests', step4);
var frameworkRegexString = ''; var frameworkRegexString = '';
Common.settingForTest('skipStackFramesPattern').set(frameworkRegexString); Common.settingForTest('skipStackFramesPattern').set(frameworkRegexString);
} }
function step4() { async function step4() {
dumpConsoleMessageURLs(); await dumpConsoleMessageURLs();
TestRunner.completeTest(); TestRunner.completeTest();
} }
function dumpConsoleMessageURLs() { async function dumpConsoleMessageURLs() {
var messages = Console.ConsoleView.instance()._visibleViewMessages; var messages = Console.ConsoleView.instance()._visibleViewMessages;
for (var i = 0; i < messages.length; ++i) { 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].toMessageElement(); var element = messages[i].toMessageElement();
await TestRunner.waitForPendingLiveLocationUpdates();
var anchor = element.querySelector('.console-message-anchor'); var anchor = element.querySelector('.console-message-anchor');
TestRunner.addResult(anchor.textContent.replace(/VM\d+/g, 'VM')); TestRunner.addResult(anchor.textContent.replace(/VM\d+/g, 'VM'));
} }
......
...@@ -12,8 +12,12 @@ ...@@ -12,8 +12,12 @@
var messages = Console.ConsoleView.instance()._visibleViewMessages; var messages = Console.ConsoleView.instance()._visibleViewMessages;
TestRunner.runTestSuite([ TestRunner.runTestSuite([
function testClickRelativeLink(next) { async function testClickRelativeLink(next) {
var clickTarget = messages[0].element().querySelectorAll('.console-message-text .devtools-link')[1]; // Ordering is important here, as accessing the element the first time around
// triggers live location creation and updates which we need to await properly.
const element = messages[0].element();
await TestRunner.waitForPendingLiveLocationUpdates();
const clickTarget = element.querySelectorAll('.console-message-text .devtools-link')[1];
TestRunner.addResult('Clicking link ' + clickTarget.textContent); TestRunner.addResult('Clicking link ' + clickTarget.textContent);
UI.inspectorView._tabbedPane.once(UI.TabbedPane.Events.TabSelected).then(() => { UI.inspectorView._tabbedPane.once(UI.TabbedPane.Events.TabSelected).then(() => {
TestRunner.addResult('Panel ' + UI.inspectorView._tabbedPane._currentTab.id + ' was opened.'); TestRunner.addResult('Panel ' + UI.inspectorView._tabbedPane._currentTab.id + ' was opened.');
......
...@@ -37,7 +37,11 @@ ...@@ -37,7 +37,11 @@
}, },
async function testClickLinkToRevealAnotherPanel(next) { async function testClickLinkToRevealAnotherPanel(next) {
consoleView._visibleViewMessages[0]._element.querySelector('.devtools-link').click(); // Ordering is important here, as accessing the element the first time around
// triggers live location creation and updates which we need to await properly.
const element = consoleView._visibleViewMessages[0]._element;
await TestRunner.waitForPendingLiveLocationUpdates();
element.querySelector('.devtools-link').click();
await UI.inspectorView._tabbedPane.once(UI.TabbedPane.Events.TabSelected); await UI.inspectorView._tabbedPane.once(UI.TabbedPane.Events.TabSelected);
await TestRunner.showPanel('console'); await TestRunner.showPanel('console');
dumpScrollTop(); dumpScrollTop();
......
...@@ -8,7 +8,7 @@ promiseTest1 @ console-uncaught-promise.js:29 ...@@ -8,7 +8,7 @@ promiseTest1 @ console-uncaught-promise.js:29
timeout @ console-uncaught-promise.js:19 timeout @ console-uncaught-promise.js:19
setTimeout (async) setTimeout (async)
runNextPromiseTest @ console-uncaught-promise.js:18 runNextPromiseTest @ console-uncaught-promise.js:18
(anonymous) @ console-uncaught-promise.js:103 (anonymous) @ console-uncaught-promise.js:100
console-uncaught-promise.js:47 Uncaught (in promise) Error: err2 console-uncaught-promise.js:47 Uncaught (in promise) Error: err2
promiseTest2 @ console-uncaught-promise.js:47 promiseTest2 @ console-uncaught-promise.js:47
timeout @ console-uncaught-promise.js:19 timeout @ console-uncaught-promise.js:19
...@@ -23,7 +23,7 @@ promiseTest2 @ console-uncaught-promise.js:40 ...@@ -23,7 +23,7 @@ promiseTest2 @ console-uncaught-promise.js:40
timeout @ console-uncaught-promise.js:19 timeout @ console-uncaught-promise.js:19
setTimeout (async) setTimeout (async)
runNextPromiseTest @ console-uncaught-promise.js:18 runNextPromiseTest @ console-uncaught-promise.js:18
(anonymous) @ console-uncaught-promise.js:106 (anonymous) @ console-uncaught-promise.js:100
console-uncaught-promise.js:65 Uncaught (in promise) DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node. console-uncaught-promise.js:65 Uncaught (in promise) DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
throwDOMException @ console-uncaught-promise.js:65 throwDOMException @ console-uncaught-promise.js:65
catcher @ console-uncaught-promise.js:57 catcher @ console-uncaught-promise.js:57
...@@ -32,25 +32,25 @@ promiseTest3 @ console-uncaught-promise.js:56 ...@@ -32,25 +32,25 @@ promiseTest3 @ console-uncaught-promise.js:56
timeout @ console-uncaught-promise.js:19 timeout @ console-uncaught-promise.js:19
setTimeout (async) setTimeout (async)
runNextPromiseTest @ console-uncaught-promise.js:18 runNextPromiseTest @ console-uncaught-promise.js:18
(anonymous) @ console-uncaught-promise.js:106 (anonymous) @ console-uncaught-promise.js:100
console-uncaught-promise.js:71 Uncaught (in promise) 42 console-uncaught-promise.js:71 Uncaught (in promise) 42
promiseTest4 @ console-uncaught-promise.js:71 promiseTest4 @ console-uncaught-promise.js:71
timeout @ console-uncaught-promise.js:19 timeout @ console-uncaught-promise.js:19
setTimeout (async) setTimeout (async)
runNextPromiseTest @ console-uncaught-promise.js:18 runNextPromiseTest @ console-uncaught-promise.js:18
(anonymous) @ console-uncaught-promise.js:106 (anonymous) @ console-uncaught-promise.js:100
console-uncaught-promise.js:76 Uncaught (in promise) 1e+100 console-uncaught-promise.js:76 Uncaught (in promise) 1e+100
promiseTest5 @ console-uncaught-promise.js:76 promiseTest5 @ console-uncaught-promise.js:76
timeout @ console-uncaught-promise.js:19 timeout @ console-uncaught-promise.js:19
setTimeout (async) setTimeout (async)
runNextPromiseTest @ console-uncaught-promise.js:18 runNextPromiseTest @ console-uncaught-promise.js:18
(anonymous) @ console-uncaught-promise.js:106 (anonymous) @ console-uncaught-promise.js:100
console-uncaught-promise.js:81 Uncaught (in promise) foo console-uncaught-promise.js:81 Uncaught (in promise) foo
promiseTest6 @ console-uncaught-promise.js:81 promiseTest6 @ console-uncaught-promise.js:81
timeout @ console-uncaught-promise.js:19 timeout @ console-uncaught-promise.js:19
setTimeout (async) setTimeout (async)
runNextPromiseTest @ console-uncaught-promise.js:18 runNextPromiseTest @ console-uncaught-promise.js:18
(anonymous) @ console-uncaught-promise.js:106 (anonymous) @ console-uncaught-promise.js:100
console-uncaught-promise.js:86 Uncaught (in promise) {foo: 42} console-uncaught-promise.js:86 Uncaught (in promise) {foo: 42}
foo: 42 foo: 42
__proto__: Object __proto__: Object
...@@ -58,13 +58,13 @@ promiseTest7 @ console-uncaught-promise.js:86 ...@@ -58,13 +58,13 @@ promiseTest7 @ console-uncaught-promise.js:86
timeout @ console-uncaught-promise.js:19 timeout @ console-uncaught-promise.js:19
setTimeout (async) setTimeout (async)
runNextPromiseTest @ console-uncaught-promise.js:18 runNextPromiseTest @ console-uncaught-promise.js:18
(anonymous) @ console-uncaught-promise.js:106 (anonymous) @ console-uncaught-promise.js:100
console-uncaught-promise.js:91 Uncaught (in promise) undefined console-uncaught-promise.js:91 Uncaught (in promise) undefined
promiseTest8 @ console-uncaught-promise.js:91 promiseTest8 @ console-uncaught-promise.js:91
timeout @ console-uncaught-promise.js:19 timeout @ console-uncaught-promise.js:19
setTimeout (async) setTimeout (async)
runNextPromiseTest @ console-uncaught-promise.js:18 runNextPromiseTest @ console-uncaught-promise.js:18
(anonymous) @ console-uncaught-promise.js:106 (anonymous) @ console-uncaught-promise.js:100
A bad HTTP response code (404) was received when fetching the script. A bad HTTP response code (404) was received when fetching the script.
inspected-page.html:1 Uncaught (in promise) TypeError: Failed to register a ServiceWorker for scope ('http://127.0.0.1:8000/devtools/console/') with script ('http://127.0.0.1:8000/devtools/console/404'): A bad HTTP response code (404) was received when fetching the script. inspected-page.html:1 Uncaught (in promise) TypeError: Failed to register a ServiceWorker for scope ('http://127.0.0.1:8000/devtools/console/') with script ('http://127.0.0.1:8000/devtools/console/404'): A bad HTTP response code (404) was received when fetching the script.
...@@ -97,22 +97,12 @@ ...@@ -97,22 +97,12 @@
} }
`); `);
ConsoleTestRunner.addConsoleViewSniffer(checkConsoleMessages, true); while (await TestRunner.evaluateInPagePromise('runNextPromiseTest()')) {
Common.console.showPromise(); // Run all the test cases until there are no more.
checkConsoleMessages();
function checkConsoleMessages() {
TestRunner.evaluateInPage('runNextPromiseTest()', callback);
function callback(result) {
if (!result)
ConsoleTestRunner.expandConsoleMessages(dump);
}
} }
function dump() { ConsoleTestRunner.expandConsoleMessages(async () => {
ConsoleTestRunner.dumpConsoleMessagesIgnoreErrorStackFrames(); await ConsoleTestRunner.dumpConsoleMessagesIgnoreErrorStackFrames();
TestRunner.completeTest(); TestRunner.completeTest();
} });
})(); })();
...@@ -25,29 +25,29 @@ ...@@ -25,29 +25,29 @@
var viewportMessagesCount; var viewportMessagesCount;
var testSuite = [ var testSuite = [
function testSelectionSingleLineText(next) { async function testSelectionSingleLineText(next) {
viewport.invalidate(); viewport.invalidate();
viewport.forceScrollItemToBeFirst(0); viewport.forceScrollItemToBeFirst(0);
viewportMessagesCount = viewport.lastVisibleIndex() - viewport.firstVisibleIndex() + 1; viewportMessagesCount = viewport.lastVisibleIndex() - viewport.firstVisibleIndex() + 1;
selectMessages(middleMessage, 2, middleMessage, 7); await selectMessages(middleMessage, 2, middleMessage, 7);
dumpSelectionText(); dumpSelectionText();
next(); next();
}, },
function testReversedSelectionSingleLineText(next) { async function testReversedSelectionSingleLineText(next) {
selectMessages(middleMessage, 7, middleMessage, 2); await selectMessages(middleMessage, 7, middleMessage, 2);
dumpSelectionText(); dumpSelectionText();
next(); next();
}, },
function testSelectionMultiLineText(next) { async function testSelectionMultiLineText(next) {
selectMessages(middleMessage - 1, 4, middleMessage + 1, 7); await selectMessages(middleMessage - 1, 4, middleMessage + 1, 7);
dumpSelectionText(); dumpSelectionText();
next(); next();
}, },
function testSimpleVisibleSelection(next) { async function testSimpleVisibleSelection(next) {
selectMessages(middleMessage - 3, 6, middleMessage + 2, 6); await selectMessages(middleMessage - 3, 6, middleMessage + 2, 6);
dumpSelectionModel(); dumpSelectionModel();
next(); next();
}, },
...@@ -77,14 +77,14 @@ ...@@ -77,14 +77,14 @@
next(); next();
}, },
function testShiftClickSelectionOver(next) { async function testShiftClickSelectionOver(next) {
emulateShiftClickOnMessage(minimumViewportMessagesCount); await emulateShiftClickOnMessage(minimumViewportMessagesCount);
dumpSelectionModel(); dumpSelectionModel();
next(); next();
}, },
function testShiftClickSelectionBelow(next) { async function testShiftClickSelectionBelow(next) {
emulateShiftClickOnMessage(messagesCount - minimumViewportMessagesCount); await emulateShiftClickOnMessage(messagesCount - minimumViewportMessagesCount);
dumpSelectionModel(); dumpSelectionModel();
next(); next();
}, },
...@@ -96,20 +96,20 @@ ...@@ -96,20 +96,20 @@
next(); next();
}, },
function testReversedVisibleSelection(next) { async function testReversedVisibleSelection(next) {
selectMessages(middleMessage + 1, 6, middleMessage - 4, 6); await selectMessages(middleMessage + 1, 6, middleMessage - 4, 6);
dumpSelectionModel(); dumpSelectionModel();
next(); next();
}, },
function testShiftClickReversedSelectionOver(next) { async function testShiftClickReversedSelectionOver(next) {
emulateShiftClickOnMessage(minimumViewportMessagesCount); await emulateShiftClickOnMessage(minimumViewportMessagesCount);
dumpSelectionModel(); dumpSelectionModel();
next(); next();
}, },
function testShiftClickReversedSelectionBelow(next) { async function testShiftClickReversedSelectionBelow(next) {
emulateShiftClickOnMessage(messagesCount - minimumViewportMessagesCount); await emulateShiftClickOnMessage(messagesCount - minimumViewportMessagesCount);
dumpSelectionModel(); dumpSelectionModel();
next(); next();
}, },
...@@ -196,7 +196,7 @@ ...@@ -196,7 +196,7 @@
TestRunner.addResult('Selected text:<<<EOL\n' + text + '\nEOL'); TestRunner.addResult('Selected text:<<<EOL\n' + text + '\nEOL');
} }
function emulateShiftClickOnMessage(messageIndex) { async function emulateShiftClickOnMessage(messageIndex) {
viewport.refresh(); viewport.refresh();
var selection = window.getSelection(); var selection = window.getSelection();
if (!selection || !selection.rangeCount) { if (!selection || !selection.rangeCount) {
...@@ -205,11 +205,13 @@ ...@@ -205,11 +205,13 @@
} }
viewport.forceScrollItemToBeFirst(Math.max(messageIndex - minimumViewportMessagesCount / 2, 0)); viewport.forceScrollItemToBeFirst(Math.max(messageIndex - minimumViewportMessagesCount / 2, 0));
var element = consoleView.itemElement(messageIndex).element(); var element = consoleView.itemElement(messageIndex).element();
// Console messages contain live locations.
await TestRunner.waitForPendingLiveLocationUpdates();
selection.setBaseAndExtent(selection.anchorNode, selection.anchorOffset, element, 0); selection.setBaseAndExtent(selection.anchorNode, selection.anchorOffset, element, 0);
viewport.refresh(); viewport.refresh();
} }
function selectMessages(fromMessage, fromTextOffset, toMessage, toTextOffset) { async function selectMessages(fromMessage, fromTextOffset, toMessage, toTextOffset) {
if (Math.abs(toMessage - fromMessage) > minimumViewportMessagesCount) { if (Math.abs(toMessage - fromMessage) > minimumViewportMessagesCount) {
TestRunner.addResult(String.sprintf( TestRunner.addResult(String.sprintf(
'FAILURE: Cannot select more than %d messages (requested to select from %d to %d', 'FAILURE: Cannot select more than %d messages (requested to select from %d to %d',
...@@ -219,7 +221,7 @@ ...@@ -219,7 +221,7 @@
} }
viewport.forceScrollItemToBeFirst(Math.min(fromMessage, toMessage)); viewport.forceScrollItemToBeFirst(Math.min(fromMessage, toMessage));
ConsoleTestRunner.selectConsoleMessages(fromMessage, fromTextOffset, toMessage, toTextOffset); await ConsoleTestRunner.selectConsoleMessages(fromMessage, fromTextOffset, toMessage, toTextOffset);
viewport.refresh(); viewport.refresh();
} }
})(); })();
...@@ -24,125 +24,125 @@ ...@@ -24,125 +24,125 @@
await ConsoleTestRunner.waitForPendingViewportUpdates(); await ConsoleTestRunner.waitForPendingViewportUpdates();
TestRunner.runTestSuite([ TestRunner.runTestSuite([
function testBetweenViewportAndExternal(next) { async function testBetweenViewportAndExternal(next) {
TestRunner.addResult(`Setting focus in prompt:`); TestRunner.addResult(`Setting focus in prompt:`);
prompt.focus(); prompt.focus();
dumpFocus(); await dumpFocus();
shiftPress('Tab'); shiftPress('Tab');
dumpFocus(); await dumpFocus();
press('ArrowUp'); press('ArrowUp');
dumpFocus(); await dumpFocus();
shiftPress('Tab'); shiftPress('Tab');
dumpFocus(); await dumpFocus();
press('Tab'); press('Tab');
dumpFocus(); await dumpFocus();
press('ArrowUp'); press('ArrowUp');
dumpFocus(); await dumpFocus();
press('Tab'); press('Tab');
dumpFocus(); await dumpFocus();
next(); next();
}, },
function testBetweenViewportAndExternalWithSelectedItemNotInDOM(next) { async function testBetweenViewportAndExternalWithSelectedItemNotInDOM(next) {
TestRunner.addResult(`Setting focus in prompt:`); TestRunner.addResult(`Setting focus in prompt:`);
prompt.focus(); prompt.focus();
dumpFocus(); await dumpFocus();
shiftPress('Tab'); shiftPress('Tab');
dumpFocus(); await dumpFocus();
press('ArrowUp'); press('ArrowUp');
dumpFocus(); await dumpFocus();
scrollViewportToTop(); scrollViewportToTop();
dumpFocus(); await dumpFocus();
shiftPress('Tab'); shiftPress('Tab');
dumpFocus(); await dumpFocus();
press('Tab'); press('Tab');
dumpFocus(); await dumpFocus();
press('ArrowUp'); press('ArrowUp');
dumpFocus(); await dumpFocus();
TestRunner.addResult(`\nSetting focus in prompt:`); TestRunner.addResult(`\nSetting focus in prompt:`);
prompt.focus(); prompt.focus();
dumpFocus(); await dumpFocus();
shiftPress('Tab'); shiftPress('Tab');
dumpFocus(); await dumpFocus();
press('ArrowUp'); press('ArrowUp');
dumpFocus(); await dumpFocus();
scrollViewportToTop(); scrollViewportToTop();
dumpFocus(); await dumpFocus();
press('Tab'); press('Tab');
dumpFocus(); await dumpFocus();
next(); next();
}, },
function testMoveAcrossLogsWithinViewport(next) { async function testMoveAcrossLogsWithinViewport(next) {
forceSelect(logCount - 1); forceSelect(logCount - 1);
dumpFocus(); await dumpFocus();
press('Home'); press('Home');
dumpFocus(); await dumpFocus();
press('ArrowDown'); press('ArrowDown');
dumpFocus(); await dumpFocus();
press('ArrowDown'); press('ArrowDown');
dumpFocus(); await dumpFocus();
press('End'); press('End');
dumpFocus(); await dumpFocus();
press('ArrowUp'); press('ArrowUp');
dumpFocus(); await dumpFocus();
press('ArrowUp'); press('ArrowUp');
dumpFocus(); await dumpFocus();
next(); next();
}, },
function testViewportDoesNotChangeFocusOnScroll(next) { async function testViewportDoesNotChangeFocusOnScroll(next) {
forceSelect(logCount - 2); forceSelect(logCount - 2);
dumpFocus(); await dumpFocus();
scrollViewportToTop(); scrollViewportToTop();
dumpFocus(); await dumpFocus();
scrollViewportToBottom(); scrollViewportToBottom();
dumpFocus(); await dumpFocus();
next(); next();
}, },
function testViewportDoesNotStealFocusOnScroll(next) { async function testViewportDoesNotStealFocusOnScroll(next) {
forceSelect(logCount - 1); forceSelect(logCount - 1);
dumpFocus(); await dumpFocus();
TestRunner.addResult(`Setting focus in prompt:`); TestRunner.addResult(`Setting focus in prompt:`);
prompt.focus(); prompt.focus();
dumpFocus(); await dumpFocus();
scrollViewportToTop(); scrollViewportToTop();
dumpFocus(); await dumpFocus();
scrollViewportToBottom(); scrollViewportToBottom();
dumpFocus(); await dumpFocus();
next(); next();
}, },
...@@ -150,20 +150,20 @@ ...@@ -150,20 +150,20 @@
async function testNewLogsShouldNotMoveFocus(next) { async function testNewLogsShouldNotMoveFocus(next) {
TestRunner.addResult(`Setting focus in prompt:`); TestRunner.addResult(`Setting focus in prompt:`);
prompt.focus(); prompt.focus();
dumpFocus(); await dumpFocus();
await TestRunner.evaluateInPagePromise(`console.log("New Message")`); await TestRunner.evaluateInPagePromise(`console.log("New Message")`);
await ConsoleTestRunner.waitForConsoleMessagesPromise(logCount + 1); await ConsoleTestRunner.waitForConsoleMessagesPromise(logCount + 1);
await ConsoleTestRunner.waitForPendingViewportUpdates(); await ConsoleTestRunner.waitForPendingViewportUpdates();
dumpFocus(); await dumpFocus();
next(); next();
}, },
function testClearingConsoleFocusesPrompt(next) { async function testClearingConsoleFocusesPrompt(next) {
TestRunner.addResult(`\nConsole cleared:`); TestRunner.addResult(`\nConsole cleared:`);
consoleView._consoleCleared(); consoleView._consoleCleared();
dumpFocus(); await dumpFocus();
next(); next();
} }
]); ]);
...@@ -200,8 +200,10 @@ ...@@ -200,8 +200,10 @@
eventSender.keyDown(key, ['shiftKey']); eventSender.keyDown(key, ['shiftKey']);
} }
function dumpFocus() { async function dumpFocus() {
var element = document.deepActiveElement(); var element = document.deepActiveElement();
// Console elements contain live locations that might not be fully resolved yet.
await TestRunner.waitForPendingLiveLocationUpdates();
if (!element) { if (!element) {
TestRunner.addResult('null'); TestRunner.addResult('null');
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment