Bug 892605 - part 1: move the BlackBoxChange DOM event to blackboxchange thread client event; r=vporof
authorNick Fitzgerald <fitzgen@gmail.com>
Sat, 27 Jul 2013 10:49:45 -0700
changeset 152539 893b7d8e7b175de977c8aeb0cdb7eb161a02521d
parent 152538 0c80222426fe8757b91f9db09ded8697a1017479
child 152540 aa190a916dcc3a1dac3655558e87790be5320a87
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvporof
bugs892605
milestone25.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 892605 - part 1: move the BlackBoxChange DOM event to blackboxchange thread client event; r=vporof
browser/devtools/debugger/debugger-controller.js
browser/devtools/debugger/test/browser_dbg_blackboxing-01.js
browser/devtools/debugger/test/browser_dbg_blackboxing-02.js
browser/devtools/debugger/test/browser_dbg_blackboxing-03.js
browser/devtools/debugger/test/browser_dbg_blackboxing-04.js
toolkit/devtools/client/dbg-client.jsm
--- a/browser/devtools/debugger/debugger-controller.js
+++ b/browser/devtools/debugger/debugger-controller.js
@@ -443,33 +443,33 @@ StackFrames.prototype = {
    * Connect to the current thread client.
    */
   connect: function() {
     dumpn("StackFrames is connecting...");
     this.activeThread.addListener("paused", this._onPaused);
     this.activeThread.addListener("resumed", this._onResumed);
     this.activeThread.addListener("framesadded", this._onFrames);
     this.activeThread.addListener("framescleared", this._onFramesCleared);
-    window.addEventListener("Debugger:BlackBoxChange", this._onBlackBoxChange, false);
+    this.activeThread.addListener("blackboxchange", this._onBlackBoxChange);
     this._handleTabNavigation();
   },
 
   /**
    * Disconnect from the client.
    */
   disconnect: function() {
     if (!this.activeThread) {
       return;
     }
     dumpn("StackFrames is disconnecting...");
     this.activeThread.removeListener("paused", this._onPaused);
     this.activeThread.removeListener("resumed", this._onResumed);
     this.activeThread.removeListener("framesadded", this._onFrames);
     this.activeThread.removeListener("framescleared", this._onFramesCleared);
-    window.removeEventListener("Debugger:BlackBoxChange", this._onBlackBoxChange, false);
+    this.activeThread.removeListener("blackboxchange", this._onBlackBoxChange);
   },
 
   /**
    * Handles any initialization on a tab navigation event issued by the client.
    */
   _handleTabNavigation: function() {
     dumpn("Handling tab navigation in the StackFrames");
     // Nothing to do here yet.
@@ -635,17 +635,17 @@ StackFrames.prototype = {
     // After each frame step (in, over, out), framescleared is fired, which
     // forces the UI to be emptied and rebuilt on framesadded. Most of the times
     // this is not necessary, and will result in a brief redraw flicker.
     // To avoid it, invalidate the UI only after a short time if necessary.
     window.setTimeout(this._afterFramesCleared, FRAME_STEP_CLEAR_DELAY);
   },
 
   /**
-   * Handler for the debugger's BlackBoxChange notification.
+   * Handler for the debugger's blackboxchange notification.
    */
   _onBlackBoxChange: function() {
     if (this.activeThread.state == "paused") {
       // We have to clear out the existing frames and refetch them to get their
       // updated black boxed status.
       this.activeThread._clearFrames();
       this.activeThread.fillFrames(CALL_STACK_PAGE_SIZE);
     }
@@ -1037,17 +1037,16 @@ SourceScripts.prototype = {
     const sourceClient = this.activeThread.source(aSource);
     sourceClient[aBlackBoxFlag ? "blackBox" : "unblackBox"](function({ error, message }) {
       if (error) {
         let msg = "Could not toggle black boxing for "
           + aSource.url + ": " + message;
         dumpn(msg);
         return void Cu.reportError(msg);
       }
-      window.dispatchEvent(document, "Debugger:BlackBoxChange", sourceClient);
     });
   },
 
   /**
    * Gets a specified source's text.
    *
    * @param object aSource
    *        The source object coming from the active thread.
--- a/browser/devtools/debugger/test/browser_dbg_blackboxing-01.js
+++ b/browser/devtools/debugger/test/browser_dbg_blackboxing-01.js
@@ -31,18 +31,18 @@ function test()
 }
 
 function testBlackBoxSource() {
   once(gDebugger, "Debugger:SourceShown", function () {
     const checkbox = gDebugger.document.querySelector(".side-menu-widget-item-checkbox");
     ok(checkbox, "Should get the checkbox for black boxing the source");
     ok(checkbox.checked, "Should not be black boxed by default");
 
-    once(gDebugger, "Debugger:BlackBoxChange", function (event) {
-      const sourceClient = event.detail;
+    const { activeThread } = gDebugger.DebuggerController;
+    activeThread.addOneTimeListener("blackboxchange", function (event, sourceClient) {
       ok(sourceClient.isBlackBoxed, "The source should be black boxed now");
       ok(!checkbox.checked, "The checkbox should no longer be checked.");
 
       testBlackBoxReload();
     });
 
     checkbox.click();
   });
--- a/browser/devtools/debugger/test/browser_dbg_blackboxing-02.js
+++ b/browser/devtools/debugger/test/browser_dbg_blackboxing-02.js
@@ -32,18 +32,18 @@ function test()
   });
 }
 
 function testBlackBoxSource() {
   once(gDebugger, "Debugger:SourceShown", function () {
     const checkbox = getBlackBoxCheckbox(BLACKBOXME_URL);
     ok(checkbox, "Should get the checkbox for blackBoxing the source");
 
-    once(gDebugger, "Debugger:BlackBoxChange", function (event) {
-      const sourceClient = event.detail;
+    const { activeThread } = gDebugger.DebuggerController;
+    activeThread.addOneTimeListener("blackboxchange", function (event, sourceClient) {
       ok(sourceClient.isBlackBoxed, "The source should be black boxed now");
 
       testBlackBoxStack();
     });
 
     checkbox.click();
   });
 }
--- a/browser/devtools/debugger/test/browser_dbg_blackboxing-03.js
+++ b/browser/devtools/debugger/test/browser_dbg_blackboxing-03.js
@@ -50,20 +50,19 @@ function testBlackBoxStack() {
 
   gDebuggee.runTest();
 }
 
 function testBlackBoxSource() {
   const checkbox = getBlackBoxCheckbox(BLACKBOXME_URL);
   ok(checkbox, "Should get the checkbox for black boxing the source");
 
-  once(gDebugger, "Debugger:BlackBoxChange", function (event) {
-    const { activeThread } = gDebugger.DebuggerController;
+  const { activeThread } = gDebugger.DebuggerController;
+  activeThread.addOneTimeListener("blackboxchange", function (event, sourceClient) {
     activeThread.addOneTimeListener("framesadded", function () {
-      const sourceClient = event.detail;
       ok(sourceClient.isBlackBoxed, "The source should be black boxed now");
 
       const frames = gDebugger.DebuggerView.StackFrames.widget._list;
       is(frames.querySelectorAll(".dbg-stackframe").length, 3,
          "Should only get 3 frames");
       is(frames.querySelectorAll(".dbg-stackframe-black-boxed").length, 1,
          "And one of them is the combined black boxed frames");
 
--- a/browser/devtools/debugger/test/browser_dbg_blackboxing-04.js
+++ b/browser/devtools/debugger/test/browser_dbg_blackboxing-04.js
@@ -30,25 +30,24 @@ function test()
     once(gDebugger, "Debugger:SourceShown", function () {
       blackBoxSources();
     });
   });
 }
 
 function blackBoxSources() {
   let timesFired = 0;
-  gDebugger.addEventListener("Debugger:BlackBoxChange", function _onBlackboxChange() {
+  const { activeThread } = gDebugger.DebuggerController;
+  activeThread.addListener("blackboxchange", function _onBlackBoxChange() {
     if (++timesFired !== 3) {
       return;
     }
-    gDebugger.removeEventListener("Debugger:BlackBoxChange", _onBlackboxChange, false);
+    activeThread.removeListener("blackboxchange", _onBlackBoxChange);
 
-    const { activeThread } = gDebugger.DebuggerController;
     activeThread.addOneTimeListener("framesadded", testStackFrames);
-
     gDebuggee.one();
   }, false);
 
   getBlackBoxCheckbox(EXAMPLE_URL + "blackboxing_one.js").click();
   getBlackBoxCheckbox(EXAMPLE_URL + "blackboxing_two.js").click();
   getBlackBoxCheckbox(EXAMPLE_URL + "blackboxing_three.js").click();
 }
 
--- a/toolkit/devtools/client/dbg-client.jsm
+++ b/toolkit/devtools/client/dbg-client.jsm
@@ -1752,16 +1752,17 @@ LongStringClient.prototype = {
 function SourceClient(aClient, aForm) {
   this._form = aForm;
   this._isBlackBoxed = aForm.isBlackBoxed;
   this._client = aClient;
 }
 
 SourceClient.prototype = {
   get _transport() this._client._transport,
+  get _activeThread() this._client.activeThread,
   get isBlackBoxed() this._isBlackBoxed,
   get actor() this._form.actor,
   get request() this._client.request,
 
   /**
    * Black box this SourceClient's source.
    *
    * @param aCallback Function
@@ -1769,16 +1770,19 @@ SourceClient.prototype = {
    */
   blackBox: DebuggerClient.requester({
     type: "blackbox"
   }, {
     telemetry: "BLACKBOX",
     after: function (aResponse) {
       if (!aResponse.error) {
         this._isBlackBoxed = true;
+        if (this._activeThread) {
+          this._activeThread.notify("blackboxchange", this);
+        }
       }
       return aResponse;
     }
   }),
 
   /**
    * Un-black box this SourceClient's source.
    *
@@ -1787,16 +1791,19 @@ SourceClient.prototype = {
    */
   unblackBox: DebuggerClient.requester({
     type: "unblackbox"
   }, {
     telemetry: "UNBLACKBOX",
     after: function (aResponse) {
       if (!aResponse.error) {
         this._isBlackBoxed = false;
+        if (this._activeThread) {
+          this._activeThread.notify("blackboxchange", this);
+        }
       }
       return aResponse;
     }
   }),
 
   /**
    * Get a long string grip for this SourceClient's source.
    */