Commit 5100e756 authored by dgozman@chromium.org's avatar dgozman@chromium.org

[DevTools] Prepare to pass modified InspectorFrontendHost to inspector app.

BUG=431697

Review URL: https://codereview.chromium.org/725583003

git-svn-id: svn://svn.chromium.org/blink/trunk@185317 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent b4eed002
...@@ -113,7 +113,6 @@ ...@@ -113,7 +113,6 @@
'front_end/components/TargetsComboBoxController.js', 'front_end/components/TargetsComboBoxController.js',
], ],
'devtools_host_js_files': [ 'devtools_host_js_files': [
'front_end/host/InspectorAppHost.js',
'front_end/host/InspectorFrontendHost.js', 'front_end/host/InspectorFrontendHost.js',
'front_end/host/Platform.js', 'front_end/host/Platform.js',
'front_end/host/UserMetrics.js', 'front_end/host/UserMetrics.js',
...@@ -197,6 +196,7 @@ ...@@ -197,6 +196,7 @@
], ],
'devtools_devtools_app_js_files': [ 'devtools_devtools_app_js_files': [
'front_end/devtools_app/DevToolsApp.js', 'front_end/devtools_app/DevToolsApp.js',
'front_end/devtools_app/UITests.js',
], ],
'devtools_platform_js_files': [ 'devtools_platform_js_files': [
'front_end/platform/DOMExtension.js', 'front_end/platform/DOMExtension.js',
......
...@@ -4,47 +4,20 @@ ...@@ -4,47 +4,20 @@
/** /**
* @constructor * @constructor
* @implements {InspectorAppHostAPI} * @suppressGlobalPropertiesCheck
*/ */
WebInspector.DevToolsApp = function() WebInspector.DevToolsApp = function()
{ {
window.InspectorAppHost = this; this._iframe = document.querySelector("iframe.inspector-app-iframe");
/** /**
* @type {?Window} * @type {!Window}
*/ */
this._inspectorWindow = null; this._inspectorWindow = this._iframe.contentWindow;
this._inspectorWindow.InspectorFrontendHost = window.InspectorFrontendHost;
} }
WebInspector.DevToolsApp.prototype = { WebInspector.DevToolsApp.prototype = {
/**
* @param {!Window} inspectorWindow
* @override
*/
inspectorAppWindowLoaded: function(inspectorWindow)
{
this._inspectorWindow = inspectorWindow;
if (window.domAutomationController)
this._inspectorWindow.domAutomationController = window.domAutomationController;
},
/**
* @override
*/
beforeInspectorAppLoad: function()
{
if (this._inspectorWindow.uiTests) {
// FIXME: move Tests to the host or teach browser counterpart about iframe.
window.uiTests = this._inspectorWindow.uiTests;
}
},
/**
* @override
*/
afterInspectorAppLoad: function()
{
}
} }
new WebInspector.DevToolsApp(); runOnWindowLoad(function() { new WebInspector.DevToolsApp(); });
// Copyright 2014 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.
if (window.domAutomationController) {
var uiTests = {};
uiTests.runTest = function(name)
{
if (uiTests._testSuite)
uiTests._testSuite._runTest(name);
else
uiTests._pendingTestName = name;
};
uiTests.testSuiteReady = function(testSuiteConstructor)
{
uiTests._testSuite = testSuiteConstructor(window.domAutomationController);
if (uiTests._pendingTestName) {
var name = uiTests._pendingTestName;
delete uiTests._pendingTestName;
uiTests._testSuite._runTest(name);
}
};
}
...@@ -5,6 +5,10 @@ ...@@ -5,6 +5,10 @@
"platform" "platform"
], ],
"scripts": [ "scripts": [
"UITests.js",
"DevToolsApp.js" "DevToolsApp.js"
],
"skip_compilation": [
"UITests.js"
] ]
} }
// Copyright 2014 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.
/**
* @interface
*/
function InspectorAppHostAPI()
{
}
InspectorAppHostAPI.prototype = {
/**
* @param {!Window} window
*/
inspectorAppWindowLoaded: function(window) { },
beforeInspectorAppLoad: function() { },
afterInspectorAppLoad: function() { }
}
/**
* @type {!InspectorAppHostAPI}
*/
var InspectorAppHost;
/**
* @suppressGlobalPropertiesCheck
*/
(function()
{
if (window.parent !== window) {
InspectorAppHost = window.parent.InspectorAppHost;
InspectorAppHost.inspectorAppWindowLoaded(window);
}
})();
...@@ -632,10 +632,6 @@ WebInspector.InspectorFrontendHostStub.prototype = { ...@@ -632,10 +632,6 @@ WebInspector.InspectorFrontendHostStub.prototype = {
var InspectorFrontendHost = window.InspectorFrontendHost || null; var InspectorFrontendHost = window.InspectorFrontendHost || null;
(function() { (function() {
if (window.top) {
// FIXME(dgozman): use InspectorAppHost everywhere in inspector app instead of InspectorFrontendHost.
InspectorFrontendHost = window.top.InspectorFrontendHost || null;
}
if (!InspectorFrontendHost) { if (!InspectorFrontendHost) {
// Instantiate stub for web-hosted mode if necessary. // Instantiate stub for web-hosted mode if necessary.
InspectorFrontendHost = new WebInspector.InspectorFrontendHostStub(); InspectorFrontendHost = new WebInspector.InspectorFrontendHostStub();
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
"scripts": [ "scripts": [
"InspectorFrontendHost.js", "InspectorFrontendHost.js",
"Platform.js", "Platform.js",
"UserMetrics.js", "UserMetrics.js"
"InspectorAppHost.js"
] ]
} }
...@@ -36,11 +36,6 @@ ...@@ -36,11 +36,6 @@
*/ */
WebInspector.Main = function() WebInspector.Main = function()
{ {
if (!InspectorAppHost) {
console.error("Inspector should be embedded.");
return;
}
InspectorAppHost.beforeInspectorAppLoad();
WebInspector.console.setUIDelegate(this); WebInspector.console.setUIDelegate(this);
runOnWindowLoad(this._loaded.bind(this)); runOnWindowLoad(this._loaded.bind(this));
} }
...@@ -256,7 +251,6 @@ WebInspector.Main.prototype = { ...@@ -256,7 +251,6 @@ WebInspector.Main.prototype = {
WebInspector.inspectElementModeController = new WebInspector.InspectElementModeController(); WebInspector.inspectElementModeController = new WebInspector.InspectElementModeController();
this._createGlobalStatusBarItems(); this._createGlobalStatusBarItems();
InspectorAppHost.afterInspectorAppLoad();
InspectorFrontendHost.loadCompleted(); InspectorFrontendHost.loadCompleted();
// Give UI cycles to repaint, then proceed with creating connection. // Give UI cycles to repaint, then proceed with creating connection.
......
...@@ -37,7 +37,8 @@ ...@@ -37,7 +37,8 @@
* FIXME: change field naming style to use trailing underscore. * FIXME: change field naming style to use trailing underscore.
*/ */
if (window.domAutomationController) { function createTestSuite(domAutomationController)
{
var ___interactiveUiTestsMode = true; var ___interactiveUiTestsMode = true;
...@@ -45,7 +46,7 @@ var ___interactiveUiTestsMode = true; ...@@ -45,7 +46,7 @@ var ___interactiveUiTestsMode = true;
* Test suite for interactive UI tests. * Test suite for interactive UI tests.
* @constructor * @constructor
*/ */
TestSuite = function() function TestSuite()
{ {
this.controlTaken_ = false; this.controlTaken_ = false;
this.timerId_ = -1; this.timerId_ = -1;
...@@ -148,7 +149,7 @@ TestSuite.prototype.releaseControl = function() ...@@ -148,7 +149,7 @@ TestSuite.prototype.releaseControl = function()
*/ */
TestSuite.prototype.reportOk_ = function() TestSuite.prototype.reportOk_ = function()
{ {
window.domAutomationController.send("[OK]"); domAutomationController.send("[OK]");
}; };
...@@ -161,7 +162,7 @@ TestSuite.prototype.reportFailure_ = function(error) ...@@ -161,7 +162,7 @@ TestSuite.prototype.reportFailure_ = function(error)
clearTimeout(this.timerId_); clearTimeout(this.timerId_);
this.timerId_ = -1; this.timerId_ = -1;
} }
window.domAutomationController.send("[FAILED] " + error); domAutomationController.send("[FAILED] " + error);
}; };
...@@ -904,21 +905,15 @@ TestSuite.createKeyEvent = function(keyIdentifier) ...@@ -904,21 +905,15 @@ TestSuite.createKeyEvent = function(keyIdentifier)
}; };
/**
* Test runner for the test suite.
*/
var uiTests = {};
/** /**
* Run each test from the test suit on a fresh instance of the suite. * Run each test from the test suit on a fresh instance of the suite.
*/ */
uiTests.runAllTests = function() TestSuite._runAllTests = function()
{ {
// For debugging purposes. // For debugging purposes.
for (var name in TestSuite.prototype) { for (var name in TestSuite.prototype) {
if (name.substring(0, 4) === "test" && typeof TestSuite.prototype[name] === "function") if (name.substring(0, 4) === "test" && typeof TestSuite.prototype[name] === "function")
uiTests.runTest(name); TestSuite._runTest(name);
} }
}; };
...@@ -927,27 +922,28 @@ uiTests.runAllTests = function() ...@@ -927,27 +922,28 @@ uiTests.runAllTests = function()
* Run specified test on a fresh instance of the test suite. * Run specified test on a fresh instance of the test suite.
* @param {string} name Name of a test method from TestSuite class. * @param {string} name Name of a test method from TestSuite class.
*/ */
uiTests.runTest = function(name) TestSuite._runTest = function(name)
{ {
if (uiTests._populatedInterface) if (TestSuite._populatedInterface)
new TestSuite().runTest(name); new TestSuite().runTest(name);
else else
uiTests._pendingTestName = name; TestSuite._pendingTestName = name;
}; };
(function() {
function runTests() function runTests()
{ {
uiTests._populatedInterface = true; TestSuite._populatedInterface = true;
var name = uiTests._pendingTestName; var name = TestSuite._pendingTestName;
delete uiTests._pendingTestName; delete TestSuite._pendingTestName;
if (name) if (name)
new TestSuite().runTest(name); new TestSuite().runTest(name);
} }
WebInspector.notifications.addEventListener(WebInspector.NotificationService.Events.InspectorAgentEnabledForTests, runTests); WebInspector.notifications.addEventListener(WebInspector.NotificationService.Events.InspectorAgentEnabledForTests, runTests);
})(); return TestSuite;
} }
if (window.parent && window.parent.uiTests)
window.parent.uiTests.testSuiteReady(createTestSuite);
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