Bug 1492482 - Remove CPOW usage from browser_onboarding_tourset.js. r=ursula
authorMike Conley <mconley@mozilla.com>
Tue, 02 Oct 2018 17:59:42 +0000
changeset 494970 0c2a8c43e38efe614fd7f70e6f5c364bb63e93c4
parent 494969 6cbfcebf531fbe916bb6848ecf820b4e4ef7259f
child 494971 e36f11e684015e5d4abf3df854a3d32be2e7a228
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersursula
bugs1492482
milestone64.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 1492482 - Remove CPOW usage from browser_onboarding_tourset.js. r=ursula Depends on D6959 Differential Revision: https://phabricator.services.mozilla.com/D6960
browser/extensions/onboarding/test/browser/browser_onboarding_tourset.js
--- a/browser/extensions/onboarding/test/browser/browser_onboarding_tourset.js
+++ b/browser/extensions/onboarding/test/browser/browser_onboarding_tourset.js
@@ -1,29 +1,36 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 requestLongerTimeout(2);
 
+async function testTourIDs(browser, tourIDs) {
+  await ContentTask.spawn(browser, tourIDs, async (tourIDsContent) => {
+    let doc = content.document;
+    let doms = doc.querySelectorAll(".onboarding-tour-item");
+    Assert.equal(doms.length, tourIDsContent.length, "has exact tour numbers");
+    doms.forEach((dom, idx) => {
+      Assert.equal(tourIDsContent[idx], dom.id, "contain defined onboarding id");
+    });
+  });
+}
+
 add_task(async function test_onboarding_default_new_tourset() {
   resetOnboardingDefaultState();
 
   let tab = await openTab(ABOUT_NEWTAB_URL);
-  await promiseOnboardingOverlayLoaded(tab.linkedBrowser);
-  await BrowserTestUtils.synthesizeMouseAtCenter("#onboarding-overlay-button", {}, tab.linkedBrowser);
-  await promiseOnboardingOverlayOpened(tab.linkedBrowser);
+  let browser = tab.linkedBrowser;
+  await promiseOnboardingOverlayLoaded(browser);
+  await BrowserTestUtils.synthesizeMouseAtCenter("#onboarding-overlay-button", {}, browser);
+  await promiseOnboardingOverlayOpened(browser);
 
-  let doc = gBrowser.contentDocumentAsCPOW;
-  let doms = doc.querySelectorAll(".onboarding-tour-item");
-  is(doms.length, TOUR_IDs.length, "has exact tour numbers");
-  doms.forEach((dom, idx) => {
-    is(TOUR_IDs[idx], dom.id, "contain defined onboarding id");
-  });
+  await testTourIDs(browser, TOUR_IDs);
 
   BrowserTestUtils.removeTab(tab);
 });
 
 add_task(async function test_onboarding_custom_new_tourset() {
   const CUSTOM_NEW_TOURs = [
     "onboarding-tour-private-browsing",
     "onboarding-tour-addons",
@@ -34,26 +41,22 @@ add_task(async function test_onboarding_
   await SpecialPowers.pushPrefEnv({set: [
     ["browser.onboarding.tour-type", "new"],
     ["browser.onboarding.tourset-version", 1],
     ["browser.onboarding.seen-tourset-version", 1],
     ["browser.onboarding.newtour", "private,addons,customize"],
   ]});
 
   let tab = await openTab(ABOUT_NEWTAB_URL);
-  await promiseOnboardingOverlayLoaded(tab.linkedBrowser);
-  await BrowserTestUtils.synthesizeMouseAtCenter("#onboarding-overlay-button", {}, tab.linkedBrowser);
-  await promiseOnboardingOverlayOpened(tab.linkedBrowser);
+  let browser = tab.linkedBrowser;
+  await promiseOnboardingOverlayLoaded(browser);
+  await BrowserTestUtils.synthesizeMouseAtCenter("#onboarding-overlay-button", {}, browser);
+  await promiseOnboardingOverlayOpened(browser);
 
-  let doc = gBrowser.contentDocumentAsCPOW;
-  let doms = doc.querySelectorAll(".onboarding-tour-item");
-  is(doms.length, CUSTOM_NEW_TOURs.length, "has exact tour numbers");
-  doms.forEach((dom, idx) => {
-    is(CUSTOM_NEW_TOURs[idx], dom.id, "contain defined onboarding id");
-  });
+  await testTourIDs(browser, CUSTOM_NEW_TOURs);
 
   BrowserTestUtils.removeTab(tab);
 });
 
 add_task(async function test_onboarding_custom_update_tourset() {
   const CUSTOM_UPDATE_TOURs = [
     "onboarding-tour-customize",
     "onboarding-tour-private-browsing",
@@ -63,21 +66,17 @@ add_task(async function test_onboarding_
   await SpecialPowers.pushPrefEnv({set: [
     ["browser.onboarding.tour-type", "update"],
     ["browser.onboarding.tourset-version", 1],
     ["browser.onboarding.seen-tourset-version", 1],
     ["browser.onboarding.updatetour", "customize,private,addons"],
   ]});
 
   let tab = await openTab(ABOUT_NEWTAB_URL);
-  await promiseOnboardingOverlayLoaded(tab.linkedBrowser);
-  await BrowserTestUtils.synthesizeMouseAtCenter("#onboarding-overlay-button", {}, tab.linkedBrowser);
-  await promiseOnboardingOverlayOpened(tab.linkedBrowser);
+  let browser = tab.linkedBrowser;
+  await promiseOnboardingOverlayLoaded(browser);
+  await BrowserTestUtils.synthesizeMouseAtCenter("#onboarding-overlay-button", {}, browser);
+  await promiseOnboardingOverlayOpened(browser);
 
-  let doc = gBrowser.contentDocumentAsCPOW;
-  let doms = doc.querySelectorAll(".onboarding-tour-item");
-  is(doms.length, CUSTOM_UPDATE_TOURs.length, "has exact tour numbers");
-  doms.forEach((dom, idx) => {
-    is(CUSTOM_UPDATE_TOURs[idx], dom.id, "contain defined onboarding id");
-  });
+  await testTourIDs(browser, CUSTOM_UPDATE_TOURs);
 
   BrowserTestUtils.removeTab(tab);
 });