Bug 887889 - Fix intermittent failure in browser_bug419612.js r=mak
authorDoug Thayer <dothayer@mozilla.com>
Fri, 20 Apr 2018 09:35:40 -0700
changeset 472029 20e6e6da280d51500e980084e17b83e768268b4c
parent 472028 fad1b59c9f557e5d6f09c51b578c2ee9762d26c1
child 472030 d52b265b6b52a817374add2c4e927530dab571a6
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs887889, 419612
milestone61.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 887889 - Fix intermittent failure in browser_bug419612.js r=mak MozReview-Commit-ID: 8gp5hdbnzaC
browser/base/content/browser-fullZoom.js
browser/base/content/test/general/browser_bug419612.js
--- a/browser/base/content/browser-fullZoom.js
+++ b/browser/base/content/browser-fullZoom.js
@@ -256,31 +256,31 @@ var FullZoom = {
     menuItem.setAttribute("checked", !ZoomManager.useFullZoom);
   },
 
   // Setting & Pref Manipulation
 
   /**
    * Reduces the zoom level of the page in the current browser.
    */
-  reduce: function FullZoom_reduce() {
+  async reduce() {
     ZoomManager.reduce();
     let browser = gBrowser.selectedBrowser;
     this._ignorePendingZoomAccesses(browser);
-    this._applyZoomToPref(browser);
+    await this._applyZoomToPref(browser);
   },
 
   /**
    * Enlarges the zoom level of the page in the current browser.
    */
-  enlarge: function FullZoom_enlarge() {
+  async enlarge() {
     ZoomManager.enlarge();
     let browser = gBrowser.selectedBrowser;
     this._ignorePendingZoomAccesses(browser);
-    this._applyZoomToPref(browser);
+    await this._applyZoomToPref(browser);
   },
 
   /**
    * Sets the zoom level for the given browser to the given floating
    * point value, where 1 is the default zoom level.
    */
   setZoom(value, browser = gBrowser.selectedBrowser) {
     ZoomManager.setZoomForBrowser(browser, value);
@@ -365,24 +365,27 @@ var FullZoom = {
    * prefs store.
    *
    * @param browser  The zoom of this browser will be saved.  Required.
    */
   _applyZoomToPref: function FullZoom__applyZoomToPref(browser) {
     if (!this.siteSpecific ||
         gInPrintPreviewMode ||
         browser.isSyntheticDocument)
-      return;
+      return null;
 
-    this._cps2.set(browser.currentURI.spec, this.name,
-                   ZoomManager.getZoomForBrowser(browser),
-                   this._loadContextFromBrowser(browser), {
-      handleCompletion: () => {
-        this._isNextContentPrefChangeInternal = true;
-      },
+    return new Promise(resolve => {
+      this._cps2.set(browser.currentURI.spec, this.name,
+                     ZoomManager.getZoomForBrowser(browser),
+                     this._loadContextFromBrowser(browser), {
+        handleCompletion: () => {
+          this._isNextContentPrefChangeInternal = true;
+          resolve();
+        },
+      });
     });
   },
 
   /**
    * Removes from the content prefs store the zoom level of the given browser.
    *
    * @param browser  The zoom of this browser will be removed.  Required.
    */
--- a/browser/base/content/test/general/browser_bug419612.js
+++ b/browser/base/content/test/general/browser_bug419612.js
@@ -5,17 +5,17 @@ function test() {
     let testPage = "http://example.org/browser/browser/base/content/test/general/dummy_page.html";
     let tab1 = BrowserTestUtils.addTab(gBrowser);
     await FullZoomHelper.selectTabAndWaitForLocationChange(tab1);
     await FullZoomHelper.load(tab1, testPage);
 
     let tab2 = BrowserTestUtils.addTab(gBrowser);
     await FullZoomHelper.load(tab2, testPage);
 
-    FullZoom.enlarge();
+    await FullZoom.enlarge();
     let tab1Zoom = ZoomManager.getZoomForBrowser(tab1.linkedBrowser);
 
     await FullZoomHelper.selectTabAndWaitForLocationChange(tab2);
     let tab2Zoom = ZoomManager.getZoomForBrowser(tab2.linkedBrowser);
     is(tab2Zoom, tab1Zoom, "Zoom should affect background tabs");
 
     Services.prefs.setBoolPref("browser.zoom.updateBackgroundTabs", false);
     await FullZoom.reset();