Bug 1374563 - Enable highlighting screenshot widget by UITour. r=Gijs
MozReview-Commit-ID: JKklfpuW5pj
--- 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* <li>")`</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,