From 02b64ef2951d36a683110e34f129a675b0096975 Mon Sep 17 00:00:00 2001 From: Drew Willcoxon Date: Mon, 7 Oct 2013 21:59:22 -0700 Subject: [PATCH] Bug 555390 - Fix intermittent failure in browser_bug419612.js by waiting for location-change notification after tabs are removed. r=mak --- browser/base/content/browser-fullZoom.js | 4 --- .../content/test/general/browser_bug386835.js | 6 ++-- .../content/test/general/browser_bug416661.js | 12 ++++---- .../content/test/general/browser_bug419612.js | 4 +-- .../content/test/general/browser_bug441778.js | 4 +-- .../content/test/general/browser_bug555224.js | 12 ++++---- .../content/test/general/browser_bug559991.js | 16 ++++++----- .../content/test/general/browser_bug575830.js | 7 ++--- .../content/test/general/browser_bug719271.js | 4 +-- browser/base/content/test/general/head.js | 28 +++++++++++++------ 10 files changed, 55 insertions(+), 42 deletions(-) diff --git a/browser/base/content/browser-fullZoom.js b/browser/base/content/browser-fullZoom.js index 9c503b72821..d92dfcc625e 100644 --- a/browser/base/content/browser-fullZoom.js +++ b/browser/base/content/browser-fullZoom.js @@ -243,10 +243,6 @@ var FullZoom = { let browser = aBrowser || gBrowser.selectedBrowser; this._ignorePendingZoomAccesses(browser); - // Bug 691614 - zooming support for electrolysis - if (gMultiProcessBrowser) - return; - if (!aURI || (aIsTabSwitch && !this.siteSpecific)) { this._notifyOnLocationChange(); return; diff --git a/browser/base/content/test/general/browser_bug386835.js b/browser/base/content/test/general/browser_bug386835.js index 023cf7b4636..98191698dff 100644 --- a/browser/base/content/test/general/browser_bug386835.js +++ b/browser/base/content/test/general/browser_bug386835.js @@ -80,10 +80,10 @@ function finishTest() { finishTestStarted = true; yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); FullZoom.reset(); - gBrowser.removeTab(gTab1); + yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab1); FullZoom.reset(); - gBrowser.removeTab(gTab2); + yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab2); FullZoom.reset(); - gBrowser.removeTab(gTab3); + yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab3); }).then(finish, FullZoomHelper.failAndContinue(finish)); } diff --git a/browser/base/content/test/general/browser_bug416661.js b/browser/base/content/test/general/browser_bug416661.js index 3a13082e7a9..776f6ad2ecc 100644 --- a/browser/base/content/test/general/browser_bug416661.js +++ b/browser/base/content/test/general/browser_bug416661.js @@ -22,12 +22,14 @@ function continue_test_prefNotSet () { } function end_test_prefNotSet() { - is(ZoomManager.zoom, zoomLevel, "the zoom level should have persisted"); + Task.spawn(function () { + is(ZoomManager.zoom, zoomLevel, "the zoom level should have persisted"); - // Reset the zoom so that other tests have a fresh zoom level - FullZoom.reset(); - gBrowser.removeCurrentTab(); - finish(); + // Reset the zoom so that other tests have a fresh zoom level + FullZoom.reset(); + yield FullZoomHelper.removeTabAndWaitForLocationChange(); + finish(); + }); } function test() { diff --git a/browser/base/content/test/general/browser_bug419612.js b/browser/base/content/test/general/browser_bug419612.js index 38e1e102112..805280d2716 100644 --- a/browser/base/content/test/general/browser_bug419612.js +++ b/browser/base/content/test/general/browser_bug419612.js @@ -26,7 +26,7 @@ function test() { if (gPrefService.prefHasUserValue("browser.zoom.updateBackgroundTabs")) gPrefService.clearUserPref("browser.zoom.updateBackgroundTabs"); - gBrowser.removeTab(tab1); - gBrowser.removeTab(tab2); + yield FullZoomHelper.removeTabAndWaitForLocationChange(tab1); + yield FullZoomHelper.removeTabAndWaitForLocationChange(tab2); }).then(finish, FullZoomHelper.failAndContinue(finish)); } diff --git a/browser/base/content/test/general/browser_bug441778.js b/browser/base/content/test/general/browser_bug441778.js index f2ea19cf20c..ef68018a0d1 100644 --- a/browser/base/content/test/general/browser_bug441778.js +++ b/browser/base/content/test/general/browser_bug441778.js @@ -36,8 +36,8 @@ function test() { is(e.target.defaultView.location, TEST_IFRAME_URL, "got the load event for the iframe"); is(ZoomManager.zoom, zoomLevel, "zoom is retained after sub-document load"); - gBrowser.removeCurrentTab(); - deferred.resolve(); + FullZoomHelper.removeTabAndWaitForLocationChange(). + then(() => deferred.resolve()); }, true); content.document.querySelector("iframe").src = TEST_IFRAME_URL; }); diff --git a/browser/base/content/test/general/browser_bug555224.js b/browser/base/content/test/general/browser_bug555224.js index b337a979e8d..cc32cee299e 100644 --- a/browser/base/content/test/general/browser_bug555224.js +++ b/browser/base/content/test/general/browser_bug555224.js @@ -5,13 +5,15 @@ const TEST_PAGE = "/browser/browser/base/content/test/general/dummy_page.html"; var gTestTab, gBgTab, gTestZoom; function testBackgroundLoad() { - is(ZoomManager.zoom, gTestZoom, "opening a background tab should not change foreground zoom"); + Task.spawn(function () { + is(ZoomManager.zoom, gTestZoom, "opening a background tab should not change foreground zoom"); - gBrowser.removeTab(gBgTab); + yield FullZoomHelper.removeTabAndWaitForLocationChange(gBgTab); - FullZoom.reset(); - gBrowser.removeTab(gTestTab); - finish(); + FullZoom.reset(); + yield FullZoomHelper.removeTabAndWaitForLocationChange(gTestTab); + finish(); + }); } function testInitialZoom() { diff --git a/browser/base/content/test/general/browser_bug559991.js b/browser/base/content/test/general/browser_bug559991.js index ff18f652f46..500bca3c59f 100644 --- a/browser/base/content/test/general/browser_bug559991.js +++ b/browser/base/content/test/general/browser_bug559991.js @@ -26,15 +26,17 @@ function test() { // ------------- // Test clean-up function endTest() { - gBrowser.removeTab(tab); + Task.spawn(function () { + yield FullZoomHelper.removeTabAndWaitForLocationChange(tab); - tab = null; + tab = null; - if (gPrefService.prefHasUserValue("browser.zoom.updateBackgroundTabs")) - gPrefService.clearUserPref("browser.zoom.updateBackgroundTabs"); + if (gPrefService.prefHasUserValue("browser.zoom.updateBackgroundTabs")) + gPrefService.clearUserPref("browser.zoom.updateBackgroundTabs"); - if (gPrefService.prefHasUserValue("browser.zoom.siteSpecific")) - gPrefService.clearUserPref("browser.zoom.siteSpecific"); + if (gPrefService.prefHasUserValue("browser.zoom.siteSpecific")) + gPrefService.clearUserPref("browser.zoom.siteSpecific"); - finish(); + finish(); + }); } diff --git a/browser/base/content/test/general/browser_bug575830.js b/browser/base/content/test/general/browser_bug575830.js index 8987ba7e22c..76935d05d4a 100644 --- a/browser/base/content/test/general/browser_bug575830.js +++ b/browser/base/content/test/general/browser_bug575830.js @@ -8,10 +8,6 @@ function test() { const TEST_IMAGE = "http://example.org/browser/browser/base/content/test/general/moz.png"; waitForExplicitFinish(); - registerCleanupFunction(function cleanup() { - gBrowser.removeTab(tab1); - gBrowser.removeTab(tab2); - }); Task.spawn(function () { tab1 = gBrowser.addTab(); @@ -30,5 +26,8 @@ function test() { yield FullZoomHelper.selectTabAndWaitForLocationChange(tab1); is(ZoomManager.zoom, zoom, "zoom level for first tab should not have changed"); + + yield FullZoomHelper.removeTabAndWaitForLocationChange(tab1); + yield FullZoomHelper.removeTabAndWaitForLocationChange(tab2); }).then(finish, FullZoomHelper.failAndContinue(finish)); } diff --git a/browser/base/content/test/general/browser_bug719271.js b/browser/base/content/test/general/browser_bug719271.js index b1a4dce039e..98dec50358c 100644 --- a/browser/base/content/test/general/browser_bug719271.js +++ b/browser/base/content/test/general/browser_bug719271.js @@ -81,9 +81,9 @@ function finishTest() { yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); FullZoom.reset(); - gBrowser.removeTab(gTab1); + yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab1); yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2); FullZoom.reset(); - gBrowser.removeTab(gTab2); + yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab2); }).then(finish, FullZoomHelper.failAndContinue(finish)); } diff --git a/browser/base/content/test/general/head.js b/browser/base/content/test/general/head.js index b6b51ba7b66..4cdd459e409 100644 --- a/browser/base/content/test/general/head.js +++ b/browser/base/content/test/general/head.js @@ -305,13 +305,25 @@ function promiseHistoryClearedState(aURIs, aShouldBeCleared) { let FullZoomHelper = { selectTabAndWaitForLocationChange: function selectTabAndWaitForLocationChange(tab) { + if (!tab) + throw new Error("tab must be given."); + if (gBrowser.selectedTab == tab) + return Promise.resolve(); + gBrowser.selectedTab = tab; + return this.waitForLocationChange(); + }, + + removeTabAndWaitForLocationChange: function removeTabAndWaitForLocationChange(tab) { + tab = tab || gBrowser.selectedTab; + let selected = gBrowser.selectedTab == tab; + gBrowser.removeTab(tab); + if (selected) + return this.waitForLocationChange(); + return Promise.resolve(); + }, + + waitForLocationChange: function waitForLocationChange() { let deferred = Promise.defer(); - if (tab && gBrowser.selectedTab == tab) { - deferred.resolve(); - return deferred.promise; - } - if (tab) - gBrowser.selectedTab = tab; Services.obs.addObserver(function obs(subj, topic, data) { Services.obs.removeObserver(obs, topic); deferred.resolve(); @@ -331,7 +343,7 @@ let FullZoomHelper = { deferred.resolve(); }, true); - this.selectTabAndWaitForLocationChange(null).then(function () { + this.waitForLocationChange().then(function () { didZoom = true; if (didLoad) deferred.resolve(); @@ -383,7 +395,7 @@ let FullZoomHelper = { else if (direction == this.FORWARD) gBrowser.goForward(); - this.selectTabAndWaitForLocationChange(null).then(function () { + this.waitForLocationChange().then(function () { didZoom = true; if (didPs) deferred.resolve();