|
| 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