[lighthouse] Remove lighthouse-emulate-run.js web test
This CL moves the expectations to e2e tests.
Bug: 1331155
Change-Id: I80f8653c26b1404e73913bd7b54cba83b05ca152
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3925371
Commit-Queue: Adam Raine <asraine@chromium.org>
Reviewed-by: Paul Irish <paulirish@chromium.org>
diff --git a/test/e2e/lighthouse/navigation_test.ts b/test/e2e/lighthouse/navigation_test.ts
index 0900440..4ba39ca 100644
--- a/test/e2e/lighthouse/navigation_test.ts
+++ b/test/e2e/lighthouse/navigation_test.ts
@@ -52,36 +52,42 @@
assert.strictEqual(lhr.lighthouseVersion, '9.6.6');
assert.match(lhr.finalUrl, /^https:\/\/localhost:[0-9]+\/test\/e2e\/resources\/lighthouse\/hello.html/);
+
assert.strictEqual(lhr.configSettings.throttlingMethod, 'simulate');
assert.strictEqual(lhr.configSettings.disableStorageReset, false);
assert.strictEqual(lhr.configSettings.formFactor, 'mobile');
+ assert.strictEqual(lhr.configSettings.throttling.rttMs, 150);
+ assert.strictEqual(lhr.configSettings.screenEmulation.disabled, true);
+ assert.include(lhr.configSettings.emulatedUserAgent, 'Mobile');
- const {innerWidth, innerHeight, outerWidth, outerHeight, devicePixelRatio} = artifacts.ViewportDimensions;
- // This value can vary slightly, depending on the display.
- // https://bugs.chromium.org/p/chromium/issues/detail?id=1346355
- assert.approximately(innerHeight, 1742, 1);
- assert.strictEqual(innerWidth, 980);
- assert.strictEqual(outerWidth, 360);
- assert.strictEqual(outerHeight, 640);
- assert.strictEqual(devicePixelRatio, 3);
+ // A bug in FR caused `networkUserAgent` to be excluded from the LHR.
+ // https://github.com/GoogleChrome/lighthouse/pull/14392
+ // TODO: Reenable once the fix lands in DT.
+ if (mode === 'legacy') {
+ assert.include(lhr.environment.networkUserAgent, 'Mobile');
+ }
+
+ assert.deepStrictEqual(artifacts.ViewportDimensions, {
+ innerHeight: 640,
+ innerWidth: 360,
+ outerHeight: 640,
+ outerWidth: 360,
+ devicePixelRatio: 3,
+ });
const {auditResults, erroredAudits, failedAudits} = getAuditsBreakdown(lhr);
assert.strictEqual(auditResults.length, 152);
assert.strictEqual(erroredAudits.length, 0);
assert.deepStrictEqual(failedAudits.map(audit => audit.id), [
'service-worker',
- 'viewport',
'installable-manifest',
'apple-touch-icon',
'splash-screen',
'themed-omnibox',
'maskable-icon',
- 'content-width',
'document-title',
'html-has-lang',
'meta-description',
- 'font-size',
- 'tap-targets',
]);
const viewTraceText = await reportEl.$eval('.lh-button--trace', viewTraceEl => {
@@ -113,18 +119,14 @@
assert.strictEqual(erroredAudits.length, 0);
assert.deepStrictEqual(failedAudits.map(audit => audit.id), [
'service-worker',
- 'viewport',
'installable-manifest',
'apple-touch-icon',
'splash-screen',
'themed-omnibox',
'maskable-icon',
- 'content-width',
'document-title',
'html-has-lang',
'meta-description',
- 'font-size',
- 'tap-targets',
]);
const viewTraceText = await reportEl.$eval('.lh-button--trace', viewTraceEl => {
@@ -158,6 +160,16 @@
assert.deepStrictEqual(Object.keys(lhr.categories), ['performance', 'best-practices']);
assert.strictEqual(lhr.configSettings.disableStorageReset, true);
assert.strictEqual(lhr.configSettings.formFactor, 'desktop');
+ assert.strictEqual(lhr.configSettings.throttling.rttMs, 40);
+ assert.strictEqual(lhr.configSettings.screenEmulation.disabled, true);
+ assert.notInclude(lhr.configSettings.emulatedUserAgent, 'Mobile');
+
+ // A bug in FR caused `networkUserAgent` to be excluded from the LHR.
+ // https://github.com/GoogleChrome/lighthouse/pull/14392
+ // TODO: Reenable once the fix lands in DT.
+ if (mode === 'legacy') {
+ assert.notInclude(lhr.environment.networkUserAgent, 'Mobile');
+ }
const viewTraceText = await reportEl.$eval('.lh-button--trace', viewTraceEl => {
return viewTraceEl.textContent;
diff --git a/test/e2e/lighthouse/snapshot_test.ts b/test/e2e/lighthouse/snapshot_test.ts
index a0df209..a1c2d07 100644
--- a/test/e2e/lighthouse/snapshot_test.ts
+++ b/test/e2e/lighthouse/snapshot_test.ts
@@ -52,25 +52,22 @@
assert.strictEqual(lhr.gatherMode, 'snapshot');
- const {innerWidth, innerHeight, outerWidth, outerHeight, devicePixelRatio} = artifacts.ViewportDimensions;
- // This value can vary slightly, depending on the display.
- // https://bugs.chromium.org/p/chromium/issues/detail?id=1346355
- assert.approximately(innerHeight, 1742, 1);
- assert.strictEqual(innerWidth, 980);
- assert.strictEqual(outerWidth, 360);
- assert.strictEqual(outerHeight, 640);
- assert.strictEqual(devicePixelRatio, 3);
+ assert.deepStrictEqual(artifacts.ViewportDimensions, {
+ innerHeight: 640,
+ innerWidth: 360,
+ outerHeight: 640,
+ outerWidth: 360,
+ devicePixelRatio: 3,
+ });
const {auditResults, erroredAudits, failedAudits} = getAuditsBreakdown(lhr);
assert.strictEqual(auditResults.length, 73);
assert.strictEqual(erroredAudits.length, 0);
assert.deepStrictEqual(failedAudits.map(audit => audit.id), [
- 'viewport',
'document-title',
'html-has-lang',
'label',
'meta-description',
- 'font-size',
'tap-targets',
]);
diff --git a/test/e2e/resources/lighthouse/hello.html b/test/e2e/resources/lighthouse/hello.html
index 4d3fd4e..00bb6f1 100644
--- a/test/e2e/resources/lighthouse/hello.html
+++ b/test/e2e/resources/lighthouse/hello.html
@@ -2,6 +2,7 @@
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="basic.css">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<h1>Hello</h1>
diff --git a/test/webtests/http/tests/devtools/lighthouse/lighthouse-emulate-run-expected.txt b/test/webtests/http/tests/devtools/lighthouse/lighthouse-emulate-run-expected.txt
deleted file mode 100644
index 3ab68b5..0000000
--- a/test/webtests/http/tests/devtools/lighthouse/lighthouse-emulate-run-expected.txt
+++ /dev/null
@@ -1,34 +0,0 @@
-Tests that mobile emulation works.
-
-
-========== Lighthouse Start Audit State ==========
-[x] Performance
-[x] Accessibility
-[x] Best practices
-[x] SEO
-[x] Progressive Web App
-[ ] Publisher Ads
-[x] Legacy navigation
-[x] Clear storage
-Throttling method: simulate
-Analyze page load: enabled visible
-
-=============== Lighthouse Results ===============
-URL: http://127.0.0.1:8000/devtools/lighthouse/resources/lighthouse-emulate-pass.html
-Version: 9.6.6
-formFactor: mobile
-screenEmulation: {
- "mobile": true,
- "width": 360,
- "height": 640,
- "deviceScaleFactor": 2.625,
- "disabled": true
-}
-Mobile network UA?: true
-Mobile configured UA?: true
-throttlingMethod: simulate
-throttling.rttMs: 150
-
-
-content-width: pass undefined
-
diff --git a/test/webtests/http/tests/devtools/lighthouse/lighthouse-emulate-run.js b/test/webtests/http/tests/devtools/lighthouse/lighthouse-emulate-run.js
deleted file mode 100644
index 16c095b..0000000
--- a/test/webtests/http/tests/devtools/lighthouse/lighthouse-emulate-run.js
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2019 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-(async function() {
- TestRunner.addResult('Tests that mobile emulation works.\n');
- await TestRunner.navigatePromise('resources/lighthouse-emulate-pass.html');
-
- await TestRunner.loadTestModule('lighthouse_test_runner');
- await TestRunner.showPanel('lighthouse');
-
- LighthouseTestRunner.dumpStartAuditState();
- LighthouseTestRunner.getRunButton().click();
- const {lhr} = await LighthouseTestRunner.waitForResults();
-
- TestRunner.addResult('\n=============== Lighthouse Results ===============');
- TestRunner.addResult(`URL: ${lhr.finalUrl}`);
- TestRunner.addResult(`Version: ${lhr.lighthouseVersion}`);
- TestRunner.addResult(`formFactor: ${lhr.configSettings.formFactor}`);
- TestRunner.addResult(`screenEmulation: ${JSON.stringify(lhr.configSettings.screenEmulation, null, 2)}`);
- TestRunner.addResult(`Mobile network UA?: ${lhr.environment.networkUserAgent.includes('Mobile')}`);
- TestRunner.addResult(`Mobile configured UA?: ${lhr.configSettings.emulatedUserAgent.includes('Mobile')}`);
- TestRunner.addResult(`throttlingMethod: ${lhr.configSettings.throttlingMethod}`);
- TestRunner.addResult(`throttling.rttMs: ${lhr.configSettings.throttling.rttMs}`);
- TestRunner.addResult('\n');
-
- const auditName = 'content-width';
- const audit = lhr.audits[auditName];
- if (audit.scoreDisplayMode === 'error') {
- TestRunner.addResult(`${auditName}: ERROR ${audit.errorMessage}`);
- } else if (audit.scoreDisplayMode === 'binary') {
- TestRunner.addResult(`${auditName}: ${audit.score ? 'pass' : 'fail'} ${audit.explanation}`);
- } else {
- TestRunner.addResult(`${auditName}: ${audit.scoreDisplayMode}`);
- }
-
- TestRunner.completeTest();
-})();