Bug 1547440 - cleanup waitForCondition calls in app update browser chrome tests. r=bytesized
authorRobert Strong <robert.bugzilla@gmail.com>
Mon, 29 Apr 2019 16:35:56 +0000
changeset 530620 315a91d0266efa186d7a6ba9ce5da9a82f47d096
parent 530619 a03cccee49fa6223711a1459636094949ce391e8
child 530621 f27bd6eac64adf18990f35e5be504bc1c827a8c0
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbytesized
bugs1547440
milestone68.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 1547440 - cleanup waitForCondition calls in app update browser chrome tests. r=bytesized Change BrowserTestUtils.waitForCondition to TestUtils.waitForCondition per waitForCondition comment in BrowserTestUtils. Catch waitForCondition exceptions and let checks in the tests catch the failure when dynamic information is helpful for debugging. Differential Revision: https://phabricator.services.mozilla.com/D29097
toolkit/mozapps/update/tests/browser/browser_doorhanger_bc_downloadAutoFailures_bgWin.js
toolkit/mozapps/update/tests/browser/browser_doorhanger_bc_downloadOptIn_bgWin.js
toolkit/mozapps/update/tests/browser/head.js
--- a/toolkit/mozapps/update/tests/browser/browser_doorhanger_bc_downloadAutoFailures_bgWin.js
+++ b/toolkit/mozapps/update/tests/browser/browser_doorhanger_bc_downloadAutoFailures_bgWin.js
@@ -5,19 +5,19 @@ add_task(async function testBackgroundWi
   ]});
 
   let updateParams = "badURL=1";
   let extraWindow = await BrowserTestUtils.openNewBrowserWindow();
   await SimpleTest.promiseFocus(extraWindow);
 
   function getBackgroundWindowHandler(destroyWindow) {
     return async function() {
-      await BrowserTestUtils.waitForCondition(() => PanelUI.menuButton.hasAttribute("badge-status"),
-                                              "Background window has a badge.");
-
+      await TestUtils.waitForCondition(() =>
+        PanelUI.menuButton.hasAttribute("badge-status"),
+        "Background window has a badge.");
       is(PanelUI.notificationPanel.state, "closed",
          "The doorhanger is not showing for the background window");
       is(PanelUI.menuButton.getAttribute("badge-status"), "update-available",
          "The badge is showing for the background window");
 
       checkWhatsNewLink(extraWindow, "update-available-whats-new");
       let buttonEl = getNotificationButton(extraWindow, "update-available", "button");
       buttonEl.click();
--- a/toolkit/mozapps/update/tests/browser/browser_doorhanger_bc_downloadOptIn_bgWin.js
+++ b/toolkit/mozapps/update/tests/browser/browser_doorhanger_bc_downloadOptIn_bgWin.js
@@ -5,18 +5,19 @@ add_task(async function testUpdatesBackg
   await UpdateUtils.setAppUpdateAutoEnabled(false);
 
   let updateParams = "promptWaitTime=0";
   let extraWindow = await BrowserTestUtils.openNewBrowserWindow();
   await SimpleTest.promiseFocus(extraWindow);
 
   await runUpdateTest(updateParams, 1, [
     async function() {
-      await BrowserTestUtils.waitForCondition(() => PanelUI.menuButton.hasAttribute("badge-status"),
-                                              "Background window has a badge.");
+      await TestUtils.waitForCondition(() =>
+        PanelUI.menuButton.hasAttribute("badge-status"),
+        "Background window has a badge.");
       is(PanelUI.notificationPanel.state, "closed",
          "The doorhanger is not showing for the background window");
       is(PanelUI.menuButton.getAttribute("badge-status"), "update-available",
          "The badge is showing for the background window");
       let popupShownPromise = BrowserTestUtils.waitForEvent(PanelUI.notificationPanel, "popupshown");
       await BrowserTestUtils.closeWindow(extraWindow);
       await SimpleTest.promiseFocus(window);
       await popupShownPromise;
--- a/toolkit/mozapps/update/tests/browser/head.js
+++ b/toolkit/mozapps/update/tests/browser/head.js
@@ -138,18 +138,18 @@ async function continueFileHandler(leafN
   // after the test that created it.
   registerCleanupFunction(() => {
     if (continueFile.exists()) {
       logTestInfo("Removing continue file during test cleanup, path: " +
                   continueFile.path);
       continueFile.remove(false);
     }
   });
-  return BrowserTestUtils.waitForCondition(() => (
-    !continueFile.exists()),
+  return TestUtils.waitForCondition(() =>
+    (!continueFile.exists()),
     "Waiting for file to be deleted, path: " + continueFile.path,
     interval, retries
   ).catch(e => {
     logTestInfo("Continue file was not removed after checking " +
                 retries + " times, path: " + continueFile.path);
   });
 }
 
@@ -646,21 +646,24 @@ function runAboutDialogUpdateTest(update
   function processAboutDialogStep(step) {
     if (typeof(step) == "function") {
       return step();
     }
 
     const {panelId, checkActiveUpdate, continueFile, downloadInfo} = step;
     return (async function() {
       let updateDeck = aboutDialog.document.getElementById("updateDeck");
-      await BrowserTestUtils.waitForCondition(() =>
+      await TestUtils.waitForCondition(() =>
         (updateDeck.selectedPanel && updateDeck.selectedPanel.id == panelId),
-        "Waiting for expected panel ID - got: \"" +
-        updateDeck.selectedPanel.id + "\", expected: \"" + panelId + "\"",
-        undefined, 200);
+        "Waiting for the expected panel ID: " + panelId, undefined, 200
+      ).catch(e => {
+        // Instead of throwing let the check below fail the test so the panel
+        // ID and the expected panel ID is printed in the log.
+        logTestInfo(e);
+      });
       let selectedPanel = updateDeck.selectedPanel;
       is(selectedPanel.id, panelId, "The panel ID should equal " + panelId);
 
       if (checkActiveUpdate) {
         ok(!!gUpdateManager.activeUpdate, "There should be an active update");
         is(gUpdateManager.activeUpdate.state, checkActiveUpdate.state,
            "The active update state should equal " + checkActiveUpdate.state);
       } else {
@@ -675,21 +678,26 @@ function runAboutDialogUpdateTest(update
           await continueFileHandler(continueFile);
           let patch = getPatchOfType(info.patchType);
           // The update is removed early when the last download fails so check
           // that there is a patch before proceeding.
           let isLastPatch = (i == downloadInfo.length - 1);
           if (!isLastPatch || patch) {
             let resultName = info.bitsResult ? "bitsResult" : "internalResult";
             patch.QueryInterface(Ci.nsIWritablePropertyBag);
-            await BrowserTestUtils.waitForCondition(() =>
+            await TestUtils.waitForCondition(() =>
               (patch.getProperty(resultName) == info[resultName]),
-              "Waiting for expected patch property " + resultName + " value " +
-              "- got: \"" + patch.getProperty(resultName) + "\", expected: \"" +
-              info[resultName] + "\"", undefined, 200);
+              "Waiting for expected patch property " + resultName + " value: " +
+              info[resultName], undefined, 200
+            ).catch(e => {
+              // Instead of throwing let the check below fail the test so the
+              // property value and the expected property value is printed in
+              // the log.
+              logTestInfo(e);
+            });
             is(patch.getProperty(resultName), info[resultName],
                "The patch property " + resultName + " value should equal " +
                info[resultName]);
           }
         }
       } else if (continueFile) {
         await continueFileHandler(continueFile);
       }
@@ -702,17 +710,17 @@ function runAboutDialogUpdateTest(update
         let link = selectedPanel.querySelector("label.text-link");
         is(link.href, detailsURL,
            "The panel's link href should equal the expected value");
       }
 
       let buttonPanels = ["downloadAndInstall", "apply"];
       if (buttonPanels.includes(panelId)) {
         let buttonEl = selectedPanel.querySelector("button");
-        await BrowserTestUtils.waitForCondition(() =>
+        await TestUtils.waitForCondition(() =>
           (aboutDialog.document.activeElement == buttonEl),
           "The button should receive focus");
         ok(!buttonEl.disabled, "The button should be enabled");
         // Don't click the button on the apply panel since this will restart the
         // application.
         if (panelId != "apply") {
           buttonEl.click();
         }
@@ -785,19 +793,22 @@ function runAboutPrefsUpdateTest(updateP
 
     const {panelId, checkActiveUpdate, continueFile, downloadInfo} = step;
     return (async function() {
       await ContentTask.spawn(tab.linkedBrowser, {panelId},
                               async ({panelId}) => {
         let updateDeck = content.document.getElementById("updateDeck");
         await ContentTaskUtils.waitForCondition(() =>
           (updateDeck.selectedPanel && updateDeck.selectedPanel.id == panelId),
-          "Waiting for expected panel ID - got: \"" +
-          updateDeck.selectedPanel.id + "\", expected: \"" + panelId + "\"",
-          undefined, 200);
+          "Waiting for the expected panel ID: " + panelId, undefined, 200
+        ).catch(e => {
+          // Instead of throwing let the check below fail the test so the panel
+          // ID and the expected panel ID is printed in the log.
+          logTestInfo(e);
+        });
         is(updateDeck.selectedPanel.id, panelId,
            "The panel ID should equal " + panelId);
       });
 
       if (checkActiveUpdate) {
         ok(!!gUpdateManager.activeUpdate, "There should be an active update");
         is(gUpdateManager.activeUpdate.state, checkActiveUpdate.state,
            "The active update state should equal " + checkActiveUpdate.state);
@@ -813,21 +824,26 @@ function runAboutPrefsUpdateTest(updateP
           await continueFileHandler(continueFile);
           let patch = getPatchOfType(info.patchType);
           // The update is removed early when the last download fails so check
           // that there is a patch before proceeding.
           let isLastPatch = (i == downloadInfo.length - 1);
           if (!isLastPatch || patch) {
             let resultName = info.bitsResult ? "bitsResult" : "internalResult";
             patch.QueryInterface(Ci.nsIWritablePropertyBag);
-            await BrowserTestUtils.waitForCondition(() =>
+            await TestUtils.waitForCondition(() =>
               (patch.getProperty(resultName) == info[resultName]),
-              "Waiting for expected patch property " + resultName + " value " +
-              "- got: \"" + patch.getProperty(resultName) + "\", expected: \"" +
-              info[resultName] + "\"", undefined, 200);
+              "Waiting for expected patch property " + resultName + " value: " +
+              info[resultName], undefined, 200
+            ).catch(e => {
+              // Instead of throwing let the check below fail the test so the
+              // property value and the expected property value is printed in
+              // the log.
+              logTestInfo(e);
+            });
             is(patch.getProperty(resultName), info[resultName],
                "The patch property " + resultName + " value should equal " +
                info[resultName]);
           }
         }
       } else if (continueFile) {
         await continueFileHandler(continueFile);
       }