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

DevTools: migrate some of the startup tests

This is a part-automated / part-manual process to migrate these /startup/
tests to the new integration test framework:

1. extract the precondition activities into an html file for the inspected
window.
2. add TestRunner.setupStartupTest(...) as the first line of the js test to
navigate to the inspected window before the DevTools session is started.
3. add testRunner.navigateSecondaryWindow(...) once the inspected page is
done w/ the precondition activities.

Bug: 667560
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_mojo
Change-Id: I708c0719aa8ccdb38161e558fd535de12e7ccf9f
Reviewed-on: https://chromium-review.googlesource.com/821517
Commit-Queue: Will Chen <chenwilliam@chromium.org>
Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523671}
parent dee035a7
...@@ -182,7 +182,7 @@ crbug.com/764474 fast/loader/reload-zero-byte-plugin.html [ Failure ] ...@@ -182,7 +182,7 @@ crbug.com/764474 fast/loader/reload-zero-byte-plugin.html [ Failure ]
crbug.com/764474 plugins/plugin-document-back-forward.html [ Crash Failure Timeout ] crbug.com/764474 plugins/plugin-document-back-forward.html [ Crash Failure Timeout ]
# DevTools crbug.com/783982 # DevTools crbug.com/783982
crbug.com/783982 http/tests/devtools/startup/console/console-uncaught-promise-no-inspector.html [ Failure ] crbug.com/783982 http/tests/devtools/startup/console/console-uncaught-promise-no-inspector.js [ Failure ]
crbug.com/783982 http/tests/devtools/elements/styles-2/property-ui-location.js [ Failure ] crbug.com/783982 http/tests/devtools/elements/styles-2/property-ui-location.js [ Failure ]
crbug.com/783982 http/tests/devtools/elements/styles-1/empty-background-url.js [ Failure ] crbug.com/783982 http/tests/devtools/elements/styles-1/empty-background-url.js [ Failure ]
......
CONSOLE ERROR: line 9: Uncaught (in promise) Error: err1
CONSOLE ERROR: line 28: Uncaught (in promise) Error: err2
CONSOLE ERROR: line 47: Uncaught (in promise) NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
Tests that uncaught promise rejection messages have line numbers when the inspector is closed and stack traces are not collected. Tests that uncaught promise rejection messages have line numbers when the inspector is closed and stack traces are not collected.
console-uncaught-pro…no-inspector.html:9 Uncaught (in promise) Error: err1 console-uncaught-pro…no-inspector.html:4 Uncaught (in promise) Error: err1
console-uncaught-pro…o-inspector.html:28 Uncaught (in promise) Error: err2 console-uncaught-pro…o-inspector.html:23 Uncaught (in promise) Error: err2
console-uncaught-pro…o-inspector.html:47 Uncaught (in promise) DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node. console-uncaught-pro…o-inspector.html:42 Uncaught (in promise) DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
// 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() {
await TestRunner.setupStartupTest('resources/console-uncaught-promise-no-inspector.html');
TestRunner.addResult(
`Tests that uncaught promise rejection messages have line numbers when the inspector is closed and stack traces are not collected.\n`);
await TestRunner.loadModule('console_test_runner');
ConsoleTestRunner.expandConsoleMessages(onExpanded);
function onExpanded() {
ConsoleTestRunner.dumpConsoleMessagesIgnoreErrorStackFrames();
TestRunner.completeTest();
}
})();
<html>
<head>
<script src="../../../inspector/inspector-test.js"></script>
<script src="../../../inspector/console-test.js"></script>
<script> <script>
function createRejectedPromises() function createRejectedPromises()
{ {
Promise.reject(new Error("err1")) Promise.reject(new Error("err1"))
...@@ -41,45 +36,12 @@ function rejectWithDOMException() ...@@ -41,45 +36,12 @@ function rejectWithDOMException()
function throwDOMException() function throwDOMException()
{ {
setTimeout(showWebInspector, 0); setTimeout(() => testRunner.inspectSecondaryWindow(), 0);
var a = document.createElement("div"); var a = document.createElement("div");
var b = document.createElement("div"); var b = document.createElement("div");
a.removeChild(b); a.removeChild(b);
} }
} }
function onload() createRejectedPromises();
{ </script>
if (window.testRunner) { \ No newline at end of file
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
createRejectedPromises();
}
function showWebInspector()
{
if (window.testRunner)
testRunner.showWebInspector();
runTest();
}
function test() {
ConsoleTestRunner.expandConsoleMessages(onExpanded);
function onExpanded() {
ConsoleTestRunner.dumpConsoleMessagesIgnoreErrorStackFrames();
TestRunner.completeTest();
}
}
</script>
</head>
<body onload="onload()">
<p>
Tests that uncaught promise rejection messages have line numbers when the inspector is closed and stack traces are not collected.
</p>
</body>
</html>
Tests main resource content is correctly loaded and decoded using correct encoding. Tests main resource content is correctly loaded and decoded using correct encoding.
Requesting content: Requesting content:
......
<html> // Copyright 2017 The Chromium Authors. All rights reserved.
<head> // Use of this source code is governed by a BSD-style license that can be
<script src="../../../inspector/inspector-test.js"></script> // found in the LICENSE file.
<script src="../../../inspector/resources-test.js"></script>
<script src="../../../inspector/resource-tree/resource-tree-test.js"></script> (async function() {
<script> await TestRunner.setupStartupTest('resources/main-resource-content.html');
function onload() TestRunner.addResult(`Tests main resource content is correctly loaded and decoded using correct encoding.\n`);
{ await TestRunner.loadModule('application_test_runner');
if (window.testRunner) {
testRunner.waitUntilDone();
testRunner.showWebInspector();
}
runTest();
}
function test() {
ApplicationTestRunner.runAfterResourcesAreFinished( ApplicationTestRunner.runAfterResourcesAreFinished(
['main-resource-content-frame-utf8.php', 'main-resource-content-frame.html'], step2); ['main-resource-content-frame-utf8.php', 'main-resource-content-frame.html'], step2);
...@@ -35,14 +28,4 @@ function test() { ...@@ -35,14 +28,4 @@ function test() {
TestRunner.addResult('Resource content: ' + content); TestRunner.addResult('Resource content: ' + content);
TestRunner.completeTest(); TestRunner.completeTest();
} }
} })();
</script>
</head>
<body onload="onload()">
<iframe src="resources/main-resource-content-frame.html"></iframe>
<iframe src="resources/main-resource-content-frame-utf8.php"></iframe>
<p>
Tests main resource content is correctly loaded and decoded using correct encoding.
</p>
</body>
</html>
Tests that resources panel correctly shows mime type when it loads data from memory cache. Tests that resources panel correctly shows mime type when it loads data from memory cache. https://bugs.webkit.org/show_bug.cgi?id=63701
Bug 63701
image text/html http://127.0.0.1:8000/devtools/devtools/resource-tree/resources/empty.png image text/html http://127.0.0.1:8000/devtools/devtools/resource-tree/resources/empty.png
stylesheet text/html http://127.0.0.1:8000/devtools/devtools/resource-tree/resources/styles-initial.css stylesheet text/html http://127.0.0.1:8000/devtools/devtools/resource-tree/resources/styles-initial.css
document text/html http://127.0.0.1:8000/devtools/startup/resource-tree/resource-tree-mimetype.html document text/html http://127.0.0.1:8000/devtools/startup/resource-tree/resources/resource-tree-mimetype.html
script application/x-javascript http://127.0.0.1:8000/inspector/inspector-test.js
script application/x-javascript http://127.0.0.1:8000/inspector/resource-tree/resource-tree-test.js
// 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() {
await TestRunner.setupStartupTest('resources/resource-tree-mimetype.html');
TestRunner.addResult(
`Tests that resources panel correctly shows mime type when it loads data from memory cache. https://bugs.webkit.org/show_bug.cgi?id=63701\n`);
await TestRunner.loadModule('application_test_runner');
function format(resource) {
return resource.resourceType().name() + ' ' + resource.mimeType + ' ' + resource.url;
}
ApplicationTestRunner.dumpResources(format);
TestRunner.completeTest();
})();
<body onload="testRunner.inspectSecondaryWindow()">
<iframe src="main-resource-content-frame.html"></iframe>
<iframe src="main-resource-content-frame-utf8.php"></iframe>
</body>
\ No newline at end of file
<html> <html>
<head> <head>
<script src="../../../inspector/inspector-test.js"></script> <link rel="stylesheet" href="../../../devtools/resource-tree/resources/styles-initial.css">
<script src="../../../inspector/resource-tree/resource-tree-test.js"></script>
<link rel="stylesheet" href="../../devtools/resource-tree/resources/styles-initial.css">
<script> <script>
function onload() function onload()
{ {
if (window.testRunner) {
testRunner.waitUntilDone();
testRunner.showWebInspector();
}
// This test enumerates all resources currently registered, potentially // This test enumerates all resources currently registered, potentially
// including ones no longer reachable, but not yet garbage collected // including ones no longer reachable, but not yet garbage collected
// and finalized. // and finalized.
...@@ -17,22 +11,11 @@ function onload() ...@@ -17,22 +11,11 @@ function onload()
// To ensure stable test output, perform a GC right here to flush out // To ensure stable test output, perform a GC right here to flush out
// the finalizable resources. // the finalizable resources.
gc(); gc();
runTest(); testRunner.inspectSecondaryWindow();
}
function test() {
function format(resource) {
return resource.resourceType().name() + ' ' + resource.mimeType + ' ' + resource.url;
}
ApplicationTestRunner.dumpResources(format);
TestRunner.completeTest();
} }
</script> </script>
</head> </head>
<body onload="onload()"> <body onload="onload()">
<p>Tests that resources panel correctly shows mime type when it loads data from memory cache.</p> <img src="../../../devtools/resource-tree/resources/empty.png">
<a href="https://bugs.webkit.org/show_bug.cgi?id=63701">Bug 63701</a>
<img src="../../devtools/resource-tree/resources/empty.png">
</body> </body>
</html> </html>
...@@ -2,7 +2,30 @@ Tests that Linkifier works correctly. ...@@ -2,7 +2,30 @@ Tests that Linkifier works correctly.
listeners added on raw source code: 1 listeners added on raw source code: 1
original location: linkifier.html:9 original location: linkifier.html:9
pretty printed location: linkifier.html:formatted:14 pretty printed location: linkifier.html:formatted:11
pretty printed content:
<html>
<head>
<script>
// It is important that script starts on line 5 (zero-based 4)
function nonFormattedFunction() {
var i = 2 + 2;
var a = 4;
return a + i;
}
function dummyScript() {
console.log("dummy string");
}
function onload() {
testRunner.inspectSecondaryWindow();
}
</script>
</head>
<body onload="onload()"></body>
</html>
reverted location: linkifier.html:9 reverted location: linkifier.html:9
listeners removed from raw source code: 1 listeners removed from raw source code: 1
<html> // Copyright 2017 The Chromium Authors. All rights reserved.
<head> // Use of this source code is governed by a BSD-style license that can be
<script src="../../../../inspector/inspector-test.js"></script> // found in the LICENSE file.
<script src="../../../../inspector/debugger-test.js"></script>
<script>// It is important that script starts on line 5 (zero-based 4)
function nonFormattedFunction() { var i = 2 + 2; var a = 4; return a + i; } (async function() {
await TestRunner.setupStartupTest('resources/linkifier.html');
TestRunner.addResult(`Tests that Linkifier works correctly.\n`);
await TestRunner.loadModule('sources_test_runner');
await TestRunner.showPanel('sources');
function dummyScript() var resourceURL = TestRunner.url('resources/linkifier.html');
{
console.log("dummy string");
}
function onload()
{
if (window.testRunner) {
testRunner.waitUntilDone();
testRunner.showWebInspector();
}
runTest();
}
function test() {
var scriptFormatter; var scriptFormatter;
var linkifier; var linkifier;
var link; var link;
...@@ -40,18 +29,18 @@ function test() { ...@@ -40,18 +29,18 @@ function test() {
function debuggerTest() { function debuggerTest() {
for (var scriptCandidate of TestRunner.debuggerModel.scripts()) { for (var scriptCandidate of TestRunner.debuggerModel.scripts()) {
if (scriptCandidate.sourceURL === TestRunner.mainTarget.inspectedURL() && scriptCandidate.lineOffset === 4) { if (scriptCandidate.sourceURL === resourceURL && scriptCandidate.lineOffset === 4) {
script = scriptCandidate; script = scriptCandidate;
break; break;
} }
} }
uiSourceCode = Workspace.workspace.uiSourceCodeForURL(TestRunner.mainTarget.inspectedURL()); uiSourceCode = Workspace.workspace.uiSourceCodeForURL(resourceURL);
linkifier = new Components.Linkifier(); linkifier = new Components.Linkifier();
var count1 = liveLocationsCount(); var count1 = liveLocationsCount();
link = linkifier.linkifyScriptLocation( link = linkifier.linkifyScriptLocation(
SDK.targetManager.mainTarget(), null, TestRunner.mainTarget.inspectedURL(), 8, 0, 'dummy-class'); SDK.targetManager.mainTarget(), null, resourceURL, 8, 0, 'dummy-class');
var count2 = liveLocationsCount(); var count2 = liveLocationsCount();
TestRunner.addResult('listeners added on raw source code: ' + (count2 - count1)); TestRunner.addResult('listeners added on raw source code: ' + (count2 - count1));
...@@ -60,8 +49,11 @@ function test() { ...@@ -60,8 +49,11 @@ function test() {
scriptFormatter._toggleFormatScriptSource(); scriptFormatter._toggleFormatScriptSource();
} }
function uiSourceCodeScriptFormatted() { async function uiSourceCodeScriptFormatted() {
TestRunner.addResult('pretty printed location: ' + link.textContent); TestRunner.addResult('pretty printed location: ' + link.textContent);
var formattedContent = await Sources.sourceFormatter._formattedSourceCodes.get(uiSourceCode).formatData.formattedSourceCode.requestContent();
TestRunner.addResult('pretty printed content:');
TestRunner.addResult(formattedContent);
Sources.sourceFormatter.discardFormattedUISourceCode(UI.panels.sources.visibleView.uiSourceCode()); Sources.sourceFormatter.discardFormattedUISourceCode(UI.panels.sources.visibleView.uiSourceCode());
TestRunner.addResult('reverted location: ' + link.textContent); TestRunner.addResult('reverted location: ' + link.textContent);
...@@ -79,15 +71,4 @@ function test() { ...@@ -79,15 +71,4 @@ function test() {
var locations = modelData._locations.get(script); var locations = modelData._locations.get(script);
return locations.size; return locations.size;
} }
} })();
</script>
</head>
<body onload="onload()">
<p>
Tests that Linkifier works correctly.
<p>
</body>
</html>
<html>
<head>
<script>// It is important that script starts on line 5 (zero-based 4)
function nonFormattedFunction() { var i = 2 + 2; var a = 4; return a + i; }
function dummyScript()
{
console.log("dummy string");
}
function onload()
{
testRunner.inspectSecondaryWindow();
}
</script>
</head>
<body onload="onload()"></body>
</html>
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