Bug 887889 - Fix intermittent failure in browser_bug419612.js r?mak
MozReview-Commit-ID: 8gp5hdbnzaC
--- 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();