Skip to content

Commit ceb03cb

Browse files
authoredMar 1, 2022
tests: add more cases for oopif smoke test (#13705)
1 parent a1de8e9 commit ceb03cb

10 files changed

+176
-19
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<body>
4+
<h1>Hello frames</h1>
5+
<iframe id="oopif" src="https://www.paulirish.com/2012/why-moving-elements-with-translate-is-better-than-posabs-topleft/" style="width: 100vw; height: 110vh;"></iframe>
6+
</body>
7+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<body>
4+
<h1>Hello frames</h1>
5+
<iframe id="iframe-1" src="http://localhost:10200/oopif-simple-page.html" style="position: fixed"></iframe>
6+
<iframe id="iframe-2" src="http://localhost:10503/oopif-simple-page.html" style="position: fixed"></iframe>
7+
</body>
8+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<script src="simple-script.js"></script>
8+
<script>
9+
new Worker('simple-worker.mjs', { type: 'module' });
10+
new Worker('simple-worker.js');
11+
12+
window.addEventListener('load', () => {
13+
fetch('simple-script.js').then(r => r.text()).then(eval);
14+
});
15+
</script>
16+
</head>
17+
<body>
18+
<h1>Just a simple page</h1>
19+
</body>
20+
</html>

‎lighthouse-cli/test/fixtures/oopif.html

-8
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict';
2+
3+
console.log('🪁');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict';
2+
3+
self.importScripts('./simple-script.js?importScripts');
4+
5+
console.log('hello from worker!');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict';
2+
3+
import './simple-script.js?esm';
4+
5+
console.log('hello from worker!');

‎lighthouse-cli/test/smokehouse/core-tests.js

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import offlineReady from './test-definitions/offline-ready.js';
3333
import offlineSwBroken from './test-definitions/offline-sw-broken.js';
3434
import offlineSwSlow from './test-definitions/offline-sw-slow.js';
3535
import oopifRequests from './test-definitions/oopif-requests.js';
36+
import oopifScripts from './test-definitions/oopif-scripts.js';
3637
import perfBudgets from './test-definitions/perf-budgets.js';
3738
import perfDebug from './test-definitions/perf-debug.js';
3839
import perfDiagnosticsAnimations from './test-definitions/perf-diagnostics-animations.js';
@@ -92,6 +93,7 @@ const smokeTests = [
9293
offlineSwBroken,
9394
offlineSwSlow,
9495
oopifRequests,
96+
oopifScripts,
9597
perfBudgets,
9698
perfDebug,
9799
perfDiagnosticsAnimations,

‎lighthouse-cli/test/smokehouse/test-definitions/oopif-requests.js

+3-11
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ const config = {
4040
*/
4141
const expectations = {
4242
lhr: {
43-
requestedUrl: 'http://localhost:10200/oopif.html',
44-
finalUrl: 'http://localhost:10200/oopif.html',
43+
requestedUrl: 'http://localhost:10200/oopif-requests.html',
44+
finalUrl: 'http://localhost:10200/oopif-requests.html',
4545
audits: {
4646
'network-requests': {
4747
details: {
@@ -67,16 +67,8 @@ const expectations = {
6767
},
6868
isPositionFixed: false,
6969
},
70-
{
71-
id: 'outer-iframe',
72-
src: 'http://localhost:10200/online-only.html',
73-
clientRect: {
74-
width: '>0',
75-
height: '>0',
76-
},
77-
isPositionFixed: true,
78-
},
7970
],
71+
ScriptElements: [],
8072
},
8173
};
8274

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/**
2+
* @license Copyright 2022 The Lighthouse Authors. All Rights Reserved.
3+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
4+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
5+
*/
6+
'use strict';
7+
8+
/** @type {LH.Config.Json} */
9+
const config = {
10+
extends: 'lighthouse:default',
11+
categories: {
12+
performance: {
13+
title: 'Performance',
14+
auditRefs: [{id: 'oopif-iframe-test-audit', weight: 0}],
15+
},
16+
},
17+
audits: [
18+
// Include an audit that *forces* the IFrameElements artifact to be used for our test.
19+
{path: 'oopif-iframe-test-audit'},
20+
],
21+
settings: {
22+
// This test runs in CI and hits the outside network of a live site.
23+
// Be a little more forgiving on how long it takes all network requests of several nested iframes
24+
// to complete.
25+
maxWaitForLoad: 180000,
26+
},
27+
passes: [
28+
// CI machines are pretty weak which lead to many more long tasks than normal.
29+
// Reduce our requirement for CPU quiet.
30+
{
31+
passName: 'defaultPass',
32+
cpuQuietThresholdMs: 500,
33+
},
34+
],
35+
};
36+
37+
/**
38+
* @type {Smokehouse.ExpectedRunnerResult}
39+
* Expected Lighthouse audit values for sites with OOPIFS.
40+
*/
41+
const expectations = {
42+
lhr: {
43+
requestedUrl: 'http://localhost:10200/oopif-scripts.html',
44+
finalUrl: 'http://localhost:10200/oopif-scripts.html',
45+
audits: {
46+
'network-requests': {
47+
details: {
48+
items: {
49+
_includes: [
50+
{url: 'http://localhost:10200/oopif-scripts.html'},
51+
{url: 'http://localhost:10200/oopif-simple-page.html'},
52+
{url: 'http://localhost:10503/oopif-simple-page.html'},
53+
// simple-script.js is included many times
54+
// 2 * (1 from <script>, 1 from fetch) = 4
55+
// Note, the network records from the workers are _not_ captured! If they
56+
// were, then we would see 8 simple-script.js
57+
{url: 'http://localhost:10200/simple-script.js', resourceType: 'Script'},
58+
{url: 'http://localhost:10503/simple-script.js', resourceType: 'Script'},
59+
{url: 'http://localhost:10200/simple-script.js', resourceType: 'Fetch'},
60+
{url: 'http://localhost:10503/simple-script.js', resourceType: 'Fetch'},
61+
{url: 'http://localhost:10200/simple-worker.js'},
62+
{url: 'http://localhost:10503/simple-worker.js'},
63+
// For some reason, we only see these when running in DevTools!
64+
{_runner: 'devtools', url: 'http://localhost:10200/simple-worker.mjs'},
65+
{_runner: 'devtools', url: 'http://localhost:10503/simple-worker.mjs'},
66+
{_runner: 'devtools', url: 'http://localhost:10200/simple-script.js?esm', resourceType: 'Script'},
67+
{_runner: 'devtools', url: 'http://localhost:10503/simple-script.js?esm', resourceType: 'Script'},
68+
{_runner: 'devtools', url: 'http://localhost:10200/simple-script.js?importScripts', resourceType: 'Other'},
69+
{_runner: 'devtools', url: 'http://localhost:10503/simple-script.js?importScripts', resourceType: 'Other'},
70+
],
71+
// Ensure the above is exhaustive (except for favicon, which won't be fetched in devtools/LR).
72+
_excludes: [
73+
{url: /^((?!favicon).)*$/s},
74+
],
75+
},
76+
},
77+
},
78+
},
79+
},
80+
artifacts: {
81+
IFrameElements: [
82+
{
83+
id: 'iframe-1',
84+
src: 'http://localhost:10200/oopif-simple-page.html',
85+
clientRect: {
86+
width: '>0',
87+
height: '>0',
88+
},
89+
isPositionFixed: true,
90+
},
91+
{
92+
id: 'iframe-2',
93+
src: 'http://localhost:10503/oopif-simple-page.html',
94+
clientRect: {
95+
width: '>0',
96+
height: '>0',
97+
},
98+
isPositionFixed: true,
99+
},
100+
],
101+
// Only `oopif-simple-page.html`'s inclusion of `simple-script.js` should show up here.
102+
// All other scripts are filtered out because of our "OOPIF" filter (including anything
103+
// that is just in another process, like a worker).
104+
ScriptElements: [
105+
{
106+
src: 'http://localhost:10200/simple-script.js',
107+
source: 'network',
108+
content: /🪁/,
109+
},
110+
{
111+
src: 'http://localhost:10503/simple-script.js',
112+
source: 'network',
113+
content: /🪁/,
114+
},
115+
],
116+
},
117+
};
118+
119+
export default {
120+
id: 'oopif-scripts',
121+
expectations,
122+
config,
123+
};

0 commit comments

Comments
 (0)
Please sign in to comment.