Bug 1383741 - Ensure browser_experiments.js works with both new and old Preferences UI.
MozReview-Commit-ID: Bj2r0xLKxAj
--- 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);