Bug 1371543 - Support Screenshots page action with UITour, r=dveditz,Gijs
☠☠ backed out by cd88f7fba8bd ☠ ☠
authorFischer.json <fischer.json@gmail.com>
Wed, 30 Aug 2017 11:25:59 +0800
changeset 379680 34db5bec9cad5bd0b83235b3d1a9ea1ebce8692a
parent 379679 d12b61881a56d3ba674dc83aca671f35fc511b26
child 379681 404a3fe96ab028d5aea5a811388f1ffbb5701297
push id32461
push userkwierso@gmail.com
push dateFri, 08 Sep 2017 20:15:32 +0000
treeherdermozilla-central@dd3736e98e4e [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,28 @@ function getExpectedTargets() {
     "pageAction-bookmark",
     "pageAction-copyURL",
     "pageAction-emailLink",
     "pageAction-sendToDevice",
       ...(hasPocket ? ["pocket"] : []),
     "privateWindow",
       ...(hasQuit ? ["quit"] : []),
     "readerMode-urlBar",
+    "screenshots",
+    "search",
+    "searchIcon",
     "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 +79,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 +99,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 +151,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");
+}