Skip to content

Commit

Permalink
extension: close the popup once the report has opened (#5341)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed May 24, 2018
1 parent 520f9ac commit 872cba7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lighthouse-extension/app/src/lighthouse-ext-background.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ window.runLighthouseInExtension = function(options, categoryIDs) {
.then(runnerResult => {
// return enableOtherChromeExtensions(true).then(_ => {
const blobURL = window.createReportPageAsBlob(runnerResult, 'extension');
chrome.windows.create({url: blobURL});
return new Promise(resolve => chrome.windows.create({url: blobURL}, resolve));
// });
}).catch(err => {
// return enableOtherChromeExtensions(true).then(_ => {
Expand Down
17 changes: 11 additions & 6 deletions lighthouse-extension/app/src/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,23 @@ function createOptionItem(text, id, isChecked) {
* @param {!Window} background Reference to the extension's background page.
* @param {{selectedCategories: !Object<boolean>, useDevTools: boolean}} settings
*/
function onGenerateReportButtonClick(background, settings) {
async function onGenerateReportButtonClick(background, settings) {
showRunningSubpage();

const feedbackEl = document.querySelector('.feedback');
feedbackEl.textContent = '';

const {selectedCategories, useDevTools} = settings;

background.runLighthouseInExtension({
restoreCleanState: true,
flags: {throttlingMethod: useDevTools ? 'devtools' : 'simulate'},
}, selectedCategories).catch(err => {
try {
await background.runLighthouseInExtension({
restoreCleanState: true,
flags: {throttlingMethod: useDevTools ? 'devtools' : 'simulate'},
}, selectedCategories);

// Close popup once report is opened in a new tab
window.close();
} catch (err) {
let message = err.message;
let includeReportLink = true;

Expand All @@ -151,7 +156,7 @@ function onGenerateReportButtonClick(background, settings) {

hideRunningSubpage();
background.console.error(err);
});
}
}

/**
Expand Down

0 comments on commit 872cba7

Please sign in to comment.