Bug 1034084 - Avoid sending reflow events after the window has been closed; r=miker
authorPatrick Brosset <pbrosset@mozilla.com>
Thu, 03 Jul 2014 12:18:00 +0200
changeset 192603 3271ce25db004f93597060325e34a2f7001fc682
parent 192602 161b47c4a8adca4040222460eb01b8a020ce1932
child 192604 1c3ec706f97bc8b5d13f5cab79aa7323729e84e1
push id27091
push userkwierso@gmail.com
push dateMon, 07 Jul 2014 21:11:34 +0000
treeherdermozilla-central@f14b47c39013 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmiker
bugs1034084
milestone33.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 1034084 - Avoid sending reflow events after the window has been closed; r=miker
toolkit/devtools/server/actors/layout.js
toolkit/devtools/server/tests/unit/test_layout-reflows-observer.js
--- a/toolkit/devtools/server/actors/layout.js
+++ b/toolkit/devtools/server/actors/layout.js
@@ -271,16 +271,22 @@ LayoutChangesObserver.prototype = Herita
   },
 
   /**
    * Start the event loop, which regularly checks if there are any observer
    * events to be sent as batched events
    * Calls itself in a loop.
    */
   _startEventLoop: function() {
+    // Avoid emitting events if the tabActor has been detached (may happen
+    // during shutdown)
+    if (!this.tabActor.attached) {
+      return;
+    }
+
     // Send any reflows we have
     if (this.reflows && this.reflows.length) {
       this.emit("reflows", this.reflows);
       this.reflows = [];
     }
     this.eventLoopTimer = this._setTimeout(this._startEventLoop,
       this.EVENT_BATCHING_DELAY);
   },
--- a/toolkit/devtools/server/tests/unit/test_layout-reflows-observer.js
+++ b/toolkit/devtools/server/tests/unit/test_layout-reflows-observer.js
@@ -16,16 +16,17 @@ let {
 LayoutChangesObserver.prototype._setTimeout = cb => cb;
 LayoutChangesObserver.prototype._clearTimeout = function() {};
 
 // Mock the tabActor since we only really want to test the LayoutChangesObserver
 // and don't want to depend on a window object, nor want to test protocol.js
 function MockTabActor() {
   this.window = new MockWindow();
   this.windows = [this.window];
+  this.attached = true;
 }
 
 function MockWindow() {}
 MockWindow.prototype = {
   QueryInterface: function() {
     let self = this;
     return {
       getInterface: function() {