Fix window focus not always working
This commit is contained in:
parent
7abc7fd0e7
commit
ce92591b63
@ -367,7 +367,19 @@ async function apiFindTab(timeout, checkUrl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function apiFocusTab(tab) {
|
async function apiFocusTab(tab) {
|
||||||
if (typeof chrome.windows === 'object' && chrome.windows !== null) {
|
await new Promise((resolve, reject) => {
|
||||||
|
chrome.tabs.update(tab.id, {active: true}, () => {
|
||||||
|
const e = chrome.runtime.lastError;
|
||||||
|
if (e) { reject(e); }
|
||||||
|
else { resolve(); }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!(typeof chrome.windows === 'object' && chrome.windows !== null)) {
|
||||||
|
// Windows not supported (e.g. on Firefox mobile)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const tabWindow = await new Promise((resolve) => {
|
const tabWindow = await new Promise((resolve) => {
|
||||||
chrome.windows.get(tab.windowId, {}, (tabWindow) => {
|
chrome.windows.get(tab.windowId, {}, (tabWindow) => {
|
||||||
const e = chrome.runtime.lastError;
|
const e = chrome.runtime.lastError;
|
||||||
@ -385,11 +397,3 @@ async function apiFocusTab(tab) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await new Promise((resolve, reject) => {
|
|
||||||
chrome.tabs.update(tab.id, {active: true}, () => {
|
|
||||||
const e = chrome.runtime.lastError;
|
|
||||||
if (e) { reject(e); }
|
|
||||||
else { resolve(); }
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user