Bug 1472670 - use Protocol.js events instead of this.conn.send; r=ochameau
authoryulia <ystartsev@mozilla.com>
Wed, 04 Jul 2018 12:55:28 +0200
changeset 425317 fa92a04dda3d16d7c391f39fe5ae06e27ac42c26
parent 425316 9cf5aaf0177240e944a6e2063d7e67f411c75ddd
child 425318 7c5a7b0b6bc6123e774c8527c1a3cc5448b9fc12
push id34243
push userbtara@mozilla.com
push dateFri, 06 Jul 2018 21:59:02 +0000
treeherdermozilla-central@79197e2d630a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1472670
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1472670 - use Protocol.js events instead of this.conn.send; r=ochameau MozReview-Commit-ID: EtabuC1PCNw
devtools/client/debugger/new/src/client/firefox/events.js
devtools/server/actors/targets/browsing-context.js
devtools/shared/specs/targets/browsing-context.js
--- a/devtools/client/debugger/new/src/client/firefox/events.js
+++ b/devtools/client/debugger/new/src/client/firefox/events.js
@@ -96,9 +96,9 @@ function workerListChanged() {
 }
 
 const clientEvents = {
   paused,
   resumed,
   newSource
 };
 exports.setupEvents = setupEvents;
-exports.clientEvents = clientEvents;
\ No newline at end of file
+exports.clientEvents = clientEvents;
--- a/devtools/server/actors/targets/browsing-context.js
+++ b/devtools/server/actors/targets/browsing-context.js
@@ -681,17 +681,17 @@ const browsingContextTargetPrototype = {
     scriptError.initWithWindowID(text, null, null, 0, 0, flags,
                                  category, getInnerId(this.window));
     Services.console.logMessage(scriptError);
     return {};
   },
 
   _onWorkerTargetActorListChanged() {
     this._workerTargetActorList.onListChanged = null;
-    this.conn.sendActorEvent(this.actorID, "workerListChanged");
+    this.emit("workerListChanged");
   },
 
   observe(subject, topic, data) {
     // Ignore any event that comes before/after the actor is attached.
     // That typically happens during Firefox shutdown.
     if (!this.attached) {
       return;
     }
@@ -815,47 +815,41 @@ const browsingContextTargetPrototype = {
   _notifyDocShellsUpdate(docshells) {
     const windows = this._docShellsToWindows(docshells);
 
     // Do not send the `frameUpdate` event if the windows array is empty.
     if (windows.length == 0) {
       return;
     }
 
-    this.conn.send({
-      from: this.actorID,
-      type: "frameUpdate",
+    this.emit("frameUpdate", {
       frames: windows
     });
   },
 
   _updateChildDocShells() {
     this._notifyDocShellsUpdate(this.docShells);
   },
 
   _notifyDocShellDestroy(webProgress) {
     webProgress = webProgress.QueryInterface(Ci.nsIWebProgress);
     const id = webProgress.DOMWindow
                         .QueryInterface(Ci.nsIInterfaceRequestor)
                         .getInterface(Ci.nsIDOMWindowUtils)
                         .outerWindowID;
-    this.conn.send({
-      from: this.actorID,
-      type: "frameUpdate",
+    this.emit("frameUpdate", {
       frames: [{
         id,
         destroy: true
       }]
     });
   },
 
   _notifyDocShellDestroyAll() {
-    this.conn.send({
-      from: this.actorID,
-      type: "frameUpdate",
+    this.emit("frameUpdate", {
       destroyAll: true
     });
   },
 
   /**
    * Creates a thread actor and a pool for context-lifetime actors. It then sets
    * up the content window for debugging.
    */
@@ -928,18 +922,17 @@ const browsingContextTargetPrototype = {
 
     if (this._workerTargetActorPool !== null) {
       this.conn.removeActorPool(this._workerTargetActorPool);
       this._workerTargetActorPool = null;
     }
 
     this._attached = false;
 
-    this.conn.send({ from: this.actorID,
-                     type: "tabDetached" });
+    this.emit("tabDetached");
 
     return true;
   },
 
   // Protocol Request Handlers
 
   attach(request) {
     if (this.exited) {
@@ -1252,19 +1245,17 @@ const browsingContextTargetPrototype = {
     // browsing context (it will indirectly update this.window and many other
     // attributes defined from docShell).
     Object.defineProperty(this, "docShell", {
       value: docShell,
       enumerable: true,
       configurable: true
     });
     this.emit("changed-toplevel-document");
-    this.conn.send({
-      from: this.actorID,
-      type: "frameUpdate",
+    this.emit("frameUpdate", {
       selected: this.outerWindowID
     });
   },
 
   /**
    * Handle location changes, by clearing the previous debuggees and enabling
    * debugging, which may have been disabled temporarily by the
    * DebuggerProgressListener.
@@ -1360,19 +1351,17 @@ const browsingContextTargetPrototype = {
     const threadActor = this.threadActor;
     if (threadActor.state == "paused") {
       this.conn.send(
         threadActor.unsafeSynchronize(Promise.resolve(threadActor.onResume())));
       threadActor.dbg.enabled = false;
     }
     threadActor.disableAllBreakpoints();
 
-    this.conn.send({
-      from: this.actorID,
-      type: "tabNavigated",
+    this.emit("tabNavigated", {
       url: newURI,
       nativeConsoleAPI: true,
       state: "start",
       isFrameSwitching: isFrameSwitching
     });
 
     if (reset) {
       this._setWindow(this._originalWindow);
@@ -1402,19 +1391,17 @@ const browsingContextTargetPrototype = {
     }
 
     // TODO bug 997119: move that code to ThreadActor by listening to navigate
     const threadActor = this.threadActor;
     if (threadActor.state == "running") {
       threadActor.dbg.enabled = true;
     }
 
-    this.conn.send({
-      from: this.actorID,
-      type: "tabNavigated",
+    this.emit("tabNavigated", {
       url: this.url,
       title: this.title,
       nativeConsoleAPI: this.hasNativeConsoleAPI(this.window),
       state: "stop",
       isFrameSwitching: isFrameSwitching
     });
   },
 
--- a/devtools/shared/specs/targets/browsing-context.js
+++ b/devtools/shared/specs/targets/browsing-context.js
@@ -25,18 +25,19 @@ types.addDictType("browsingContextTarget
 
 types.addDictType("browsingContextTarget.listframes", {
   frames: "array:browsingContextTarget.window"
 });
 
 types.addDictType("browsingContextTarget.window", {
   id: "string",
   parentID: "nullable:string",
-  url: "string",
-  title: "string"
+  url: "nullable:string", // should be present if not destroying
+  title: "nullable:string", // should be present if not destroying
+  destroy: "nullable:boolean" // not present if not destroying
 });
 
 types.addDictType("browsingContextTarget.workers", {
   error: "nullable:string"
 });
 
 types.addDictType("browsingContextTarget.reload", {
   force: "boolean"
@@ -105,14 +106,36 @@ const browsingContextTargetSpecPrototype
       request: {
         text: Option(0, "string"),
         category: Option(0, "string"),
         flags: Option(0, "string")
       },
       response: {}
     }
   },
+  events: {
+    tabNavigated: {
+      type: "tabNavigated",
+      url: Option(0, "string"),
+      title: Option(0, "string"),
+      nativeConsoleAPI: Option(0, "boolean"),
+      state: Option(0, "string"),
+      isFrameSwitching: Option(0, "boolean")
+    },
+    frameUpdate: {
+      type: "frameUpdate",
+      frames: Option(0, "nullable:array:browsingContextTarget.window"),
+      selected: Option(0, "nullable:number"),
+      destroyAll: Option(0, "nullable:boolean")
+    },
+    tabDetached: {
+      type: "tabDetached"
+    },
+    workerListChanged: {
+      type: "workerListChanged"
+    }
+  }
 };
 
 const browsingContextTargetSpec = generateActorSpec(browsingContextTargetSpecPrototype);
 
 exports.browsingContextTargetSpecPrototype = browsingContextTargetSpecPrototype;
 exports.browsingContextTargetSpec = browsingContextTargetSpec;