Devtools: initialize protocol enums synchronously
BUG=
Review URL: https://codereview.chromium.org/1355423003
git-svn-id: svn://svn.chromium.org/blink/trunk@202661 bbb929c8-8fbe-4397-9dbb-9b2b20218538
diff --git a/LayoutTests/http/tests/inspector/inspector-test.js b/LayoutTests/http/tests/inspector/inspector-test.js
index 45891d6..6ddc6ab 100644
--- a/LayoutTests/http/tests/inspector/inspector-test.js
+++ b/LayoutTests/http/tests/inspector/inspector-test.js
@@ -847,6 +847,7 @@
InspectorTest.serviceWorkerManager = target.serviceWorkerManager;
InspectorTest.tracingManager = target.tracingManager;
InspectorTest.mainTarget = target;
+ InspectorTest.connection = target._connection;
},
targetRemoved: function(target) { }
diff --git a/LayoutTests/inspector/elements/styles-1/cached-sync-computed-styles.html b/LayoutTests/inspector/elements/styles-1/cached-sync-computed-styles.html
index bd8233c..6f702fd 100644
--- a/LayoutTests/inspector/elements/styles-1/cached-sync-computed-styles.html
+++ b/LayoutTests/inspector/elements/styles-1/cached-sync-computed-styles.html
@@ -30,7 +30,7 @@
{
var callsLeft = 2;
nodeId = node.id;
- InspectorTest.addSniffer(InspectorBackend.connection(), "_wrapCallbackAndSendMessageObject", onBackendCall, true);
+ InspectorTest.addSniffer(InspectorTest.connection, "_wrapCallbackAndSendMessageObject", onBackendCall, true);
InspectorTest.cssModel.computedStylePromise(nodeId).then(styleCallback);
InspectorTest.cssModel.computedStylePromise(nodeId).then(styleCallback);
function styleCallback()
diff --git a/LayoutTests/inspector/profiler/heap-snapshot-loader.html b/LayoutTests/inspector/profiler/heap-snapshot-loader.html
index 6e139f2..81198c2 100644
--- a/LayoutTests/inspector/profiler/heap-snapshot-loader.html
+++ b/LayoutTests/inspector/profiler/heap-snapshot-loader.html
@@ -11,7 +11,7 @@
var partSize = sourceStringified.length >> 3;
function injectMockProfile(callback) {
- var dispatcher = InspectorBackend._connection._dispatchers["HeapProfiler"]._dispatcher;
+ var dispatcher = InspectorTest.connection._dispatchers["HeapProfiler"]._dispatcher;
var panel = WebInspector.panels.profiles;
panel._reset();
diff --git a/LayoutTests/inspector/report-API-errors.html b/LayoutTests/inspector/report-API-errors.html
index 211f868..3ba297f 100644
--- a/LayoutTests/inspector/report-API-errors.html
+++ b/LayoutTests/inspector/report-API-errors.html
@@ -18,8 +18,8 @@
InspectorTest.RuntimeAgent.evaluate("true", "test");
InspectorTest.RuntimeAgent.evaluate("true", "test", function(){});
InspectorTest.RuntimeAgent.evaluate("true", "test", undefined, function(){});
- InspectorBackend.connection().dispatch('{"method": "wrongDomain.something-strange", "params": {}}');
- InspectorBackend.connection().dispatch('{"method": "Inspector.something-strange", "params": {}}');
+ InspectorTest.connection.dispatch('{"method": "wrongDomain.something-strange", "params": {}}');
+ InspectorTest.connection.dispatch('{"method": "Inspector.something-strange", "params": {}}');
InspectorTest.completeTest();
}
diff --git a/Source/devtools/front_end/main/Main.js b/Source/devtools/front_end/main/Main.js
index 5ecd8c2..6f30e75 100644
--- a/Source/devtools/front_end/main/Main.js
+++ b/Source/devtools/front_end/main/Main.js
@@ -313,7 +313,6 @@
new WebInspector.RemoteDebuggingTerminatedScreen(event.data.reason).showModal();
}
- InspectorBackend.setConnection(connection);
var targetType = Runtime.queryParam("isSharedWorker") ? WebInspector.Target.Type.ServiceWorker : WebInspector.Target.Type.Page;
WebInspector.targetManager.createTarget(WebInspector.UIString("Main"), targetType, connection, null, this._mainTargetCreated.bind(this));
},
diff --git a/Source/devtools/front_end/main/TestController.js b/Source/devtools/front_end/main/TestController.js
index be9366e..f376515 100644
--- a/Source/devtools/front_end/main/TestController.js
+++ b/Source/devtools/front_end/main/TestController.js
@@ -42,5 +42,6 @@
console.error(e.stack);
}
}
- InspectorBackend.connection().runAfterPendingDispatches(invokeMethod);
+
+ WebInspector.targetManager.mainTarget()._connection.runAfterPendingDispatches(invokeMethod);
}
diff --git a/Source/devtools/front_end/main/module.json b/Source/devtools/front_end/main/module.json
index 9bd334a..ad7a81f 100644
--- a/Source/devtools/front_end/main/module.json
+++ b/Source/devtools/front_end/main/module.json
@@ -331,7 +331,8 @@
"Main.js"
],
"skip_compilation": [
- "Tests.js"
+ "Tests.js",
+ "TestController.js"
],
"resources": [
]
diff --git a/Source/devtools/front_end/sdk/InspectorBackend.js b/Source/devtools/front_end/sdk/InspectorBackend.js
index 6d5f8b3..fdbc8ba 100644
--- a/Source/devtools/front_end/sdk/InspectorBackend.js
+++ b/Source/devtools/front_end/sdk/InspectorBackend.js
@@ -33,11 +33,9 @@
*/
function InspectorBackendClass()
{
- this._connection = null;
this._agentPrototypes = {};
this._dispatcherPrototypes = {};
this._initialized = false;
- this._enums = {};
this._initProtocolAgentsConstructor();
}
@@ -100,30 +98,6 @@
},
/**
- * @return {!InspectorBackendClass.Connection}
- */
- connection: function()
- {
- if (!this._connection)
- throw "Main connection was not initialized";
- return this._connection;
- },
-
- /**
- * @param {!InspectorBackendClass.MainConnection} connection
- */
- setConnection: function(connection)
- {
- this._connection = connection;
-
- this._connection.registerAgentsOn(window);
- for (var type in this._enums) {
- var domainAndMethod = type.split(".");
- window[domainAndMethod[0] + "Agent"][domainAndMethod[1]] = this._enums[type];
- }
- },
-
- /**
* @param {string} domain
* @return {!InspectorBackendClass.AgentPrototype}
*/
@@ -167,7 +141,12 @@
*/
registerEnum: function(type, values)
{
- this._enums[type] = values;
+ var domainAndMethod = type.split(".");
+ var agentName = domainAndMethod[0] + "Agent";
+ if (!window[agentName])
+ window[agentName] = {};
+
+ window[agentName][domainAndMethod[1]] = values;
this._initialized = true;
},
@@ -366,15 +345,6 @@
},
/**
- * @param {!Object} object
- */
- registerAgentsOn: function(object)
- {
- for (var domain in this._agents)
- object[domain + "Agent"] = {};
- },
-
- /**
* @return {number}
*/
nextMessageId: function()
diff --git a/Source/devtools/scripts/generate_protocol_externs.py b/Source/devtools/scripts/generate_protocol_externs.py
index 8fe30e4..1cf87c1 100755
--- a/Source/devtools/scripts/generate_protocol_externs.py
+++ b/Source/devtools/scripts/generate_protocol_externs.py
@@ -160,7 +160,7 @@
output_file.write("/** @param {function(%s):void=} opt_callback */\n" % ", ".join(returns))
output_file.write("Protocol.%sAgent.prototype.invoke_%s = function(obj, opt_callback) {}\n" % (domain_name, command["name"]))
- output_file.write("\n\n\nvar %sAgent = {};\n" % domain_name)
+ output_file.write("\n\n\nvar %sAgent = function(){};\n" % domain_name)
if "types" in domain:
for type in domain["types"]: