Commit 85b0527c authored by Guido Urdaneta's avatar Guido Urdaneta Committed by Commit Bot

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

This reverts commit 9869d2f1.

Reason for revert: Suspect of making console tests to fail consistently on WebKit Win7 (dbg) (stats) bot.

See
https://build.chromium.org/p/chromium.webkit/builders/WebKit%20Win7%20%28dbg%29/builds/10448


Unexpected Failures:
* http/tests/devtools/console/console-correct-suggestions.js
* virtual/mojo-loading/http/tests/devtools/console/console-correct-suggestions.js



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}

TBR=dgozman@chromium.org,chenwilliam@chromium.org

Change-Id: Ib2d71bb01073eedd692d2416c688c2985b16b3c3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 667560
Reviewed-on: https://chromium-review.googlesource.com/599828Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Commit-Queue: Guido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491695}
parent efadb500
...@@ -612,11 +612,27 @@ crbug.com/728378 virtual/layout_ng/overflow/overflow-position-004.html [ Failure ...@@ -612,11 +612,27 @@ 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 ]
### Manually fix after migration crbug.com/667560 virtual/mojo-loading/http/tests/devtools/console/console-call-getter-on-proto.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-command-clear.js [ Skip ]
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 ======
......
// Copyright 2017 The Chromium Authors. All rights reserved. <html>
// Use of this source code is governed by a BSD-style license that can be <head>
// found in the LICENSE file. <script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
<script>
var foo = 'fooValue';
(async function() { Function.prototype.bind = function () { throw ":P"; };
TestRunner.addResult(`Tests that overriding Function.prototype.bind does not break inspector.\n`);
await TestRunner.loadModule('console_test_runner'); function test()
await TestRunner.showPanel('console'); {
InspectorTest.evaluateInConsole("foo", step1);
await TestRunner.evaluateInPagePromise(` function step1()
var foo = 'fooValue'; {
Function.prototype.bind = function () { throw ":P"; }; InspectorTest.dumpConsoleMessages();
`); InspectorTest.completeTest();
}
}
</script>
</head>
ConsoleTestRunner.evaluateInConsole('foo', step1); <body onload="runTest()">
<p>
Tests that overriding Function.prototype.bind does not break inspector.
</p>
function step1() { </body>
ConsoleTestRunner.dumpConsoleMessages(); </html>
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.js:27 B {value: 239} console-call-getter-on-proto.html:21 B {value: 239}
foo: 239 foo: 239
value: 239 value: 239
__proto__: A __proto__: A
......
// Copyright 2017 The Chromium Authors. All rights reserved. <html>
// Use of this source code is governed by a BSD-style license that can be <head>
// found in the LICENSE file. <script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
(async function() { <script>
TestRunner.addResult(`Tests that calling getter on prototype will call it on the object.\n`); function logObject()
{
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,
...@@ -25,30 +19,40 @@ ...@@ -25,30 +19,40 @@
__proto__: A.prototype __proto__: A.prototype
} }
console.log(new B()); console.log(new B());
} }
`);
TestRunner.evaluateInPage('logObject()', step2);
function step2() { function test()
ConsoleTestRunner.expandConsoleMessages(step3); {
InspectorTest.evaluateInPage("logObject()", step2);
function step2()
{
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() {
ConsoleTestRunner.expandConsoleMessages(step4, expandTreeElementFilter);
} }
function step3()
function step4() { {
ConsoleTestRunner.expandGettersInConsoleMessages(step5); InspectorTest.expandConsoleMessages(step4, expandTreeElementFilter);
} }
function step4()
function step5() { {
ConsoleTestRunner.dumpConsoleMessages(false, false, TestRunner.textContentWithLineBreaks); InspectorTest.expandGettersInConsoleMessages(step5);
TestRunner.completeTest();
} }
})(); function step5()
{
InspectorTest.dumpConsoleMessages(false, false, InspectorTest.textContentWithLineBreaks);
InspectorTest.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.js:14 one console-command-clear.html:9 one
console-command-clear.js:15 two console-command-clear.html:10 two
console-command-clear.js:16 three console-command-clear.html:11 three
=== After clear === === After clear ===
VM:1 Console was cleared VM:1 Console was cleared
// Copyright 2017 The Chromium Authors. All rights reserved. <html>
// Use of this source code is governed by a BSD-style license that can be <head>
// found in the LICENSE file. <script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
<script>
(async function() { function log() {
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();
`); log();
TestRunner.addResult('=== Before clear ==='); function test()
ConsoleTestRunner.dumpConsoleMessages(); {
function callback() { InspectorTest.addResult("=== Before clear ===");
TestRunner.addResult('=== After clear ==='); InspectorTest.dumpConsoleMessages();
ConsoleTestRunner.dumpConsoleMessages();
TestRunner.completeTest(); function callback()
{
InspectorTest.addResult("=== After clear ===");
InspectorTest.dumpConsoleMessages();
InspectorTest.completeTest();
} }
InspectorTest.evaluateInConsole("clear()", callback);
}
</script>
</head>
<body onload="runTest()">
<p>
Tests that console is cleared upon clear() eval in console.
</p>
ConsoleTestRunner.evaluateInConsole('clear()', callback); </body>
})(); </html>
// Copyright 2017 The Chromium Authors. All rights reserved. <html>
// Use of this source code is governed by a BSD-style license that can be <head>
// found in the LICENSE file. <script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
<script>
(async function() { function test()
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);
await TestRunner.loadModule('console_test_runner'); function onEvaluated()
await TestRunner.showPanel('console'); {
InspectorTest.dumpConsoleMessages();
InspectorTest.completeTest();
}
}
ConsoleTestRunner.evaluateInConsole('var\u001d i = 0;', onEvaluated); </script>
</head>
function onEvaluated() { <body onload="runTest()">
ConsoleTestRunner.dumpConsoleMessages(); <p>
TestRunner.completeTest(); Verify that control characters are substituted with printable characters.
} </p>
})();
</body>
</html>
// Copyright 2017 The Chromium Authors. All rights reserved. <html>
// Use of this source code is governed by a BSD-style license that can be <head>
// found in the LICENSE file. <script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
(async function() { <script>
TestRunner.addResult(`Tests that console correctly finds suggestions in complicated cases.\n`); function templateString()
{
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 shouldFindThisFunction() { } function shouldNotFindThisFunction() { }
window["should not find this"] = true; function shouldFindThisFunction() { }
var myMap = new Map([['first', 1], ['second', 2], ['third', 3], ['shouldNotFindThis', 4]]); window["should not find this"] = true;
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 TestRunner.addSnifferPromise(consoleEditor._autocompleteController, '_onSuggestionsShownForTest').then(checkExpected); return InspectorTest.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)
TestRunner.addResult('Found: ' + expected[i] + ', displayed as ' + completions.get(expected[i]).title); InspectorTest.addResult("Found: " + expected[i] + ", displayed as " + completions.get(expected[i]).title);
else else
TestRunner.addResult('Found: ' + expected[i]); InspectorTest.addResult("Found: " + expected[i]);
} else { } else {
TestRunner.addResult('Not Found: ' + expected[i]); InspectorTest.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([
() => ConsoleTestRunner.waitUntilConsoleEditorLoaded().then(e => consoleEditor = e), InspectorTest.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"]']),
...@@ -122,6 +111,13 @@ ...@@ -122,6 +111,13 @@
() => 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(TestRunner.completeTest); ]).then(InspectorTest.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.js:17 Window console-dir-deprecated.html:9 Window
console-dir-deprecated.js:18 #document-fragment console-dir-deprecated.html:10 #document-fragment
// Copyright 2017 The Chromium Authors. All rights reserved. <html>
// Use of this source code is governed by a BSD-style license that can be <head>
// found in the LICENSE file. <script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
<script>
(async function() { function logObjects()
TestRunner.addResult(`Tests that console does not log deprecated warning messages while dir-dumping objects.\n`); {
await TestRunner.loadModule('console_test_runner');
await TestRunner.showPanel('console');
await TestRunner.loadHTML(`
<div id="foo"></div>
`);
await TestRunner.evaluateInPagePromise(`
function logObjects()
{
console.dir(window); console.dir(window);
console.dir(document.getElementById("foo").createShadowRoot()); console.dir(document.getElementById("foo").createShadowRoot());
}
function test()
{
InspectorTest.evaluateInPage("logObjects()", step2);
function step2()
{
InspectorTest.dumpConsoleMessages();
InspectorTest.completeTest();
} }
`); }
TestRunner.evaluateInPage('logObjects()', step2); </script>
</head>
function step2() { <body onload="runTest()">
ConsoleTestRunner.dumpConsoleMessages(); <div id="foo"></div>
TestRunner.completeTest(); <p>
} Tests that console does not log deprecated warning messages while dir-dumping objects.
})(); </p>
</body>
</html>
CONSOLE MESSAGE: line 9: [object Window]
Tests that console dumps global object with properties. Tests that console dumps global object with properties.
{ {
......
// Copyright 2017 The Chromium Authors. All rights reserved. <html>
// Use of this source code is governed by a BSD-style license that can be <head>
// found in the LICENSE file. <script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
(async function() { <script>
TestRunner.addResult(`Tests that console dumps global object with properties.\n`);
function doit()
await TestRunner.loadModule('console_test_runner'); {
await TestRunner.showPanel('console');
await TestRunner.evaluateInPagePromise(`
function doit()
{
console.dir(window); console.dir(window);
}; runTest();
`); }
TestRunner.RuntimeAgent.evaluate('window', 'console', false).then(evalCallback); function test()
{
InspectorTest.RuntimeAgent.evaluate("window", "console", false).then(evalCallback);
function evalCallback(result) { function evalCallback(result)
{
if (!result) { if (!result) {
testController.notifyDone('Exception'); testController.notifyDone("Exception");
return; return;
} }
if (result.type === "error")
if (result.type === 'error') testController.notifyDone("Exception:" + result);
testController.notifyDone('Exception:' + result); var objectProxy = InspectorTest.runtimeModel.createRemoteObject(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);
TestRunner.addObject(result); InspectorTest.completeTest();
TestRunner.completeTest();
} }
})(); }
</script>
</head>
<body onload="doit()">
<p>
Tests that console dumps global object with properties.
</p>
</body>
</html>
// Copyright 2017 The Chromium Authors. All rights reserved. <html>
// Use of this source code is governed by a BSD-style license that can be <head>
// found in the LICENSE file. <script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
(async function() { <script>
TestRunner.addResult(`Tests that console logging dumps proper messages.\n`); function onload()
{
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));
...@@ -49,23 +44,40 @@ ...@@ -49,23 +44,40 @@
console.dir(event); console.dir(event);
runTest(); runTest();
} }
//# sourceURL=console-dir.js //# sourceURL=console-dir.html
`); </script>
ConsoleTestRunner.expandConsoleMessages(step1, expandTreeElementFilter); <script>
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(); {
TestRunner.completeTest(); InspectorTest.dumpConsoleMessagesIgnoreErrorStackFrames();
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
...@@ -5,7 +6,7 @@ Node was hidden after dblclick: true ...@@ -5,7 +6,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.js:15 {a: 1, b: "foo", c: null, d: 2} console-edit-property-value.html:10 {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]
......
// Copyright 2017 The Chromium Authors. All rights reserved. <html>
// Use of this source code is governed by a BSD-style license that can be <head>
// found in the LICENSE file. <script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
<script>
(async function() { function logToConsole()
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);
} }
`);
ConsoleTestRunner.evaluateInConsole('logToConsole()', step1); var test = function()
{
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");
ConsoleTestRunner.waitForRemoteObjectsConsoleMessages(step3); InspectorTest.waitForRemoteObjectsConsoleMessages(step3);
} }
function step3() { function step3()
{
var valueElements = getValueElements(); var valueElements = getValueElements();
doubleClickTypeAndEnter(valueElements[1], 'nonExistingValue'); doubleClickTypeAndEnter(valueElements[1], "nonExistingValue");
ConsoleTestRunner.waitForRemoteObjectsConsoleMessages(step4); InspectorTest.waitForRemoteObjectsConsoleMessages(step4);
} }
function step4() { function step4()
{
var valueElements = getValueElements(); var valueElements = getValueElements();
doubleClickTypeAndEnter(valueElements[2], '[1, 2, 3]'); doubleClickTypeAndEnter(valueElements[2], "[1, 2, 3]");
ConsoleTestRunner.waitForRemoteObjectsConsoleMessages(step5); InspectorTest.waitForRemoteObjectsConsoleMessages(step5);
} }
function step5() { function step5()
{
var valueElements = getValueElements(); var valueElements = getValueElements();
doubleClickTypeAndEnter(valueElements[3], '{x: 2}'); doubleClickTypeAndEnter(valueElements[3], "{x: 2}");
ConsoleTestRunner.waitForRemoteObjectsConsoleMessages(step6); InspectorTest.waitForRemoteObjectsConsoleMessages(step6);
} }
function step6() { function step6()
ConsoleTestRunner.dumpConsoleMessagesIgnoreErrorStackFrames(); {
TestRunner.completeTest(); InspectorTest.dumpConsoleMessagesIgnoreErrorStackFrames();
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'); {
event.initMouseEvent('dblclick', true, true, null, 2); var event = document.createEvent("MouseEvent");
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(TestRunner.createKeyEvent('Enter')); editPrompt.dispatchEvent(InspectorTest.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|undefined} messageFormatter * @param {function(!Element):string} 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,
ConsoleTestRunner.formatterIgnoreStackFrameUrls.bind(this, messageFormatter))); messageFormatter ? ConsoleTestRunner.formatterIgnoreStackFrameUrls.bind(this, messageFormatter) : undefined));
}; };
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 prompt = Console.ConsoleView.instance()._prompt; var editor = Console.ConsoleView.instance()._prompt._editor;
if (prompt._editor) if (editor)
fulfill(prompt._editor); fulfill(editor);
else else
TestRunner.addSniffer(Console.ConsolePrompt.prototype, '_editorSetForTest', _ => fulfill(prompt._editor)); TestRunner.addSniffer(Console.ConsolePrompt.prototype, '_editorSetForTest', _ => fulfill(editor));
return promise; return promise;
}; };
......
...@@ -56,13 +56,9 @@ function migrateTest(inputPath, identifierMap) { ...@@ -56,13 +56,9 @@ function migrateTest(inputPath, identifierMap) {
helperScripts.push(filename); helperScripts.push(filename);
}); });
const testsPath = path.resolve(__dirname, 'tests.txt'); const outPath = migrateUtils.getOutPath(inputPath);
const newToOldTests = new Map(fs.readFileSync(testsPath, 'utf-8').split('\n').map(line => line.split(' ').reverse())); const srcResourcePaths = resourceScripts.map(s => path.resolve(path.dirname(inputPath), s));
const originalTestPath = path.resolve( const destResourcePaths = resourceScripts.map(s => path.resolve(path.dirname(outPath), s));
__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;
...@@ -90,9 +86,16 @@ function migrateTest(inputPath, identifierMap) { ...@@ -90,9 +86,16 @@ function migrateTest(inputPath, identifierMap) {
console.log(outputCode); console.log(outputCode);
if (!DRY_RUN) { if (!DRY_RUN) {
fs.writeFileSync(inputPath, outputCode); mkdirp.sync(path.dirname(outPath));
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);
} }
} }
...@@ -176,11 +179,12 @@ function transformTestScript( ...@@ -176,11 +179,12 @@ 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