Bug 1371543 - Support Screenshots page action with UITour, r=dveditz,Gijs
authorFischer.json <fischer.json@gmail.com>
Wed, 30 Aug 2017 11:25:59 +0800
changeset 379750 6f6a270a020f26f88c6ee099de86073f00ac84c1
parent 379749 0d384af83d69bd3a553bb34a698e0665cd9cbeeb
child 379751 0a49941e45a5d58b01051b4283d4bd1fff7aadd1
push id50776
push userryanvm@gmail.com
push dateFri, 08 Sep 2017 15:01:07 +0000
treeherderautoland@6f6a270a020f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdveditz, Gijs
bugs1371543, 1393668
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 1371543 - Support Screenshots page action with UITour, r=dveditz,Gijs This patch - supports Screenshots page action with UITour - adds https://screenshots.firefox.com into the uitour permission list for the bug 1393668 MozReview-Commit-ID: K4v0LU2WSyl
browser/app/permissions
browser/components/uitour/UITour-lib.js
browser/components/uitour/UITour.jsm
browser/components/uitour/test/browser_UITour_availableTargets.js
--- a/browser/app/permissions
+++ b/browser/app/permissions
@@ -3,16 +3,17 @@
 # * matchtype \t type \t permission \t host
 # * "origin" should be used for matchtype, "host" is supported for legacy reasons
 # * type is a string that identifies the type of permission (e.g. "cookie")
 # * permission is an integer between 1 and 15
 # See nsPermissionManager.cpp for more...
 
 # UITour
 origin	uitour	1	https://www.mozilla.org
+origin	uitour	1	https://screenshots.firefox.com
 origin	uitour	1	https://support.mozilla.org
 origin	uitour	1	https://addons.mozilla.org
 origin	uitour	1	https://discovery.addons.mozilla.org
 origin	uitour	1	about:home
 origin	uitour	1	about:newtab
 
 # XPInstall
 origin	install	1	https://addons.mozilla.org
--- a/browser/components/uitour/UITour-lib.js
+++ b/browser/components/uitour/UITour-lib.js
@@ -115,16 +115,17 @@ if (typeof Mozilla == "undefined") {
    * <li>pageAction-bookmark
    * <li>pageAction-copyURL
    * <li>pageAction-emailLink
    * <li>pageAction-sendToDevice
    * <li>pocket
    * <li>privateWindow
    * <li>quit
    * <li>readerMode-urlBar
+   * <li>screenshots
    * <li>search
    * <li>searchIcon
    * <li>searchPrefsLink
    * <li>selectedTabIcon
    * <li>trackingProtection
    * <li>urlbar
    * <li>webide
    * </ul>
--- a/browser/components/uitour/UITour.jsm
+++ b/browser/components/uitour/UITour.jsm
@@ -252,16 +252,22 @@ this.UITour = {
                aDocument.getElementById("pageAction-panel-emailLink");
       },
     }],
     ["pageAction-sendToDevice", {
       query: (aDocument) => {
         return aDocument.getElementById("pageAction-urlbar-sendToDevice") ||
                aDocument.getElementById("pageAction-panel-sendToDevice");
       },
+    }],
+    ["screenshots", {
+      query: (aDocument) => {
+        return aDocument.getElementById("pageAction-urlbar-screenshots") ||
+               aDocument.getElementById("pageAction-panel-screenshots");
+      },
     }]
   ]),
 
   init() {
     log.debug("Initializing UITour");
     // Lazy getter is initialized here so it can be replicated any time
     // in a test.
     delete this.seenPageIDs;
--- a/browser/components/uitour/test/browser_UITour_availableTargets.js
+++ b/browser/components/uitour/test/browser_UITour_availableTargets.js
@@ -24,24 +24,26 @@ function getExpectedTargets() {
     "pageAction-bookmark",
     "pageAction-copyURL",
     "pageAction-emailLink",
     "pageAction-sendToDevice",
       ...(hasPocket ? ["pocket"] : []),
     "privateWindow",
       ...(hasQuit ? ["quit"] : []),
     "readerMode-urlBar",
+    "screenshots",
     "trackingProtection",
     "urlbar",
   ];
 }
 
 add_task(setup_UITourTest);
 
 add_UITour_task(async function test_availableTargets() {
+  await ensureScreenshotsEnabled();
   let data = await getConfigurationPromise("availableTargets");
   let expecteds = getExpectedTargets();
   ok_targets(data, expecteds);
   ok(UITour.availableTargetsCache.has(window),
      "Targets should now be cached");
 });
 
 add_UITour_task(async function test_availableTargets_changeWidgets() {
@@ -75,16 +77,17 @@ add_UITour_task(async function test_avai
 add_UITour_task(async function test_availableTargets_removeUrlbarPageActionsAll() {
   pageActionsHelper.setActionsUrlbarState(false);
   UITour.clearAvailableTargetsCache();
   let data = await getConfigurationPromise("availableTargets");
   let expecteds = getExpectedTargets();
   ok_targets(data, expecteds);
   let expectedActions = [
     [ "pocket", "pageAction-panel-pocket" ],
+    [ "screenshots", "pageAction-panel-screenshots" ],
     [ "pageAction-bookmark", "pageAction-panel-bookmark" ],
     [ "pageAction-copyURL", "pageAction-panel-copyURL" ],
     [ "pageAction-emailLink", "pageAction-panel-emailLink" ],
     [ "pageAction-sendToDevice", "pageAction-panel-sendToDevice" ],
   ];
   for (let [ targetName, expectedNodeId ] of expectedActions) {
     await assertTargetNode(targetName, expectedNodeId);
   }
@@ -94,16 +97,17 @@ add_UITour_task(async function test_avai
 add_UITour_task(async function test_availableTargets_addUrlbarPageActionsAll() {
   pageActionsHelper.setActionsUrlbarState(true);
   UITour.clearAvailableTargetsCache();
   let data = await getConfigurationPromise("availableTargets");
   let expecteds = getExpectedTargets();
   ok_targets(data, expecteds);
   let expectedActions = [
     [ "pocket", "pocket-button-box" ],
+    [ "screenshots", "pageAction-urlbar-screenshots" ],
     [ "pageAction-bookmark", "star-button-box" ],
     [ "pageAction-copyURL", "pageAction-urlbar-copyURL" ],
     [ "pageAction-emailLink", "pageAction-urlbar-emailLink" ],
     [ "pageAction-sendToDevice", "pageAction-urlbar-sendToDevice" ],
   ];
   for (let [ targetName, expectedNodeId ] of expectedActions) {
     await assertTargetNode(targetName, expectedNodeId);
   }
@@ -145,8 +149,19 @@ var pageActionsHelper = {
       return;
     }
     for (let [ action, originalState] of this._originalStates) {
       action.shownInUrlbar = originalState;
     }
     this._originalStates = null;
   }
 };
+
+function ensureScreenshotsEnabled() {
+  SpecialPowers.pushPrefEnv({ set: [
+    [ "extensions.screenshots.system", false ],
+    [ "extensions.screenshots.system-disabled", false ]
+  ]});
+  return BrowserTestUtils.waitForCondition(() => {
+    return PageActions.actionForID("screenshots") &&
+           !CustomizableUI.getWidget("screenshots_mozilla_org-browser-action");
+  }, "Should enable Screenshots");
+}