Bug 1790855 - Enable screenshots button on about pages when screenshots component is enabled. r=sfoster
Differential Revision: https://phabricator.services.mozilla.com/D157355
This commit is contained in:
@@ -547,6 +547,34 @@ XPCOMUtils.defineLazyPreferenceGetter(
|
|||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
|
XPCOMUtils.defineLazyPreferenceGetter(
|
||||||
|
this,
|
||||||
|
"gScreenshotsDisabled",
|
||||||
|
"extensions.screenshots.disabled",
|
||||||
|
false,
|
||||||
|
() => {
|
||||||
|
Services.obs.notifyObservers(
|
||||||
|
window,
|
||||||
|
"toggle-screenshot-disable",
|
||||||
|
gScreenshots.shouldScreenshotsButtonBeDisabled()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
XPCOMUtils.defineLazyPreferenceGetter(
|
||||||
|
this,
|
||||||
|
"gScreenshotsComponentEnabled",
|
||||||
|
"screenshots.browser.component.enabled",
|
||||||
|
false,
|
||||||
|
() => {
|
||||||
|
Services.obs.notifyObservers(
|
||||||
|
window,
|
||||||
|
"toggle-screenshot-disable",
|
||||||
|
gScreenshots.shouldScreenshotsButtonBeDisabled()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
customElements.setElementCreationCallback("translation-notification", () => {
|
customElements.setElementCreationCallback("translation-notification", () => {
|
||||||
Services.scriptloader.loadSubScript(
|
Services.scriptloader.loadSubScript(
|
||||||
"chrome://browser/content/translation-notification.js",
|
"chrome://browser/content/translation-notification.js",
|
||||||
@@ -679,6 +707,25 @@ var gNavigatorBundle = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var gScreenshots = {
|
||||||
|
shouldScreenshotsButtonBeDisabled(uri) {
|
||||||
|
// About pages other than about:reader are not currently supported by
|
||||||
|
// the screenshots extension (see Bug 1620992).
|
||||||
|
let shouldBeDisabled;
|
||||||
|
if (uri) {
|
||||||
|
shouldBeDisabled =
|
||||||
|
gScreenshotsDisabled ||
|
||||||
|
(!gScreenshotsComponentEnabled &&
|
||||||
|
uri.scheme === "about" &&
|
||||||
|
!uri.spec.startsWith("about:reader"));
|
||||||
|
} else {
|
||||||
|
shouldBeDisabled = gScreenshotsDisabled || !gScreenshotsComponentEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
return shouldBeDisabled;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
function updateFxaToolbarMenu(enable, isInitialUpdate = false) {
|
function updateFxaToolbarMenu(enable, isInitialUpdate = false) {
|
||||||
// We only show the Firefox Account toolbar menu if the feature is enabled and
|
// We only show the Firefox Account toolbar menu if the feature is enabled and
|
||||||
// if sync is enabled.
|
// if sync is enabled.
|
||||||
@@ -5441,14 +5488,13 @@ var XULBrowserWindow = {
|
|||||||
closeOpenPanels("panel[locationspecific='true']");
|
closeOpenPanels("panel[locationspecific='true']");
|
||||||
}
|
}
|
||||||
|
|
||||||
// About pages other than about:reader are not currently supported by
|
let screenshotsButtonsDisabled = gScreenshots.shouldScreenshotsButtonBeDisabled(
|
||||||
// screenshots (see Bug 1620992).
|
aLocationURI
|
||||||
|
);
|
||||||
Services.obs.notifyObservers(
|
Services.obs.notifyObservers(
|
||||||
window,
|
window,
|
||||||
"toggle-screenshot-disable",
|
"toggle-screenshot-disable",
|
||||||
(aLocationURI.scheme == "about" &&
|
screenshotsButtonsDisabled
|
||||||
!aLocationURI.spec.startsWith("about:reader")) ||
|
|
||||||
Services.prefs.getBoolPref("extensions.screenshots.disabled")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
gPermissionPanel.onLocationChange();
|
gPermissionPanel.onLocationChange();
|
||||||
|
|||||||
@@ -1280,8 +1280,7 @@ class nsContextMenu {
|
|||||||
// screenshots (see Bug 1620992)
|
// screenshots (see Bug 1620992)
|
||||||
let uri = this.contentData?.documentURIObject;
|
let uri = this.contentData?.documentURIObject;
|
||||||
let shouldShow =
|
let shouldShow =
|
||||||
!screenshotsDisabled &&
|
!gScreenshots.shouldScreenshotsButtonBeDisabled(uri) &&
|
||||||
(uri.scheme != "about" || uri.spec.startsWith("about:reader")) &&
|
|
||||||
this.inTabBrowser &&
|
this.inTabBrowser &&
|
||||||
!this.onTextInput &&
|
!this.onTextInput &&
|
||||||
!this.onLink &&
|
!this.onLink &&
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ add_task(async function testScreenshotButtonDisabled() {
|
|||||||
await BrowserTestUtils.withNewTab("about:home", () => {
|
await BrowserTestUtils.withNewTab("about:home", () => {
|
||||||
Assert.equal(
|
Assert.equal(
|
||||||
screenshotBtn.disabled,
|
screenshotBtn.disabled,
|
||||||
true,
|
false,
|
||||||
"Screenshots button is now disabled"
|
"Screenshots button is still enabled on about pages"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user