Bug 1471941 - Clean up dangling stylesheet listener in DevTools. r=ochameau
authorJ. Ryan Stinnett <jryans@gmail.com>
Tue, 03 Jul 2018 13:53:30 +0000
changeset 424890 30bdb22bbe5a2bdecd09a188b78850bd460b4fae
parent 424889 dc54472ca3bf5db07602280d1e361cd120fdb858
child 424891 e29214662562389d45a7dd4b00c290e5e4c7e759
push id104933
push usershindli@mozilla.com
push dateTue, 03 Jul 2018 22:35:47 +0000
treeherdermozilla-inbound@00de580e868f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1471941, 1465637
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 1471941 - Clean up dangling stylesheet listener in DevTools. r=ochameau In bug 1465637, we removed the redundant actor pool that was used only for creating stylesheet actors in a target. This change happened to lead to errors that uncovered a dangling listener in `StyleSheetsActor` that would continue to create actors after toolbox destroy when a new sheet is added. Differential Revision: https://phabricator.services.mozilla.com/D1866
devtools/server/actors/stylesheets.js
devtools/server/actors/targets/browsing-context.js
--- a/devtools/server/actors/stylesheets.js
+++ b/devtools/server/actors/stylesheets.js
@@ -674,18 +674,18 @@ var StyleSheetsActor = protocol.ActorCla
       // This flag only exists for devtools, so we are free to clear
       // it when we're done.
       win.document.styleSheetChangeEventsEnabled = false;
     }
 
     this.parentActor.off("stylesheet-added", this._onNewStyleSheetActor);
     this.parentActor.off("window-ready", this._onWindowReady);
 
-    this.parentActor.chromeEventHandler.removeEventListener("StyleSheetAdded",
-                                                            this._onSheetAdded, true);
+    this.parentActor.chromeEventHandler
+      .removeEventListener("StyleSheetApplicableStateChanged", this._onSheetAdded, true);
 
     protocol.Actor.prototype.destroy.call(this);
   },
 
   /**
    * Event handler that is called when a the target actor emits window-ready.
    *
    * @param {Event} evt
--- a/devtools/server/actors/targets/browsing-context.js
+++ b/devtools/server/actors/targets/browsing-context.js
@@ -1446,16 +1446,17 @@ const browsingContextTargetPrototype = {
    *
    * @param DOMStyleSheet styleSheet
    *        The style sheet to create an actor for.
    * @return StyleSheetActor actor
    *         The actor for this style sheet.
    *
    */
   createStyleSheetActor(styleSheet) {
+    assert(!this.exited, "Target must not be exited to create a sheet actor.");
     if (this._styleSheetActors.has(styleSheet)) {
       return this._styleSheetActors.get(styleSheet);
     }
     const actor = new StyleSheetActor(styleSheet, this);
     this._styleSheetActors.set(styleSheet, actor);
 
     this._targetScopedActorPool.addActor(actor);
     this.emit("stylesheet-added", actor);