Bug 937197 - Handle requestTypes RDP request for any existent RDP actor. r=fitzgen
authorLuca Greco <luca.greco@alcacoop.it>
Mon, 06 Jan 2014 18:27:10 +0100
changeset 162252 05d387f1dc78b7454e5eb343f01e95eae6287d1b
parent 162241 f78ec00f29f5ff6d509f71942c6941bcf64e2706
child 162253 64c3bdede7dd7f510f95909b7393ca5c88019ddf
push idunknown
push userunknown
push dateunknown
reviewersfitzgen
bugs937197
milestone29.0a1
Bug 937197 - Handle requestTypes RDP request for any existent RDP actor. r=fitzgen
toolkit/devtools/server/main.js
toolkit/devtools/server/tests/unit/test_requestTypes.js
toolkit/devtools/server/tests/unit/xpcshell.ini
--- a/toolkit/devtools/server/main.js
+++ b/toolkit/devtools/server/main.js
@@ -1009,18 +1009,22 @@ DebuggerServerConnection.prototype = {
       // actor. Reusing the existing actor ID will make sure ActorPool.addActor
       // does the right thing.
       instance.actorID = actor.actorID;
       actor.registeredPool.addActor(instance);
       actor = instance;
     }
 
     var ret = null;
-    // Dispatch the request to the actor.
-    if (actor.requestTypes && actor.requestTypes[aPacket.type]) {
+
+    // handle "requestTypes" RDP request.
+    if (aPacket.type == "requestTypes") {
+      ret = { from: actor.actorID, requestTypes: Object.keys(actor.requestTypes) };
+    } else if (actor.requestTypes && actor.requestTypes[aPacket.type]) {
+      // Dispatch the request to the actor.
       try {
         this.currentPacket = aPacket;
         ret = actor.requestTypes[aPacket.type].bind(actor)(aPacket, this);
       } catch(e) {
         this.transport.send(this._unknownError(
           "error occurred while processing '" + aPacket.type,
           e));
       } finally {
new file mode 100644
--- /dev/null
+++ b/toolkit/devtools/server/tests/unit/test_requestTypes.js
@@ -0,0 +1,52 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+let promise = devtools.require("sdk/core/promise");
+
+function test_requestTypes_request(aClient, anActor)
+{
+  var calls = [];
+
+  calls.push(test_existent_actor(aClient, anActor));
+
+  promise.all(calls).then(() => {
+    aClient.close(() => {
+      do_test_finished();
+    });
+  });
+}
+
+function test_existent_actor(aClient, anActor)
+{
+  let deferred = promise.defer();
+
+  aClient.request({ to: anActor, type: "requestTypes" }, function (aResponse) {
+    var expectedRequestTypes = Object.keys(DebuggerServer.
+                                           globalActorFactories["chromeDebugger"].
+                                           prototype.requestTypes);
+
+    do_check_true(Array.isArray(aResponse.requestTypes));
+    do_check_eq(JSON.stringify(aResponse.requestTypes),
+                JSON.stringify(expectedRequestTypes));
+
+    deferred.resolve();
+  });
+
+  return deferred.promise;
+}
+
+function run_test()
+{
+  DebuggerServer.init(function () { return true; });
+  DebuggerServer.addBrowserActors();
+  var client = new DebuggerClient(DebuggerServer.connectPipe());
+  client.connect(function() {
+    client.listTabs(function(aResponse) {
+      test_requestTypes_request(client, aResponse.chromeDebugger);
+    });
+  });
+
+  do_test_pending();
+}
--- a/toolkit/devtools/server/tests/unit/xpcshell.ini
+++ b/toolkit/devtools/server/tests/unit/xpcshell.ini
@@ -188,8 +188,10 @@ reason = bug 820380
 [test_trace_actor-03.js]
 [test_trace_actor-04.js]
 [test_trace_actor-05.js]
 [test_trace_actor-06.js]
 [test_trace_actor-07.js]
 [test_trace_actor-08.js]
 [test_trace_actor-09.js]
 [test_ignore_caught_exceptions.js]
+[test_requestTypes.js]
+reason = bug 937197