Bug 1347413 - Remove the unused browser-fullZoom:zoomReset and browser-fullZoom:zoomChange notifications. r=dao,mccr8
authorJared Wein <jwein@mozilla.com>
Wed, 15 Mar 2017 11:26:57 -0400
changeset 569309 06411e9100ace74e3cacb520a65b2e8166ffe7c0
parent 569139 36a3a336b4455d70899eda5224f8c01eb5b985be
child 569310 0b8bf5cb743f4b6da71aa03b456aa551d6b96d4f
push id56143
push userbmo:jeremychen@mozilla.com
push dateThu, 27 Apr 2017 10:17:21 +0000
reviewersdao, mccr8
bugs1347413
milestone55.0a1
Bug 1347413 - Remove the unused browser-fullZoom:zoomReset and browser-fullZoom:zoomChange notifications. r=dao,mccr8 MozReview-Commit-ID: GeqfVngo9QT
browser/base/content/browser-fullZoom.js
browser/components/customizableui/test/browser_934951_zoom_in_toolbar.js
dom/events/test/window_wheel_default_action.html
testing/specialpowers/content/specialpowersAPI.js
--- a/browser/base/content/browser-fullZoom.js
+++ b/browser/base/content/browser-fullZoom.js
@@ -282,17 +282,16 @@ var FullZoom = {
    * @return A promise which resolves when the zoom reset has been applied.
    */
   reset: function FullZoom_reset(browser = gBrowser.selectedBrowser) {
     let token = this._getBrowserToken(browser);
     let result = this._getGlobalValue(browser).then(value => {
       if (token.isCurrent) {
         ZoomManager.setZoomForBrowser(browser, value === undefined ? 1 : value);
         this._ignorePendingZoomAccesses(browser);
-        Services.obs.notifyObservers(browser, "browser-fullZoom:zoomReset");
       }
     });
     this._removePref(browser);
     return result;
   },
 
   /**
    * Set the zoom level for a given browser.
@@ -350,17 +349,16 @@ var FullZoom = {
 
   /**
    * Saves the zoom level of the page in the given browser to the content
    * prefs store.
    *
    * @param browser  The zoom of this browser will be saved.  Required.
    */
   _applyZoomToPref: function FullZoom__applyZoomToPref(browser) {
-    Services.obs.notifyObservers(browser, "browser-fullZoom:zoomChange");
     if (!this.siteSpecific ||
         gInPrintPreviewMode ||
         browser.isSyntheticDocument)
       return;
 
     this._cps2.set(browser.currentURI.spec, this.name,
                    ZoomManager.getZoomForBrowser(browser),
                    this._loadContextFromBrowser(browser), {
@@ -371,17 +369,16 @@ var FullZoom = {
   },
 
   /**
    * Removes from the content prefs store the zoom level of the given browser.
    *
    * @param browser  The zoom of this browser will be removed.  Required.
    */
   _removePref: function FullZoom__removePref(browser) {
-    Services.obs.notifyObservers(browser, "browser-fullZoom:zoomReset");
     if (browser.isSyntheticDocument)
       return;
     let ctxt = this._loadContextFromBrowser(browser);
     this._cps2.removeByDomainAndName(browser.currentURI.spec, this.name, ctxt, {
       handleCompletion: function() {
         this._isNextContentPrefChangeInternal = true;
       }.bind(this),
     });
--- a/browser/components/customizableui/test/browser_934951_zoom_in_toolbar.js
+++ b/browser/components/customizableui/test/browser_934951_zoom_in_toolbar.js
@@ -19,29 +19,29 @@ add_task(function*() {
   registerCleanupFunction(() => {
     info("Cleaning up.");
     CustomizableUI.reset();
     gBrowser.removeTab(tab2);
     gBrowser.removeTab(tab1);
   });
 
   is(parseInt(zoomResetButton.label, 10), 100, "Default zoom is 100% for about:mozilla");
-  let zoomChangePromise = promiseObserverNotification("browser-fullZoom:zoomChange");
+  let zoomChangePromise = BrowserTestUtils.waitForEvent(window, "FullZoomChange");
   FullZoom.enlarge();
   yield zoomChangePromise;
   is(parseInt(zoomResetButton.label, 10), 110, "Zoom is changed to 110% for about:mozilla");
 
   let tabSelectPromise = promiseObserverNotification("browser-fullZoom:location-change");
   gBrowser.selectedTab = tab2;
   yield tabSelectPromise;
   yield new Promise(resolve => executeSoon(resolve));
   is(parseInt(zoomResetButton.label, 10), 100, "Default zoom is 100% for about:robots");
 
   gBrowser.selectedTab = tab1;
-  let zoomResetPromise = promiseObserverNotification("browser-fullZoom:zoomReset");
+  let zoomResetPromise = BrowserTestUtils.waitForEvent(window, "FullZoomChange");
   FullZoom.reset();
   yield zoomResetPromise;
   is(parseInt(zoomResetButton.label, 10), 100, "Default zoom is 100% for about:mozilla");
 
   // Test zoom label updates while navigating pages in the same tab.
   FullZoom.enlarge();
   yield zoomChangePromise;
   is(parseInt(zoomResetButton.label, 10), 110, "Zoom is changed to 110% for about:mozilla");
--- a/dom/events/test/window_wheel_default_action.html
+++ b/dom/events/test/window_wheel_default_action.html
@@ -80,25 +80,27 @@ function hitEventLoop(aFunc, aTimes)
 
   if (--aTimes) {
     setTimeout(hitEventLoop, 0, aFunc, aTimes);
   } else {
     setTimeout(aFunc, 20);
   }
 }
 
-const zoomResetTopic = "browser-fullZoom:zoomReset";
-SpecialPowers.registerObservers(zoomResetTopic);
-
 function onZoomReset(aCallback) {
-  var specialPowersTopic = "specialpowers-" + zoomResetTopic;
-  SpecialPowers.addObserver(function observe() {
-    SpecialPowers.removeObserver(observe, specialPowersTopic);
+  var fullZoom = SpecialPowers.getFullZoom(window);
+  if (fullZoom == 1) {
     SimpleTest.executeSoon(aCallback);
-  }, specialPowersTopic);
+    return;
+  }
+  SpecialPowers.addChromeEventListener("FullZoomChange", function onFullZoomChange(event) {
+    is(SpecialPowers.getFullZoom(window), 1, "Zoom should be reset to 1");
+    SpecialPowers.removeChromeEventListener("FullZoomChange", onFullZoomChange);
+    SimpleTest.executeSoon(aCallback);
+  });
 }
 
 function setDeltaMultiplierSettings(aSettings, aCallback)
 {
   SpecialPowers.pushPrefEnv({"set": [
     ["mousewheel.default.delta_multiplier_x", aSettings.deltaMultiplierX * 100],
     ["mousewheel.default.delta_multiplier_y", aSettings.deltaMultiplierY * 100],
     ["mousewheel.default.delta_multiplier_z", aSettings.deltaMultiplierZ * 100],
--- a/testing/specialpowers/content/specialpowersAPI.js
+++ b/testing/specialpowers/content/specialpowersAPI.js
@@ -1185,19 +1185,16 @@ SpecialPowersAPI.prototype = {
     }
   },
 
   _proxiedObservers: {
     "specialpowers-http-notify-request": function(aMessage) {
       let uri = aMessage.json.uri;
       Services.obs.notifyObservers(null, "specialpowers-http-notify-request", uri);
     },
-    "specialpowers-browser-fullZoom:zoomReset": function() {
-      Services.obs.notifyObservers(null, "specialpowers-browser-fullZoom:zoomReset");
-    },
   },
 
   _addObserverProxy: function(notification) {
     if (notification in this._proxiedObservers) {
       this._addMessageListener(notification, this._proxiedObservers[notification]);
     }
   },
   _removeObserverProxy: function(notification) {