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

DevTools: integration test uses http inspected page & can add resource scripts

Bug: 667560
Change-Id: I4f8f168de679d5cdcc16353349332c9aaedce709
Reviewed-on: https://chromium-review.googlesource.com/592497
Commit-Queue: Will Chen <chenwilliam@chromium.org>
Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491094}
parent 3a8c8601
......@@ -401,7 +401,8 @@ void BlinkTestController::LoadDevToolsJSTest() {
devtools_bindings_.reset(LayoutTestDevToolsBindings::LoadDevTools(
devtools_window_->web_contents(), secondary->web_contents(), "",
test_url_.spec()));
secondary->LoadURL(GURL(url::kAboutBlankURL));
secondary->LoadURL(
LayoutTestDevToolsBindings::GetInspectedPageURL(test_url_));
}
bool BlinkTestController::ResetAfterLayoutTest() {
......
......@@ -101,6 +101,18 @@ LayoutTestDevToolsBindings* LayoutTestDevToolsBindings::LoadDevTools(
return bindings;
}
// static.
GURL LayoutTestDevToolsBindings::GetInspectedPageURL(const GURL& test_url) {
std::string spec = test_url.spec();
std::string test_query_param = "&test=";
std::string test_script_url =
spec.substr(spec.find(test_query_param) + test_query_param.length());
std::string inspected_page_url = test_script_url.replace(
test_script_url.find("/devtools/"), std::string::npos,
"/devtools/resources/inspected-page.html");
return GURL(inspected_page_url);
}
void LayoutTestDevToolsBindings::EvaluateInFrontend(int call_id,
const std::string& script) {
if (!ready_for_test_) {
......
......@@ -20,6 +20,8 @@ class LayoutTestDevToolsBindings : public ShellDevToolsBindings {
static GURL MapTestURLIfNeeded(const GURL& test_url,
bool* is_devtools_js_test);
static GURL GetInspectedPageURL(const GURL& test_url);
static LayoutTestDevToolsBindings* LoadDevTools(
WebContents* devtools_contents_,
WebContents* inspected_contents_,
......
......@@ -11793,7 +11793,7 @@ crbug.com/591099 http/tests/inspector/console-resource-errors.html [ Crash Failu
crbug.com/591099 http/tests/inspector/console-show-all-messages.html [ Crash Failure ]
crbug.com/591099 http/tests/inspector/console-xhr-logging-async.html [ Crash Failure ]
crbug.com/591099 http/tests/inspector/console-xhr-logging.html [ Crash Failure ]
crbug.com/591099 http/tests/inspector/console/console-links-in-errors-with-trace.html [ Crash Failure ]
crbug.com/591099 http/tests/devtools/console/console-links-in-errors-with-trace.js [ Crash Failure ]
crbug.com/591099 http/tests/inspector/console/console-links-on-messages-before-inspection.html [ Failure ]
crbug.com/591099 http/tests/inspector/console/console-on-paint-worklet.html [ Failure Timeout ]
crbug.com/591099 http/tests/inspector/debugger/fetch-breakpoints.html [ Crash Failure Timeout ]
......@@ -7,7 +7,7 @@
await TestRunner.loadModule('console_test_runner');
await TestRunner.loadModule('elements_test_runner');
await TestRunner.loadPanel('console');
await TestRunner.showPanel('console');
await TestRunner.loadHTML(`
<p id='foo'>
Tests that command line api works.
......
......@@ -6,7 +6,7 @@
TestRunner.addResult('Tests that console.assert() will dump a message and stack trace with source URLs and line numbers.\n');
await TestRunner.loadModule('console_test_runner');
await TestRunner.loadPanel('console');
await TestRunner.showPanel('console');
await TestRunner.evaluateInPagePromise(`
function b()
......
......@@ -6,7 +6,7 @@
TestRunner.addResult('Tests that console logging dumps large arrays properly.\n');
await TestRunner.loadModule('console_test_runner');
await TestRunner.loadPanel('console');
await TestRunner.showPanel('console');
await TestRunner.evaluateInPagePromise(`
(function onload()
......
......@@ -5,7 +5,7 @@
(async function() {
TestRunner.addResult("Tests that console is cleared upon requestClearMessages call.\n");
await TestRunner.loadPanel("console");
await TestRunner.showPanel("console");
await TestRunner.loadModule("console_test_runner");
await TestRunner.evaluateInPagePromise(`
......
......@@ -6,7 +6,7 @@
TestRunner.addResult('Tests that console logging dumps properly when there are multiple custom formatters on the page\n');
await TestRunner.loadModule('console_test_runner');
await TestRunner.loadPanel('console');
await TestRunner.showPanel('console');
await TestRunner.evaluateInPagePromise(`
var a = {name: "a"};
......
......@@ -6,7 +6,7 @@
TestRunner.addResult('Tests that console logging dumps proper messages.\n');
await TestRunner.loadModule('console_test_runner');
await TestRunner.loadPanel('console');
await TestRunner.showPanel('console');
await TestRunner.evaluateInPagePromise(`
(function onload()
......
......@@ -6,7 +6,7 @@
TestRunner.addResult('Tests that console logging dumps proper messages.\n');
await TestRunner.loadModule('console_test_runner');
await TestRunner.loadPanel('console');
await TestRunner.showPanel('console');
await TestRunner.evaluateInPagePromise(`
function logToConsole()
......
......@@ -6,7 +6,7 @@
TestRunner.addResult('Tests that expanded tree element is editable in console.\n');
await TestRunner.loadModule('console_test_runner');
await TestRunner.loadPanel('console');
await TestRunner.showPanel('console');
await TestRunner.evaluateInPagePromise(`
(function onload()
......
......@@ -6,7 +6,7 @@
TestRunner.addResult('Tests that console logging detects external arrays as arrays.\n');
await TestRunner.loadModule('console_test_runner');
await TestRunner.loadPanel('console');
await TestRunner.showPanel('console');
await TestRunner.evaluateInPagePromise(`
function logToConsole()
......
......@@ -6,7 +6,7 @@
TestRunner.addResult('Tests that console logging dumps array values defined on Array.prototype[].\n');
await TestRunner.loadModule('console_test_runner');
await TestRunner.loadPanel('console');
await TestRunner.showPanel('console');
await TestRunner.evaluateInPagePromise(`
function log(data)
......
......@@ -6,7 +6,7 @@
TestRunner.addResult('Tests that console properly displays information about ES6 features.\n');
await TestRunner.loadModule('console_test_runner');
await TestRunner.loadPanel('console');
await TestRunner.showPanel('console');
await TestRunner.evaluateInPagePromise(`
var globals = [];
......
......@@ -6,7 +6,7 @@
TestRunner.addResult('Tests that console properly displays information about ES6 Symbols.\n');
await TestRunner.loadModule('console_test_runner');
await TestRunner.loadPanel('console');
await TestRunner.showPanel('console');
await TestRunner.evaluateInPagePromise(`
function logSymbolToConsoleWithError()
......
......@@ -6,7 +6,7 @@
TestRunner.addResult('Tests that console properly displays information about ES6 features.\n');
await TestRunner.loadModule('console_test_runner');
await TestRunner.loadPanel('console');
await TestRunner.showPanel('console');
await TestRunner.evaluateInPagePromise(`
var globals = [];
......
......@@ -6,7 +6,7 @@
TestRunner.addResult('Tests that console logging dumps properly styled messages.\n');
await TestRunner.loadModule('console_test_runner');
await TestRunner.loadPanel('console');
await TestRunner.showPanel('console');
await TestRunner.evaluateInPagePromise(`
(function onload()
......
CONSOLE ERROR: line 3: Error: http://127.0.0.1:8000/inspector/resources/source3.js
Test that relative links in traces open in the sources panel.
Clicking link source3.js: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.
(async function() {
TestRunner.addResult('Test that relative links in traces open in the sources panel.\n');
await TestRunner.loadModule('console_test_runner');
await TestRunner.showPanel('console');
await TestRunner.addScriptTag('../resources/source3.js');
TestRunner.evaluateInPage('foo()', step1);
UI.inspectorView._tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected, panelChanged);
function panelChanged() {
TestRunner.addResult('Panel ' + UI.inspectorView._tabbedPane._currentTab.id + ' was opened.');
TestRunner.completeTest();
}
var clickTarget;
function step1() {
var firstMessageEl = Console.ConsoleView.instance()._visibleViewMessages[0].element();
clickTarget = firstMessageEl.querySelectorAll('.console-message-text .devtools-link')[1];
UI.inspectorView.showPanel('console').then(testClickTarget);
}
function testClickTarget() {
TestRunner.addResult('Clicking link ' + clickTarget.textContent);
clickTarget.click();
}
InspectorFrontendHost.openInNewTab = function() {
TestRunner.addResult('Failure: Open link in new tab!!');
TestRunner.completeTest();
};
})();
......@@ -6,7 +6,7 @@
TestRunner.addResult('Tests that console prompt keyboard events work.\n');
await TestRunner.loadModule('console_test_runner');
await TestRunner.loadPanel('console');
await TestRunner.showPanel('console');
await ConsoleTestRunner.waitUntilConsoleEditorLoaded();
var firstCommand = 'First\nmultiline command';
......
function foo()
{
console.error(new Error("http://127.0.0.1:8000/inspector/resources/source3.js"));
}
\ No newline at end of file
<html>
<head>
<script src="../inspector-test.js"></script>
<script src="../console-test.js"></script>
<script src="../resources/source3.js"></script>
<script>
function test()
{
InspectorTest.evaluateInPage("foo()", step1);
UI.inspectorView._tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected, panelChanged);
function panelChanged()
{
InspectorTest.addResult("Panel " + UI.inspectorView._tabbedPane._currentTab.id + " was opened.");
InspectorTest.completeTest();
}
var clickTarget;
function step1()
{
var firstMessageEl = Console.ConsoleView.instance()._visibleViewMessages[0].element();
clickTarget = firstMessageEl.querySelectorAll(".console-message-text .devtools-link")[1];
UI.inspectorView.showPanel("console").then(testClickTarget);
}
function testClickTarget()
{
InspectorTest.addResult("Clicking link " + clickTarget.textContent);
clickTarget.click();
}
InspectorFrontendHost.openInNewTab = function()
{
InspectorTest.addResult("Failure: Open link in new tab!!");
InspectorTest.completeTest();
};
}
</script>
</head>
<body onload="runTest()">
<p>
Test that relative links in traces open in the sources panel.
</p>
</body>
</html>
......@@ -140,6 +140,23 @@ TestRunner.loadHTML = function(html) {
return TestRunner.evaluateInPagePromise(`document.write('${html}');document.close();`);
};
/**
* @param {string} path
* @return {!Promise<!SDK.RemoteObject>}
*/
TestRunner.addScriptTag = function(path) {
var testScriptURL = /** @type {string} */ (Runtime.queryParam('test'));
var resolvedPath = testScriptURL + '/../' + path;
return TestRunner.evaluateInPagePromise(`
(function(){
var script = document.createElement('script');
script.src = '${resolvedPath}';
document.head.append(script);
})();
`);
};
/**
* @param {string} title
*/
......
......@@ -163,10 +163,10 @@ TestRunner.loadModule = function(module) {
/**
* @param {string} panel
* @return {!Promise<!UI.Panel>}
* @return {!Promise.<?UI.Panel>}
*/
TestRunner.loadPanel = function(panel) {
return UI.inspectorView.panel(panel);
TestRunner.showPanel = function(panel) {
return UI.viewManager.showView(panel);
};
/**
......
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