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
# ====== 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
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 ]
### Manually fix after migration
crbug.com/667560 virtual/mojo-loading/http/tests/devtools/console/console-dir.js [ NeedsManualRebaseline ]
# ====== DevTools test migration failures until here ======
......
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
<script>
var foo = 'fooValue';
// 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.
Function.prototype.bind = function () { throw ":P"; };
(async function() {
TestRunner.addResult(`Tests that overriding Function.prototype.bind does not break inspector.\n`);
function test()
{
InspectorTest.evaluateInConsole("foo", step1);
await TestRunner.loadModule('console_test_runner');
await TestRunner.showPanel('console');
function step1()
{
InspectorTest.dumpConsoleMessages();
InspectorTest.completeTest();
}
}
</script>
</head>
await TestRunner.evaluateInPagePromise(`
var foo = 'fooValue';
Function.prototype.bind = function () { throw ":P"; };
`);
<body onload="runTest()">
<p>
Tests that overriding Function.prototype.bind does not break inspector.
</p>
ConsoleTestRunner.evaluateInConsole('foo', step1);
</body>
</html>
function step1() {
ConsoleTestRunner.dumpConsoleMessages();
TestRunner.completeTest();
}
})();
CONSOLE MESSAGE: line 21: [object 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
value: 239
__proto__: A
......
<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,
get foo()
{
return this.value;
}
}
var B = function() { A.call(this); }
B.prototype = {
constructor: B,
__proto__: A.prototype
}
console.log(new B());
}
// 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.
function test()
{
InspectorTest.evaluateInPage("logObject()", step2);
function step2()
{
InspectorTest.expandConsoleMessages(step3);
}
function expandTreeElementFilter(treeElement)
{
var name = treeElement.nameElement && treeElement.nameElement.textContent;
return name === "__proto__";
}
function step3()
{
InspectorTest.expandConsoleMessages(step4, expandTreeElementFilter);
}
function step4()
{
InspectorTest.expandGettersInConsoleMessages(step5);
}
function step5()
(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()
{
InspectorTest.dumpConsoleMessages(false, false, InspectorTest.textContentWithLineBreaks);
InspectorTest.completeTest();
var A = function() { this.value = 239; }
A.prototype = {
constructor: A,
get foo()
{
return this.value;
}
}
var B = function() { A.call(this); }
B.prototype = {
constructor: B,
__proto__: A.prototype
}
console.log(new B());
}
}
</script>
</head>
<body onload="runTest()">
<p>
Tests that calling getter on prototype will call it on the object.
</p>
</body>
</html>
`);
TestRunner.evaluateInPage('logObject()', step2);
function step2() {
ConsoleTestRunner.expandConsoleMessages(step3);
}
function expandTreeElementFilter(treeElement) {
var name = treeElement.nameElement && treeElement.nameElement.textContent;
return name === '__proto__';
}
function step3() {
ConsoleTestRunner.expandConsoleMessages(step4, expandTreeElementFilter);
}
function step4() {
ConsoleTestRunner.expandGettersInConsoleMessages(step5);
}
function step5() {
ConsoleTestRunner.dumpConsoleMessages(false, false, TestRunner.textContentWithLineBreaks);
TestRunner.completeTest();
}
})();
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.html:9 one
console-command-clear.html:10 two
console-command-clear.html:11 three
console-command-clear.js:14 one
console-command-clear.js:15 two
console-command-clear.js:16 three
=== After clear ===
VM:1 Console was cleared
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
<script>
function log() {
// Fill console.
console.log("one");
console.log("two");
console.log("three");
}
log();
function test()
{
InspectorTest.addResult("=== Before clear ===");
InspectorTest.dumpConsoleMessages();
function callback()
{
InspectorTest.addResult("=== After clear ===");
InspectorTest.dumpConsoleMessages();
InspectorTest.completeTest();
// 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 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.
console.log("one");
console.log("two");
console.log("three");
}
InspectorTest.evaluateInConsole("clear()", callback);
}
log();
`);
</script>
</head>
TestRunner.addResult('=== Before clear ===');
ConsoleTestRunner.dumpConsoleMessages();
<body onload="runTest()">
<p>
Tests that console is cleared upon clear() eval in console.
</p>
function callback() {
TestRunner.addResult('=== After clear ===');
ConsoleTestRunner.dumpConsoleMessages();
TestRunner.completeTest();
}
</body>
</html>
ConsoleTestRunner.evaluateInConsole('clear()', callback);
})();
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
<script>
// 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.
function test()
{
// The following command has control character.
InspectorTest.evaluateInConsole("var\u001D i = 0;", onEvaluated);
(async function() {
TestRunner.addResult(`Verify that control characters are substituted with printable characters.\n`);
function onEvaluated()
{
InspectorTest.dumpConsoleMessages();
InspectorTest.completeTest();
}
}
await TestRunner.loadModule('console_test_runner');
await TestRunner.showPanel('console');
</script>
</head>
ConsoleTestRunner.evaluateInConsole('var\u001d i = 0;', onEvaluated);
<body onload="runTest()">
<p>
Verify that control characters are substituted with printable characters.
</p>
</body>
</html>
function onEvaluated() {
ConsoleTestRunner.dumpConsoleMessages();
TestRunner.completeTest();
}
})();
<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.html:9 Window
console-dir-deprecated.html:10 #document-fragment
console-dir-deprecated.js:17 Window
console-dir-deprecated.js:18 #document-fragment
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
<script>
// 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.
function logObjects()
{
console.dir(window);
console.dir(document.getElementById("foo").createShadowRoot());
}
(async function() {
TestRunner.addResult(`Tests that console does not log deprecated warning messages while dir-dumping objects.\n`);
function test()
{
InspectorTest.evaluateInPage("logObjects()", step2);
function step2()
await TestRunner.loadModule('console_test_runner');
await TestRunner.showPanel('console');
await TestRunner.loadHTML(`
<div id="foo"></div>
`);
await TestRunner.evaluateInPagePromise(`
function logObjects()
{
InspectorTest.dumpConsoleMessages();
InspectorTest.completeTest();
console.dir(window);
console.dir(document.getElementById("foo").createShadowRoot());
}
}
</script>
</head>
`);
<body onload="runTest()">
<div id="foo"></div>
<p>
Tests that console does not log deprecated warning messages while dir-dumping objects.
</p>
TestRunner.evaluateInPage('logObjects()', step2);
</body>
</html>
function step2() {
ConsoleTestRunner.dumpConsoleMessages();
TestRunner.completeTest();
}
})();
CONSOLE MESSAGE: line 9: [object Window]
Tests that console dumps global object with properties.
{
......
<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();
}
function test()
{
InspectorTest.RuntimeAgent.evaluate("window", "console", false).then(evalCallback);
function evalCallback(result)
{
if (!result) {
testController.notifyDone("Exception");
return;
}
if (result.type === "error")
testController.notifyDone("Exception:" + result);
var objectProxy = InspectorTest.runtimeModel.createRemoteObject(result);
objectProxy.getOwnProperties(false, getPropertiesCallback);
}
// 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`);
function getPropertiesCallback(properties)
await TestRunner.loadModule('console_test_runner');
await TestRunner.showPanel('console');
await TestRunner.evaluateInPagePromise(`
function doit()
{
properties.sort(ObjectUI.ObjectPropertiesSection.CompareProperties);
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;
}
InspectorTest.addObject(result);
InspectorTest.completeTest();
console.dir(window);
};
`);
TestRunner.RuntimeAgent.evaluate('window', 'console', false).then(evalCallback);
function evalCallback(result) {
if (!result) {
testController.notifyDone('Exception');
return;
}
}
</script>
</head>
if (result.type === 'error')
testController.notifyDone('Exception:' + result);
<body onload="doit()">
<p>
Tests that console dumps global object with properties.
</p>
var objectProxy = TestRunner.runtimeModel.createRemoteObject(result);
objectProxy.getOwnProperties(false, getPropertiesCallback);
}
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 result = {};
for (var i = 0; i < properties.length; ++i) {
var name = properties[i].name;
if (golden[name])
result[name] = 1;
}
</body>
</html>
TestRunner.addObject(result);
TestRunner.completeTest();
}
})();
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
// 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.
<script>
function onload()
{
console.dir(["test1", "test2"]);
console.dir(document.childNodes);
console.dir(document.evaluate("//head", document, null, XPathResult.ANY_TYPE, null));
(async function() {
TestRunner.addResult(`Tests that console logging dumps proper messages.\n`);
// Object with properties containing whitespaces
var obj = { $foo5_: 0 };
obj[" a b "] = " a b ";
obj["c d"] = "c d";
obj[""] = "";
obj[" "] = " ";
obj["a\n\nb\nc"] = "a\n\nb\nc";
obj["negZero"] = -0;
console.dir(obj);
await TestRunner.loadModule('console_test_runner');
await TestRunner.showPanel('console');
// This should correctly display information about the function.
console.dir(function() {});
await TestRunner.evaluateInPagePromise(`
function onload()
{
console.dir(["test1", "test2"]);
console.dir(document.childNodes);
console.dir(document.evaluate("//head", document, null, XPathResult.ANY_TYPE, null));
// Test function inferred name in prototype constructor.
var outer = { inner: function() {} };
console.dir(new outer.inner());
// Object with properties containing whitespaces
var obj = { $foo5_: 0 };
obj[" a b "] = " a b ";
obj["c d"] = "c d";
obj[""] = "";
obj[" "] = " ";
obj["a\n\nb\nc"] = "a\n\nb\nc";
obj["negZero"] = -0;
console.dir(obj);
// Test "No Properties" placeholder.
console.dir({ __proto__: null });
console.dir({ foo: { __proto__: null }});
// Test "No Scopes" placeholder.
console.dir(Object.getOwnPropertyDescriptor(Object.prototype, "__proto__").get);
// This should correctly display information about the function.
console.dir(function() {});
// Test big typed array: should be no crash or timeout.
var bigTypedArray = new Uint8Array(new ArrayBuffer(400 * 1000 * 1000));
bigTypedArray["FAIL"] = "FAIL: Object.getOwnPropertyNames() should not have been run";
console.dir(bigTypedArray);
// Test function inferred name in prototype constructor.
var outer = { inner: function() {} };
console.dir(new outer.inner());
// document.createEvent("Event") has a special property "isTrusted" flagged "Unforgeable".
var event = document.createEvent("Event");
Object.defineProperty(event, "timeStamp", {value: 0})
console.dir(event);
// Test "No Properties" placeholder.
console.dir({ __proto__: null });
console.dir({ foo: { __proto__: null }});
// Test "No Scopes" placeholder.
console.dir(Object.getOwnPropertyDescriptor(Object.prototype, "__proto__").get);
runTest();
}
//# sourceURL=console-dir.html
</script>
// Test big typed array: should be no crash or timeout.
var bigTypedArray = new Uint8Array(new ArrayBuffer(400 * 1000 * 1000));
bigTypedArray["FAIL"] = "FAIL: Object.getOwnPropertyNames() should not have been run";
console.dir(bigTypedArray);
<script>
function test()
{
InspectorTest.expandConsoleMessages(step1, expandTreeElementFilter);
// document.createEvent("Event") has a special property "isTrusted" flagged "Unforgeable".
var event = document.createEvent("Event");
Object.defineProperty(event, "timeStamp", {value: 0})
console.dir(event);
function expandTreeElementFilter(treeElement)
{
var name = treeElement.nameElement && treeElement.nameElement.textContent;
return name === "foo" || treeElement.title === "<function scope>";
runTest();
}
//# sourceURL=console-dir.js
`);
function step1()
{
InspectorTest.expandConsoleMessages(dumpConsoleMessages, expandTreeElementFilter);
}
function dumpConsoleMessages()
{
InspectorTest.dumpConsoleMessagesIgnoreErrorStackFrames();
InspectorTest.completeTest();
}
}
ConsoleTestRunner.expandConsoleMessages(step1, expandTreeElementFilter);
</script>
</head>
function expandTreeElementFilter(treeElement) {
var name = treeElement.nameElement && treeElement.nameElement.textContent;
return name === 'foo' || treeElement.title === '<function scope>';
}
<body onload="onload()">
<p>
Tests that console logging dumps proper messages.
</p>
function step1() {
ConsoleTestRunner.expandConsoleMessages(dumpConsoleMessages, expandTreeElementFilter);
}
</body>
</html>
function dumpConsoleMessages() {
ConsoleTestRunner.dumpConsoleMessagesIgnoreErrorStackFrames();
TestRunner.completeTest();
}
})();
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
......@@ -6,7 +5,7 @@ Node was hidden after dblclick: true
Node was hidden after dblclick: true
Node was hidden after dblclick: true
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
b: "foo"
c: (3) [1, 2, 3]
......
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
<script>
// 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.
function logToConsole()
{
var obj = {a: 1, b: "foo", c: null, d: 2};
console.log(obj);
}
(async function() {
TestRunner.addResult(`Tests that property values can be edited inline in the console via double click.\n`);
var test = function()
{
InspectorTest.evaluateInConsole("logToConsole()", step1);
await TestRunner.loadModule('console_test_runner');
await TestRunner.showPanel('console');
function step1()
await TestRunner.evaluateInPagePromise(`
function logToConsole()
{
InspectorTest.expandConsoleMessages(step2);
var obj = {a: 1, b: "foo", c: null, d: 2};
console.log(obj);
}
`);
function step2()
{
var valueElements = getValueElements();
doubleClickTypeAndEnter(valueElements[0], "1 + 2");
InspectorTest.waitForRemoteObjectsConsoleMessages(step3);
}
ConsoleTestRunner.evaluateInConsole('logToConsole()', step1);
function step3()
{
var valueElements = getValueElements();
doubleClickTypeAndEnter(valueElements[1], "nonExistingValue");
InspectorTest.waitForRemoteObjectsConsoleMessages(step4);
}
function step1() {
ConsoleTestRunner.expandConsoleMessages(step2);
}
function step4()
{
var valueElements = getValueElements();
doubleClickTypeAndEnter(valueElements[2], "[1, 2, 3]");
InspectorTest.waitForRemoteObjectsConsoleMessages(step5);
}
function step2() {
var valueElements = getValueElements();
doubleClickTypeAndEnter(valueElements[0], '1 + 2');
ConsoleTestRunner.waitForRemoteObjectsConsoleMessages(step3);
}
function step5()
{
var valueElements = getValueElements();
doubleClickTypeAndEnter(valueElements[3], "{x: 2}");
InspectorTest.waitForRemoteObjectsConsoleMessages(step6);
}
function step3() {
var valueElements = getValueElements();
doubleClickTypeAndEnter(valueElements[1], 'nonExistingValue');
ConsoleTestRunner.waitForRemoteObjectsConsoleMessages(step4);
}
function step6()
{
InspectorTest.dumpConsoleMessagesIgnoreErrorStackFrames();
InspectorTest.completeTest();
}
function getValueElements()
{
var messageElement = Console.ConsoleView.instance()._visibleViewMessages[1].element();
return messageElement.querySelector(".console-message-text *").shadowRoot.querySelectorAll(".value");
}
function step4() {
var valueElements = getValueElements();
doubleClickTypeAndEnter(valueElements[2], '[1, 2, 3]');
ConsoleTestRunner.waitForRemoteObjectsConsoleMessages(step5);
}
function doubleClickTypeAndEnter(node, text)
{
var event = document.createEvent("MouseEvent");
event.initMouseEvent("dblclick", true, true, null, 2);
node.dispatchEvent(event);
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");
editPrompt.textContent = text;
editPrompt.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
}
}
function step5() {
var valueElements = getValueElements();
doubleClickTypeAndEnter(valueElements[3], '{x: 2}');
ConsoleTestRunner.waitForRemoteObjectsConsoleMessages(step6);
}
</script>
</head>
function step6() {
ConsoleTestRunner.dumpConsoleMessagesIgnoreErrorStackFrames();
TestRunner.completeTest();
}
<body onload="runTest()">
<p>
Tests that property values can be edited inline in the console via double click.
</p>
function getValueElements() {
var messageElement = Console.ConsoleView.instance()._visibleViewMessages[1].element();
return messageElement.querySelector('.console-message-text *').shadowRoot.querySelectorAll('.value');
}
</body>
</html>
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'));
var messageElement = Console.ConsoleView.instance()._visibleViewMessages[1].element();
var editPrompt = messageElement.querySelector('.console-message-text *').shadowRoot.querySelector('.text-prompt');
editPrompt.textContent = text;
editPrompt.dispatchEvent(TestRunner.createKeyEvent('Enter'));
}
})();
......@@ -217,7 +217,7 @@ ConsoleTestRunner.consoleMessagesCount = function() {
};
/**
* @param {function(!Element):string} messageFormatter
* @param {function(!Element):string|undefined} messageFormatter
* @param {!Element} node
* @return {string}
*/
......@@ -261,7 +261,7 @@ ConsoleTestRunner.dumpConsoleMessagesIgnoreErrorStackFrames = function(
printOriginatingCommand, dumpClassNames, messageFormatter) {
TestRunner.addResults(ConsoleTestRunner.dumpConsoleMessagesIntoArray(
printOriginatingCommand, dumpClassNames,
messageFormatter ? ConsoleTestRunner.formatterIgnoreStackFrameUrls.bind(this, messageFormatter) : undefined));
ConsoleTestRunner.formatterIgnoreStackFrameUrls.bind(this, messageFormatter)));
};
ConsoleTestRunner.dumpConsoleMessagesWithStyles = function() {
......@@ -410,11 +410,11 @@ ConsoleTestRunner.waitForRemoteObjectsConsoleMessages = function(callback) {
ConsoleTestRunner.waitUntilConsoleEditorLoaded = function() {
var fulfill;
var promise = new Promise(x => (fulfill = x));
var editor = Console.ConsoleView.instance()._prompt._editor;
if (editor)
fulfill(editor);
var prompt = Console.ConsoleView.instance()._prompt;
if (prompt._editor)
fulfill(prompt._editor);
else
TestRunner.addSniffer(Console.ConsolePrompt.prototype, '_editorSetForTest', _ => fulfill(editor));
TestRunner.addSniffer(Console.ConsolePrompt.prototype, '_editorSetForTest', _ => fulfill(prompt._editor));
return promise;
};
......
......@@ -56,9 +56,13 @@ function migrateTest(inputPath, identifierMap) {
helperScripts.push(filename);
});
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 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 relativeResourcePaths = destResourcePaths.map(p => p.slice(p.indexOf('/http/tests') + '/http/tests'.length));
let outputCode;
......@@ -86,16 +90,9 @@ function migrateTest(inputPath, identifierMap) {
console.log(outputCode);
if (!DRY_RUN) {
mkdirp.sync(path.dirname(outPath));
fs.writeFileSync(outPath, outputCode);
const expectationsPath = inputPath.replace('.html', '-expected.txt');
copyExpectations(expectationsPath, outPath);
fs.writeFileSync(inputPath, outputCode);
copyResourceScripts(srcResourcePaths, destResourcePaths);
fs.unlinkSync(inputPath);
fs.unlinkSync(expectationsPath);
console.log('Migrated to: ', outPath);
console.log('Migrated: ', inputPath);
}
}
......@@ -179,12 +176,11 @@ 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