Bug 800905 - Load script in to every new tab. r=davidb, a=akeybl
authorEitan Isaacson <eitan@monotonous.org>
Tue, 16 Oct 2012 11:07:16 -0700
changeset 116171 0d094ad653e8604c9b3dfea245723ed0d038967a
parent 116170 d5accf7d85e9eda60e3277909f3a8453a0acb413
child 116172 6de378a17e559f2029838be869edc2bca994d904
push id1708
push userakeybl@mozilla.com
push dateMon, 19 Nov 2012 21:10:21 +0000
treeherdermozilla-beta@27b14fe50103 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdavidb, akeybl
bugs800905
milestone18.0a2
Bug 800905 - Load script in to every new tab. r=davidb, a=akeybl
accessible/src/jsat/AccessFu.jsm
--- a/accessible/src/jsat/AccessFu.jsm
+++ b/accessible/src/jsat/AccessFu.jsm
@@ -94,16 +94,17 @@ var AccessFu = {
     Input.attach(this.chromeWin);
     Output.attach(this.chromeWin);
     this.touchAdapter.attach(this.chromeWin);
 
     Services.obs.addObserver(this, 'remote-browser-frame-shown', false);
     Services.obs.addObserver(this, 'Accessibility:NextObject', false);
     Services.obs.addObserver(this, 'Accessibility:PreviousObject', false);
     Services.obs.addObserver(this, 'Accessibility:CurrentObject', false);
+    this.chromeWin.addEventListener('TabOpen', this);
   },
 
   /**
    * Disable AccessFu and return to default interaction mode.
    */
   _disable: function _disable() {
     if (!this._enabled)
       return;
@@ -113,16 +114,18 @@ var AccessFu = {
     Logger.info('disable');
 
     this.chromeWin.document.removeChild(this.stylesheet);
     for each (let mm in Utils.getAllMessageManagers(this.chromeWin))
       mm.sendAsyncMessage('AccessFu:Stop');
 
     Input.detach();
 
+    this.chromeWin.removeEventListener('TabOpen', this);
+
     Services.obs.removeObserver(this, 'remote-browser-frame-shown');
     Services.obs.removeObserver(this, 'Accessibility:NextObject');
     Services.obs.removeObserver(this, 'Accessibility:PreviousObject');
     Services.obs.removeObserver(this, 'Accessibility:CurrentObject');
   },
 
   _enableOrDisable: function _enableOrDisable() {
     try {
@@ -200,20 +203,30 @@ var AccessFu = {
         this._loadFrameScript(
           aSubject.QueryInterface(Ci.nsIFrameLoader).messageManager);
         break;
       }
     }
   },
 
   handleEvent: function handleEvent(aEvent) {
-    if (aEvent.type == 'mozContentEvent' &&
-        aEvent.detail.type == 'accessibility-screenreader') {
-      this._systemPref = aEvent.detail.enabled;
-      this._enableOrDisable();
+    switch (aEvent.type) {
+      case 'mozContentEvent':
+      {
+        if (aEvent.detail.type == 'accessibility-screenreader') {
+          this._systemPref = aEvent.detail.enabled;
+          this._enableOrDisable();
+        }
+        break;
+      }
+      case 'TabOpen':
+      {
+        this._loadFrameScript(Utils.getMessageManager(aEvent.target));
+        break;
+      }
     }
   },
 
   // So we don't enable/disable twice
   _enabled: false
 };
 
 var Output = {