Commit 06929038 authored by Will Chen's avatar Will Chen Committed by Commit Bot

Reland "DevTools: transform console tests (part 2)"

This is a reland of 9869d2f1

I've marked the tests as Slow in this CL (https://chromium-review.googlesource.com/c/600829)
which is why there were flaky before.

Original change's description:
> DevTools: transform console tests (part 2)
> 
> F/u from https://chromium-review.googlesource.com/c/595238
> 
> Bug: 667560
> Change-Id: I4e387fae79ab4de0965f84a045c4fd04631b9e7d
> Reviewed-on: https://chromium-review.googlesource.com/597312
> Commit-Queue: Will Chen <chenwilliam@chromium.org>
> Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#491501}

Bug: 667560
Change-Id: Ie2cc4dd1249b46b7ce784a516647acaee223c39f
Reviewed-on: https://chromium-review.googlesource.com/600814Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Will Chen <chenwilliam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491884}
parent 322a5469
...@@ -612,27 +612,11 @@ crbug.com/728378 virtual/layout_ng/overflow/overflow-position-004.html [ Failure ...@@ -612,27 +612,11 @@ crbug.com/728378 virtual/layout_ng/overflow/overflow-position-004.html [ Failure
# ====== DevTools test migration failures from here ====== # ====== DevTools test migration failures from here ======
# Temporary failures (these tests are moves from html to js) # Temporary failures (these tests are moves from html to js)
# See crbug.com/667560 for details # See crbug.com/667560 for details
crbug.com/667560 http/tests/devtools/console/console-bind-fake.js [ Skip ]
crbug.com/667560 http/tests/devtools/console/console-call-getter-on-proto.js [ Skip ]
crbug.com/667560 http/tests/devtools/console/console-command-clear.js [ Skip ]
crbug.com/667560 http/tests/devtools/console/console-control-characters.js [ Skip ]
crbug.com/667560 http/tests/devtools/console/console-correct-suggestions.js [ Skip ]
crbug.com/667560 http/tests/devtools/console/console-css-unterminated-comment.js [ Skip ]
crbug.com/667560 http/tests/devtools/console/console-dir-deprecated.js [ Skip ]
crbug.com/667560 http/tests/devtools/console/console-dir-global.js [ Skip ]
crbug.com/667560 http/tests/devtools/console/console-edit-property-value.js [ Skip ]
### virtual/mojo-loading/http/tests/devtools ### virtual/mojo-loading/http/tests/devtools
crbug.com/667560 virtual/mojo-loading/http/tests/devtools/console/console-bind-fake.js [ Skip ]
crbug.com/667560 virtual/mojo-loading/http/tests/devtools/console/console-call-getter-on-proto.js [ Skip ] ### Manually fix after migration
crbug.com/667560 virtual/mojo-loading/http/tests/devtools/console/console-command-clear.js [ Skip ] crbug.com/667560 virtual/mojo-loading/http/tests/devtools/console/console-dir.js [ NeedsManualRebaseline ]
crbug.com/667560 virtual/mojo-loading/http/tests/devtools/console/console-control-characters.js [ Skip ]
crbug.com/667560 virtual/mojo-loading/http/tests/devtools/console/console-correct-suggestions.js [ Skip ]
crbug.com/667560 virtual/mojo-loading/http/tests/devtools/console/console-css-unterminated-comment.js [ Skip ]
crbug.com/667560 virtual/mojo-loading/http/tests/devtools/console/console-dir-deprecated.js [ Skip ]
crbug.com/667560 virtual/mojo-loading/http/tests/devtools/console/console-dir-global.js [ Skip ]
crbug.com/667560 virtual/mojo-loading/http/tests/devtools/console/console-dir.js [ Skip ]
crbug.com/667560 virtual/mojo-loading/http/tests/devtools/console/console-edit-property-value.js [ Skip ]
# ====== DevTools test migration failures until here ====== # ====== DevTools test migration failures until here ======
......
<html> // Copyright 2017 The Chromium Authors. All rights reserved.
<head> // Use of this source code is governed by a BSD-style license that can be
<script src="../../http/tests/inspector/inspector-test.js"></script> // found in the LICENSE file.
<script src="../../http/tests/inspector/console-test.js"></script>
<script>
var foo = 'fooValue';
Function.prototype.bind = function () { throw ":P"; }; (async function() {
TestRunner.addResult(`Tests that overriding Function.prototype.bind does not break inspector.\n`);
function test() await TestRunner.loadModule('console_test_runner');
{ await TestRunner.showPanel('console');
InspectorTest.evaluateInConsole("foo", step1);
function step1() await TestRunner.evaluateInPagePromise(`
{ var foo = 'fooValue';
InspectorTest.dumpConsoleMessages(); Function.prototype.bind = function () { throw ":P"; };
InspectorTest.completeTest(); `);
}
}
</script>
</head>
<body onload="runTest()"> ConsoleTestRunner.evaluateInConsole('foo', step1);
<p>
Tests that overriding Function.prototype.bind does not break inspector.
</p>
</body> function step1() {
</html> ConsoleTestRunner.dumpConsoleMessages();
TestRunner.completeTest();
}
})();
CONSOLE MESSAGE: line 21: [object Object]
Tests that calling getter on prototype will call it on the object. Tests that calling getter on prototype will call it on the object.
console-call-getter-on-proto.html:21 B {value: 239} console-call-getter-on-proto.js:27 B {value: 239}
foo: 239 foo: 239
value: 239 value: 239
__proto__: A __proto__: A
......
<html> // Copyright 2017 The Chromium Authors. All rights reserved.
<head> // Use of this source code is governed by a BSD-style license that can be
<script src="../../http/tests/inspector/inspector-test.js"></script> // found in the LICENSE file.
<script src="../../http/tests/inspector/console-test.js"></script>
<script> (async function() {
function logObject() TestRunner.addResult(`Tests that calling getter on prototype will call it on the object.\n`);
{
await TestRunner.loadModule('console_test_runner');
await TestRunner.showPanel('console');
await TestRunner.evaluateInPagePromise(`
function logObject()
{
var A = function() { this.value = 239; } var A = function() { this.value = 239; }
A.prototype = { A.prototype = {
constructor: A, constructor: A,
...@@ -19,40 +25,30 @@ function logObject() ...@@ -19,40 +25,30 @@ function logObject()
__proto__: A.prototype __proto__: A.prototype
} }
console.log(new B()); console.log(new B());
} }
`);
function test() TestRunner.evaluateInPage('logObject()', step2);
{
InspectorTest.evaluateInPage("logObject()", step2); function step2() {
function step2() ConsoleTestRunner.expandConsoleMessages(step3);
{
InspectorTest.expandConsoleMessages(step3);
} }
function expandTreeElementFilter(treeElement)
{ function expandTreeElementFilter(treeElement) {
var name = treeElement.nameElement && treeElement.nameElement.textContent; var name = treeElement.nameElement && treeElement.nameElement.textContent;
return name === "__proto__"; return name === '__proto__';
} }
function step3()
{ function step3() {
InspectorTest.expandConsoleMessages(step4, expandTreeElementFilter); ConsoleTestRunner.expandConsoleMessages(step4, expandTreeElementFilter);
} }
function step4()
{ function step4() {
InspectorTest.expandGettersInConsoleMessages(step5); ConsoleTestRunner.expandGettersInConsoleMessages(step5);
} }
function step5()
{ function step5() {
InspectorTest.dumpConsoleMessages(false, false, InspectorTest.textContentWithLineBreaks); ConsoleTestRunner.dumpConsoleMessages(false, false, TestRunner.textContentWithLineBreaks);
InspectorTest.completeTest(); TestRunner.completeTest();
} }
} })();
</script>
</head>
<body onload="runTest()">
<p>
Tests that calling getter on prototype will call it on the object.
</p>
</body>
</html>
CONSOLE MESSAGE: line 9: one
CONSOLE MESSAGE: line 10: two
CONSOLE MESSAGE: line 11: three
Tests that console is cleared upon clear() eval in console. Tests that console is cleared upon clear() eval in console.
=== Before clear === === Before clear ===
console-command-clear.html:9 one console-command-clear.js:14 one
console-command-clear.html:10 two console-command-clear.js:15 two
console-command-clear.html:11 three console-command-clear.js:16 three
=== After clear === === After clear ===
VM:1 Console was cleared VM:1 Console was cleared
<html> // Copyright 2017 The Chromium Authors. All rights reserved.
<head> // Use of this source code is governed by a BSD-style license that can be
<script src="../../http/tests/inspector/inspector-test.js"></script> // found in the LICENSE file.
<script src="../../http/tests/inspector/console-test.js"></script>
<script>
function log() { (async function() {
TestRunner.addResult(`Tests that console is cleared upon clear() eval in console.\n`);
await TestRunner.loadModule('console_test_runner');
await TestRunner.showPanel('console');
await TestRunner.evaluateInPagePromise(`
function log() {
// Fill console. // Fill console.
console.log("one"); console.log("one");
console.log("two"); console.log("two");
console.log("three"); console.log("three");
}
log();
function test()
{
InspectorTest.addResult("=== Before clear ===");
InspectorTest.dumpConsoleMessages();
function callback()
{
InspectorTest.addResult("=== After clear ===");
InspectorTest.dumpConsoleMessages();
InspectorTest.completeTest();
} }
InspectorTest.evaluateInConsole("clear()", callback); log();
} `);
</script> TestRunner.addResult('=== Before clear ===');
</head> ConsoleTestRunner.dumpConsoleMessages();
<body onload="runTest()"> function callback() {
<p> TestRunner.addResult('=== After clear ===');
Tests that console is cleared upon clear() eval in console. ConsoleTestRunner.dumpConsoleMessages();
</p> TestRunner.completeTest();
}
</body> ConsoleTestRunner.evaluateInConsole('clear()', callback);
</html> })();
<html> // Copyright 2017 The Chromium Authors. All rights reserved.
<head> // Use of this source code is governed by a BSD-style license that can be
<script src="../../http/tests/inspector/inspector-test.js"></script> // found in the LICENSE file.
<script src="../../http/tests/inspector/console-test.js"></script>
<script>
function test() (async function() {
{ TestRunner.addResult(`Verify that control characters are substituted with printable characters.\n`);
// The following command has control character.
InspectorTest.evaluateInConsole("var\u001D i = 0;", onEvaluated);
function onEvaluated() await TestRunner.loadModule('console_test_runner');
{ await TestRunner.showPanel('console');
InspectorTest.dumpConsoleMessages();
InspectorTest.completeTest();
}
}
</script>
</head>
<body onload="runTest()"> ConsoleTestRunner.evaluateInConsole('var\u001d i = 0;', onEvaluated);
<p>
Verify that control characters are substituted with printable characters.
</p>
</body> function onEvaluated() {
</html> ConsoleTestRunner.dumpConsoleMessages();
TestRunner.completeTest();
}
})();
<html> // Copyright 2017 The Chromium Authors. All rights reserved.
<head> // Use of this source code is governed by a BSD-style license that can be
<script src="../../http/tests/inspector/inspector-test.js"></script> // found in the LICENSE file.
<script src="../../http/tests/inspector/console-test.js"></script>
<script> (async function() {
function templateString() TestRunner.addResult(`Tests that console correctly finds suggestions in complicated cases.\n`);
{
await TestRunner.loadModule('console_test_runner');
await TestRunner.showPanel('console');
await TestRunner.evaluateInPagePromise(`
function templateString()
{
console.log("The template string should not run and you should not see this log"); console.log("The template string should not run and you should not see this log");
return { return {
shouldNotFindThis:56 shouldNotFindThis:56
}; };
} }
function shouldNotFindThisFunction() { }
function shouldNotFindThisFunction() { } function shouldFindThisFunction() { }
function shouldFindThisFunction() { } window["should not find this"] = true;
window["should not find this"] = true; var myMap = new Map([['first', 1], ['second', 2], ['third', 3], ['shouldNotFindThis', 4]]);
var complicatedObject = {
var myMap = new Map([['first', 1], ['second', 2], ['third', 3], ['shouldNotFindThis', 4]]);
var complicatedObject = {
'foo-bar': true, 'foo-bar': true,
'"double-qouted"': true, '"double-qouted"': true,
"'single-qouted'": true, "'single-qouted'": true,
"notDangerous();": true "notDangerous();": true
} }
function test() `);
{
var consoleEditor; var consoleEditor;
function testCompletions(text, expected, force)
{ function testCompletions(text, expected, force) {
var cursorPosition = text.indexOf('|'); var cursorPosition = text.indexOf('|');
if (cursorPosition < 0) if (cursorPosition < 0)
cursorPosition = Infinity; cursorPosition = Infinity;
consoleEditor.setText(text.replace('|', '')); consoleEditor.setText(text.replace('|', ''));
consoleEditor.setSelection(TextUtils.TextRange.createFromLocation(0, cursorPosition)); consoleEditor.setSelection(TextUtils.TextRange.createFromLocation(0, cursorPosition));
consoleEditor._autocompleteController.autocomplete(force); consoleEditor._autocompleteController.autocomplete(force);
return InspectorTest.addSnifferPromise(consoleEditor._autocompleteController, "_onSuggestionsShownForTest").then(checkExpected); return TestRunner.addSnifferPromise(consoleEditor._autocompleteController, '_onSuggestionsShownForTest').then(checkExpected);
function checkExpected(suggestions) function checkExpected(suggestions) {
{
var completions = new Map(suggestions.map(suggestion => [suggestion.text, suggestion])); var completions = new Map(suggestions.map(suggestion => [suggestion.text, suggestion]));
var message = "Checking '" + text.replace('\n', '\\n').replace('\r', '\\r') + "'"; var message = 'Checking \'' + text.replace('\n', '\\n').replace('\r', '\\r') + '\'';
if (force) if (force)
message += " forcefully"; message += ' forcefully';
InspectorTest.addResult(message);
TestRunner.addResult(message);
for (var i = 0; i < expected.length; i++) { for (var i = 0; i < expected.length; i++) {
if (completions.has(expected[i])) { if (completions.has(expected[i])) {
if (completions.get(expected[i]).title) if (completions.get(expected[i]).title)
InspectorTest.addResult("Found: " + expected[i] + ", displayed as " + completions.get(expected[i]).title); TestRunner.addResult('Found: ' + expected[i] + ', displayed as ' + completions.get(expected[i]).title);
else else
InspectorTest.addResult("Found: " + expected[i]); TestRunner.addResult('Found: ' + expected[i]);
} else { } else {
InspectorTest.addResult("Not Found: " + expected[i]); TestRunner.addResult('Not Found: ' + expected[i]);
} }
} }
InspectorTest.addResult("");
TestRunner.addResult('');
} }
} }
function sequential(tests)
{ function sequential(tests) {
var promise = Promise.resolve(); var promise = Promise.resolve();
for (var i = 0; i < tests.length; i++) for (var i = 0; i < tests.length; i++)
promise = promise.then(tests[i]); promise = promise.then(tests[i]);
return promise; return promise;
} }
sequential([ sequential([
InspectorTest.waitUntilConsoleEditorLoaded().then(e => consoleEditor = e), () => ConsoleTestRunner.waitUntilConsoleEditorLoaded().then(e => consoleEditor = e),
() => testCompletions("window.do", ["document"]), () => testCompletions('window.do', ['document']),
() => testCompletions("win", ["window"]), () => testCompletions('win', ['window']),
() => testCompletions('window["doc', ['"document"]']), () => testCompletions('window["doc', ['"document"]']),
() => testCompletions('window["document"].bo', ["body"]), () => testCompletions('window["document"].bo', ['body']),
() => testCompletions('window["document"]["body"].textC', ["textContent"]), () => testCompletions('window["document"]["body"].textC', ['textContent']),
() => testCompletions('document.body.inner', ["innerText", "innerHTML"]), () => testCompletions('document.body.inner', ['innerText', 'innerHTML']),
() => testCompletions('document["body"][window.do', ["document"]), () => testCompletions('document["body"][window.do', ['document']),
() => testCompletions('document["body"][window["document"].body.childNodes[0].text', ["textContent"]), () => testCompletions('document["body"][window["document"].body.childNodes[0].text', ['textContent']),
() => testCompletions("templateString`asdf`should", ["shouldNotFindThis"]), () => testCompletions('templateString`asdf`should', ['shouldNotFindThis']),
() => testCompletions("window.document.BODY", ["body"]), () => testCompletions('window.document.BODY', ['body']),
() => testCompletions("window.dOcUmE", ["document"]), () => testCompletions('window.dOcUmE', ['document']),
() => testCompletions("window.node", ["NodeList", "AudioNode", "GainNode"]), () => testCompletions('window.node', ['NodeList', 'AudioNode', 'GainNode']),
() => testCompletions("32", ["Float32Array", "Int32Array"]), () => testCompletions('32', ['Float32Array', 'Int32Array']),
() => testCompletions("window.32", ["Float32Array", "Int32Array"]), () => testCompletions('window.32', ['Float32Array', 'Int32Array']),
() => testCompletions("", ["window"], false), () => testCompletions('', ['window'], false),
() => testCompletions("", ["window"], true), () => testCompletions('', ['window'], true),
() => testCompletions('"string g', ["getComputedStyle"], false), () => testCompletions('"string g', ['getComputedStyle'], false),
() => testCompletions("`template string docu", ["document"], false), () => testCompletions('`template string docu', ['document'], false),
() => testCompletions("`${do", ["document"], false), () => testCompletions('`${do', ['document'], false),
() => testCompletions("// do", ["document"], false), () => testCompletions('// do', ['document'], false),
() => testCompletions('["should', ["shouldNotFindThisFunction"]), () => testCompletions('["should', ['shouldNotFindThisFunction']),
() => testCompletions("shou", ["should not find this"]), () => testCompletions('shou', ['should not find this']),
() => testCompletions('myMap.get(', ['"first")', '"second")', '"third")']), () => testCompletions('myMap.get(', ['"first")', '"second")', '"third")']),
() => testCompletions('myMap.get(\'', ['\'first\')', '\'second\')', '\'third\')']), () => testCompletions('myMap.get(\'', ['\'first\')', '\'second\')', '\'third\')']),
() => testCompletions('myMap.set(\'firs', ['\'first\', ']), () => testCompletions('myMap.set(\'firs', ['\'first\', ']),
() => testCompletions('myMap.set(should', ['shouldFindThisFunction', 'shouldNotFindThis', '\"shouldNotFindThis\")']), () => testCompletions('myMap.set(should', ['shouldFindThisFunction', 'shouldNotFindThis', '"shouldNotFindThis")']),
() => testCompletions('myMap.delete(\'', ['\'first\')', '\'second\')', '\'third\')']), () => testCompletions('myMap.delete(\'', ['\'first\')', '\'second\')', '\'third\')']),
() => testCompletions("document. bo", ["body"]), () => testCompletions('document. bo', ['body']),
() => testCompletions("document.\tbo", ["body"]), () => testCompletions('document.\tbo', ['body']),
() => testCompletions("document.\nbo", ["body"]), () => testCompletions('document.\nbo', ['body']),
() => testCompletions("document.\r\nbo", ["body"]), () => testCompletions('document.\r\nbo', ['body']),
() => testCompletions("document [ 'bo", ["'body']"]), () => testCompletions('document [ \'bo', ['\'body\']']),
() => testCompletions("function hey(should", ["shouldNotFindThisFunction"]), () => testCompletions('function hey(should', ['shouldNotFindThisFunction']),
() => testCompletions("var should", ["shouldNotFindThisFunction"]), () => testCompletions('var should', ['shouldNotFindThisFunction']),
() => testCompletions("document[[win", ["window"]), () => testCompletions('document[[win', ['window']),
() => testCompletions("document[ [win", ["window"]), () => testCompletions('document[ [win', ['window']),
() => testCompletions("document[ [ win", ["window"]), () => testCompletions('document[ [ win', ['window']),
() => testCompletions('I|mag', ['Image', 'Infinity']), () => testCompletions('I|mag', ['Image', 'Infinity']),
() => testCompletions('var x = (do|);', ['document']), () => testCompletions('var x = (do|);', ['document']),
() => testCompletions('complicatedObject["foo', ['"foo-bar"]']), () => testCompletions('complicatedObject["foo', ['"foo-bar"]']),
...@@ -111,13 +122,6 @@ function test() ...@@ -111,13 +122,6 @@ function test()
() => testCompletions('complicatedObject[\'\\\'sing', ['\'\\\'single-qouted\\\'\']']), () => testCompletions('complicatedObject[\'\\\'sing', ['\'\\\'single-qouted\\\'\']']),
() => testCompletions('complicatedObject["\'single-qou', ['"\'single-qouted\'"]']), () => testCompletions('complicatedObject["\'single-qou', ['"\'single-qouted\'"]']),
() => testCompletions('complicatedObject["\\"double-qouted\\"', ['"\\"double-qouted\\""]']), () => testCompletions('complicatedObject["\\"double-qouted\\"', ['"\\"double-qouted\\""]']),
() => testCompletions('complicatedObject["notDangerous();', ['"notDangerous();"]']), () => testCompletions('complicatedObject["notDangerous();', ['"notDangerous();"]'])
]).then(InspectorTest.completeTest); ]).then(TestRunner.completeTest);
})();
}
</script>
</head>
<body onload="runTest()">
<p>Tests that console correctly finds suggestions in complicated cases.</p>
</body>
</html>
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
<style>/* unterminated comment </style>
<style>/*</style>
<style>/* terminated comment */</style>
<style>/* terminated comment *//*</style>
<script>
function test()
{
InspectorTest.consoleModel.messages().forEach(function(message)
{
InspectorTest.addResult(message.message + " (line " + message.line + ")");
});
InspectorTest.completeTest();
}
</script>
</head>
<body onload="runTest()">
<p id="p">Tests that unterminated comment in CSS generates a warning.</p>
</body>
</html>
CONSOLE MESSAGE: line 9: [object Window]
CONSOLE MESSAGE: line 10: [object ShadowRoot]
Tests that console does not log deprecated warning messages while dir-dumping objects. Tests that console does not log deprecated warning messages while dir-dumping objects.
console-dir-deprecated.html:9 Window console-dir-deprecated.js:17 Window
console-dir-deprecated.html:10 #document-fragment console-dir-deprecated.js:18 #document-fragment
<html> // Copyright 2017 The Chromium Authors. All rights reserved.
<head> // Use of this source code is governed by a BSD-style license that can be
<script src="../../http/tests/inspector/inspector-test.js"></script> // found in the LICENSE file.
<script src="../../http/tests/inspector/console-test.js"></script>
<script>
function logObjects() (async function() {
{ TestRunner.addResult(`Tests that console does not log deprecated warning messages while dir-dumping objects.\n`);
console.dir(window);
console.dir(document.getElementById("foo").createShadowRoot());
}
function test() await TestRunner.loadModule('console_test_runner');
{ await TestRunner.showPanel('console');
InspectorTest.evaluateInPage("logObjects()", step2);
function step2() await TestRunner.loadHTML(`
<div id="foo"></div>
`);
await TestRunner.evaluateInPagePromise(`
function logObjects()
{ {
InspectorTest.dumpConsoleMessages(); console.dir(window);
InspectorTest.completeTest(); console.dir(document.getElementById("foo").createShadowRoot());
} }
} `);
</script>
</head>
<body onload="runTest()"> TestRunner.evaluateInPage('logObjects()', step2);
<div id="foo"></div>
<p>
Tests that console does not log deprecated warning messages while dir-dumping objects.
</p>
</body> function step2() {
</html> ConsoleTestRunner.dumpConsoleMessages();
TestRunner.completeTest();
}
})();
CONSOLE MESSAGE: line 9: [object Window]
Tests that console dumps global object with properties. Tests that console dumps global object with properties.
{ {
......
<html> // Copyright 2017 The Chromium Authors. All rights reserved.
<head> // Use of this source code is governed by a BSD-style license that can be
<script src="../../http/tests/inspector/inspector-test.js"></script> // found in the LICENSE file.
<script src="../../http/tests/inspector/console-test.js"></script>
<script> (async function() {
TestRunner.addResult(`Tests that console dumps global object with properties.\n`);
function doit()
{
console.dir(window);
runTest();
}
function test() await TestRunner.loadModule('console_test_runner');
{ await TestRunner.showPanel('console');
InspectorTest.RuntimeAgent.evaluate("window", "console", false).then(evalCallback);
function evalCallback(result) await TestRunner.evaluateInPagePromise(`
function doit()
{ {
console.dir(window);
};
`);
TestRunner.RuntimeAgent.evaluate('window', 'console', false).then(evalCallback);
function evalCallback(result) {
if (!result) { if (!result) {
testController.notifyDone("Exception"); testController.notifyDone('Exception');
return; return;
} }
if (result.type === "error")
testController.notifyDone("Exception:" + result); if (result.type === 'error')
var objectProxy = InspectorTest.runtimeModel.createRemoteObject(result); testController.notifyDone('Exception:' + result);
var objectProxy = TestRunner.runtimeModel.createRemoteObject(result);
objectProxy.getOwnProperties(false, getPropertiesCallback); objectProxy.getOwnProperties(false, getPropertiesCallback);
} }
function getPropertiesCallback(properties) function getPropertiesCallback(properties) {
{
properties.sort(ObjectUI.ObjectPropertiesSection.CompareProperties); properties.sort(ObjectUI.ObjectPropertiesSection.CompareProperties);
var golden = { "window": 1, "document": 1, "eval": 1, "console": 1, "frames": 1, "Array": 1, "doit": 1 };
var golden = {
'window': 1,
'document': 1,
'eval': 1,
'console': 1,
'frames': 1,
'Array': 1,
'doit': 1
};
var result = {}; var result = {};
for (var i = 0; i < properties.length; ++i) { for (var i = 0; i < properties.length; ++i) {
var name = properties[i].name; var name = properties[i].name;
if (golden[name]) if (golden[name])
result[name] = 1; result[name] = 1;
} }
InspectorTest.addObject(result);
InspectorTest.completeTest();
}
}
</script>
</head>
<body onload="doit()"> TestRunner.addObject(result);
<p> TestRunner.completeTest();
Tests that console dumps global object with properties. }
</p> })();
</body>
</html>
<html> // Copyright 2017 The Chromium Authors. All rights reserved.
<head> // Use of this source code is governed by a BSD-style license that can be
<script src="../../http/tests/inspector/inspector-test.js"></script> // found in the LICENSE file.
<script src="../../http/tests/inspector/console-test.js"></script>
<script> (async function() {
function onload() TestRunner.addResult(`Tests that console logging dumps proper messages.\n`);
{
await TestRunner.loadModule('console_test_runner');
await TestRunner.showPanel('console');
await TestRunner.evaluateInPagePromise(`
function onload()
{
console.dir(["test1", "test2"]); console.dir(["test1", "test2"]);
console.dir(document.childNodes); console.dir(document.childNodes);
console.dir(document.evaluate("//head", document, null, XPathResult.ANY_TYPE, null)); console.dir(document.evaluate("//head", document, null, XPathResult.ANY_TYPE, null));
...@@ -44,40 +49,23 @@ function onload() ...@@ -44,40 +49,23 @@ function onload()
console.dir(event); console.dir(event);
runTest(); runTest();
} }
//# sourceURL=console-dir.html //# sourceURL=console-dir.js
</script> `);
<script> ConsoleTestRunner.expandConsoleMessages(step1, expandTreeElementFilter);
function test()
{
InspectorTest.expandConsoleMessages(step1, expandTreeElementFilter);
function expandTreeElementFilter(treeElement) function expandTreeElementFilter(treeElement) {
{
var name = treeElement.nameElement && treeElement.nameElement.textContent; var name = treeElement.nameElement && treeElement.nameElement.textContent;
return name === "foo" || treeElement.title === "<function scope>"; return name === 'foo' || treeElement.title === '<function scope>';
} }
function step1() function step1() {
{ ConsoleTestRunner.expandConsoleMessages(dumpConsoleMessages, expandTreeElementFilter);
InspectorTest.expandConsoleMessages(dumpConsoleMessages, expandTreeElementFilter);
} }
function dumpConsoleMessages() function dumpConsoleMessages() {
{ ConsoleTestRunner.dumpConsoleMessagesIgnoreErrorStackFrames();
InspectorTest.dumpConsoleMessagesIgnoreErrorStackFrames(); TestRunner.completeTest();
InspectorTest.completeTest();
} }
} })();
</script>
</head>
<body onload="onload()">
<p>
Tests that console logging dumps proper messages.
</p>
</body>
</html>
CONSOLE MESSAGE: line 10: [object Object]
Tests that property values can be edited inline in the console via double click. Tests that property values can be edited inline in the console via double click.
Node was hidden after dblclick: true Node was hidden after dblclick: true
...@@ -6,7 +5,7 @@ Node was hidden after dblclick: true ...@@ -6,7 +5,7 @@ Node was hidden after dblclick: true
Node was hidden after dblclick: true Node was hidden after dblclick: true
Node was hidden after dblclick: true Node was hidden after dblclick: true
logToConsole() logToConsole()
console-edit-property-value.html:10 {a: 1, b: "foo", c: null, d: 2} console-edit-property-value.js:15 {a: 1, b: "foo", c: null, d: 2}
a: 3 a: 3
b: "foo" b: "foo"
c: (3) [1, 2, 3] c: (3) [1, 2, 3]
......
<html> // Copyright 2017 The Chromium Authors. All rights reserved.
<head> // Use of this source code is governed by a BSD-style license that can be
<script src="../../http/tests/inspector/inspector-test.js"></script> // found in the LICENSE file.
<script src="../../http/tests/inspector/console-test.js"></script>
<script>
function logToConsole() (async function() {
{ TestRunner.addResult(`Tests that property values can be edited inline in the console via double click.\n`);
await TestRunner.loadModule('console_test_runner');
await TestRunner.showPanel('console');
await TestRunner.evaluateInPagePromise(`
function logToConsole()
{
var obj = {a: 1, b: "foo", c: null, d: 2}; var obj = {a: 1, b: "foo", c: null, d: 2};
console.log(obj); console.log(obj);
} }
`);
var test = function() ConsoleTestRunner.evaluateInConsole('logToConsole()', step1);
{
InspectorTest.evaluateInConsole("logToConsole()", step1);
function step1() function step1() {
{ ConsoleTestRunner.expandConsoleMessages(step2);
InspectorTest.expandConsoleMessages(step2);
} }
function step2() function step2() {
{
var valueElements = getValueElements(); var valueElements = getValueElements();
doubleClickTypeAndEnter(valueElements[0], "1 + 2"); doubleClickTypeAndEnter(valueElements[0], '1 + 2');
InspectorTest.waitForRemoteObjectsConsoleMessages(step3); ConsoleTestRunner.waitForRemoteObjectsConsoleMessages(step3);
} }
function step3() function step3() {
{
var valueElements = getValueElements(); var valueElements = getValueElements();
doubleClickTypeAndEnter(valueElements[1], "nonExistingValue"); doubleClickTypeAndEnter(valueElements[1], 'nonExistingValue');
InspectorTest.waitForRemoteObjectsConsoleMessages(step4); ConsoleTestRunner.waitForRemoteObjectsConsoleMessages(step4);
} }
function step4() function step4() {
{
var valueElements = getValueElements(); var valueElements = getValueElements();
doubleClickTypeAndEnter(valueElements[2], "[1, 2, 3]"); doubleClickTypeAndEnter(valueElements[2], '[1, 2, 3]');
InspectorTest.waitForRemoteObjectsConsoleMessages(step5); ConsoleTestRunner.waitForRemoteObjectsConsoleMessages(step5);
} }
function step5() function step5() {
{
var valueElements = getValueElements(); var valueElements = getValueElements();
doubleClickTypeAndEnter(valueElements[3], "{x: 2}"); doubleClickTypeAndEnter(valueElements[3], '{x: 2}');
InspectorTest.waitForRemoteObjectsConsoleMessages(step6); ConsoleTestRunner.waitForRemoteObjectsConsoleMessages(step6);
} }
function step6() function step6() {
{ ConsoleTestRunner.dumpConsoleMessagesIgnoreErrorStackFrames();
InspectorTest.dumpConsoleMessagesIgnoreErrorStackFrames(); TestRunner.completeTest();
InspectorTest.completeTest();
} }
function getValueElements() function getValueElements() {
{
var messageElement = Console.ConsoleView.instance()._visibleViewMessages[1].element(); var messageElement = Console.ConsoleView.instance()._visibleViewMessages[1].element();
return messageElement.querySelector(".console-message-text *").shadowRoot.querySelectorAll(".value"); return messageElement.querySelector('.console-message-text *').shadowRoot.querySelectorAll('.value');
} }
function doubleClickTypeAndEnter(node, text) function doubleClickTypeAndEnter(node, text) {
{ var event = document.createEvent('MouseEvent');
var event = document.createEvent("MouseEvent"); event.initMouseEvent('dblclick', true, true, null, 2);
event.initMouseEvent("dblclick", true, true, null, 2);
node.dispatchEvent(event); node.dispatchEvent(event);
TestRunner.addResult('Node was hidden after dblclick: ' + node.classList.contains('hidden'));
InspectorTest.addResult("Node was hidden after dblclick: " + node.classList.contains("hidden"));
var messageElement = Console.ConsoleView.instance()._visibleViewMessages[1].element(); var messageElement = Console.ConsoleView.instance()._visibleViewMessages[1].element();
var editPrompt = messageElement.querySelector(".console-message-text *").shadowRoot.querySelector(".text-prompt"); var editPrompt = messageElement.querySelector('.console-message-text *').shadowRoot.querySelector('.text-prompt');
editPrompt.textContent = text; editPrompt.textContent = text;
editPrompt.dispatchEvent(InspectorTest.createKeyEvent("Enter")); editPrompt.dispatchEvent(TestRunner.createKeyEvent('Enter'));
} }
} })();
</script>
</head>
<body onload="runTest()">
<p>
Tests that property values can be edited inline in the console via double click.
</p>
</body>
</html>
...@@ -217,7 +217,7 @@ ConsoleTestRunner.consoleMessagesCount = function() { ...@@ -217,7 +217,7 @@ ConsoleTestRunner.consoleMessagesCount = function() {
}; };
/** /**
* @param {function(!Element):string} messageFormatter * @param {function(!Element):string|undefined} messageFormatter
* @param {!Element} node * @param {!Element} node
* @return {string} * @return {string}
*/ */
...@@ -261,7 +261,7 @@ ConsoleTestRunner.dumpConsoleMessagesIgnoreErrorStackFrames = function( ...@@ -261,7 +261,7 @@ ConsoleTestRunner.dumpConsoleMessagesIgnoreErrorStackFrames = function(
printOriginatingCommand, dumpClassNames, messageFormatter) { printOriginatingCommand, dumpClassNames, messageFormatter) {
TestRunner.addResults(ConsoleTestRunner.dumpConsoleMessagesIntoArray( TestRunner.addResults(ConsoleTestRunner.dumpConsoleMessagesIntoArray(
printOriginatingCommand, dumpClassNames, printOriginatingCommand, dumpClassNames,
messageFormatter ? ConsoleTestRunner.formatterIgnoreStackFrameUrls.bind(this, messageFormatter) : undefined)); ConsoleTestRunner.formatterIgnoreStackFrameUrls.bind(this, messageFormatter)));
}; };
ConsoleTestRunner.dumpConsoleMessagesWithStyles = function() { ConsoleTestRunner.dumpConsoleMessagesWithStyles = function() {
...@@ -410,11 +410,11 @@ ConsoleTestRunner.waitForRemoteObjectsConsoleMessages = function(callback) { ...@@ -410,11 +410,11 @@ ConsoleTestRunner.waitForRemoteObjectsConsoleMessages = function(callback) {
ConsoleTestRunner.waitUntilConsoleEditorLoaded = function() { ConsoleTestRunner.waitUntilConsoleEditorLoaded = function() {
var fulfill; var fulfill;
var promise = new Promise(x => (fulfill = x)); var promise = new Promise(x => (fulfill = x));
var editor = Console.ConsoleView.instance()._prompt._editor; var prompt = Console.ConsoleView.instance()._prompt;
if (editor) if (prompt._editor)
fulfill(editor); fulfill(prompt._editor);
else else
TestRunner.addSniffer(Console.ConsolePrompt.prototype, '_editorSetForTest', _ => fulfill(editor)); TestRunner.addSniffer(Console.ConsolePrompt.prototype, '_editorSetForTest', _ => fulfill(prompt._editor));
return promise; return promise;
}; };
......
...@@ -56,9 +56,13 @@ function migrateTest(inputPath, identifierMap) { ...@@ -56,9 +56,13 @@ function migrateTest(inputPath, identifierMap) {
helperScripts.push(filename); helperScripts.push(filename);
}); });
const outPath = migrateUtils.getOutPath(inputPath); const testsPath = path.resolve(__dirname, 'tests.txt');
const srcResourcePaths = resourceScripts.map(s => path.resolve(path.dirname(inputPath), s)); const newToOldTests = new Map(fs.readFileSync(testsPath, 'utf-8').split('\n').map(line => line.split(' ').reverse()));
const destResourcePaths = resourceScripts.map(s => path.resolve(path.dirname(outPath), s)); const originalTestPath = path.resolve(
__dirname, '..', '..', '..', '..', 'LayoutTests', newToOldTests.get(inputPath.slice(inputPath.indexOf('http/'))));
const srcResourcePaths = resourceScripts.map(s => path.resolve(path.dirname(originalTestPath), s));
const destResourcePaths = resourceScripts.map(s => path.resolve(path.dirname(inputPath), s));
const relativeResourcePaths = destResourcePaths.map(p => p.slice(p.indexOf('/http/tests') + '/http/tests'.length)); const relativeResourcePaths = destResourcePaths.map(p => p.slice(p.indexOf('/http/tests') + '/http/tests'.length));
let outputCode; let outputCode;
...@@ -86,16 +90,9 @@ function migrateTest(inputPath, identifierMap) { ...@@ -86,16 +90,9 @@ function migrateTest(inputPath, identifierMap) {
console.log(outputCode); console.log(outputCode);
if (!DRY_RUN) { if (!DRY_RUN) {
mkdirp.sync(path.dirname(outPath)); fs.writeFileSync(inputPath, outputCode);
fs.writeFileSync(outPath, outputCode);
const expectationsPath = inputPath.replace('.html', '-expected.txt');
copyExpectations(expectationsPath, outPath);
copyResourceScripts(srcResourcePaths, destResourcePaths); copyResourceScripts(srcResourcePaths, destResourcePaths);
console.log('Migrated: ', inputPath);
fs.unlinkSync(inputPath);
fs.unlinkSync(expectationsPath);
console.log('Migrated to: ', outPath);
} }
} }
...@@ -179,12 +176,11 @@ function transformTestScript( ...@@ -179,12 +176,11 @@ function transformTestScript(
* Create test header based on extracted data * Create test header based on extracted data
*/ */
const headerLines = []; const headerLines = [];
headerLines.push(createExpressionNode(`TestRunner.addResult('${bodyText}\\n');`)); headerLines.push(createExpressionNode(`TestRunner.addResult(\`${bodyText}\\n\`);`));
headerLines.push(createNewLineNode()); headerLines.push(createNewLineNode());
for (const helper of allTestHelpers) { for (const helper of allTestHelpers) {
headerLines.push(createAwaitExpressionNode(`await TestRunner.loadModule('${helper}');`)); headerLines.push(createAwaitExpressionNode(`await TestRunner.loadModule('${helper}');`));
} }
headerLines.push(createAwaitExpressionNode(`await TestRunner.loadPanel('${panel}');`));
headerLines.push(createAwaitExpressionNode(`await TestRunner.showPanel('${panel}');`)); headerLines.push(createAwaitExpressionNode(`await TestRunner.showPanel('${panel}');`));
if (domFixture) { if (domFixture) {
......
inspector/console/alert-toString-exception.html inspector/console/alert-toString-exception.html
inspector/console/console-api-on-call-frame.html inspector/console/console-api-on-call-frame.html
inspector/console/console-bind-fake.html http/tests/devtools/console/console-bind-fake.js
inspector/console/console-call-getter-on-proto.html http/tests/devtools/console/console-call-getter-on-proto.js
inspector/console/console-clear-function.html inspector/console/console-clear-function.html
inspector/console/console-command-clear.html http/tests/devtools/console/console-command-clear.js
inspector/console/console-command-copy.html inspector/console/console-command-copy.html
inspector/console/console-context-selector.html inspector/console/console-context-selector.html
inspector/console/console-control-characters.html http/tests/devtools/console/console-control-characters.js
inspector/console/console-copy-treeoutline.html inspector/console/console-copy-treeoutline.html
inspector/console/console-copy-truncated-text.html inspector/console/console-copy-truncated-text.html
inspector/console/console-correct-suggestions.html http/tests/devtools/console/console-correct-suggestions.js
inspector/console/console-css-unterminated-comment.html http/tests/devtools/console/console-css-unterminated-comment.js
inspector/console/console-dir-deprecated.html http/tests/devtools/console/console-dir-deprecated.js
inspector/console/console-dir-global.html http/tests/devtools/console/console-dir-global.js
inspector/console/console-dir.html http/tests/devtools/console/console-dir.js
inspector/console/console-edit-property-value.html http/tests/devtools/console/console-edit-property-value.js
inspector/console/console-error-on-call-frame.html inspector/console/console-error-on-call-frame.html
\ No newline at end of file
// 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.
'use strict';
const fs = require('fs');
const path = require('path');
const childProcess = require('child_process');
const utils = require('../utils');
const MIGRATE_SCRIPT_PATH = path.resolve(__dirname, 'migrate_test.js');
const TESTS_PATH = path.resolve(__dirname, 'tests.txt');
const TEST_EXPECTATIONS_PATH = path.resolve(__dirname, '..', '..', '..', '..', 'LayoutTests', 'TestExpectations');
const FLAG_EXPECTATIONS_PATH = path.resolve(__dirname, '..', '..', '..', '..', 'LayoutTests', 'FlagExpectations');
function main() {
const tests = fs.readFileSync(TESTS_PATH, 'utf-8').split('\n').map(line => line.split(' '));
const oldToNewTests = new Map(tests);
const testCount = oldToNewTests.size;
const migratedTests = new Set();
for (const [_, testPath] of tests) {
if (!testPath)
continue;
const fullTestPath = path.resolve(__dirname, '..', '..', '..', '..', 'LayoutTests', testPath);
try {
childProcess.execSync(`node ${MIGRATE_SCRIPT_PATH} ${fullTestPath}`)
} catch (err) {
console.log(err.stdout.toString());
continue;
}
for (const [oldTest, newTest] of oldToNewTests) {
if (testPath === newTest)
oldToNewTests.delete(oldTest);
}
migratedTests.add(testPath);
}
console.log(`Successfully migrated: ${migratedTests.size} of ${testCount}`);
const updatedTests = Array.from(oldToNewTests.entries()).map(line => line.join(' ')).join('\n');
console.log(updatedTests);
// Update TestExpectations
const testExpectations = fs.readFileSync(TEST_EXPECTATIONS_PATH, 'utf-8');
const updatedTestExpecationLines = [];
let seenStartSentinel = false;
let seenEndSentinel = false;
for (const line of testExpectations.split('\n')) {
if (line === '# ====== DevTools test migration failures from here ======') {
seenStartSentinel = true;
updatedTestExpecationLines.push(line);
continue;
}
if (line === '# ====== DevTools test migration failures until here ======') {
seenEndSentinel = true;
updatedTestExpecationLines.push(line);
continue;
}
if (seenEndSentinel) {
updatedTestExpecationLines.push(line);
continue;
}
if (!seenStartSentinel) {
updatedTestExpecationLines.push(line);
continue;
}
let skipLine = false;
for (const test of migratedTests) {
if (line.indexOf(test) !== -1) {
skipLine = true;
break;
}
}
if (!skipLine)
updatedTestExpecationLines.push(line);
}
fs.writeFileSync(TEST_EXPECTATIONS_PATH, updatedTestExpecationLines.join('\n'));
// Update tests.txt
fs.writeFileSync(TESTS_PATH, updatedTests);
}
main();
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