Bug 1733428 - Toggle screenshots UI if screenshots toolbar button is pressed. r=sfoster

Differential Revision: https://phabricator.services.mozilla.com/D127893
This commit is contained in:
Niklas Baumgardner 2021-10-13 15:25:05 +00:00
parent 48a4be6ee9
commit 4dfb677424
5 changed files with 4 additions and 45 deletions

View File

@ -35,23 +35,10 @@ this.main = (function() {
}
}
function setIconActive(active) {
let windowIDPromise = browser.windows.getLastFocused().then(windowInfo => {
return windowInfo.id;
});
windowIDPromise.then(id => {
return browser.experiments.screenshots.setIcon(active, id);
});
}
function toggleSelector(tab) {
return analytics
.refreshTelemetryPref()
.then(() => selectorLoader.toggle(tab.id))
.then(active => {
setIconActive(active);
return active;
})
.catch(error => {
if (
error.message &&
@ -255,10 +242,6 @@ this.main = (function() {
});
});
communication.register("closeSelector", sender => {
setIconActive(false);
});
communication.register("abortStartShot", () => {
// Note, we only show the error but don't report it, as we know that we can't
// take shots of these pages:

View File

@ -35,13 +35,6 @@ this.screenshots = class extends ExtensionAPI {
isHistoryEnabled() {
return Services.prefs.getBoolPref("places.history.enabled", true);
},
setIcon: (isActive, windowId) => {
Services.obs.notifyObservers(
Services.wm.getOuterWindowWithId(windowId),
"toggle-screenshot-disable",
isActive
);
},
onScreenshotCommand: new EventManager({
context,
name: "experiments.screenshots.onScreenshotCommand",

View File

@ -16,22 +16,6 @@
"description": "Returns the value of the 'places.history.enabled' preference",
"parameters": [],
"async": true
},
{
"name": "setIcon",
"type": "function",
"description": "Disables or enables the screenshot toolbar button",
"parameters": [
{
"name": "isActive",
"type": "boolean"
},
{
"name": "windowId",
"type": "integer"
}
],
"async": false
}
],
"events": [

View File

@ -856,7 +856,6 @@ this.uicontrol = (function() {
try {
sendEvent("internal", "deactivate");
setState("cancel");
callBackground("closeSelector");
selectorLoader.unloadModules();
} catch (e) {
log.error("Error in deactivate", e);

View File

@ -49,10 +49,10 @@ add_task(async function test_disabledMultiWindow() {
"The screenshots button was added to the nav bar"
);
Assert.equal(
screenshotBtn.disabled,
true,
"Screenshots button is now disabled"
info("Waiting for the preselect UI");
await helper.waitForUIContent(
helper.selector.preselectIframe,
helper.selector.fullPageButton
);
let newWin = await BrowserTestUtils.openNewBrowserWindow();