@@ -560,6 +560,37 @@ describe('Page.Events.PageError', function() {
560
560
] ) ;
561
561
expect ( error . stack ) . toContain ( 'myscript.js' ) ;
562
562
} ) ;
563
+ it ( 'should handle odd values' , async ( { page} ) => {
564
+ const cases = [
565
+ [ null , 'null' ] ,
566
+ [ undefined , 'undefined' ] ,
567
+ [ 0 , '0' ] ,
568
+ [ '' , '' ] ,
569
+ ] ;
570
+ for ( const [ value , message ] of cases ) {
571
+ const [ error ] = await Promise . all ( [
572
+ page . waitForEvent ( 'pageerror' ) ,
573
+ page . evaluate ( value => setTimeout ( ( ) => { throw value ; } , 0 ) , value ) ,
574
+ ] ) ;
575
+ expect ( error . message ) . toBe ( FFOX ? 'uncaught exception: ' + message : message ) ;
576
+ }
577
+ } ) ;
578
+ it . fail ( FFOX ) ( 'should handle object' , async ( { page} ) => {
579
+ // Firefox just does not report this error.
580
+ const [ error ] = await Promise . all ( [
581
+ page . waitForEvent ( 'pageerror' ) ,
582
+ page . evaluate ( ( ) => setTimeout ( ( ) => { throw { } ; } , 0 ) ) ,
583
+ ] ) ;
584
+ expect ( error . message ) . toBe ( CHROMIUM ? 'Object' : '[object Object]' ) ;
585
+ } ) ;
586
+ it . fail ( FFOX ) ( 'should handle window' , async ( { page} ) => {
587
+ // Firefox just does not report this error.
588
+ const [ error ] = await Promise . all ( [
589
+ page . waitForEvent ( 'pageerror' ) ,
590
+ page . evaluate ( ( ) => setTimeout ( ( ) => { throw window ; } , 0 ) ) ,
591
+ ] ) ;
592
+ expect ( error . message ) . toBe ( CHROMIUM ? 'Window' : '[object Window]' ) ;
593
+ } ) ;
563
594
} ) ;
564
595
565
596
describe ( 'Page.setContent' , function ( ) {
0 commit comments