From 13c60732986317ee5c907073b56366d9479ac866 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Sat, 23 Apr 2016 23:56:28 -0700 Subject: [PATCH] Bug 1238310: Follow-up: Fix some timing issues in tests. r=bustage MozReview-Commit-ID: BjKiNO1T5yN --HG-- extra : amend_source : ae884bd9cd629853d6d2998ef4e460bc46f67107 --- browser/base/content/test/general/browser_bug1015721.js | 4 ++-- browser/base/content/test/general/browser_bug386835.js | 6 +++--- browser/base/content/test/general/browser_bug416661.js | 4 ++-- browser/base/content/test/general/browser_bug419612.js | 2 +- browser/base/content/test/general/browser_bug555224.js | 2 +- browser/base/content/test/general/browser_bug719271.js | 4 ++-- browser/base/content/test/general/head.js | 2 +- .../test/browser_947914_button_zoomReset.js | 2 ++ .../shared/test/browser_layoutHelpers-getBoxQuads.js | 8 ++++---- 9 files changed, 18 insertions(+), 16 deletions(-) diff --git a/browser/base/content/test/general/browser_bug1015721.js b/browser/base/content/test/general/browser_bug1015721.js index 5aa2f28621a6..2915f82ff784 100644 --- a/browser/base/content/test/general/browser_bug1015721.js +++ b/browser/base/content/test/general/browser_bug1015721.js @@ -45,10 +45,10 @@ function zoomTab1() { function finishTest() { Task.spawn(function () { yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); - FullZoom.reset(); + yield FullZoom.reset(); yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab1); yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2); - FullZoom.reset(); + yield FullZoom.reset(); yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab2); }).then(finish, FullZoomHelper.failAndContinue(finish)); } diff --git a/browser/base/content/test/general/browser_bug386835.js b/browser/base/content/test/general/browser_bug386835.js index 98191698dff2..81c6b46243a5 100644 --- a/browser/base/content/test/general/browser_bug386835.js +++ b/browser/base/content/test/general/browser_bug386835.js @@ -79,11 +79,11 @@ function finishTest() { ok(!finishTestStarted, "finishTest called more than once"); finishTestStarted = true; yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); - FullZoom.reset(); + yield FullZoom.reset(); yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab1); - FullZoom.reset(); + yield FullZoom.reset(); yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab2); - FullZoom.reset(); + yield FullZoom.reset(); 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 776f6ad2eccf..aaddf6fe2de2 100644 --- a/browser/base/content/test/general/browser_bug416661.js +++ b/browser/base/content/test/general/browser_bug416661.js @@ -15,7 +15,7 @@ function start_test_prefNotSet() { function continue_test_prefNotSet () { Task.spawn(function () { 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"); }).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"); // Reset the zoom so that other tests have a fresh zoom level - FullZoom.reset(); + yield FullZoom.reset(); yield FullZoomHelper.removeTabAndWaitForLocationChange(); finish(); }); diff --git a/browser/base/content/test/general/browser_bug419612.js b/browser/base/content/test/general/browser_bug419612.js index 805280d27165..15b4d3be5532 100644 --- a/browser/base/content/test/general/browser_bug419612.js +++ b/browser/base/content/test/general/browser_bug419612.js @@ -18,7 +18,7 @@ function test() { is(tab2Zoom, tab1Zoom, "Zoom should affect background tabs"); gPrefService.setBoolPref("browser.zoom.updateBackgroundTabs", false); - FullZoom.reset(); + yield FullZoom.reset(); gBrowser.selectedTab = tab1; tab1Zoom = ZoomManager.getZoomForBrowser(tab1.linkedBrowser); tab2Zoom = ZoomManager.getZoomForBrowser(tab2.linkedBrowser); diff --git a/browser/base/content/test/general/browser_bug555224.js b/browser/base/content/test/general/browser_bug555224.js index cc32cee299eb..574d487d0d33 100644 --- a/browser/base/content/test/general/browser_bug555224.js +++ b/browser/base/content/test/general/browser_bug555224.js @@ -10,7 +10,7 @@ function testBackgroundLoad() { yield FullZoomHelper.removeTabAndWaitForLocationChange(gBgTab); - FullZoom.reset(); + yield FullZoom.reset(); yield FullZoomHelper.removeTabAndWaitForLocationChange(gTestTab); finish(); }); diff --git a/browser/base/content/test/general/browser_bug719271.js b/browser/base/content/test/general/browser_bug719271.js index 8c928c5ee79c..131afdd8f3a6 100644 --- a/browser/base/content/test/general/browser_bug719271.js +++ b/browser/base/content/test/general/browser_bug719271.js @@ -80,10 +80,10 @@ function finishTest() { finishTestStarted = true; yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); - FullZoom.reset(); + yield FullZoom.reset(); yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab1); yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2); - FullZoom.reset(); + yield FullZoom.reset(); 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 c11de28cc09c..30e8a5a80b7f 100644 --- a/browser/base/content/test/general/head.js +++ b/browser/base/content/test/general/head.js @@ -556,7 +556,7 @@ var FullZoomHelper = { }, reset: function reset() { - return new Promise(resolve => FullZoom.reset(resolve)); + return FullZoom.reset(); }, BACK: 0, diff --git a/browser/components/customizableui/test/browser_947914_button_zoomReset.js b/browser/components/customizableui/test/browser_947914_button_zoomReset.js index e35976df719c..372097665b6f 100644 --- a/browser/components/customizableui/test/browser_947914_button_zoomReset.js +++ b/browser/components/customizableui/test/browser_947914_button_zoomReset.js @@ -18,6 +18,8 @@ add_task(function*() { ok(zoomResetButton, "Zoom reset button exists in Panel Menu"); zoomResetButton.click(); + yield new Promise(SimpleTest.executeSoon); + let pageZoomLevel = Math.floor(ZoomManager.zoom * 100); let expectedZoomLevel = 100; let buttonZoomLevel = parseInt(zoomResetButton.getAttribute("label"), 10); diff --git a/devtools/client/shared/test/browser_layoutHelpers-getBoxQuads.js b/devtools/client/shared/test/browser_layoutHelpers-getBoxQuads.js index 1b56b5371c53..f6ba85b39881 100644 --- a/devtools/client/shared/test/browser_layoutHelpers-getBoxQuads.js +++ b/devtools/client/shared/test/browser_layoutHelpers-getBoxQuads.js @@ -25,7 +25,7 @@ add_task(function* () { returnsLikeGetBoxQuadsInSimpleCase(doc); takesIframesOffsetsIntoAccount(doc); takesScrollingIntoAccount(doc); - takesZoomIntoAccount(doc); + yield takesZoomIntoAccount(doc); returnsMultipleItemsForWrappingInlineElements(doc); 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"); } -function takesZoomIntoAccount(doc) { +function* takesZoomIntoAccount(doc) { 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 @@ -193,7 +193,7 @@ function takesZoomIntoAccount(doc) { "The zoomed in quad is bigger than the default one"); info("Zoom out"); - window.FullZoom.reset(); + yield window.FullZoom.reset(); window.FullZoom.reduce(); let [zoomedOutQuad] = getAdjustedQuads(doc.defaultView, node); @@ -202,7 +202,7 @@ function takesZoomIntoAccount(doc) { ok(zoomedOutQuad.bounds.height < defaultQuad.bounds.height, "The zoomed out quad is smaller than the default one"); - window.FullZoom.reset(); + yield window.FullZoom.reset(); } function returnsMultipleItemsForWrappingInlineElements(doc) {