Skip to content

Commit

Permalink
Improved currentTab impl
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Sep 21, 2016
1 parent 30a7036 commit f4cf966
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions lighthouse-core/gather/drivers/extension.js
Expand Up @@ -130,19 +130,23 @@ class ExtensionDriver extends Driver {
}

queryCurrentTab_() {
const currentTab = {
active: true,
windowId: chrome.windows.WINDOW_ID_CURRENT
};

return new Promise((resolve, reject) => {
chrome.tabs.query(currentTab, tabs => {
const queryOpts = {
active: true,
lastFocusedWindow: true,
windowType: 'normal'
};

chrome.tabs.query(queryOpts, (tabs => {
if (chrome.runtime.lastError) {
return reject(chrome.runtime.lastError);
}

if (tabs.length === 0) {
const message = 'Couldn\'t resolve current tab. Please file a bug.';
return reject(new Error(message));
}
resolve(tabs[0]);
});
}));
});
}

Expand Down

0 comments on commit f4cf966

Please sign in to comment.