Bug 1238310: Follow-up: Fix some timing issues in tests. r=bustage
authorKris Maglione <maglione.k@gmail.com>
Sat, 23 Apr 2016 23:56:28 -0700
changeset 332384 67e03d012ea92d93c128bd8b20bbea7fd6f048a2
parent 332383 8afadb96e97704a98492c2286fb92479deb3365f
child 332385 6f5e1ec74f4908a610bbe0274e03ff31abc3bd3c
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbustage
bugs1238310
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1238310: Follow-up: Fix some timing issues in tests. r=bustage MozReview-Commit-ID: BjKiNO1T5yN
browser/base/content/test/general/browser_bug1015721.js
browser/base/content/test/general/browser_bug386835.js
browser/base/content/test/general/browser_bug416661.js
browser/base/content/test/general/browser_bug419612.js
browser/base/content/test/general/browser_bug555224.js
browser/base/content/test/general/browser_bug719271.js
browser/base/content/test/general/head.js
browser/components/customizableui/test/browser_947914_button_zoomReset.js
devtools/client/shared/test/browser_layoutHelpers-getBoxQuads.js
--- a/browser/base/content/test/general/browser_bug1015721.js
+++ b/browser/base/content/test/general/browser_bug1015721.js
@@ -40,15 +40,15 @@ function zoomTab1() {
     yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2);
     FullZoomHelper.zoomTest(gTab2, gLevel1, "Tab 2 should have zoomed along with tab 1");
   }).then(finishTest, FullZoomHelper.failAndContinue(finish));
 }
 
 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));
 }
--- a/browser/base/content/test/general/browser_bug386835.js
+++ b/browser/base/content/test/general/browser_bug386835.js
@@ -74,16 +74,16 @@ function imageZoomSwitch() {
 }
 
 var finishTestStarted  = false;
 function finishTest() {
   Task.spawn(function () {
     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));
 }
