Bug 1383741 - Ensure browser_experiments.js works with both new and old Preferences UI. draft
authorEvan Tseng <evan@tseng.io>
Tue, 25 Jul 2017 17:26:47 +0800
changeset 616420 2bbf0b3a7fe4460cb40a36c63d2424098c07fc57
parent 615492 9eddb0a92820c6445f9d1e680e4c239e888e93f0
child 639465 45cf007494fd3d6a43609bbaa08bdf801a6fd64e
push id70677
push userbmo:evan@tseng.io
push dateThu, 27 Jul 2017 01:14:42 +0000
bugs1383741
milestone56.0a1
Bug 1383741 - Ensure browser_experiments.js works with both new and old Preferences UI. 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);