@@ -31,6 +31,31 @@ test('every browser spec owns production application retirement', async () => {
3131 }
3232} ) ;
3333
34+ test ( 'every explicit browser page or context retires before closure' , async ( ) => {
35+ const specFiles = ( await readdir ( browserDir ) )
36+ . filter ( name => name . endsWith ( '.spec.mjs' ) )
37+ . sort ( ) ;
38+
39+ for ( const filename of specFiles ) {
40+ const source = await readFile ( path . join ( browserDir , filename ) , 'utf8' ) ;
41+ if ( / b r o w s e r \. n e w C o n t e x t \( / . test ( source ) ) {
42+ assert . match (
43+ source ,
44+ / c l o s e C o n t e x t W i t h A p p l i c a t i o n R e t i r e m e n t / ,
45+ `${ filename } closes a custom context without application retirement` ,
46+ ) ;
47+ assert . doesNotMatch ( source , / \b c o n t e x t \? * \. c l o s e \( / ) ;
48+ }
49+ if ( / c o n t e x t \. n e w P a g e \( / . test ( source ) ) {
50+ assert . match (
51+ source ,
52+ / c l o s e (?: P a g e | C o n t e x t ) W i t h A p p l i c a t i o n R e t i r e m e n t / ,
53+ `${ filename } closes an explicit page without application retirement` ,
54+ ) ;
55+ }
56+ }
57+ } ) ;
58+
3459test ( 'the browser fixture retires even a failed test through the stable owner' , async ( ) => {
3560 const source = await readFile (
3661 path . join ( browserDir , 'helpers' , 'test.mjs' ) ,
@@ -40,7 +65,8 @@ test('the browser fixture retires even a failed test through the stable owner',
4065 source ,
4166 / f i n a l l y \s * \{ [ \s \S ] * r e t i r e C o n t e x t A p p l i c a t i o n s \( c o n t e x t \) / ,
4267 ) ;
43- assert . match ( source , / a p p l i c a t i o n R e t i r e m e n t : [ \s \S ] * a u t o : \s * t r u e / ) ;
68+ assert . match ( source , / p a g e : \s * a s y n c \s * \( \{ \s * c o n t e x t , \s * p a g e \s * \} , \s * u s e \) / ) ;
69+ assert . doesNotMatch ( source , / a p p l i c a t i o n R e t i r e m e n t : [ \s \S ] * a u t o : \s * t r u e / ) ;
4470 assert . match ( source , / w i n d o w \. _ c e l l u c i d D i s p o s e / ) ;
4571 assert . match ( source , / s e c o n d T a s k \s * ! = = \s * f i r s t T a s k / ) ;
4672 assert . match (
0 commit comments