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 @@
'front_end/components/TargetsComboBoxController.js',
],
'devtools_host_js_files': [
'front_end/host/InspectorAppHost.js',
'front_end/host/InspectorFrontendHost.js',
'front_end/host/Platform.js',
'front_end/host/UserMetrics.js',
......@@ -197,6 +196,7 @@
],
'devtools_devtools_app_js_files': [
'front_end/devtools_app/DevToolsApp.js',
'front_end/devtools_app/UITests.js',
],
'devtools_platform_js_files': [
'front_end/platform/DOMExtension.js',
......
......@@ -4,47 +4,20 @@
/**
* @constructor
* @implements {InspectorAppHostAPI}
* @suppressGlobalPropertiesCheck
*/
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 = {
/**
* @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 @@
"platform"
],
"scripts": [
"UITests.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 = {
var InspectorFrontendHost = window.InspectorFrontendHost || null;
(function() {
if (window.top) {
// FIXME(dgozman): use InspectorAppHost everywhere in inspector app instead of InspectorFrontendHost.
InspectorFrontendHost = window.top.InspectorFrontendHost || null;
}
if (!InspectorFrontendHost) {
// Instantiate stub for web-hosted mode if necessary.
InspectorFrontendHost = new WebInspector.InspectorFrontendHostStub();
......
......@@ -6,7 +6,6 @@
"scripts": [
"InspectorFrontendHost.js",
"Platform.js",
"UserMetrics.js",
"InspectorAppHost.js"
"UserMetrics.js"
]
}
......@@ -36,11 +36,6 @@
*/
WebInspector.Main = function()
{
if (!InspectorAppHost) {
console.error("Inspector should be embedded.");
return;
}
InspectorAppHost.beforeInspectorAppLoad();
WebInspector.console.setUIDelegate(this);
runOnWindowLoad(this._loaded.bind(this));
}
......@@ -256,7 +251,6 @@ WebInspector.Main.prototype = {
WebInspector.inspectElementModeController = new WebInspector.InspectElementModeController();
this._createGlobalStatusBarItems();
InspectorAppHost.afterInspectorAppLoad();
InspectorFrontendHost.loadCompleted();
// Give UI cycles to repaint, then proceed with creating connection.
......
......@@ -37,7 +37,8 @@
* FIXME: change field naming style to use trailing underscore.
*/
if (window.domAutomationController) {
function createTestSuite(domAutomationController)
{
var ___interactiveUiTestsMode = true;
......@@ -45,7 +46,7 @@ var ___interactiveUiTestsMode = true;
* Test suite for interactive UI tests.
* @constructor
*/
TestSuite = function()
function TestSuite()
{
this.controlTaken_ = false;
this.timerId_ = -1;
......@@ -148,7 +149,7 @@ TestSuite.prototype.releaseControl = function()
*/
TestSuite.prototype.reportOk_ = function()
{
window.domAutomationController.send("[OK]");
domAutomationController.send("[OK]");
};
......@@ -161,7 +162,7 @@ TestSuite.prototype.reportFailure_ = function(error)
clearTimeout(this.timerId_);
this.timerId_ = -1;
}
window.domAutomationController.send("[FAILED] " + error);
domAutomationController.send("[FAILED] " + error);
};
......@@ -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.
*/
uiTests.runAllTests = function()
TestSuite._runAllTests = function()
{
// For debugging purposes.
for (var name in TestSuite.prototype) {
if (name.substring(0, 4) === "test" && typeof TestSuite.prototype[name] === "function")
uiTests.runTest(name);
TestSuite._runTest(name);
}
};
......@@ -927,27 +922,28 @@ uiTests.runAllTests = function()
* Run specified test on a fresh instance of the test suite.
* @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);
else
uiTests._pendingTestName = name;
TestSuite._pendingTestName = name;
};
(function() {
function runTests()
{
uiTests._populatedInterface = true;
var name = uiTests._pendingTestName;
delete uiTests._pendingTestName;
TestSuite._populatedInterface = true;
var name = TestSuite._pendingTestName;
delete TestSuite._pendingTestName;
if (name)
new TestSuite().runTest(name);
}
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