Bug 1374563 - Enable highlighting screenshot widget by UITour. r=Gijs draft
authorRex Lee <rexboy@mozilla.com>
Mon, 19 Jun 2017 12:50:03 +0800
changeset 597189 c83f8ad1f99a338061d1a23b6e200f9f9dfecae2
parent 596219 95543bdc59bd038a3d5d084b85a4fec493c349ee
child 634170 5929e01fd8848909afc18c3f6d50094833acac5d
push id64867
push userbmo:rexboy@mozilla.com
push dateTue, 20 Jun 2017 08:36:07 +0000
reviewersGijs
bugs1374563
milestone56.0a1
Bug 1374563 - Enable highlighting screenshot widget by UITour. r=Gijs MozReview-Commit-ID: JKklfpuW5pj
browser/components/uitour/UITour-lib.js
browser/components/uitour/UITour.jsm
browser/components/uitour/test/browser_UITour_availableTargets.js
--- a/browser/components/uitour/UITour-lib.js
+++ b/browser/components/uitour/UITour-lib.js
@@ -117,16 +117,17 @@ if (typeof Mozilla == "undefined") {
    * <li>readerMode-urlBar
    * <li>search
    * <li>searchIcon
    * <li>searchPrefsLink
    * <li>selectedTabIcon
    * <li>trackingProtection
    * <li>urlbar
    * <li>webide
+   * <li>screenshot
    * </ul>
    *
    * Generate using the following in the Browser Console:
    * <code>`[...UITour.targets.keys()].join("\n* &lt;li&gt;")`</code>
    */
 
   /**
    * Ensure the browser is ready to handle this document as a tour.
--- a/browser/components/uitour/UITour.jsm
+++ b/browser/components/uitour/UITour.jsm
@@ -250,16 +250,21 @@ this.UITour = {
     }],
     ["trackingProtection", {
       query: "#tracking-protection-icon",
     }],
     ["urlbar",      {
       query: "#urlbar",
       widgetName: "urlbar-container",
     }],
+    ["screenshot", {
+      allowAdd: true,
+      query: "#screenshots_mozilla_org-browser-action",
+      widgetName: "screenshots_mozilla_org-browser-action",
+    }],
   ]),
 
   init() {
     log.debug("Initializing UITour");
     // Lazy getter is initialized here so it can be replicated any time
     // in a test.
     delete this.seenPageIDs;
     Object.defineProperty(this, "seenPageIDs", {
--- a/browser/components/uitour/test/browser_UITour_availableTargets.js
+++ b/browser/components/uitour/test/browser_UITour_availableTargets.js
@@ -4,16 +4,18 @@ 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 hasScreenshot = !Services.prefs.getBoolPref("extensions.screenshots.system-disabled") &&
+                    !Services.prefs.getBoolPref("extensions.screenshots.disabled");
 
 requestLongerTimeout(2);
 add_task(setup_UITourTest);
 
 add_UITour_task(async function test_availableTargets() {
   let data = await getConfigurationPromise("availableTargets");
   ok_targets(data, [
     "accountStatus",
@@ -25,16 +27,17 @@ add_UITour_task(async function test_avai
     "devtools",
     "help",
     "home",
       ...(hasLibrary ? ["library"] : []),
       ...(hasPocket ? ["pocket"] : []),
     "privateWindow",
       ...(hasQuit ? ["quit"] : []),
     "readerMode-urlBar",
+      ...(hasScreenshot ? ["screenshot"] : []),
     "search",
     "searchIcon",
     "trackingProtection",
     "urlbar",
   ]);
 
   ok(UITour.availableTargetsCache.has(window),
      "Targets should now be cached");
@@ -54,25 +57,31 @@ add_UITour_task(async function test_avai
     "help",
     "devtools",
     "home",
       ...(hasLibrary ? ["library"] : []),
       ...(hasPocket ? ["pocket"] : []),
     "privateWindow",
       ...(hasQuit ? ["quit"] : []),
     "readerMode-urlBar",
+      ...(hasScreenshot ? ["screenshot"] : []),
     "search",
     "searchIcon",
     "trackingProtection",
     "urlbar",
   ]);
 
   ok(UITour.availableTargetsCache.has(window),
      "Targets should now be cached again");
   CustomizableUI.reset();
+  // Resetting UI gets rid of screenshot which is not in the default set. It
+  // needs to be added back manually.
+  if (hasScreenshot) {
+    CustomizableUI.addWidgetToArea("screenshots_mozilla_org-browser-action", CustomizableUI.AREA_NAVBAR);
+  }
   ok(!UITour.availableTargetsCache.has(window),
      "Targets should not be cached after reset");
 });
 
 add_UITour_task(async function test_availableTargets_exceptionFromGetTarget() {
   // The query function for the "search" target will throw if it's not found.
   // Make sure the callback still fires with the other available targets.
   CustomizableUI.removeWidgetFromArea("search-container");
@@ -88,21 +97,28 @@ add_UITour_task(async function test_avai
     "devtools",
     "help",
     "home",
       ...(hasLibrary ? ["library"] : []),
       ...(hasPocket ? ["pocket"] : []),
     "privateWindow",
       ...(hasQuit ? ["quit"] : []),
     "readerMode-urlBar",
+      ...(hasScreenshot ? ["screenshot"] : []),
     "trackingProtection",
     "urlbar",
   ]);
 
   CustomizableUI.reset();
+  // Resetting UI gets rid of screenshot which is not in the default set. It
+  // needs to be added back manually.
+  if (hasScreenshot) {
+    CustomizableUI.addWidgetToArea("screenshots_mozilla_org-browser-action", CustomizableUI.AREA_NAVBAR);
+  }
+
 });
 
 function ok_targets(actualData, expectedTargets) {
   // Depending on how soon after page load this is called, the selected tab icon
   // may or may not be showing the loading throbber.  Check for its presence and
   // insert it into expectedTargets if it's visible.
   let selectedTabIcon =
     document.getAnonymousElementByAttribute(gBrowser.selectedTab,