Extension shouldn't be enabled in pb mode as it's currently not working in many places. Fixes #756

This commit is contained in:
Jonathan Kingston 2017-08-23 15:23:49 +01:00
parent 29f078d2c9
commit 70573d0559
3 changed files with 29 additions and 18 deletions

View file

@ -1,9 +1,15 @@
const MAJOR_VERSIONS = ["2.3.0", "2.4.0"]; const MAJOR_VERSIONS = ["2.3.0", "2.4.0"];
const badge = { const badge = {
init() { async init() {
this.displayBrowserActionBadge(); const currentWindow = await browser.windows.getCurrent();
this.displayBrowserActionBadge(currentWindow.incognito);
}, },
async displayBrowserActionBadge() { async displayBrowserActionBadge(disable) {
if (disable) {
browser.browserAction.disable();
} else {
browser.browserAction.enable();
}
const extensionInfo = await backgroundLogic.getExtensionInfo(); const extensionInfo = await backgroundLogic.getExtensionInfo();
const storage = await browser.storage.local.get({browserActionBadgesClicked: []}); const storage = await browser.storage.local.get({browserActionBadgesClicked: []});

View file

@ -109,20 +109,7 @@ const messageHandler = {
}); });
browser.windows.onFocusChanged.addListener((windowId) => { browser.windows.onFocusChanged.addListener((windowId) => {
assignManager.removeContextMenu(); this.onFocusChangedCallback(windowId);
// browserAction loses background color in new windows ...
// https://bugzil.la/1314674
// https://github.com/mozilla/testpilot-containers/issues/608
// ... so re-call displayBrowserActionBadge on window changes
badge.displayBrowserActionBadge();
browser.tabs.query({active: true, windowId}).then((tabs) => {
if (tabs && tabs[0]) {
tabPageCounter.initTabCounter(tabs[0]);
assignManager.calculateContextMenu(tabs[0]);
}
}).catch((e) => {
throw e;
});
}); });
browser.idle.onStateChanged.addListener((newState) => { browser.idle.onStateChanged.addListener((newState) => {
@ -161,6 +148,24 @@ const messageHandler = {
}, this.LAST_CREATED_TAB_TIMER); }, this.LAST_CREATED_TAB_TIMER);
}); });
},
async onFocusChangedCallback(windowId) {
assignManager.removeContextMenu();
const currentWindow = await browser.windows.getCurrent();
// browserAction loses background color in new windows ...
// https://bugzil.la/1314674
// https://github.com/mozilla/testpilot-containers/issues/608
// ... so re-call displayBrowserActionBadge on window changes
badge.displayBrowserActionBadge(currentWindow.incognito);
browser.tabs.query({active: true, windowId}).then((tabs) => {
if (tabs && tabs[0]) {
tabPageCounter.initTabCounter(tabs[0]);
assignManager.calculateContextMenu(tabs[0]);
}
}).catch((e) => {
throw e;
});
} }
}; };

View file

@ -451,7 +451,7 @@ Logic.registerPanel(P_CONTAINERS_LIST, {
panelSelector: "#container-panel", panelSelector: "#container-panel",
// This method is called when the object is registered. // This method is called when the object is registered.
initialize() { async initialize() {
Logic.addEnterHandler(document.querySelector("#container-add-link"), () => { Logic.addEnterHandler(document.querySelector("#container-add-link"), () => {
Logic.showPanel(P_CONTAINER_EDIT, { name: Logic.generateIdentityName() }); Logic.showPanel(P_CONTAINER_EDIT, { name: Logic.generateIdentityName() });
}); });