Bug 1725430: disable screenshot shortcut for extension when screenshots.browser.component.enabled is true. r=emalysz,fluent-reviewers,flod
Differential Revision: https://phabricator.services.mozilla.com/D125850
This commit is contained in:
@@ -74,7 +74,7 @@ this.main = (function() {
|
||||
_startShotFlow(tab, "context-menu");
|
||||
});
|
||||
|
||||
exports.onCommand = catcher.watchFunction(tab => {
|
||||
exports.onShortcut = catcher.watchFunction(tab => {
|
||||
_startShotFlow(tab, "keyboard-shortcut");
|
||||
});
|
||||
|
||||
|
||||
@@ -64,47 +64,26 @@ this.startBackground = (function() {
|
||||
];
|
||||
|
||||
browser.experiments.screenshots.onScreenshotCommand.addListener(
|
||||
async isContextMenuClick => {
|
||||
async type => {
|
||||
try {
|
||||
let [[tab]] = await Promise.all([
|
||||
browser.tabs.query({ currentWindow: true, active: true }),
|
||||
loadIfNecessary(),
|
||||
]);
|
||||
zoomFactor = await browser.tabs.getZoom(tab.id);
|
||||
isContextMenuClick
|
||||
? main.onClickedContextMenu(tab)
|
||||
: main.onClicked(tab);
|
||||
if (type === "contextMenu") {
|
||||
main.onClickedContextMenu(tab);
|
||||
} else if (type === "toolbar") {
|
||||
main.onClicked(tab);
|
||||
} else if (type === "shortcut") {
|
||||
main.onShortcut(tab);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error loading Screenshots:", error);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
browser.commands.onCommand.addListener(cmd => {
|
||||
if (cmd !== "take-screenshot") {
|
||||
return;
|
||||
}
|
||||
loadIfNecessary()
|
||||
.then(() => {
|
||||
browser.tabs
|
||||
.query({ currentWindow: true, active: true })
|
||||
.then(async tabs => {
|
||||
const activeTab = tabs[0];
|
||||
zoomFactor = await browser.tabs.getZoom(activeTab.id);
|
||||
main.onCommand(activeTab);
|
||||
})
|
||||
.catch(error => {
|
||||
throw error;
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(
|
||||
"Error toggling Screenshots via keyboard shortcut: ",
|
||||
error
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
browser.runtime.onMessage.addListener((req, sender, sendResponse) => {
|
||||
loadIfNecessary()
|
||||
.then(() => {
|
||||
|
||||
@@ -47,8 +47,8 @@ this.screenshots = class extends ExtensionAPI {
|
||||
name: "experiments.screenshots.onScreenshotCommand",
|
||||
register: fire => {
|
||||
let observer = (subject, topic, data) => {
|
||||
let isContexMenuClick = data;
|
||||
fire.sync(isContexMenuClick);
|
||||
let type = data;
|
||||
fire.sync(type);
|
||||
};
|
||||
Services.obs.addObserver(observer, TOPIC);
|
||||
return () => {
|
||||
|
||||
@@ -18,14 +18,6 @@
|
||||
"background/startBackground.js"
|
||||
]
|
||||
},
|
||||
"commands": {
|
||||
"take-screenshot": {
|
||||
"suggested_key": {
|
||||
"default": "Ctrl+Shift+S"
|
||||
},
|
||||
"description": "Open the Firefox Screenshots UI"
|
||||
}
|
||||
},
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["https://screenshots.firefox.com/*"],
|
||||
|
||||
@@ -65,7 +65,13 @@ add_task(async function test_inject_srcdoc() {
|
||||
});
|
||||
|
||||
// Now try to start the screenshot flow:
|
||||
document.querySelector("keyset[id*=screenshot] > key").doCommand();
|
||||
CustomizableUI.addWidgetToArea(
|
||||
"screenshot-button",
|
||||
CustomizableUI.AREA_NAVBAR
|
||||
);
|
||||
|
||||
let screenshotBtn = document.getElementById("screenshot-button");
|
||||
screenshotBtn.click();
|
||||
await Promise.race([errorPromise, responsePromise]);
|
||||
ok(error, "Should get the relevant error: " + error?.message);
|
||||
ok(!response, "Should not get a response from the webpage.");
|
||||
|
||||
Reference in New Issue
Block a user