Bug 1493984 - Change event listener to the mm to be able to receive chrome events. r=mconley
authorFelipe Gomes <felipc@gmail.com>
Tue, 30 Oct 2018 21:47:05 +0000
changeset 443642 e4acca06cb52a3a91399f38cb6a171ee71e5edca
parent 443641 8e32732468a346179d630d0c23a5996572dfc24a
child 443643 50da96ec0040585c2d0d1cd46b2ce7f93af78ae5
push id109420
push useraciure@mozilla.com
push dateWed, 31 Oct 2018 05:11:56 +0000
treeherdermozilla-inbound@b357da105c49 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1493984
milestone65.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 1493984 - Change event listener to the mm to be able to receive chrome events. r=mconley Some events that actors need to listen to are chrome events which are not received by the listener in the window (even with mozSystemGroup = true). Differential Revision: https://phabricator.services.mozilla.com/D8014
toolkit/modules/ActorManagerChild.jsm
--- a/toolkit/modules/ActorManagerChild.jsm
+++ b/toolkit/modules/ActorManagerChild.jsm
@@ -207,17 +207,17 @@ class SingletonDispatcher extends Dispat
 
   cleanup() {
     super.cleanup();
 
     for (let msg of this.messages.keys()) {
       this.mm.removeMessageListener(msg, this);
     }
     for (let [event, listener, options] of this.listeners) {
-      this.window.removeEventListener(event, listener, options);
+      this.mm.removeEventListener(event, listener, options);
     }
 
     for (let actor of this.instances.values()) {
       try {
         actor.cleanup();
       } catch (e) {
         Cu.reportError(e);
       }
@@ -237,20 +237,26 @@ class SingletonDispatcher extends Dispat
       }
       this.hidden = false;
     } else if (event.type == "pagehide") {
       this.hidden = true;
       this.cleanup();
     }
   }
 
+  handleActorEvent(actor, event) {
+    if (event.target.ownerGlobal == this.window) {
+      this.getActor(actor).handleEvent(event);
+    }
+  }
+
   addEventListener(event, actor, options) {
     let listener = this.handleActorEvent.bind(this, actor);
     this.listeners.push([event, listener, options]);
-    this.window.addEventListener(event, listener, options);
+    this.mm.addEventListener(event, listener, options);
   }
 }
 
 /* globals MatchPatternSet, MozDocumentMatcher, MozDocumentObserver */
 
 var ActorManagerChild = {
   groups: new DefaultMap(group => {
     return sharedData.get(`ChildActors:${group || ""}`);