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
# ====== DevTools test migration failures from here ======
# Temporary failures (these tests are moves from html to js)
# 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
### Manually fix after migration
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-bind-fake.js [ Skip ]
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-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 ======
......
// 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.
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
<script>
var foo = 'fooValue';
(async function() {
TestRunner.addResult(`Tests that overriding Function.prototype.bind does not break inspector.\n`);
Function.prototype.bind = function () { throw ":P"; };
await TestRunner.loadModule('console_test_runner');
await TestRunner.showPanel('console');
function test()
{
InspectorTest.evaluateInConsole("foo", step1);
await TestRunner.evaluateInPagePromise(`
var foo = 'fooValue';
Function.prototype.bind = function () { throw ":P"; };
`);
function step1()
{
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() {
ConsoleTestRunner.dumpConsoleMessages();
TestRunner.completeTest();
}
})();
</body>
</html>
CONSOLE MESSAGE: line 21: [object 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
value: 239
__proto__: A
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(async function() {
TestRunner.addResult(`Tests that 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()
{
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
<script>
function logObject()
{
var A = function() { this.value = 239; }
A.prototype = {
constructor: A,
......@@ -25,30 +19,40 @@
__proto__: A.prototype
}
console.log(new B());
}
`);
TestRunner.evaluateInPage('logObject()', step2);
}
function step2() {
ConsoleTestRunner.expandConsoleMessages(step3);
function test()
{
InspectorTest.evaluateInPage("logObject()", step2);
function step2()
{
InspectorTest.expandConsoleMessages(step3);
}
function expandTreeElementFilter(treeElement) {
function expandTreeElementFilter(treeElement)
{
var name = treeElement.nameElement && treeElement.nameElement.textContent;
return name === '__proto__';
}
function step3() {
ConsoleTestRunner.expandConsoleMessages(step4, expandTreeElementFilter);
return name === "__proto__";
}
function step4() {
ConsoleTestRunner.expandGettersInConsoleMessages(step5);
function step3()
{
InspectorTest.expandConsoleMessages(step4, expandTreeElementFilter);
}
function step5() {
ConsoleTestRunner.dumpConsoleMessages(false, false, TestRunner.textContentWithLineBreaks);
TestRunner.completeTest();
function step4()
{
InspectorTest.expandGettersInConsoleMessages(step5);
}
})();
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.
=== Before clear ===
console-command-clear.js:14 one
console-command-clear.js:15 two
console-command-clear.js:16 three
console-command-clear.html:9 one
console-command-clear.html:10 two
console-command-clear.html:11 three
=== After clear ===
VM:1 Console was cleared
// 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.
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
<script>
(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() {
function log() {
// Fill console.
console.log("one");
console.log("two");
console.log("three");
}
log();
`);
}
log();
TestRunner.addResult('=== Before clear ===');
ConsoleTestRunner.dumpConsoleMessages();
function test()
{
function callback() {
TestRunner.addResult('=== After clear ===');
ConsoleTestRunner.dumpConsoleMessages();
TestRunner.completeTest();
InspectorTest.addResult("=== Before clear ===");
InspectorTest.dumpConsoleMessages();
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.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
<script>
(async function() {
TestRunner.addResult(`Verify that control characters are substituted with printable characters.\n`);
function test()
{
// The following command has control character.
InspectorTest.evaluateInConsole("var\u001D i = 0;", onEvaluated);
await TestRunner.loadModule('console_test_runner');
await TestRunner.showPanel('console');
function onEvaluated()
{
InspectorTest.dumpConsoleMessages();
InspectorTest.completeTest();
}
}
ConsoleTestRunner.evaluateInConsole('var\u001d i = 0;', onEvaluated);
</script>
</head>
function onEvaluated() {
ConsoleTestRunner.dumpConsoleMessages();
TestRunner.completeTest();
}
})();
<body onload="runTest()">
<p>
Verify that control characters are substituted with printable characters.
</p>
</body>
</html>
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(async function() {
TestRunner.addResult(`Tests that console correctly finds suggestions in complicated cases.\n`);
await TestRunner.loadModule('console_test_runner');
await TestRunner.showPanel('console');
await TestRunner.evaluateInPagePromise(`
function templateString()
{
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
<script>
function templateString()
{
console.log("The template string should not run and you should not see this log");
return {
shouldNotFindThis:56
};
}
function shouldNotFindThisFunction() { }
function shouldFindThisFunction() { }
window["should not find this"] = true;
var myMap = new Map([['first', 1], ['second', 2], ['third', 3], ['shouldNotFindThis', 4]]);
var complicatedObject = {
}
function shouldNotFindThisFunction() { }
function shouldFindThisFunction() { }
window["should not find this"] = true;
var myMap = new Map([['first', 1], ['second', 2], ['third', 3], ['shouldNotFindThis', 4]]);
var complicatedObject = {
'foo-bar': true,
'"double-qouted"': true,
"'single-qouted'": true,
"notDangerous();": true
}
`);
}
function test()
{
var consoleEditor;
function testCompletions(text, expected, force) {
function testCompletions(text, expected, force)
{
var cursorPosition = text.indexOf('|');
if (cursorPosition < 0)
cursorPosition = Infinity;
consoleEditor.setText(text.replace('|', ''));
consoleEditor.setSelection(TextUtils.TextRange.createFromLocation(0, cursorPosition));
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 message = 'Checking \'' + text.replace('\n', '\\n').replace('\r', '\\r') + '\'';
var message = "Checking '" + text.replace('\n', '\\n').replace('\r', '\\r') + "'";
if (force)
message += ' forcefully';
TestRunner.addResult(message);
message += " forcefully";
InspectorTest.addResult(message);
for (var i = 0; i < expected.length; i++) {
if (completions.has(expected[i])) {
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
TestRunner.addResult('Found: ' + expected[i]);
InspectorTest.addResult("Found: " + expected[i]);
} else {
TestRunner.addResult('Not Found: ' + expected[i]);
InspectorTest.addResult("Not Found: " + expected[i]);
}
}
TestRunner.addResult('');
InspectorTest.addResult("");
}
}
function sequential(tests) {
function sequential(tests)
{
var promise = Promise.resolve();
for (var i = 0; i < tests.length; i++)
promise = promise.then(tests[i]);
return promise;
}
sequential([
() => ConsoleTestRunner.waitUntilConsoleEditorLoaded().then(e => consoleEditor = e),
() => testCompletions('window.do', ['document']),
() => testCompletions('win', ['window']),
InspectorTest.waitUntilConsoleEditorLoaded().then(e => consoleEditor = e),
() => testCompletions("window.do", ["document"]),
() => testCompletions("win", ["window"]),
() => testCompletions('window["doc', ['"document"]']),
() => testCompletions('window["document"].bo', ['body']),
() => testCompletions('window["document"]["body"].textC', ['textContent']),
() => testCompletions('document.body.inner', ['innerText', 'innerHTML']),
() => testCompletions('document["body"][window.do', ['document']),
() => testCompletions('document["body"][window["document"].body.childNodes[0].text', ['textContent']),
() => testCompletions('templateString`asdf`should', ['shouldNotFindThis']),
() => testCompletions('window.document.BODY', ['body']),
() => testCompletions('window.dOcUmE', ['document']),
() => testCompletions('window.node', ['NodeList', 'AudioNode', 'GainNode']),
() => testCompletions('32', ['Float32Array', 'Int32Array']),
() => testCompletions('window.32', ['Float32Array', 'Int32Array']),
() => testCompletions('', ['window'], false),
() => testCompletions('', ['window'], true),
() => testCompletions('"string g', ['getComputedStyle'], false),
() => testCompletions('`template string docu', ['document'], false),
() => testCompletions('`${do', ['document'], false),
() => testCompletions('// do', ['document'], false),
() => testCompletions('["should', ['shouldNotFindThisFunction']),
() => testCompletions('shou', ['should not find this']),
() => testCompletions('window["document"].bo', ["body"]),
() => testCompletions('window["document"]["body"].textC', ["textContent"]),
() => testCompletions('document.body.inner', ["innerText", "innerHTML"]),
() => testCompletions('document["body"][window.do', ["document"]),
() => testCompletions('document["body"][window["document"].body.childNodes[0].text', ["textContent"]),
() => testCompletions("templateString`asdf`should", ["shouldNotFindThis"]),
() => testCompletions("window.document.BODY", ["body"]),
() => testCompletions("window.dOcUmE", ["document"]),
() => testCompletions("window.node", ["NodeList", "AudioNode", "GainNode"]),
() => testCompletions("32", ["Float32Array", "Int32Array"]),
() => testCompletions("window.32", ["Float32Array", "Int32Array"]),
() => testCompletions("", ["window"], false),
() => testCompletions("", ["window"], true),
() => testCompletions('"string g', ["getComputedStyle"], false),
() => testCompletions("`template string docu", ["document"], false),
() => testCompletions("`${do", ["document"], false),
() => testCompletions("// do", ["document"], false),
() => testCompletions('["should', ["shouldNotFindThisFunction"]),
() => testCompletions("shou", ["should not find this"]),
() => testCompletions('myMap.get(', ['"first")', '"second")', '"third")']),
() => testCompletions('myMap.get(\'', ['\'first\')', '\'second\')', '\'third\')']),
() => 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('document. bo', ['body']),
() => testCompletions('document.\tbo', ['body']),
() => testCompletions('document.\nbo', ['body']),
() => testCompletions('document.\r\nbo', ['body']),
() => testCompletions('document [ \'bo', ['\'body\']']),
() => testCompletions('function hey(should', ['shouldNotFindThisFunction']),
() => testCompletions('var should', ['shouldNotFindThisFunction']),
() => testCompletions('document[[win', ['window']),
() => testCompletions('document[ [win', ['window']),
() => testCompletions('document[ [ win', ['window']),
() => testCompletions("document. bo", ["body"]),
() => testCompletions("document.\tbo", ["body"]),
() => testCompletions("document.\nbo", ["body"]),
() => testCompletions("document.\r\nbo", ["body"]),
() => testCompletions("document [ 'bo", ["'body']"]),
() => testCompletions("function hey(should", ["shouldNotFindThisFunction"]),
() => testCompletions("var should", ["shouldNotFindThisFunction"]),
() => testCompletions("document[[win", ["window"]),
() => testCompletions("document[ [win", ["window"]),
() => testCompletions("document[ [ win", ["window"]),
() => testCompletions('I|mag', ['Image', 'Infinity']),
() => testCompletions('var x = (do|);', ['document']),
() => testCompletions('complicatedObject["foo', ['"foo-bar"]']),
......@@ -122,6 +111,13 @@
() => testCompletions('complicatedObject[\'\\\'sing', ['\'\\\'single-qouted\\\'\']']),
() => testCompletions('complicatedObject["\'single-qou', ['"\'single-qouted\'"]']),
() => testCompletions('complicatedObject["\\"double-qouted\\"', ['"\\"double-qouted\\""]']),
() => testCompletions('complicatedObject["notDangerous();', ['"notDangerous();"]'])
]).then(TestRunner.completeTest);
})();
() => testCompletions('complicatedObject["notDangerous();', ['"notDangerous();"]']),
]).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.
console-dir-deprecated.js:17 Window
console-dir-deprecated.js:18 #document-fragment
console-dir-deprecated.html:9 Window
console-dir-deprecated.html:10 #document-fragment
// 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.
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
<script>
(async function() {
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()
{
function logObjects()
{
console.dir(window);
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() {
ConsoleTestRunner.dumpConsoleMessages();
TestRunner.completeTest();
}
})();
<body onload="runTest()">
<div id="foo"></div>
<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.
{
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(async function() {
TestRunner.addResult(`Tests that console dumps global object with properties.\n`);
await TestRunner.loadModule('console_test_runner');
await TestRunner.showPanel('console');
await TestRunner.evaluateInPagePromise(`
function doit()
{
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
<script>
function doit()
{
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) {
testController.notifyDone('Exception');
testController.notifyDone("Exception");
return;
}
if (result.type === 'error')
testController.notifyDone('Exception:' + result);
var objectProxy = TestRunner.runtimeModel.createRemoteObject(result);
if (result.type === "error")
testController.notifyDone("Exception:" + result);
var objectProxy = InspectorTest.runtimeModel.createRemoteObject(result);
objectProxy.getOwnProperties(false, getPropertiesCallback);
}
function getPropertiesCallback(properties) {
function getPropertiesCallback(properties)
{
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 = {};
for (var i = 0; i < properties.length; ++i) {
var name = properties[i].name;
if (golden[name])
result[name] = 1;
}
TestRunner.addObject(result);
TestRunner.completeTest();
InspectorTest.addObject(result);
InspectorTest.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.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
(async function() {
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()
{
<script>
function onload()
{
console.dir(["test1", "test2"]);
console.dir(document.childNodes);
console.dir(document.evaluate("//head", document, null, XPathResult.ANY_TYPE, null));
......@@ -49,23 +44,40 @@
console.dir(event);
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;
return name === 'foo' || treeElement.title === '<function scope>';
return name === "foo" || treeElement.title === "<function scope>";
}
function step1() {
ConsoleTestRunner.expandConsoleMessages(dumpConsoleMessages, expandTreeElementFilter);
function step1()
{
InspectorTest.expandConsoleMessages(dumpConsoleMessages, expandTreeElementFilter);
}
function dumpConsoleMessages() {
ConsoleTestRunner.dumpConsoleMessagesIgnoreErrorStackFrames();
TestRunner.completeTest();
function dumpConsoleMessages()
{
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.
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
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
b: "foo"
c: (3) [1, 2, 3]
......
// 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.
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
<script>
(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()
{
function logToConsole()
{
var obj = {a: 1, b: "foo", c: null, d: 2};
console.log(obj);
}
`);
}
ConsoleTestRunner.evaluateInConsole('logToConsole()', step1);
var test = function()
{
InspectorTest.evaluateInConsole("logToConsole()", step1);
function step1() {
ConsoleTestRunner.expandConsoleMessages(step2);
function step1()
{
InspectorTest.expandConsoleMessages(step2);
}
function step2() {
function step2()
{
var valueElements = getValueElements();
doubleClickTypeAndEnter(valueElements[0], '1 + 2');
ConsoleTestRunner.waitForRemoteObjectsConsoleMessages(step3);
doubleClickTypeAndEnter(valueElements[0], "1 + 2");
InspectorTest.waitForRemoteObjectsConsoleMessages(step3);
}
function step3() {
function step3()
{
var valueElements = getValueElements();
doubleClickTypeAndEnter(valueElements[1], 'nonExistingValue');
ConsoleTestRunner.waitForRemoteObjectsConsoleMessages(step4);
doubleClickTypeAndEnter(valueElements[1], "nonExistingValue");
InspectorTest.waitForRemoteObjectsConsoleMessages(step4);
}
function step4() {
function step4()
{
var valueElements = getValueElements();
doubleClickTypeAndEnter(valueElements[2], '[1, 2, 3]');
ConsoleTestRunner.waitForRemoteObjectsConsoleMessages(step5);
doubleClickTypeAndEnter(valueElements[2], "[1, 2, 3]");
InspectorTest.waitForRemoteObjectsConsoleMessages(step5);
}
function step5() {
function step5()
{
var valueElements = getValueElements();
doubleClickTypeAndEnter(valueElements[3], '{x: 2}');
ConsoleTestRunner.waitForRemoteObjectsConsoleMessages(step6);
doubleClickTypeAndEnter(valueElements[3], "{x: 2}");
InspectorTest.waitForRemoteObjectsConsoleMessages(step6);
}
function step6() {
ConsoleTestRunner.dumpConsoleMessagesIgnoreErrorStackFrames();
TestRunner.completeTest();
function step6()
{
InspectorTest.dumpConsoleMessagesIgnoreErrorStackFrames();
InspectorTest.completeTest();
}
function getValueElements() {
function getValueElements()
{
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) {
var event = document.createEvent('MouseEvent');
event.initMouseEvent('dblclick', true, true, null, 2);
function doubleClickTypeAndEnter(node, text)
{
var event = document.createEvent("MouseEvent");
event.initMouseEvent("dblclick", true, true, null, 2);
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 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.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() {
};
/**
* @param {function(!Element):string|undefined} messageFormatter
* @param {function(!Element):string} messageFormatter
* @param {!Element} node
* @return {string}
*/
......@@ -261,7 +261,7 @@ ConsoleTestRunner.dumpConsoleMessagesIgnoreErrorStackFrames = function(
printOriginatingCommand, dumpClassNames, messageFormatter) {
TestRunner.addResults(ConsoleTestRunner.dumpConsoleMessagesIntoArray(
printOriginatingCommand, dumpClassNames,
ConsoleTestRunner.formatterIgnoreStackFrameUrls.bind(this, messageFormatter)));
messageFormatter ? ConsoleTestRunner.formatterIgnoreStackFrameUrls.bind(this, messageFormatter) : undefined));
};
ConsoleTestRunner.dumpConsoleMessagesWithStyles = function() {
......@@ -410,11 +410,11 @@ ConsoleTestRunner.waitForRemoteObjectsConsoleMessages = function(callback) {
ConsoleTestRunner.waitUntilConsoleEditorLoaded = function() {
var fulfill;
var promise = new Promise(x => (fulfill = x));
var prompt = Console.ConsoleView.instance()._prompt;
if (prompt._editor)
fulfill(prompt._editor);
var editor = Console.ConsoleView.instance()._prompt._editor;
if (editor)
fulfill(editor);
else
TestRunner.addSniffer(Console.ConsolePrompt.prototype, '_editorSetForTest', _ => fulfill(prompt._editor));
TestRunner.addSniffer(Console.ConsolePrompt.prototype, '_editorSetForTest', _ => fulfill(editor));
return promise;
};
......
......@@ -56,13 +56,9 @@ function migrateTest(inputPath, identifierMap) {
helperScripts.push(filename);
});
const testsPath = path.resolve(__dirname, 'tests.txt');
const newToOldTests = new Map(fs.readFileSync(testsPath, 'utf-8').split('\n').map(line => line.split(' ').reverse()));
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 outPath = migrateUtils.getOutPath(inputPath);
const srcResourcePaths = resourceScripts.map(s => path.resolve(path.dirname(inputPath), s));
const destResourcePaths = resourceScripts.map(s => path.resolve(path.dirname(outPath), s));
const relativeResourcePaths = destResourcePaths.map(p => p.slice(p.indexOf('/http/tests') + '/http/tests'.length));
let outputCode;
......@@ -90,9 +86,16 @@ function migrateTest(inputPath, identifierMap) {
console.log(outputCode);
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);
console.log('Migrated: ', inputPath);
fs.unlinkSync(inputPath);
fs.unlinkSync(expectationsPath);
console.log('Migrated to: ', outPath);
}
}
......@@ -176,11 +179,12 @@ function transformTestScript(
* Create test header based on extracted data
*/
const headerLines = [];
headerLines.push(createExpressionNode(`TestRunner.addResult(\`${bodyText}\\n\`);`));
headerLines.push(createExpressionNode(`TestRunner.addResult('${bodyText}\\n');`));
headerLines.push(createNewLineNode());
for (const helper of allTestHelpers) {
headerLines.push(createAwaitExpressionNode(`await TestRunner.loadModule('${helper}');`));
}
headerLines.push(createAwaitExpressionNode(`await TestRunner.loadPanel('${panel}');`));
headerLines.push(createAwaitExpressionNode(`await TestRunner.showPanel('${panel}');`));
if (domFixture) {
......
inspector/console/alert-toString-exception.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-command-clear.html http/tests/devtools/console/console-command-clear.js
inspector/console/console-command-copy.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-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
\ 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