Bug 1390055 - should highlight library and addons at toolbar if exist;r=Gijs
authorgasolin <gasolin@gmail.com>
Thu, 17 Aug 2017 12:59:02 +0800
changeset 375521 fc4e3d36bf0c6bb79dfe8a9ded58655449f87fc5
parent 375520 8c617506930eed1fbfa6efb2647e8df2095d27c5
child 375522 afdd35ed8902c1a6d670a56996673e91e30979f7
push id32357
push userkwierso@gmail.com
push dateFri, 18 Aug 2017 20:11:21 +0000
treeherdermozilla-central@8febdfacc716 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1390055
milestone57.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 1390055 - should highlight library and addons at toolbar if exist;r=Gijs MozReview-Commit-ID: Ijarh8qp0D9
browser/base/content/browser.xul
browser/components/uitour/UITour.jsm
browser/components/uitour/test/browser_UITour5.js
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -916,16 +916,17 @@
                        removable="true"
                        cui-areatype="toolbar"
                        tooltip="dynamic-shortcut-tooltip"/>
 
         <toolbarbutton id="library-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
                        removable="true"
                        oncommand="PanelUI.showSubView('appMenu-libraryView', this, null, event);"
                        closemenu="none"
+                       cui-areatype="toolbar"
                        label="&places.library.title;">
           <box class="toolbarbutton-animatable-box">
             <image class="toolbarbutton-animatable-image"/>
           </box>
         </toolbarbutton>
 
       </hbox>
 
--- a/browser/components/uitour/UITour.jsm
+++ b/browser/components/uitour/UITour.jsm
@@ -110,17 +110,23 @@ this.UITour = {
         return aDocument.getAnonymousElementByAttribute(statusButton,
                                                         "class",
                                                         "toolbarbutton-icon");
       },
       // This is a fake widgetName starting with the "appMenu-" prefix so we know
       // to automatically open the appMenu when annotating this target.
       widgetName: "appMenu-fxa-label",
     }],
-    ["addons",      {query: "#appMenu-addons-button"}],
+    ["addons",      {
+      query: (aDocument) => {
+        // select toolbar icon if exist, fallback to appMenu item
+        let node = aDocument.getElementById("add-ons-button");
+        return node ? node : aDocument.getElementById("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;
@@ -144,17 +150,23 @@ this.UITour = {
     }],
     ["forget", {
       allowAdd: true,
       query: "#panic-button",
       widgetName: "panic-button",
     }],
     ["help",        {query: "#appMenu-help-button"}],
     ["home",        {query: "#home-button"}],
-    ["library",     {query: "#appMenu-library-button"}],
+    ["library",     {
+      query: (aDocument) => {
+        // select toolbar icon if exist, fallback to appMenu item
+        let node = aDocument.getElementById("library-button");
+        return node ? node : aDocument.getElementById("appMenu-library-button");
+      },
+    }],
     ["pocket", {
       allowAdd: true,
       query: "#pocket-button",
     }],
     ["privateWindow", {query: "#appMenu-private-window-button"}],
     ["quit",        {query: "#appMenu-quit-button"}],
     ["readerMode-urlBar", {query: "#reader-mode-button"}],
     ["search",      {
--- a/browser/components/uitour/test/browser_UITour5.js
+++ b/browser/components/uitour/test/browser_UITour5.js
@@ -1,17 +1,51 @@
 "use strict";
 
 var gTestTab;
 var gContentAPI;
 var gContentWindow;
 
 add_task(setup_UITourTest);
 
+add_UITour_task(async function test_highlight_library_icon_in_toolbar() {
+  let highlight = document.getElementById("UITourHighlight");
+  is_element_hidden(highlight, "Highlight should initially be hidden");
+
+  // Test highlighting the library button
+  let highlightVisiblePromise = elementVisiblePromise(highlight, "Should show highlight");
+  gContentAPI.showHighlight("library");
+  await highlightVisiblePromise;
+  UITour.getTarget(window, "library").then((target) => {
+    is("library-button", target.node.id, "Should highlight the right target");
+  });
+});
+
+add_UITour_task(async function test_highlight_addons_icon_in_toolbar() {
+  CustomizableUI.addWidgetToArea("add-ons-button", CustomizableUI.AREA_NAVBAR, 0);
+  ok(!UITour.availableTargetsCache.has(window),
+     "Targets should be evicted from cache after widget change");
+  let highlight = document.getElementById("UITourHighlight");
+  is_element_hidden(highlight, "Highlight should initially be hidden");
+
+  // Test highlighting the addons button on toolbar
+  let highlightVisiblePromise = elementVisiblePromise(highlight, "Should show highlight");
+  gContentAPI.showHighlight("addons");
+  await highlightVisiblePromise;
+  UITour.getTarget(window, "addons").then((target) => {
+    is("add-ons-button", target.node.id, "Should highlight the right target");
+    CustomizableUI.removeWidgetFromArea("add-ons-button");
+  });
+});
+
 add_UITour_task(async function test_highlight_library_and_show_library_subview() {
+  CustomizableUI.removeWidgetFromArea("library-button");
+
+  ok(!UITour.availableTargetsCache.has(window),
+     "Targets should be evicted from cache after widget change");
   let highlight = document.getElementById("UITourHighlight");
   is_element_hidden(highlight, "Highlight should initially be hidden");
 
   // Test highlighting the library button
   let appMenu = PanelUI.panel;
   let appMenuShownPromise = promisePanelElementShown(window, appMenu);
   let highlightVisiblePromise = elementVisiblePromise(highlight, "Should show highlight");
   gContentAPI.showHighlight("library");
@@ -32,10 +66,11 @@ add_UITour_task(async function test_high
   is(PanelUI.multiView.current.id, "appMenu-libraryView", "Should show the library subview");
   is(appMenu.state, "open", "Should still open the app menu for the library subview");
 
   // Clean up
   let appMenuHiddenPromise = promisePanelElementHidden(window, appMenu);
   gContentAPI.hideMenu("appMenu");
   await appMenuHiddenPromise;
   is(appMenu.state, "closed", "Should close the app menu");
+  CustomizableUI.addWidgetToArea("library", CustomizableUI.AREA_NAVBAR, 0);
 });