Skip to content

Commit

Permalink
tests(devtools): update Lighthouse sniffer for smokes (#13693)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamraine committed Feb 22, 2022
1 parent 1b4748a commit f02c6b3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lighthouse-core/scripts/pptr-run-devtools.js
Expand Up @@ -104,9 +104,12 @@ const sniffLighthouseStarted = `
new Promise(resolve => {
const panel = UI.panels.lighthouse || UI.panels.audits;
const protocolService = panel.protocolService || panel._protocolService;
const functionName = protocolService.__proto__.startLighthouse ?
'startLighthouse' :
'collectLighthouseResults';
(${addSniffer.toString()})(
protocolService.__proto__,
'startLighthouse',
functionName,
(inspectedURL) => resolve(inspectedURL)
);
});
Expand Down Expand Up @@ -237,9 +240,13 @@ async function testPage(page, browser, url, config) {
returnByValue: true,
}).catch(err => err);
// Verify the first parameter to `startLighthouse`, which should be a url.
// In M100 the LHR is returned on `collectLighthouseResults` which has just 1 options parameter containing `inspectedUrl`.
// Don't try to check the exact value (because of redirects and such), just
// make sure it exists.
if (!isValidUrl(lhStartedResponse.result.value)) {
if (
!isValidUrl(lhStartedResponse.result.value) &&
!isValidUrl(lhStartedResponse.result.value.inspectedURL)
) {
throw new Error(`Lighthouse did not start correctly. Got unexpected value for url: ${
JSON.stringify(lhStartedResponse.result.value)}`);
}
Expand Down

0 comments on commit f02c6b3

Please sign in to comment.