1616 */
1717
1818const path = require ( 'path' ) ;
19- const utils = require ( './utils' ) ;
20- const { waitEvent} = utils ;
2119const vm = require ( 'vm' ) ;
2220
2321/**
@@ -48,7 +46,7 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
4846 // fire.
4947 await newPage . click ( 'body' ) ;
5048 const pageClosingPromise = newPage . close ( { runBeforeUnload : true } ) ;
51- const dialog = await waitEvent ( newPage , 'dialog' ) ;
49+ const dialog = await newPage . waitForEvent ( 'dialog' ) ;
5250 expect ( dialog . type ( ) ) . toBe ( 'beforeunload' ) ;
5351 expect ( dialog . defaultValue ( ) ) . toBe ( '' ) ;
5452 if ( CHROMIUM )
@@ -93,7 +91,7 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
9391 it ( 'should fire when expected' , async ( { page, server} ) => {
9492 await Promise . all ( [
9593 page . goto ( 'about:blank' ) ,
96- utils . waitEvent ( page , 'load' ) ,
94+ page . waitForEvent ( 'load' ) ,
9795 ] ) ;
9896 } ) ;
9997 } ) ;
@@ -121,7 +119,7 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
121119 page . _delegate . _session . send ( 'Page.crash' , { } ) . catch ( e => { } ) ;
122120 else if ( FFOX )
123121 page . _delegate . _session . send ( 'Page.crash' , { } ) . catch ( e => { } ) ;
124- await waitEvent ( page , 'error' ) ;
122+ await new Promise ( f => page . on ( 'error' , f ) ) ;
125123 expect ( error . message ) . toBe ( 'Page crashed!' ) ;
126124 } ) ;
127125 } ) ;
@@ -152,7 +150,7 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
152150 page . once ( 'console' , m => message = m ) ;
153151 await Promise . all ( [
154152 page . evaluate ( ( ) => console . log ( 'hello' , 5 , { foo : 'bar' } ) ) ,
155- waitEvent ( page , 'console' )
153+ page . waitForEvent ( 'console' )
156154 ] ) ;
157155 expect ( message . text ( ) ) . toEqual ( 'hello 5 JSHandle@object' ) ;
158156 expect ( message . type ( ) ) . toEqual ( 'log' ) ;
@@ -191,14 +189,14 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
191189 page . once ( 'console' , msg => message = msg ) ;
192190 await Promise . all ( [
193191 page . evaluate ( ( ) => console . error ( window ) ) ,
194- waitEvent ( page , 'console' )
192+ page . waitForEvent ( 'console' )
195193 ] ) ;
196194 expect ( message . text ( ) ) . toBe ( 'JSHandle@object' ) ;
197195 } ) ;
198196 it ( 'should trigger correct Log' , async ( { page, server} ) => {
199197 await page . goto ( 'about:blank' ) ;
200198 const [ message ] = await Promise . all ( [
201- waitEvent ( page , 'console' ) ,
199+ page . waitForEvent ( 'console' ) ,
202200 page . evaluate ( async url => fetch ( url ) . catch ( e => { } ) , server . EMPTY_PAGE )
203201 ] ) ;
204202 expect ( message . text ( ) ) . toContain ( 'Access-Control-Allow-Origin' ) ;
@@ -207,7 +205,7 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
207205 it ( 'should have location for console API calls' , async ( { page, server} ) => {
208206 await page . goto ( server . EMPTY_PAGE ) ;
209207 const [ message ] = await Promise . all ( [
210- waitEvent ( page , 'console' ) ,
208+ page . waitForEvent ( 'console' ) ,
211209 page . goto ( server . PREFIX + '/consolelog.html' ) ,
212210 ] ) ;
213211 expect ( message . text ( ) ) . toBe ( 'yellow' ) ;
@@ -248,7 +246,7 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
248246 describe ( 'Page.Events.DOMContentLoaded' , function ( ) {
249247 it ( 'should fire when expected' , async ( { page, server} ) => {
250248 const navigatedPromise = page . goto ( 'about:blank' ) ;
251- await waitEvent ( page , 'domcontentloaded' ) ;
249+ await page . waitForEvent ( 'domcontentloaded' ) ;
252250 await navigatedPromise ;
253251 } ) ;
254252 } ) ;
@@ -494,7 +492,7 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
494492 page . once ( 'pageerror' , e => error = e ) ;
495493 await Promise . all ( [
496494 page . goto ( server . PREFIX + '/error.html' ) ,
497- waitEvent ( page , 'pageerror' )
495+ new Promise ( f => page . on ( 'pageerror' , f ) )
498496 ] ) ;
499497 expect ( error . message ) . toContain ( 'Fancy' ) ;
500498 } ) ;
0 commit comments