--- a/browser/base/content/test/general/browser_bug416661.js
+++ b/browser/base/content/test/general/browser_bug416661.js
@@ -10,28 +10,28 @@ function start_test_prefNotSet() {
 
     yield FullZoomHelper.load(gBrowser.selectedTab, "http://mochi.test:8888/browser/browser/base/content/test/general/moz.png");
   }).then(continue_test_prefNotSet, FullZoomHelper.failAndContinue(finish));
 }
 
 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));
 }
 
 function end_test_prefNotSet() {
   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();
+    yield FullZoom.reset();
     yield FullZoomHelper.removeTabAndWaitForLocationChange();
     finish();
   });
 }
 
 function test() {
   waitForExplicitFinish();
 
--- a/browser/base/content/test/general/browser_bug419612.js
+++ b/browser/base/content/test/general/browser_bug419612.js
@@ -13,17 +13,17 @@ function test() {
     FullZoom.enlarge();
     let tab1Zoom = ZoomManager.getZoomForBrowser(tab1.linkedBrowser);
 
     yield FullZoomHelper.selectTabAndWaitForLocationChange(tab2);
     let tab2Zoom = ZoomManager.getZoomForBrowser(tab2.linkedBrowser);
     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);
     isnot(tab1Zoom, tab2Zoom, "Zoom should not affect background tabs");
 
     if (gPrefService.prefHasUserValue("browser.zoom.updateBackgroundTabs"))
       gPrefService.clearUserPref("browser.zoom.updateBackgroundTabs");
     yield FullZoomHelper.removeTabAndWaitForLocationChange(tab1);
--- a/browser/base/content/test/general/browser_bug555224.js
+++ b/browser/base/content/test/general/browser_bug555224.js
@@ -5,17 +5,17 @@ const TEST_PAGE = "/browser/browser/base
 var gTestTab, gBgTab, gTestZoom;
 
 function testBackgroundLoad() {
   Task.spawn(function () {
     is(ZoomManager.zoom, gTestZoom, "opening a background tab should not change foreground zoom");
 
     yield FullZoomHelper.removeTabAndWaitForLocationChange(gBgTab);
 
-    FullZoom.reset();
+    yield FullZoom.reset();
     yield FullZoomHelper.removeTabAndWaitForLocationChange(gTestTab);
     finish();
   });
 }
 
 function testInitialZoom() {
   Task.spawn(function () {
     is(ZoomManager.zoom, 1, "initial zoom level should be 1");
--- a/browser/base/content/test/general/browser_bug719271.js
+++ b/browser/base/content/test/general/browser_bug719271.js
@@ -75,15 +75,15 @@ function waitForNextTurn() {
 
 var finishTestStarted  = false;
 function finishTest() {
   Task.spawn(function () {
     ok(!finishTestStarted, "finishTest called more than once");
     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));
 }
--- a/browser/base/content/test/general/head.js
+++ b/browser/base/content/test/general/head.js
@@ -551,17 +551,17 @@ var FullZoomHelper = {
     return new Promise(resolve => FullZoom.enlarge(resolve));
   },
 
   reduce: function reduce() {
     return new Promise(resolve => FullZoom.reduce(resolve));
   },
 
   reset: function reset() {
-    return new Promise(resolve => FullZoom.reset(resolve));
+    return FullZoom.reset();
   },
 
   BACK: 0,
   FORWARD: 1,
   navigate: function navigate(direction) {
     return new Promise(resolve => {
       let didPs = false;
       let didZoom = false;
--- a/browser/components/customizableui/test/browser_947914_button_zoomReset.js
+++ b/browser/components/customizableui/test/browser_947914_button_zoomReset.js
@@ -13,16 +13,18 @@ add_task(function*() {
   ZoomManager.zoom = 0.5;
   yield PanelUI.show();
   info("Menu panel was opened");
 
   let zoomResetButton = document.getElementById("zoom-reset-button");
   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);
   is(pageZoomLevel, expectedZoomLevel, "Page zoom reset correctly");
   is(pageZoomLevel, buttonZoomLevel, "Button displays the correct zoom level");
 
   // close the panel
   let panelHiddenPromise = promisePanelHidden(window);
--- a/devtools/client/shared/test/browser_layoutHelpers-getBoxQuads.js
+++ b/devtools/client/shared/test/browser_layoutHelpers-getBoxQuads.js
@@ -20,17 +20,17 @@ add_task(function* () {
 
   returnsTheRightDataStructure(doc);
   isEmptyForMissingNode(doc);
   isEmptyForHiddenNodes(doc);
   defaultsToBorderBoxIfNoneProvided(doc);
   returnsLikeGetBoxQuadsInSimpleCase(doc);
   takesIframesOffsetsIntoAccount(doc);
   takesScrollingIntoAccount(doc);
-  takesZoomIntoAccount(doc);
+  yield takesZoomIntoAccount(doc);
   returnsMultipleItemsForWrappingInlineElements(doc);
 
   gBrowser.removeCurrentTab();
 });
 
 function returnsTheRightDataStructure(doc) {
   info("Checks that the returned data contains bounds and 4 points");
 
@@ -168,17 +168,17 @@ function takesScrollingIntoAccount(doc) 
   scrolledNode.scrollTop = 0;
   subScrolledNode.scrollTop = 0;
 
   [quad] = getAdjustedQuads(doc.defaultView, innerNode, "content");
   is(quad.p1.x, 0, "p1.x 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");
 
   // Hard-coding coordinates in this zoom test is a bad idea as it can vary
   // depending on the platform, so we simply test that zooming in produces a
   // bigger quad and zooming out produces a smaller quad
 
   let node = doc.querySelector("#simple-node-with-margin-padding-border");
   let [defaultQuad] = getAdjustedQuads(doc.defaultView, node);
@@ -188,26 +188,26 @@ function takesZoomIntoAccount(doc) {
   let [zoomedInQuad] = getAdjustedQuads(doc.defaultView, node);
 
   ok(zoomedInQuad.bounds.width > defaultQuad.bounds.width,
     "The zoomed in quad is bigger than the default one");
   ok(zoomedInQuad.bounds.height > defaultQuad.bounds.height,
     "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);
 
   ok(zoomedOutQuad.bounds.width < defaultQuad.bounds.width,
     "The zoomed out quad is smaller than the default one");
   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) {
   info("Checks that several quads are returned for inline elements that span line-breaks");
 
   let node = doc.querySelector("#inline");
   let quads = getAdjustedQuads(doc.defaultView, node, "content");
   // At least 3 because of the 2 <br />, maybe more depending on the window size.