Bug 1383741 - Ensure browser_experiments.js works with both new and old Preferences UI. r=mconley
authorEvan Tseng <evan@tseng.io>
Tue, 25 Jul 2017 17:26:47 +0800
changeset 419942 f29c950fa2262e1bbae4072f3056a4662648727a
parent 419941 088f78b64f4a28a7909079d6e3d1be7e885a43ba
child 419943 8315c95af78c24ff42133c5d3cb4f95088e0e00a
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1383741
milestone56.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 1383741 - Ensure browser_experiments.js works with both new and old Preferences UI. r=mconley MozReview-Commit-ID: Bj2r0xLKxAj
toolkit/mozapps/extensions/test/browser/browser_experiments.js
--- a/toolkit/mozapps/extensions/test/browser/browser_experiments.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_experiments.js
@@ -157,38 +157,49 @@ add_task(async function testExperimentLe
   EventUtils.synthesizeMouseAtCenter(btn, {}, gManagerWindow);
   await loadPromise;
 
   Services.prefs.clearUserPref("toolkit.telemetry.infoURL");
   await BrowserTestUtils.removeTab(gBrowser.selectedTab);
 });
 
 add_task(async function testOpenPreferences() {
+  var useOldPrefs = Services.prefs.getBoolPref("browser.preferences.useOldOrganization");
+
   await gCategoryUtilities.openType("experiment");
   let btn = gManagerWindow.document.getElementById("experiments-change-telemetry");
 
   is_element_visible(btn, "Change telemetry button visible in in-content UI.");
 
   let deferred = Promise.defer();
-  Services.obs.addObserver(function observer(prefWin, topic, data) {
-    Services.obs.removeObserver(observer, "privacy-pane-loaded");
-    info("Privacy preference pane opened.");
-    executeSoon(function() {
-      // We want this test to fail if the preferences pane changes,
-      // but we can't check if the data-choices button is visible
-      // since it is only in the DOM when MOZ_TELEMETRY_REPORTING=1.
-      let el = prefWin.document.getElementById("dataCollectionGroup");
-      is_element_visible(el);
+
+  function ensureElementIsVisible(preferencesPane, visibleElement) {
+    Services.obs.addObserver(function observer(prefWin, topic, data) {
+      Services.obs.removeObserver(observer, preferencesPane + "-pane-loaded");
+      info(preferencesPane + " preference pane opened.");
+      executeSoon(function() {
+        // We want this test to fail if the preferences pane changes,
+        // but we can't check if the data-choices button is visible
+        // since it is only in the DOM when MOZ_TELEMETRY_REPORTING=1.
+        let el = prefWin.document.getElementById(visibleElement);
+        is_element_visible(el);
 
-      prefWin.close();
-      info("Closed preferences pane.");
+        prefWin.close();
+        info("Closed preferences pane.");
 
-      deferred.resolve();
-    });
-  }, "privacy-pane-loaded");
+        deferred.resolve();
+      });
+    }, preferencesPane + "-pane-loaded");
+  }
+
+  if (useOldPrefs) {
+    ensureElementIsVisible("advanced", "header-advanced");
+  } else {
+    ensureElementIsVisible("privacy", "dataCollectionGroup");
+  }
 
   info("Loading preferences pane.");
   // We need to focus before synthesizing the mouse event (bug 1240052) as
   // synthesizeMouseAtCenter currently only synthesizes the mouse in the child process.
   // This can cause some subtle differences if the child isn't focused.
   await SimpleTest.promiseFocus();
   await BrowserTestUtils.synthesizeMouseAtCenter("#experiments-change-telemetry", {},
                                                  gBrowser.selectedBrowser);