diff --git a/webextensions/background/background-cache.js b/webextensions/background/background-cache.js index 947f5f3c7..df0cdd9b4 100644 --- a/webextensions/background/background-cache.js +++ b/webextensions/background/background-cache.js @@ -375,7 +375,7 @@ export async function reserveToCacheTree(windowId) { return; const win = TabsStore.windows.get(windowId); - if (!window) + if (!win) return; // If there is any opening (but not resolved its unique id yet) tab, diff --git a/webextensions/background/commands.js b/webextensions/background/commands.js index 8fb38462e..50aed0aa4 100644 --- a/webextensions/background/commands.js +++ b/webextensions/background/commands.js @@ -550,11 +550,11 @@ export async function moveTabsWithStructure(tabs, params = {}) { } if (params.import) { - const window = TabsStore.windows.get(destinationWindowId); + const win = TabsStore.windows.get(destinationWindowId); const initialIndex = params.insertBefore ? params.insertBefore.index : params.insertAfter ? params.insertAfter.index+1 : - window.tabs.size; - window.toBeOpenedOrphanTabs += tabs.length; + win.tabs.size; + win.toBeOpenedOrphanTabs += tabs.length; movedTabs = []; let index = 0; for (const tab of tabs) { @@ -919,8 +919,8 @@ export async function openTabInWindow(tab, options = {}) { tabId: tab.id, ...getWindowParamsFromSource(sourceWindow, options), }; - const window = await browser.windows.create(windowParams).catch(ApiTabs.createErrorHandler()); - return window.id; + const win = await browser.windows.create(windowParams).catch(ApiTabs.createErrorHandler()); + return win.id; } } @@ -1286,9 +1286,9 @@ Sync.onMessage.addListener(async message => { }); const windowId = TabsStore.getCurrentWindowId() || (await browser.windows.getCurrent()).id; - const window = TabsStore.windows.get(windowId); - const initialIndex = window.tabs.size; - window.toBeOpenedOrphanTabs += data.tabs.length; + const win = TabsStore.windows.get(windowId); + const initialIndex = win.tabs.size; + win.toBeOpenedOrphanTabs += data.tabs.length; let index = 0; const tabs = []; for (const tab of data.tabs) { diff --git a/webextensions/common/tabs-store.js b/webextensions/common/tabs-store.js index 169654854..d1016aaf8 100644 --- a/webextensions/common/tabs-store.js +++ b/webextensions/common/tabs-store.js @@ -78,10 +78,10 @@ export function queryAll(query) { const startAt = Date.now(); if (query.windowId || query.ordered) { let tabs = []; - for (const window of windows.values()) { - if (query.windowId && !matched(window.id, query.windowId)) + for (const win of windows.values()) { + if (query.windowId && !matched(win.id, query.windowId)) continue; - const [sourceTabs, offset] = sourceTabsForQuery(query, window); + const [sourceTabs, offset] = sourceTabsForQuery(query, win); tabs = tabs.concat(query.iterator ? getMatchedTabsIterator(sourceTabs, query, offset) : extractMatchedTabs(sourceTabs, query, offset)); } query.elapsed = Date.now() - startAt; @@ -106,30 +106,30 @@ export function queryAll(query) { } } -function sourceTabsForQuery(query, window) { +function sourceTabsForQuery(query, win) { let offset = 0; if (!query.ordered) - return [query.tabs && query.tabs.values() || window.tabs.values(), offset]; + return [query.tabs && query.tabs.values() || win.tabs.values(), offset]; let fromId; let toId = query.toId; if (typeof query.index == 'number') { - fromId = window.order[query.index]; + fromId = win.order[query.index]; offset = query.index; } if (typeof query.fromIndex == 'number') { - fromId = window.order[query.fromIndex]; + fromId = win.order[query.fromIndex]; offset = query.fromIndex; } if (typeof query.toIndex == 'number') { - toId = window.order[query.toIndex]; + toId = win.order[query.toIndex]; } if (typeof fromId != 'number') { fromId = query.fromId; - offset = window.order.indexOf(query.fromId); + offset = win.order.indexOf(query.fromId); } if (query.last || query.reversed) - return [window.getReversedOrderedTabs(fromId, toId, query.tabs), offset]; - return [window.getOrderedTabs(fromId, toId, query.tabs), offset]; + return [win.getReversedOrderedTabs(fromId, toId, query.tabs), offset]; + return [win.getOrderedTabs(fromId, toId, query.tabs), offset]; } function extractMatchedTabs(tabs, query, offset) { @@ -283,10 +283,10 @@ export function query(query) { const startAt = Date.now(); let tabs = []; if (query.windowId || query.ordered) { - for (const window of windows.values()) { - if (query.windowId && !matched(window.id, query.windowId)) + for (const win of windows.values()) { + if (query.windowId && !matched(win.id, query.windowId)) continue; - const [sourceTabs, offset] = sourceTabsForQuery(query, window); + const [sourceTabs, offset] = sourceTabsForQuery(query, win); tabs = tabs.concat(extractMatchedTabs(sourceTabs, query, offset)); if (tabs.length > 0) break; diff --git a/webextensions/sidebar/gap-canceller.js b/webextensions/sidebar/gap-canceller.js index be93cb0e4..5b44fed0e 100644 --- a/webextensions/sidebar/gap-canceller.js +++ b/webextensions/sidebar/gap-canceller.js @@ -148,8 +148,8 @@ function updateOffset() { } mLastWindowDimension = dimension; mLastMozInnerScreenY = window.mozInnerScreenY; - browser.windows.get(mWindowId).then(window => { - mDataset.ownerWindowState = window.state; + browser.windows.get(mWindowId).then(win => { + mDataset.ownerWindowState = win.state; }); }