Bug 555390 - Fix intermittent failure in browser_bug419612.js by waiting for location-change notification after tabs are removed. r=mak

This commit is contained in:
Drew Willcoxon 2013-10-07 21:59:22 -07:00
parent 423b43dc8b
commit a5d5f779e7
10 changed files with 55 additions and 42 deletions

View File

@ -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;

View File

@ -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));
}

View File

@ -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() {

View File

@ -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));
}

View File

@ -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;
});

View File

@ -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() {

View File

@ -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();
});
}

View File

@ -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));
}

View File

@ -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));
}

View File

@ -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();