File tree Expand file tree Collapse file tree 2 files changed +75
-0
lines changed
injected/integration-test/test-pages/infra Expand file tree Collapse file tree 2 files changed +75
-0
lines changed Original file line number Diff line number Diff line change 10
10
"type" : " number" ,
11
11
"value" : 222
12
12
}
13
+ },
14
+ "Navigator.prototype.deviceMemory" : {
15
+ "type" : " descriptor" ,
16
+ "getterValue" : {
17
+ "type" : " number" ,
18
+ "value" : 1111
19
+ }
13
20
}
14
21
},
15
22
"conditionalChanges" : [
24
31
"value" : 333
25
32
}
26
33
]
34
+ },
35
+ {
36
+ "condition" : {
37
+ "context" : {
38
+ "top" : true
39
+ }
40
+ },
41
+ "patchSettings" : [
42
+ {
43
+ "op" : " replace" ,
44
+ "path" : " /apiChanges/Navigator.prototype.deviceMemory/getterValue/value" ,
45
+ "value" : 43339
46
+ }
47
+ ]
48
+ },
49
+ {
50
+ "condition" : {
51
+ "context" : {
52
+ "frame" : true
53
+ }
54
+ },
55
+ "patchSettings" : [
56
+ {
57
+ "op" : " replace" ,
58
+ "path" : " /apiChanges/Navigator.prototype.deviceMemory/getterValue/value" ,
59
+ "value" : 43338
60
+ }
61
+ ]
27
62
}
28
63
]
29
64
}
Original file line number Diff line number Diff line change 56
56
return results ;
57
57
} ) ;
58
58
59
+ test ( 'Conditional frame matching' , async ( ) => {
60
+ const results = [ ] ;
61
+ const frame = document . createElement ( 'iframe' ) ;
62
+ const scriptTag = 'script' ;
63
+ frame . srcdoc = `
64
+ <!DOCTYPE html>
65
+ <html>
66
+ <body>
67
+ <${ scriptTag } >
68
+ window.addEventListener('message', (event) => {
69
+ if (event.data === 'getDeviceMemory') {
70
+ event.source.postMessage(navigator.deviceMemory, event.origin);
71
+ }
72
+ });
73
+ </${ scriptTag } >
74
+ </body>
75
+ </html>
76
+ ` ;
77
+ document . body . appendChild ( frame ) ;
78
+ await new Promise ( resolve => frame . onload = resolve ) ;
79
+ const deviceMemoryPromise = new Promise ( resolve => {
80
+ window . addEventListener ( 'message' , ( event ) => {
81
+ resolve ( event . data ) ;
82
+ } , { once : true } ) ;
83
+ frame . contentWindow . postMessage ( 'getDeviceMemory' , '*' ) ;
84
+ } ) ;
85
+ const deviceMemory = await deviceMemoryPromise ;
86
+ results . push ( {
87
+ name : "Ensure iframe changes work" ,
88
+ result : deviceMemory ,
89
+ expected : 43338
90
+ } ) ;
91
+ results . push ( {
92
+ name : "Expect frame top modification works" ,
93
+ result : navigator . deviceMemory ,
94
+ expected : 43339
95
+ } ) ;
96
+ return results ;
97
+ } ) ;
98
+
59
99
60
100
// eslint-disable-next-line no-undef
61
101
renderResults ( ) ;
You can’t perform that action at this time.
0 commit comments