Bug 1502169 - about:studies: wait for more elements before interacting with them in tests. r=Gijs, a=test-only
authorMichael Cooper <mcooper@mozilla.com>
Fri, 02 Nov 2018 16:40:18 +0000
changeset 501087 74833aee1389ae0174a08831d53b0dc851e06bd7
parent 501086 a7b21829921c219dda2aa58a243b5ba2232c588d
child 501088 522a5434e0a42890c5292c0228eea366e7dabafd
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, test-only
bugs1502169
milestone64.0
Bug 1502169 - about:studies: wait for more elements before interacting with them in tests. r=Gijs, a=test-only Differential Revision: https://phabricator.services.mozilla.com/D10630
toolkit/components/normandy/test/browser/browser_about_studies.js
--- a/toolkit/components/normandy/test/browser/browser_about_studies.js
+++ b/toolkit/components/normandy/test/browser/browser_about_studies.js
@@ -50,17 +50,19 @@ decorate_task(
 decorate_task(
   withAboutStudies,
   async function testUpdatePreferences(browser) {
     let loadPromise = BrowserTestUtils.firstBrowserLoaded(window);
 
     // We have to use gBrowser instead of browser in most spots since we're
     // dealing with a new tab outside of the about:studies tab.
     const tab = await BrowserTestUtils.switchTab(gBrowser, () => {
-      ContentTask.spawn(browser, null, () => {
+      ContentTask.spawn(browser, null, async () => {
+        const doc = content.document;
+        await ContentTaskUtils.waitForCondition(() => doc.getElementById("shield-studies-update-preferences"));
         content.document.getElementById("shield-studies-update-preferences").click();
       });
     });
 
     await loadPromise;
 
     const location = gBrowser.currentURI.spec;
     is(
@@ -307,17 +309,20 @@ decorate_task(
     RecipeRunner.checkPrefs();
     ok(
       RecipeRunner.enabled,
       "RecipeRunner should be enabled as a Precondition",
     );
 
     await ContentTask.spawn(browser, null, async () => {
       const doc = content.document;
-      await ContentTaskUtils.waitForCondition(() => doc.querySelector(".info-box-content > span").textContent);
+      await ContentTaskUtils.waitForCondition(() => {
+        const span = doc.querySelector(".info-box-content > span");
+        return span && span.textContent;
+      });
 
       is(
         doc.querySelector(".info-box-content > span").textContent,
         "This is a list of studies that you have participated in. No new studies will run.",
         "A message is shown when studies are disabled",
       );
     });
   }