Validate chrome.windows exists before usage
This commit is contained in:
parent
ffb6ff9325
commit
205498ef3b
@ -367,21 +367,23 @@ async function apiFindTab(timeout, checkUrl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function apiFocusTab(tab) {
|
async function apiFocusTab(tab) {
|
||||||
const tabWindow = await new Promise((resolve) => {
|
if (typeof chrome.windows === 'object' && chrome.windows !== null) {
|
||||||
chrome.windows.get(tab.windowId, {}, (tabWindow) => {
|
const tabWindow = await new Promise((resolve) => {
|
||||||
const e = chrome.runtime.lastError;
|
chrome.windows.get(tab.windowId, {}, (tabWindow) => {
|
||||||
if (e) { reject(e); }
|
|
||||||
else { resolve(tabWindow); }
|
|
||||||
});
|
|
||||||
});
|
|
||||||
if (!tabWindow.focused) {
|
|
||||||
await new Promise((resolve, reject) => {
|
|
||||||
chrome.windows.update(tab.windowId, {focused: true}, () => {
|
|
||||||
const e = chrome.runtime.lastError;
|
const e = chrome.runtime.lastError;
|
||||||
if (e) { reject(e); }
|
if (e) { reject(e); }
|
||||||
else { resolve(); }
|
else { resolve(tabWindow); }
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
if (!tabWindow.focused) {
|
||||||
|
await new Promise((resolve, reject) => {
|
||||||
|
chrome.windows.update(tab.windowId, {focused: true}, () => {
|
||||||
|
const e = chrome.runtime.lastError;
|
||||||
|
if (e) { reject(e); }
|
||||||
|
else { resolve(); }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
chrome.tabs.update(tab.id, {active: true}, () => {
|
chrome.tabs.update(tab.id, {active: true}, () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user