Bug 1238310: Follow-up: Fix some timing issues in tests. r=bustage

MozReview-Commit-ID: BjKiNO1T5yN

--HG--
extra : amend_source : ae884bd9cd629853d6d2998ef4e460bc46f67107
This commit is contained in:
Kris Maglione 2016-04-23 23:56:28 -07:00
parent 24d6448f60
commit 13c6073298
9 changed files with 18 additions and 16 deletions

View File

@ -45,10 +45,10 @@ function zoomTab1() {
function finishTest() { function finishTest() {
Task.spawn(function () { Task.spawn(function () {
yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1);
FullZoom.reset(); yield FullZoom.reset();
yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab1); yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab1);
yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2); yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2);
FullZoom.reset(); yield FullZoom.reset();
yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab2); yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab2);
}).then(finish, FullZoomHelper.failAndContinue(finish)); }).then(finish, FullZoomHelper.failAndContinue(finish));
} }

View File

@ -79,11 +79,11 @@ function finishTest() {
ok(!finishTestStarted, "finishTest called more than once"); ok(!finishTestStarted, "finishTest called more than once");
finishTestStarted = true; finishTestStarted = true;
yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1);
FullZoom.reset(); yield FullZoom.reset();
yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab1); yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab1);
FullZoom.reset(); yield FullZoom.reset();
yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab2); yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab2);
FullZoom.reset(); yield FullZoom.reset();
yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab3); yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab3);
}).then(finish, FullZoomHelper.failAndContinue(finish)); }).then(finish, FullZoomHelper.failAndContinue(finish));
} }

View File

@ -15,7 +15,7 @@ function start_test_prefNotSet() {
function continue_test_prefNotSet () { function continue_test_prefNotSet () {
Task.spawn(function () { Task.spawn(function () {
is(ZoomManager.zoom, 1, "zoom level pref should not apply to an image"); is(ZoomManager.zoom, 1, "zoom level pref should not apply to an image");
FullZoom.reset(); yield FullZoom.reset();
yield FullZoomHelper.load(gBrowser.selectedTab, "http://mochi.test:8888/browser/browser/base/content/test/general/zoom_test.html"); yield FullZoomHelper.load(gBrowser.selectedTab, "http://mochi.test:8888/browser/browser/base/content/test/general/zoom_test.html");
}).then(end_test_prefNotSet, FullZoomHelper.failAndContinue(finish)); }).then(end_test_prefNotSet, FullZoomHelper.failAndContinue(finish));
@ -26,7 +26,7 @@ function end_test_prefNotSet() {
is(ZoomManager.zoom, zoomLevel, "the zoom level should have persisted"); is(ZoomManager.zoom, zoomLevel, "the zoom level should have persisted");
// Reset the zoom so that other tests have a fresh zoom level // Reset the zoom so that other tests have a fresh zoom level
FullZoom.reset(); yield FullZoom.reset();
yield FullZoomHelper.removeTabAndWaitForLocationChange(); yield FullZoomHelper.removeTabAndWaitForLocationChange();
finish(); finish();
}); });

View File

@ -18,7 +18,7 @@ function test() {
is(tab2Zoom, tab1Zoom, "Zoom should affect background tabs"); is(tab2Zoom, tab1Zoom, "Zoom should affect background tabs");
gPrefService.setBoolPref("browser.zoom.updateBackgroundTabs", false); gPrefService.setBoolPref("browser.zoom.updateBackgroundTabs", false);
FullZoom.reset(); yield FullZoom.reset();
gBrowser.selectedTab = tab1; gBrowser.selectedTab = tab1;
tab1Zoom = ZoomManager.getZoomForBrowser(tab1.linkedBrowser); tab1Zoom = ZoomManager.getZoomForBrowser(tab1.linkedBrowser);
tab2Zoom = ZoomManager.getZoomForBrowser(tab2.linkedBrowser); tab2Zoom = ZoomManager.getZoomForBrowser(tab2.linkedBrowser);

View File

@ -10,7 +10,7 @@ function testBackgroundLoad() {
yield FullZoomHelper.removeTabAndWaitForLocationChange(gBgTab); yield FullZoomHelper.removeTabAndWaitForLocationChange(gBgTab);
FullZoom.reset(); yield FullZoom.reset();
yield FullZoomHelper.removeTabAndWaitForLocationChange(gTestTab); yield FullZoomHelper.removeTabAndWaitForLocationChange(gTestTab);
finish(); finish();
}); });

