Bug 1354117 - remove photon checks from UITour, r?gasolin draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 02 Aug 2017 11:18:42 +0100
changeset 621139 74020fce8e957cead6e03b78ed96a0ee9828fcc7
parent 621138 2e6b36cfdb08fc4a08972aa2fefbd9b35de32cbf
child 621140 c5b2409456ff4597773d6566cef999b9e89666e4
push id72277
push usergijskruitbosch@gmail.com
push dateFri, 04 Aug 2017 12:03:53 +0000
reviewersgasolin
bugs1354117
milestone57.0a1
Bug 1354117 - remove photon checks from UITour, r?gasolin MozReview-Commit-ID: 83MUmyjAtVH
browser/components/uitour/UITour.jsm
browser/components/uitour/test/browser_UITour_detach_tab.js
--- a/browser/components/uitour/UITour.jsm
+++ b/browser/components/uitour/UITour.jsm
@@ -28,18 +28,16 @@ XPCOMUtils.defineLazyModuleGetter(this, 
   "resource:///modules/BrowserUITelemetry.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
   "resource://gre/modules/PrivateBrowsingUtils.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "ProfileAge",
   "resource://gre/modules/ProfileAge.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "ReaderParent",
   "resource:///modules/ReaderParent.jsm");
 
-XPCOMUtils.defineLazyPreferenceGetter(this, "gPhotonStructure", "browser.photon.structure.enabled");
-
 // See LOG_LEVELS in Console.jsm. Common examples: "All", "Info", "Warn", & "Error".
 const PREF_LOG_LEVEL      = "browser.uitour.loglevel";
 const PREF_SEENPAGEIDS    = "browser.uitour.seenPageIDs";
 
 const BACKGROUND_PAGE_ACTIONS_ALLOWED = new Set([
   "forceShowReaderIcon",
   "getConfiguration",
   "getTreatmentTag",
@@ -93,41 +91,33 @@ this.UITour = {
   },
 
   _annotationPanelMutationObservers: new WeakMap(),
 
   highlightEffects: ["random", "wobble", "zoom", "color"],
   targets: new Map([
     ["accountStatus", {
       query: (aDocument) => {
-        let prefix = gPhotonStructure ? "appMenu" : "PanelUI"
         // If the user is logged in, use the avatar element.
-        let fxAFooter = aDocument.getElementById(prefix + "-fxa-container");
+        let fxAFooter = aDocument.getElementById("appMenu-fxa-container");
         if (fxAFooter.getAttribute("fxastatus")) {
-          return aDocument.getElementById(prefix + "-fxa-avatar");
+          return aDocument.getElementById("appMenu-fxa-avatar");
         }
 
         // Otherwise use the sync setup icon.
-        let statusButton = aDocument.getElementById(prefix + "-fxa-label");
+        let statusButton = aDocument.getElementById("appMenu-fxa-label");
         return aDocument.getAnonymousElementByAttribute(statusButton,
                                                         "class",
                                                         "toolbarbutton-icon");
       },
-      // This is a fake widgetName starting with the "PanelUI-"/"appMenu-" prefix so we know
+      // This is a fake widgetName starting with the "appMenu-" prefix so we know
       // to automatically open the appMenu when annotating this target.
-      get widgetName() {
-        return gPhotonStructure ? "appMenu-fxa-label" : "PanelUI-fxa-label";
-      },
+      widgetName: "appMenu-fxa-label",
     }],
-    ["addons", {
-      query(aDocument) {
-        let buttonId = gPhotonStructure ? "appMenu-addons-button" : "add-ons-button";
-        return aDocument.getElementById(buttonId);
-      }
-    }],
+    ["addons",      {query: "#appMenu-addons-button"}],
     ["appMenu",     {
       addTargetListener: (aDocument, aCallback) => {
         let panelPopup = aDocument.defaultView.PanelUI.panel;
         panelPopup.addEventListener("popupshown", aCallback);
       },
       query: "#PanelUI-button",
       removeTargetListener: (aDocument, aCallback) => {
         let panelPopup = aDocument.defaultView.PanelUI.panel;
@@ -137,79 +127,38 @@ this.UITour = {
     ["backForward", {
       query: "#back-button",
       widgetName: "urlbar-container",
     }],
     ["bookmarks",   {query: "#bookmarks-menu-button"}],
     ["controlCenter-trackingUnblock", controlCenterTrackingToggleTarget(true)],
     ["controlCenter-trackingBlock", controlCenterTrackingToggleTarget(false)],
     ["customize",   {
-      query: (aDocument) => {
-        if (gPhotonStructure) {
-          return aDocument.getElementById("appMenu-customize-button");
-        }
-        let customizeButton = aDocument.getElementById("PanelUI-customize");
-        return aDocument.getAnonymousElementByAttribute(customizeButton,
-                                                        "class",
-                                                        "toolbarbutton-icon");
-      },
-      get widgetName() {
-        return gPhotonStructure ? "appMenu-customize-button" : "PanelUI-customize";
-      },
+      query: "#appMenu-customize-button",
+      widgetName: "appMenu-customize-button",
     }],
-    ["devtools", {
-      query(aDocument) {
-        let button = aDocument.getElementById("developer-button");
-        if (button || !gPhotonStructure) {
-          return button;
-        }
-        return aDocument.getElementById("appMenu-developer-button");
-      },
-      get widgetName() {
-        return gPhotonStructure ? "appMenu-developer-button" : "developer-button";
-      },
+    ["devtools",    {
+      query: "#appMenu-developer-button",
+      widgetName: "appMenu-developer-button",
     }],
     ["forget", {
       allowAdd: true,
       query: "#panic-button",
       widgetName: "panic-button",
     }],
-    ["help", {
-      query: (aDocument) => {
-        let buttonId = gPhotonStructure ? "appMenu-help-button" : "PanelUI-help";
-        return aDocument.getElementById(buttonId);
-      }
-    }],
+    ["help",        {query: "#appMenu-help-button"}],
     ["home",        {query: "#home-button"}],
-    ["library", {
-     query: (aDocument) => {
-        let buttonId = "appMenu-library-button";
-        return gPhotonStructure ?
-          aDocument.getElementById(buttonId) : null;
-      }
-    }],
+    ["library",     {query: "#appMenu-library-button"}],
     ["pocket", {
       allowAdd: true,
       query: "#pocket-button",
       widgetName: "pocket-button",
     }],
-    ["privateWindow", {
-      query(aDocument) {
-        let buttonId = gPhotonStructure ? "appMenu-private-window-button"
-                                        : "privatebrowsing-button";
-        return aDocument.getElementById(buttonId);
-      }
-    }],
-    ["quit", {
-      query(aDocument) {
-        let buttonId = gPhotonStructure ? "appMenu-quit-button"
-                                        : "PanelUI-quit";
-        return aDocument.getElementById(buttonId);
-      }
-    }],
+    ["privateWindow", {query: "#appMenu-private-window-button"}],
+    ["quit",        {query: "#appMenu-quit-button"}],
     ["readerMode-urlBar", {query: "#reader-mode-button"}],
     ["search",      {
       infoPanelOffsetX: 18,
       infoPanelPosition: "after_start",
       query: "#searchbar",
       widgetName: "search-container",
     }],
     ["searchIcon", {
@@ -978,31 +927,23 @@ this.UITour = {
           widgetName: targetObject.widgetName,
           allowAdd: targetObject.allowAdd,
         });
       }).catch(log.error);
     });
   },
 
   targetIsInAppMenu(aTarget) {
-    let placement = CustomizableUI.getPlacementOfWidget(aTarget.widgetName || aTarget.node.id);
-    if (placement && placement.area == CustomizableUI.AREA_PANEL) {
-      return true;
-    }
-
     let targetElement = aTarget.node;
     // Use the widget for filtering if it exists since the target may be the icon inside.
     if (aTarget.widgetName) {
       targetElement = aTarget.node.ownerDocument.getElementById(aTarget.widgetName);
     }
 
-    // Handle the non-customizable buttons at the bottom of the menu which aren't proper widgets.
-    let prefix = gPhotonStructure ? "appMenu-" : "PanelUI-";
-    return targetElement.id.startsWith(prefix)
-             && targetElement.id != "PanelUI-button";
+    return targetElement.id.startsWith("appMenu-");
   },
 
   /**
    * Called before opening or after closing a highlight or info panel to see if
    * we need to open or close the appMenu to see the annotation's anchor.
    */
   _setAppMenuStateForAnnotation(aWindow, aAnnotationType, aShouldOpenForHighlight, aTarget = null,
                                 aCallback = null) {
--- a/browser/components/uitour/test/browser_UITour_detach_tab.js
+++ b/browser/components/uitour/test/browser_UITour_detach_tab.js
@@ -76,19 +76,16 @@ var tests = [
     // reasons.
     gTestTab = gContentWindow.gBrowser.selectedTab;
 
     let shownPromise = promisePanelShown(gContentWindow);
     gContentAPI.showMenu("appMenu");
     await shownPromise;
 
     isnot(gContentWindow.PanelUI.panel.state, "closed", "Panel should be open");
-    if (!gContentWindow.gPhotonStructure) {
-      ok(gContentWindow.PanelUI.contents.children.length > 0, "Panel contents should have children");
-    }
     gContentAPI.hideHighlight();
     gContentAPI.hideMenu("appMenu");
     gTestTab = null;
 
     Services.obs.addObserver(onDOMWindowDestroyed, "dom-window-destroyed");
     gContentWindow.close();
 
     await windowDestroyedDeferred.promise;