Use currentWindow instead of lastFocusedWindow to initialize browserAction and its surrogate windows.

This commit is contained in:
hackademix 2022-03-13 23:09:03 +01:00
parent 4c6672bb21
commit 072c28e684
3 changed files with 8 additions and 7 deletions

View File

@ -189,9 +189,8 @@
},
async openStandalonePopup() {
let win = await browser.windows.getLastFocused();
let [tab] = (await browser.tabs.query({
lastFocusedWindow: true,
currentWindow: true,
active: true
}));
@ -199,6 +198,7 @@
log("No tab found to open the UI for");
return;
}
let win = await browser.windows.getCurrent();
browser.windows.create({
url: popupFor(tab.id),
width: 800,

View File

@ -45,11 +45,11 @@ addEventListener("unload", e => {
try {
let tabId;
let isBrowserAction = true;
UI.isBrowserAction = true;
let optionsClosed = false;
let tabFlags = {active: true};
if (browser.windows) tabFlags.lastFocusedWindow = true; // Desktop browsers only
if (browser.windows) tabFlags.currentWindow = true; // Desktop browsers only
let tab = (await browser.tabs.query(tabFlags))[0] ||
// work-around for Firefox "forgetting" tabs on Android
(await browser.tabs.query({url: ["*://*/*", "file:///*", "ftp://*/*"]}))[0];
@ -61,7 +61,7 @@ addEventListener("unload", e => {
close();
}
if (tab.url === document.URL) {
isBrowserAction = false;
UI.isBrowserAction = false;
try {
tabId = parseInt(document.URL.match(/#.*\btab(\d+)/)[1]);
pageTab = await browser.tabs.get(tabId);
@ -94,7 +94,7 @@ addEventListener("unload", e => {
}
if (isBrowserAction) {
if (UI.isBrowserAction) {
browser.tabs.onActivated.addListener(e => {
if (e.tabId !== tabId) close();
});
@ -387,7 +387,7 @@ addEventListener("unload", e => {
}
function close() {
if (isBrowserAction) {
if (UI.isBrowserAction) {
window.close();
} else {
browser.tabs.remove(tab.id);

View File

@ -23,6 +23,7 @@ var UI = (() => {
var UI = {
initialized: false,
isBrowserAction: false,
presets: {
"DEFAULT": "Default",