View File

@ -80,10 +80,10 @@ function finishTest() {
finishTestStarted = true; finishTestStarted = true;
yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1);
FullZoom.reset(); yield FullZoom.reset();
yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab1); yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab1);
yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2); yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2);
FullZoom.reset(); yield FullZoom.reset();
yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab2); yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab2);
}).then(finish, FullZoomHelper.failAndContinue(finish)); }).then(finish, FullZoomHelper.failAndContinue(finish));
} }

View File

@ -556,7 +556,7 @@ var FullZoomHelper = {
}, },
reset: function reset() { reset: function reset() {
return new Promise(resolve => FullZoom.reset(resolve)); return FullZoom.reset();
}, },
BACK: 0, BACK: 0,

View File

@ -18,6 +18,8 @@ add_task(function*() {
ok(zoomResetButton, "Zoom reset button exists in Panel Menu"); ok(zoomResetButton, "Zoom reset button exists in Panel Menu");
zoomResetButton.click(); zoomResetButton.click();
yield new Promise(SimpleTest.executeSoon);
let pageZoomLevel = Math.floor(ZoomManager.zoom * 100); let pageZoomLevel = Math.floor(ZoomManager.zoom * 100);
let expectedZoomLevel = 100; let expectedZoomLevel = 100;
let buttonZoomLevel = parseInt(zoomResetButton.getAttribute("label"), 10); let buttonZoomLevel = parseInt(zoomResetButton.getAttribute("label"), 10);

View File

@ -25,7 +25,7 @@ add_task(function* () {
returnsLikeGetBoxQuadsInSimpleCase(doc); returnsLikeGetBoxQuadsInSimpleCase(doc);
takesIframesOffsetsIntoAccount(doc); takesIframesOffsetsIntoAccount(doc);
takesScrollingIntoAccount(doc); takesScrollingIntoAccount(doc);
takesZoomIntoAccount(doc); yield takesZoomIntoAccount(doc);
returnsMultipleItemsForWrappingInlineElements(doc); returnsMultipleItemsForWrappingInlineElements(doc);
gBrowser.removeCurrentTab(); gBrowser.removeCurrentTab();
@ -173,7 +173,7 @@ function takesScrollingIntoAccount(doc) {
is(quad.p1.y, 0, "p1.y of the scrolled node is correct after scrolling up"); is(quad.p1.y, 0, "p1.y of the scrolled node is correct after scrolling up");
} }
function takesZoomIntoAccount(doc) { function* takesZoomIntoAccount(doc) {
info("Checks that if the page is zoomed in/out, the quad returned is correct"); info("Checks that if the page is zoomed in/out, the quad returned is correct");
// Hard-coding coordinates in this zoom test is a bad idea as it can vary // Hard-coding coordinates in this zoom test is a bad idea as it can vary
@ -193,7 +193,7 @@ function takesZoomIntoAccount(doc) {
"The zoomed in quad is bigger than the default one"); "The zoomed in quad is bigger than the default one");
info("Zoom out"); info("Zoom out");
window.FullZoom.reset(); yield window.FullZoom.reset();
window.FullZoom.reduce(); window.FullZoom.reduce();
let [zoomedOutQuad] = getAdjustedQuads(doc.defaultView, node); let [zoomedOutQuad] = getAdjustedQuads(doc.defaultView, node);
@ -202,7 +202,7 @@ function takesZoomIntoAccount(doc) {
ok(zoomedOutQuad.bounds.height < defaultQuad.bounds.height, ok(zoomedOutQuad.bounds.height < defaultQuad.bounds.height,
"The zoomed out quad is smaller than the default one"); "The zoomed out quad is smaller than the default one");
window.FullZoom.reset(); yield window.FullZoom.reset();
} }
function returnsMultipleItemsForWrappingInlineElements(doc) { function returnsMultipleItemsForWrappingInlineElements(doc) {