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