Bug 1354117 - fix telemetry and a number of tests that flip photon prefs, r?johannh draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 01 Aug 2017 20:15:48 +0100
changeset 621135 e4b19cf307976aa52e2117dedb30f11155dc0719
parent 621134 502b4cb476d3c1717f9fa8523054181e5c9aadd8
child 621136 fa270b0a427405582ece7222a4c6873f68d0b77c
push id72277
push usergijskruitbosch@gmail.com
push dateFri, 04 Aug 2017 12:03:53 +0000
reviewersjohannh
bugs1354117
milestone57.0a1
Bug 1354117 - fix telemetry and a number of tests that flip photon prefs, r?johannh MozReview-Commit-ID: 7ynaIQm22eS
addon-sdk/source/test/test-ui-action-button.js
browser/base/content/browser-sync.js
browser/base/content/test/performance/browser_appmenu_reflows.js
browser/base/content/test/sync/browser_sync.js
browser/base/content/test/touch/browser_menu_touch.js
browser/components/customizableui/test/browser_901207_searchbar_in_panel.js
browser/components/customizableui/test/browser_customization_context_menus.js
browser/components/customizableui/test/browser_panel_keyboard_navigation.js
browser/components/uitour/test/browser_UITour_availableTargets.js
browser/components/uitour/test/browser_fxa.js
browser/modules/BrowserUITelemetry.jsm
--- a/addon-sdk/source/test/test-ui-action-button.js
+++ b/addon-sdk/source/test/test-ui-action-button.js
@@ -802,17 +802,16 @@ exports['test button click'] = function*
 
   yield close(window);
 
   loader.unload();
 }
 
 exports['test button icon set'] = function(assert) {
   Cu.import("resource://gre/modules/Services.jsm");
-  Services.prefs.setBoolPref("browser.photon.structure.enabled", false);
 
   const { CustomizableUI } = Cu.import('resource:///modules/CustomizableUI.jsm', {});
   let loader = Loader(module);
   let { ActionButton } = loader.require('sdk/ui');
   let { data } = loader.require('sdk/self');
 
   // Test remote icon set
   assert.throws(
@@ -855,23 +854,21 @@ exports['test button icon set'] = functi
   // Using `loader.unload` without move back the button to the original area
   // raises an error in the CustomizableUI. This is doesn't happen if the
   // button is moved manually from navbar to panel. I believe it has to do
   // with `addWidgetToArea` method, because even with a `timeout` the issue
   // persist.
   CustomizableUI.addWidgetToArea(widgetId, CustomizableUI.AREA_NAVBAR);
 
   Cu.import("resource://gre/modules/Services.jsm");
-  Services.prefs.clearUserPref("browser.photon.structure.enabled");
   loader.unload();
 }
 
 exports['test button icon set with only one option'] = function(assert) {
   Cu.import("resource://gre/modules/Services.jsm");
-  Services.prefs.setBoolPref("browser.photon.structure.enabled", false);
 
   const { CustomizableUI } = Cu.import('resource:///modules/CustomizableUI.jsm', {});
   let loader = Loader(module);
   let { ActionButton } = loader.require('sdk/ui');
   let { data } = loader.require('sdk/self');
 
   // Test remote icon set
   assert.throws(
@@ -906,17 +903,16 @@ exports['test button icon set with only 
   // Using `loader.unload` without move back the button to the original area
   // raises an error in the CustomizableUI. This is doesn't happen if the
   // button is moved manually from navbar to panel. I believe it has to do
   // with `addWidgetToArea` method, because even with a `timeout` the issue
   // persist.
   CustomizableUI.addWidgetToArea(widgetId, CustomizableUI.AREA_NAVBAR);
 
   Cu.import("resource://gre/modules/Services.jsm");
-  Services.prefs.clearUserPref("browser.photon.structure.enabled");
   loader.unload();
 }
 
 exports['test button state validation'] = function(assert) {
   let loader = Loader(module);
   let { ActionButton } = loader.require('sdk/ui');
   let { browserWindows } = loader.require('sdk/windows');
 
--- a/browser/base/content/browser-sync.js
+++ b/browser/base/content/browser-sync.js
@@ -60,61 +60,51 @@ var gSync = {
     return UIState.get().status == UIState.STATUS_SIGNED_IN;
   },
 
   get remoteClients() {
     return Weave.Service.clientsEngine.remoteClients
            .sort((a, b) => a.name.localeCompare(b.name));
   },
 
-  _generateNodeGetters(usePhoton) {
-    let prefix = usePhoton ? "appMenu-" : "PanelUI-";
+  _generateNodeGetters() {
     for (let k of ["Status", "Avatar", "Label", "Container"]) {
       let prop = "appMenu" + k;
       let suffix = k.toLowerCase();
       delete this[prop];
       this.__defineGetter__(prop, function() {
         delete this[prop];
-        return this[prop] = document.getElementById(prefix + "fxa-" + suffix);
+        return this[prop] = document.getElementById("appMenu-fxa-" + suffix);
       });
     }
   },
 
   _maybeUpdateUIState() {
     // Update the UI.
     if (UIState.isReady()) {
       const state = UIState.get();
       // If we are not configured, the UI is already in the right state when
       // we open the window. We can avoid a repaint.
       if (state.status != UIState.STATUS_NOT_CONFIGURED) {
         this.updateAllUI(state);
       }
     }
-
-    this.maybeMoveSyncedTabsButton();
   },
 
   init() {
     // Bail out if we're already initialized or for pop-up windows.
     if (this._initialized || !window.toolbar.visible) {
       return;
     }
 
     for (let topic of this._obs) {
       Services.obs.addObserver(this, topic, true);
     }
 
-    // Use this getter not because 'lazy' but because of the observer,
-    // which lets us easily update our UI according to the pref flip
-    XPCOMUtils.defineLazyPreferenceGetter(this, "gPhotonStructure",
-      "browser.photon.structure.enabled", (pref, old, newValue) => {
-      this._generateNodeGetters(newValue);
-      this._maybeUpdateUIState();
-    });
-    this._generateNodeGetters(this.gPhotonStructure);
+    this._generateNodeGetters();
 
     // initial label for the sync buttons.
     let broadcaster = document.getElementById("sync-status");
     broadcaster.setAttribute("label", this.syncStrings.GetStringFromName("syncnow.label"));
 
     this._maybeUpdateUIState();
 
     EnsureFxAccountsWebChannel();
@@ -543,38 +533,16 @@ var gSync = {
         PanelUI.showSubView("PanelUI-remotetabs", anchor, area);
       }).catch(Cu.reportError);
     } else {
       // It is placed somewhere else - just try and show it.
       PanelUI.showSubView("PanelUI-remotetabs", anchor, area);
     }
   },
 
-  /* After we are initialized we perform a once-only check for the sync
-     button being in "customize purgatory" and if so, move it to the panel.
-     This is done primarily for profiles created before SyncedTabs landed,
-     where the button defaulted to being in that purgatory.
-     We use a preference to ensure we only do it once, so people can still
-     customize it away and have it stick.
-  */
-  maybeMoveSyncedTabsButton() {
-    if (gPhotonStructure) {
-      return;
-    }
-    const prefName = "browser.migrated-sync-button";
-    let migrated = Services.prefs.getBoolPref(prefName, false);
-    if (migrated) {
-      return;
-    }
-    if (!CustomizableUI.getPlacementOfWidget("sync-button")) {
-      CustomizableUI.addWidgetToArea("sync-button", CustomizableUI.AREA_PANEL);
-    }
-    Services.prefs.setBoolPref(prefName, true);
-  },
-
   /* Update the tooltip for the sync-status broadcaster (which will update the
      Sync Toolbar button and the Sync spinner in the FxA hamburger area.)
      If Sync is configured, the tooltip is when the last sync occurred,
      otherwise the tooltip reflects the fact that Sync needs to be
      (re-)configured.
   */
   updateSyncButtonsTooltip(state) {
     const status = state.status;
--- a/browser/base/content/test/performance/browser_appmenu_reflows.js
+++ b/browser/base/content/test/performance/browser_appmenu_reflows.js
@@ -77,20 +77,16 @@ const EXPECTED_APPMENU_SUBVIEW_REFLOWS =
   /**
    * Please don't add anything new!
    */
 ];
 
 add_task(async function() {
   await ensureNoPreloadedBrowser();
 
-  await SpecialPowers.pushPrefEnv({
-    set: [["browser.photon.structure.enabled", true]],
-  });
-
   // First, open the appmenu.
   await withReflowObserver(async function() {
     let popupPositioned =
       BrowserTestUtils.waitForEvent(PanelUI.panel, "popuppositioned");
     await PanelUI.show();
     await popupPositioned;
   }, EXPECTED_APPMENU_OPEN_REFLOWS);
 
--- a/browser/base/content/test/sync/browser_sync.js
+++ b/browser/base/content/test/sync/browser_sync.js
@@ -47,18 +47,17 @@ add_task(async function test_ui_state_sy
     displayName: "Foo Bar",
     avatarURL: "https://foo.bar",
     lastSync: new Date(),
     syncing: true
   };
 
   gSync.updateAllUI(state);
 
-  let prefix = gPhotonStructure ? "appMenu" : "PanelUI";
-  checkSyncNowButton(`${prefix}-fxa-icon`, true);
+  checkSyncNowButton("appMenu-fxa-icon", true);
   checkSyncNowButton("PanelUI-remotetabs-syncnow", true);
 
   // Be good citizens and remove the "syncing" state.
   gSync.updateAllUI({
     status: UIState.STATUS_SIGNED_IN,
     email: "foo@bar.com",
     lastSync: new Date(),
     syncing: false
@@ -141,37 +140,36 @@ add_task(async function test_FormatLastS
   let monthAgo = new Date();
   monthAgo.setMonth(monthAgo.getMonth() - 1);
   let monthAgoString = gSync.formatLastSyncDate(monthAgo);
   is(monthAgoString, "Last sync: " + monthAgo.toLocaleDateString(undefined, {month: "long", day: "numeric"}),
      "The date is correctly formatted");
 });
 
 function checkPanelUIStatusBar({label, tooltip, fxastatus, avatarURL, syncing, syncNowTooltip}) {
-  let prefix = gPhotonStructure ? "appMenu" : "PanelUI"
-  let labelNode = document.getElementById(`${prefix}-fxa-label`);
-  let tooltipNode = document.getElementById(`${prefix}-fxa-status`);
-  let statusNode = document.getElementById(`${prefix}-fxa-container`);
-  let avatar = document.getElementById(`${prefix}-fxa-avatar`);
+  let labelNode = document.getElementById("appMenu-fxa-label");
+  let tooltipNode = document.getElementById("appMenu-fxa-status");
+  let statusNode = document.getElementById("appMenu-fxa-container");
+  let avatar = document.getElementById("appMenu-fxa-avatar");
 
   is(labelNode.getAttribute("label"), label, "fxa label has the right value");
   is(tooltipNode.getAttribute("tooltiptext"), tooltip, "fxa tooltip has the right value");
   if (fxastatus) {
     is(statusNode.getAttribute("fxastatus"), fxastatus, "fxa fxastatus has the right value");
   } else {
     ok(!statusNode.hasAttribute("fxastatus"), "fxastatus is unset")
   }
   if (avatarURL) {
     is(avatar.style.listStyleImage, `url("${avatarURL}")`, "fxa avatar URL is set");
   } else {
     ok(!statusNode.style.listStyleImage, "fxa avatar URL is unset");
   }
 
   if (syncing != undefined && syncNowTooltip != undefined) {
-    checkSyncNowButton(`${prefix}-fxa-icon`, syncing, syncNowTooltip);
+    checkSyncNowButton("appMenu-fxa-icon", syncing, syncNowTooltip);
   }
 }
 
 function checkRemoteTabsPanel(expectedShownItemId, syncing, syncNowTooltip) {
   checkItemsVisiblities(["PanelUI-remotetabs-main",
                          "PanelUI-remotetabs-setupsync",
                          "PanelUI-remotetabs-reauthsync"],
                         expectedShownItemId);
--- a/browser/base/content/test/touch/browser_menu_touch.js
+++ b/browser/base/content/test/touch/browser_menu_touch.js
@@ -58,46 +58,31 @@ async function openAndCheckCustomization
 
   ok(!menu.hasAttribute("touchmode"), "Menu is not in touchmode.");
 
   menu.hidePopup();
 }
 
 // Test main ("hamburger") menu.
 add_task(async function test_main_menu_touch() {
-  if (!gPhotonStructure) {
-    ok(true, "Skipping test because we're not in Photon mode");
-    return;
-  }
-
   let mainMenu = document.getElementById("appMenu-popup");
   let target = document.getElementById("PanelUI-menu-button");
   await openAndCheckMenu(mainMenu, target);
 });
 
 // Test the page action menu.
 add_task(async function test_page_action_panel_touch() {
-  if (!gPhotonStructure) {
-    ok(true, "Skipping test because we're not in Photon mode");
-    return;
-  }
-
   let pageActionPanel = document.getElementById("page-action-panel");
   let target = document.getElementById("urlbar-page-action-button");
   await openAndCheckMenu(pageActionPanel, target);
 });
 
 // Test the customizationUI panel, which is used for various menus
 // such as library, history, sync, developer and encoding.
 add_task(async function test_customizationui_panel_touch() {
-  if (!gPhotonStructure) {
-    ok(true, "Skipping test because we're not in Photon mode");
-    return;
-  }
-
   CustomizableUI.addWidgetToArea("library-button", CustomizableUI.AREA_NAVBAR);
   CustomizableUI.addWidgetToArea("history-panelmenu", CustomizableUI.AREA_NAVBAR);
 
   await BrowserTestUtils.waitForCondition(() =>
     CustomizableUI.getPlacementOfWidget("library-button").area == "nav-bar");
 
   let target = document.getElementById("library-button");
   await openAndCheckCustomizationUIMenu(target);
--- a/browser/components/customizableui/test/browser_901207_searchbar_in_panel.js
+++ b/browser/components/customizableui/test/browser_901207_searchbar_in_panel.js
@@ -11,17 +11,16 @@ async function waitForSearchBarFocus() {
   await waitForCondition(function() {
     logActiveElement();
     return document.activeElement === searchbar.textbox.inputField;
   });
 }
 
 // Ctrl+K should open the menu panel and focus the search bar if the search bar is in the panel.
 add_task(async function() {
-  await SpecialPowers.pushPrefEnv({set: [["browser.photon.structure.enabled", true]]});
   let searchbar = document.getElementById("searchbar");
   gCustomizeMode.addToPanel(searchbar);
   let placement = CustomizableUI.getPlacementOfWidget("search-container");
   is(placement.area, CustomizableUI.AREA_FIXED_OVERFLOW_PANEL, "Should be in panel");
 
   let shownPanelPromise = promiseOverflowShown(window);
   sendWebSearchKeyCommand();
   await shownPanelPromise;
--- a/browser/components/customizableui/test/browser_customization_context_menus.js
+++ b/browser/components/customizableui/test/browser_customization_context_menus.js
@@ -9,17 +9,16 @@ requestLongerTimeout(2);
 const isOSX = (Services.appinfo.OS === "Darwin");
 
 const overflowButton = document.getElementById("nav-bar-overflow-button");
 const overflowPanel = document.getElementById("widget-overflow");
 
 // Right-click on the home button should
 // show a context menu with options to move it.
 add_task(async function home_button_context() {
-  await SpecialPowers.pushPrefEnv({set: [["browser.photon.structure.enabled", true]]});
   let contextMenu = document.getElementById("toolbar-context-menu");
   let shownPromise = popupShown(contextMenu);
   let homeButton = document.getElementById("home-button");
   EventUtils.synthesizeMouse(homeButton, 2, 2, {type: "contextmenu", button: 2 });
   await shownPromise;
 
   let expectedEntries = [
     [".customize-context-moveToPanel", true],
--- a/browser/components/customizableui/test/browser_panel_keyboard_navigation.js
+++ b/browser/components/customizableui/test/browser_panel_keyboard_navigation.js
@@ -4,17 +4,16 @@
  * Test keyboard navigation in the app menu panel.
  */
 
 const {PanelMultiView} = Cu.import("resource:///modules/PanelMultiView.jsm", {});
 const kHelpButtonId = "appMenu-help-button";
 let gHelperInstance;
 
 add_task(async function setup() {
-  await SpecialPowers.pushPrefEnv({set: [["browser.photon.structure.enabled", true]]});
   gHelperInstance = new PanelMultiView(PanelUI.panel, true);
 });
 
 add_task(async function testUpDownKeys() {
   let promise = promisePanelShown(window);
   PanelUI.show();
   await promise;
 
--- a/browser/components/uitour/test/browser_UITour_availableTargets.js
+++ b/browser/components/uitour/test/browser_UITour_availableTargets.js
@@ -1,36 +1,33 @@
 "use strict";
 
 var gTestTab;
 var gContentAPI;
 var gContentWindow;
 
 var hasPocket = Services.prefs.getBoolPref("extensions.pocket.enabled");
-var isPhoton = Services.prefs.getBoolPref("browser.photon.structure.enabled");
-var hasQuit = !isPhoton ||
-              AppConstants.platform != "macosx";
-var hasLibrary = isPhoton || false;
+var hasQuit = AppConstants.platform != "macosx";
 
 requestLongerTimeout(2);
 add_task(setup_UITourTest);
 
 add_UITour_task(async function test_availableTargets() {
   let data = await getConfigurationPromise("availableTargets");
   ok_targets(data, [
     "accountStatus",
     "addons",
     "appMenu",
     "backForward",
     "bookmarks",
     "customize",
     "devtools",
     "help",
     "home",
-      ...(hasLibrary ? ["library"] : []),
+    "library",
       ...(hasPocket ? ["pocket"] : []),
     "privateWindow",
       ...(hasQuit ? ["quit"] : []),
     "readerMode-urlBar",
     "search",
     "searchIcon",
     "trackingProtection",
     "urlbar",
@@ -49,17 +46,17 @@ add_UITour_task(async function test_avai
     "accountStatus",
     "addons",
     "appMenu",
     "backForward",
     "customize",
     "help",
     "devtools",
     "home",
-      ...(hasLibrary ? ["library"] : []),
+    "library",
       ...(hasPocket ? ["pocket"] : []),
     "privateWindow",
       ...(hasQuit ? ["quit"] : []),
     "readerMode-urlBar",
     "search",
     "searchIcon",
     "trackingProtection",
     "urlbar",
@@ -83,17 +80,17 @@ add_UITour_task(async function test_avai
     "addons",
     "appMenu",
     "backForward",
     "bookmarks",
     "customize",
     "devtools",
     "help",
     "home",
-      ...(hasLibrary ? ["library"] : []),
+    "library",
       ...(hasPocket ? ["pocket"] : []),
     "privateWindow",
       ...(hasQuit ? ["quit"] : []),
     "readerMode-urlBar",
     "trackingProtection",
     "urlbar",
   ]);
 
--- a/browser/components/uitour/test/browser_fxa.js
+++ b/browser/components/uitour/test/browser_fxa.js
@@ -37,18 +37,17 @@ var tests = [
   taskify(async function test_highlight_accountStatus_loggedIn() {
     await setSignedInUser();
     let userData = await fxAccounts.getSignedInUser();
     isnot(userData, null, "Logged in now");
     gSync.updateAllUI({ status: UIState.STATUS_SIGNED_IN, email: "foo@example.com" });
     await showMenuPromise("appMenu");
     await showHighlightPromise("accountStatus");
     let highlight = document.getElementById("UITourHighlightContainer");
-    let photon = Services.prefs.getBoolPref("browser.photon.structure.enabled");
-    let expectedTarget = photon ? "appMenu-fxa-avatar" : "PanelUI-fxa-avatar";
+    let expectedTarget = "appMenu-fxa-avatar";
     is(highlight.popupBoxObject.anchorNode.id, expectedTarget, "Anchored on avatar");
     is(highlight.getAttribute("targetName"), "accountStatus", "Correct highlight target");
   }),
 ];
 
 // Helpers copied from browser_aboutAccounts.js
 // watch out - these will fire observers which if you aren't careful, may
 // interfere with the tests.
--- a/browser/modules/BrowserUITelemetry.jsm
+++ b/browser/modules/BrowserUITelemetry.jsm
@@ -22,18 +22,16 @@ XPCOMUtils.defineLazyModuleGetter(this, 
 XPCOMUtils.defineLazyModuleGetter(this, "UITour",
   "resource:///modules/UITour.jsm");
 XPCOMUtils.defineLazyGetter(this, "Timer", function() {
   let timer = {};
   Cu.import("resource://gre/modules/Timer.jsm", timer);
   return timer;
 });
 
-XPCOMUtils.defineLazyPreferenceGetter(this, "gPhotonStructure", "browser.photon.structure.enabled");
-
 const MS_SECOND = 1000;
 const MS_MINUTE = MS_SECOND * 60;
 const MS_HOUR = MS_MINUTE * 60;
 
 const LEGACY_PANEL_PLACEMENTS = [
   "edit-controls",
   "zoom-controls",
   "new-window-button",
@@ -71,61 +69,38 @@ XPCOMUtils.defineLazyGetter(this, "DEFAU
     "TabsToolbar": [
       "tabbrowser-tabs",
       "new-tab-button",
       "alltabs-button",
     ],
     "PersonalToolbar": [
       "personal-bookmarks",
     ],
+    "widget-overflow-fixed-list": [
+    ],
   };
 
-  if (gPhotonStructure) {
-    result["widget-overflow-fixed-list"] = [];
-  } else {
-    result["PanelUI-contents"] = LEGACY_PANEL_PLACEMENTS;
-    let showCharacterEncoding = Services.prefs.getComplexValue(
-      "browser.menu.showCharacterEncoding",
-      Ci.nsIPrefLocalizedString
-    ).data;
-    if (showCharacterEncoding == "true") {
-      result["PanelUI-contents"].push("characterencoding-button");
-    }
-
-    if (AppConstants.MOZ_DEV_EDITION || AppConstants.NIGHTLY_BUILD) {
-      if (Services.prefs.getBoolPref("extensions.webcompat-reporter.enabled")) {
-        result["PanelUI-contents"].push("webcompat-reporter-button");
-      }
-    }
-  }
-
   return result;
 });
 
 XPCOMUtils.defineLazyGetter(this, "DEFAULT_AREAS", function() {
   return Object.keys(DEFAULT_AREA_PLACEMENTS);
 });
 
 XPCOMUtils.defineLazyGetter(this, "PALETTE_ITEMS", function() {
   let result = [
     "open-file-button",
     "developer-button",
     "feed-button",
     "email-link-button",
     "containers-panelmenu",
+    ...LEGACY_PANEL_PLACEMENTS,
+    "characterencoding-button",
   ];
 
-  let panelPlacements = DEFAULT_AREA_PLACEMENTS["PanelUI-contents"];
-  if (!panelPlacements) {
-    result.push(...LEGACY_PANEL_PLACEMENTS);
-  }
-  if (!panelPlacements || !panelPlacements.includes("characterencoding-button")) {
-    result.push("characterencoding-button");
-  }
-
   if (Services.prefs.getBoolPref("privacy.panicButton.enabled")) {
     result.push("panic-button");
   }
 
   return result;
 });
 
 XPCOMUtils.defineLazyGetter(this, "DEFAULT_ITEMS", function() {