forked from GoogleChrome/lighthouse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoopif-requests.js
101 lines (95 loc) · 4.56 KB
/
oopif-requests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/**
* @license Copyright 2019 The Lighthouse Authors. All Rights Reserved.
* 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
* 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.
*/
/** @type {LH.Config.Json} */
const config = {
extends: 'lighthouse:default',
categories: {
performance: {
title: 'Performance',
auditRefs: [
{id: 'oopif-iframe-test-audit', weight: 0},
{id: 'script-elements-test-audit', weight: 0},
],
},
},
audits: [
// Include an audit that *forces* the IFrameElements artifact to be used for our test.
{path: 'oopif-iframe-test-audit'},
{path: 'script-elements-test-audit'},
],
settings: {
// This test runs in CI and hits the outside network of a live site.
// Be a little more forgiving on how long it takes all network requests of several nested iframes
// to complete.
maxWaitForLoad: 180000,
},
navigations: [{
id: 'default',
// CI machines are pretty weak which lead to many more long tasks than normal.
// Reduce our requirement for CPU quiet.
cpuQuietThresholdMs: 500,
}],
};
/**
* @type {Smokehouse.ExpectedRunnerResult}
* Expected Lighthouse audit values for sites with OOPIFS.
*/
const expectations = {
lhr: {
requestedUrl: 'http://localhost:10200/oopif-requests.html',
finalUrl: 'http://localhost:10200/oopif-requests.html',
audits: {
'network-requests': {
// Multiple session attach handling fixed in M105
// https://chromiumdash.appspot.com/commit/f42337f1d623ec913397610ccf01b5526e9e919d
_minChromiumVersion: '105',
details: {
items: {
// We want to make sure we are finding the iframe's requests (paulirish.com) *AND*
// the iframe's iframe's iframe's requests (youtube.com/doubleclick/etc).
_includes: [
{url: 'http://localhost:10200/oopif-requests.html', finished: true, statusCode: 200, resourceType: 'Document', experimentalFromMainFrame: true},
// Paulirish iframe and subresource
{url: 'https://www.paulirish.com/2012/why-moving-elements-with-translate-is-better-than-posabs-topleft/', finished: true, statusCode: 200, resourceType: 'Document', experimentalFromMainFrame: undefined},
{url: 'https://www.paulirish.com/avatar150.jpg', finished: true, statusCode: 200, resourceType: 'Image', experimentalFromMainFrame: undefined},
{url: 'https://www.googletagmanager.com/gtag/js?id=G-PGXNGYWP8E', finished: true, statusCode: 200, resourceType: 'Script', experimentalFromMainFrame: undefined},
{url: /^https:\/\/fonts\.googleapis\.com\/css/, finished: true, statusCode: 200, resourceType: 'Stylesheet', experimentalFromMainFrame: undefined},
// Youtube iframe (OOPIF) and some subresources
// FYI: Youtube has a ServiceWorker which sometimes cancels the document request. As a result, there will sometimes be multiple requests for this file.
{url: 'https://www.youtube.com/embed/NZelrwd_iRs', finished: true, statusCode: 200, resourceType: 'Document'},
{url: /^https:\/\/www\.youtube\.com\/.*?player.*?css/, finished: true, statusCode: 200, resourceType: 'Stylesheet'},
{url: /^https:\/\/www\.youtube\.com\/.*?\/embed.js/, finished: true, statusCode: 200, resourceType: 'Script', experimentalFromMainFrame: undefined},
// Disqus iframe (OOPIF)
{url: /^https:\/\/disqus\.com\/embed\/comments\//, finished: true, statusCode: 200, resourceType: 'Document'},
// Disqus subframe (that's a new OOPIF)
{url: 'https://accounts.google.com/o/oauth2/iframe', finished: true, statusCode: 200, resourceType: 'Document'},
],
},
},
},
},
},
artifacts: {
IFrameElements: [
{
id: 'oopif',
src: 'https://www.paulirish.com/2012/why-moving-elements-with-translate-is-better-than-posabs-topleft/',
clientRect: {
width: '>0',
height: '>0',
},
isPositionFixed: false,
},
],
ScriptElements: [],
Scripts: [],
},
};
export default {
id: 'oopif-requests',
expectations,
config,
};