Skip to content

Commit

Permalink
Review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
wardpeet committed Sep 17, 2016
1 parent 9ddb408 commit 6dc888a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
2 changes: 2 additions & 0 deletions lighthouse-cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ function lighthouseRun(addresses) {
.catch(err => {
if (err.code === 'ECONNREFUSED') {
showConnectionError();
} else if (err.message.toLowerCase().includes('multiple tabs')) {
console.error(err.message);
} else if (err) {
showRuntimeError(err);
}
Expand Down
6 changes: 3 additions & 3 deletions lighthouse-core/gather/drivers/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class Driver {
return Promise.all([getRegistrations, getVersions, getActiveTabId]).then(res => {
const registrations = res[0].registrations;
const versions = res[1].versions;
const activePageId = res[2];
const activeTabId = res[2];
const parsedURL = parseURL(pageUrl);
const origin = `${parsedURL.protocol}//${parsedURL.hostname}` +
(parsedURL.port ? `:${parsedURL.port}` : '');
Expand Down Expand Up @@ -273,15 +273,15 @@ class Driver {

const multipleTabsAttached = ver.controlledClients.length > 1;
const oneInactiveTabIsAttached = ver.controlledClients.length === 1 &&
!ver.controlledClients.find(sw => sw === activePageId);
!ver.controlledClients.find(client => client === activeTabId);

return multipleTabsAttached || oneInactiveTabIsAttached;
});
});

if (swHasMoreThanOneClient) {
throw new Error(
'You probably have multiple tabs open.'
'You probably have multiple tabs open to the same origin.'
);
}

Expand Down
6 changes: 3 additions & 3 deletions lighthouse-core/gather/drivers/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,13 @@ class ExtensionDriver extends Driver {
return new Promise((resolve, reject) => {
this.queryCurrentTab_().then(currentTab => {
chrome.debugger.getTargets(targets => {
const tab = targets.find(tab => tab.tabId === currentTab.id);
const target = targets.find(target => target.tabId === currentTab.id);

if (!tab) {
if (!target) {
reject(new Error('We can\'t find a target id.'));
}

resolve(tab.id);
resolve(target.id);
});
});
});
Expand Down
9 changes: 1 addition & 8 deletions lighthouse-core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,7 @@ module.exports = function(url, flags, configJSON) {

// kick off a lighthouse run
resolve(Runner.run(driver, {url, flags, config}));
})).catch(err => {
if (err.message.toLowerCase().includes('multiple tabs')) {
log.error('status', err.message);
return Promise.reject('');
}

throw err;
});
}));
};

module.exports.getAuditList = Runner.getAuditList;
Expand Down
4 changes: 2 additions & 2 deletions lighthouse-extension/app/src/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ document.addEventListener('DOMContentLoaded', _ => {
message = 'You probably have DevTools open.' +
' Close DevTools to use lighthouse';
}
if (message.toLowerCase().startsWith('unable to kill')) {
message = 'You probably have multiple tabs open.' +
if (message.toLowerCase().includes('multiple tabs')) {
message = 'You probably have multiple tabs open to the same origin.' +
' Close the other tabs to use lighthouse.';
}

Expand Down

0 comments on commit 6dc888a

Please sign in to comment.