14
14
* limitations under the License.
15
15
*/
16
16
17
- const { FFOX , CHROMIUM , WEBKIT , CHANNEL } = require ( '../utils' ) . testOptions ( browserType ) ;
17
+ const { FFOX , CHROMIUM , WEBKIT , CHANNEL } = testOptions ;
18
18
19
- describe ( 'OOPIF' , function ( ) {
20
- beforeAll ( async function ( state ) {
21
- state . browser = await state . browserType . launch ( Object . assign ( { } , state . defaultBrowserOptions , {
22
- args : ( state . defaultBrowserOptions . args || [ ] ) . concat ( [ '--site-per-process' ] ) ,
23
- } ) ) ;
19
+ registerFixture ( 'sppBrowser' , async ( { browserType, defaultBrowserOptions} , test ) => {
20
+ const browser = await browserType . launch ( {
21
+ ...defaultBrowserOptions ,
22
+ args : ( defaultBrowserOptions . args || [ ] ) . concat ( [ '--site-per-process' ] )
24
23
} ) ;
25
- beforeEach ( async function ( state ) {
26
- state . context = await state . browser . newContext ( ) ;
27
- state . page = await state . context . newPage ( ) ;
28
- } ) ;
29
- afterEach ( async function ( state ) {
30
- await state . context . close ( ) ;
31
- state . page = null ;
32
- state . context = null ;
33
- } ) ;
34
- afterAll ( async function ( state ) {
35
- await state . browser . close ( ) ;
36
- state . browser = null ;
37
- } ) ;
38
- it ( 'should report oopif frames' , async function ( { browser, page, server, context} ) {
24
+ try {
25
+ await test ( browser ) ;
26
+ } finally {
27
+ await browser . close ( ) ;
28
+ }
29
+ } ) ;
30
+
31
+ registerFixture ( 'sppContext' , async ( { sppBrowser} , test ) => {
32
+ const context = await sppBrowser . newContext ( ) ;
33
+ try {
34
+ await test ( context ) ;
35
+ } finally {
36
+ await context . close ( ) ;
37
+ }
38
+ } ) ;
39
+
40
+ registerFixture ( 'sppPage' , async ( { sppContext} , test ) => {
41
+ const page = await sppContext . newPage ( ) ;
42
+ await test ( page ) ;
43
+ } ) ;
44
+
45
+
46
+ describe . skip ( ! CHROMIUM ) ( 'OOPIF' , function ( ) {
47
+ it ( 'should report oopif frames' , async function ( { sppBrowser, sppPage, server} ) {
48
+ const browser = sppBrowser ;
49
+ const page = sppPage ;
39
50
await page . goto ( server . PREFIX + '/dynamic-oopif.html' ) ;
40
51
expect ( await countOOPIFs ( browser ) ) . toBe ( 1 ) ;
41
52
expect ( page . frames ( ) . length ) . toBe ( 2 ) ;
42
53
expect ( await page . frames ( ) [ 1 ] . evaluate ( ( ) => '' + location . href ) ) . toBe ( server . CROSS_PROCESS_PREFIX + '/grid.html' ) ;
43
54
} ) ;
44
- it ( 'should handle oopif detach' , async function ( { browser, page, server, context} ) {
55
+ it ( 'should handle oopif detach' , async function ( { sppBrowser, sppPage, server} ) {
56
+ const browser = sppBrowser ;
57
+ const page = sppPage ;
45
58
await page . goto ( server . PREFIX + '/dynamic-oopif.html' ) ;
46
59
expect ( await countOOPIFs ( browser ) ) . toBe ( 1 ) ;
47
60
expect ( page . frames ( ) . length ) . toBe ( 2 ) ;
@@ -53,7 +66,9 @@ describe('OOPIF', function() {
53
66
] ) ;
54
67
expect ( detachedFrame ) . toBe ( frame ) ;
55
68
} ) ;
56
- it ( 'should handle remote -> local -> remote transitions' , async function ( { browser, page, server, context} ) {
69
+ it ( 'should handle remote -> local -> remote transitions' , async function ( { sppBrowser, sppPage, server} ) {
70
+ const browser = sppBrowser ;
71
+ const page = sppPage ;
57
72
await page . goto ( server . PREFIX + '/dynamic-oopif.html' ) ;
58
73
expect ( page . frames ( ) . length ) . toBe ( 2 ) ;
59
74
expect ( await countOOPIFs ( browser ) ) . toBe ( 1 ) ;
@@ -71,7 +86,9 @@ describe('OOPIF', function() {
71
86
expect ( await page . frames ( ) [ 1 ] . evaluate ( ( ) => '' + location . href ) ) . toBe ( server . CROSS_PROCESS_PREFIX + '/grid.html' ) ;
72
87
expect ( await countOOPIFs ( browser ) ) . toBe ( 1 ) ;
73
88
} ) ;
74
- it . fail ( CHROMIUM ) ( 'should get the proper viewport' , async ( { browser, page, server} ) => {
89
+ it . fail ( true ) ( 'should get the proper viewport' , async ( { sppBrowser, sppPage, server} ) => {
90
+ const browser = sppBrowser ;
91
+ const page = sppPage ;
75
92
expect ( page . viewportSize ( ) ) . toEqual ( { width : 1280 , height : 720 } ) ;
76
93
await page . goto ( server . PREFIX + '/dynamic-oopif.html' ) ;
77
94
expect ( page . frames ( ) . length ) . toBe ( 2 ) ;
@@ -89,7 +106,9 @@ describe('OOPIF', function() {
89
106
expect ( await oopif . evaluate ( ( ) => matchMedia ( '(device-height: 456px)' ) . matches ) ) . toBe ( true ) ;
90
107
expect ( await oopif . evaluate ( ( ) => 'ontouchstart' in window ) ) . toBe ( false ) ;
91
108
} ) ;
92
- it ( 'should expose function' , async ( { browser, page, server} ) => {
109
+ it ( 'should expose function' , async ( { sppBrowser, sppPage, server} ) => {
110
+ const browser = sppBrowser ;
111
+ const page = sppPage ;
93
112
await page . goto ( server . PREFIX + '/dynamic-oopif.html' ) ;
94
113
expect ( page . frames ( ) . length ) . toBe ( 2 ) ;
95
114
expect ( await countOOPIFs ( browser ) ) . toBe ( 1 ) ;
@@ -100,7 +119,9 @@ describe('OOPIF', function() {
100
119
} ) ;
101
120
expect ( result ) . toBe ( 36 ) ;
102
121
} ) ;
103
- it ( 'should emulate media' , async ( { browser, page, server} ) => {
122
+ it ( 'should emulate media' , async ( { sppBrowser, sppPage, server} ) => {
123
+ const browser = sppBrowser ;
124
+ const page = sppPage ;
104
125
await page . goto ( server . PREFIX + '/dynamic-oopif.html' ) ;
105
126
expect ( page . frames ( ) . length ) . toBe ( 2 ) ;
106
127
expect ( await countOOPIFs ( browser ) ) . toBe ( 1 ) ;
@@ -109,7 +130,10 @@ describe('OOPIF', function() {
109
130
await page . emulateMedia ( { colorScheme : 'dark' } ) ;
110
131
expect ( await oopif . evaluate ( ( ) => matchMedia ( '(prefers-color-scheme: dark)' ) . matches ) ) . toBe ( true ) ;
111
132
} ) ;
112
- it ( 'should emulate offline' , async ( { browser, page, context, server} ) => {
133
+ it ( 'should emulate offline' , async ( { sppBrowser, sppPage, sppContext, server} ) => {
134
+ const browser = sppBrowser ;
135
+ const context = sppContext ;
136
+ const page = sppPage ;
113
137
await page . goto ( server . PREFIX + '/dynamic-oopif.html' ) ;
114
138
expect ( page . frames ( ) . length ) . toBe ( 2 ) ;
115
139
expect ( await countOOPIFs ( browser ) ) . toBe ( 1 ) ;
@@ -118,7 +142,8 @@ describe('OOPIF', function() {
118
142
await context . setOffline ( true ) ;
119
143
expect ( await oopif . evaluate ( ( ) => navigator . onLine ) ) . toBe ( false ) ;
120
144
} ) ;
121
- it ( 'should support context options' , async ( { browser, server} ) => {
145
+ it ( 'should support context options' , async ( { sppBrowser, server, playwright} ) => {
146
+ const browser = sppBrowser ;
122
147
const iPhone = playwright . devices [ 'iPhone 6' ]
123
148
const context = await browser . newContext ( { ...iPhone , timezoneId : 'America/Jamaica' , locale : 'fr-CH' , userAgent : 'UA' } ) ;
124
149
const page = await context . newPage ( ) ;
@@ -139,7 +164,9 @@ describe('OOPIF', function() {
139
164
140
165
await context . close ( ) ;
141
166
} ) ;
142
- it ( 'should respect route' , async ( { browser, page, server} ) => {
167
+ it ( 'should respect route' , async ( { sppBrowser, sppPage, server} ) => {
168
+ const browser = sppBrowser ;
169
+ const page = sppPage ;
143
170
let intercepted = false ;
144
171
await page . route ( '**/digits/0.png' , route => {
145
172
intercepted = true ;
@@ -150,19 +177,25 @@ describe('OOPIF', function() {
150
177
expect ( await countOOPIFs ( browser ) ) . toBe ( 1 ) ;
151
178
expect ( intercepted ) . toBe ( true ) ;
152
179
} ) ;
153
- it ( 'should take screenshot' , async ( { browser, page, server, golden} ) => {
180
+ it ( 'should take screenshot' , async ( { sppBrowser, sppPage, server} ) => {
181
+ const browser = sppBrowser ;
182
+ const page = sppPage ;
154
183
await page . setViewportSize ( { width : 500 , height : 500 } ) ;
155
184
await page . goto ( server . PREFIX + '/dynamic-oopif.html' ) ;
156
185
expect ( page . frames ( ) . length ) . toBe ( 2 ) ;
157
186
expect ( await countOOPIFs ( browser ) ) . toBe ( 1 ) ;
158
- expect ( await page . screenshot ( ) ) . toBeGolden ( golden ( 'screenshot-oopif.png' ) ) ;
187
+ expect ( await page . screenshot ( ) ) . toBeGolden ( 'screenshot-oopif.png' ) ;
159
188
} ) ;
160
- it ( 'should load oopif iframes with subresources and request interception' , async function ( { browser, page, server, context} ) {
189
+ it ( 'should load oopif iframes with subresources and request interception' , async function ( { sppBrowser, sppPage, server, context} ) {
190
+ const browser = sppBrowser ;
191
+ const page = sppPage ;
161
192
await page . route ( '**/*' , route => route . continue ( ) ) ;
162
193
await page . goto ( server . PREFIX + '/dynamic-oopif.html' ) ;
163
194
expect ( await countOOPIFs ( browser ) ) . toBe ( 1 ) ;
164
195
} ) ;
165
- it ( 'should report main requests' , async function ( { browser, page, server, context} ) {
196
+ it ( 'should report main requests' , async function ( { sppBrowser, sppPage, server} ) {
197
+ const browser = sppBrowser ;
198
+ const page = sppPage ;
166
199
const requestFrames = [ ] ;
167
200
page . on ( 'request' , r => requestFrames . push ( r . frame ( ) ) ) ;
168
201
const finishedFrames = [ ] ;
@@ -199,7 +232,10 @@ describe('OOPIF', function() {
199
232
expect ( requestFrames [ 2 ] ) . toBe ( grandChild ) ;
200
233
expect ( finishedFrames [ 2 ] ) . toBe ( grandChild ) ;
201
234
} ) ;
202
- it ( 'should support exposeFunction' , async function ( { browser, page, server, context} ) {
235
+ it ( 'should support exposeFunction' , async function ( { sppBrowser, sppContext, sppPage, server} ) {
236
+ const browser = sppBrowser ;
237
+ const context = sppContext ;
238
+ const page = sppPage ;
203
239
await context . exposeFunction ( 'dec' , a => a - 1 ) ;
204
240
await page . exposeFunction ( 'inc' , a => a + 1 ) ;
205
241
await page . goto ( server . PREFIX + '/dynamic-oopif.html' ) ;
@@ -210,7 +246,10 @@ describe('OOPIF', function() {
210
246
expect ( await page . frames ( ) [ 0 ] . evaluate ( ( ) => dec ( 3 ) ) ) . toBe ( 2 ) ;
211
247
expect ( await page . frames ( ) [ 1 ] . evaluate ( ( ) => dec ( 4 ) ) ) . toBe ( 3 ) ;
212
248
} ) ;
213
- it ( 'should support addInitScript' , async function ( { browser, page, server, context} ) {
249
+ it ( 'should support addInitScript' , async function ( { sppBrowser, sppContext, sppPage, server} ) {
250
+ const browser = sppBrowser ;
251
+ const context = sppContext ;
252
+ const page = sppPage ;
214
253
await context . addInitScript ( ( ) => window . bar = 17 ) ;
215
254
await page . addInitScript ( ( ) => window . foo = 42 ) ;
216
255
await page . goto ( server . PREFIX + '/dynamic-oopif.html' ) ;
@@ -222,7 +261,9 @@ describe('OOPIF', function() {
222
261
expect ( await page . frames ( ) [ 1 ] . evaluate ( ( ) => window . bar ) ) . toBe ( 17 ) ;
223
262
} ) ;
224
263
// @see https://github.com/microsoft/playwright/issues/1240
225
- it ( 'should click a button when it overlays oopif' , async function ( { browser, page, server, context} ) {
264
+ it ( 'should click a button when it overlays oopif' , async function ( { sppBrowser, sppPage, server} ) {
265
+ const browser = sppBrowser ;
266
+ const page = sppPage ;
226
267
await page . goto ( server . PREFIX + '/button-overlay-oopif.html' ) ;
227
268
expect ( await countOOPIFs ( browser ) ) . toBe ( 1 ) ;
228
269
await page . click ( 'button' ) ;
0 commit comments