@@ -464,7 +464,7 @@ function testFailsParentTaskIfAsyncScheduledTaskFails() {
464
464
} , 10 ) ;
465
465
return d . promise ;
466
466
} ) . then ( fail , assertIsStubError ) ;
467
-
467
+
468
468
return waitForIdle ( ) . then ( function ( ) {
469
469
return d . promise ;
470
470
} ) . then ( fail , function ( e ) {
@@ -571,3 +571,99 @@ function testLongStackTraces_includesPromiseChainWhenEnabled() {
571
571
} ) ;
572
572
return waitForIdle ( ) ;
573
573
}
574
+
575
+
576
+ function testFrameCancelsRemainingTasks_onUnhandledTaskFailure ( ) {
577
+ var run = false ;
578
+ return flow . execute ( function ( ) {
579
+ flow . execute ( throwStubError ) ;
580
+ flow . execute ( function ( ) { run = true ; } ) ;
581
+ } ) . then ( fail , function ( e ) {
582
+ assertIsStubError ( e ) ;
583
+ assertFalse ( run ) ;
584
+ } ) ;
585
+ }
586
+
587
+
588
+ function testFrameCancelsRemainingTasks_onUnhandledPromiseRejection ( ) {
589
+ var run = false ;
590
+ return flow . execute ( function ( ) {
591
+ webdriver . promise . rejected ( new StubError ) ;
592
+ flow . execute ( function ( ) { run = true ; } ) ;
593
+ } ) . then ( fail , function ( e ) {
594
+ assertIsStubError ( e ) ;
595
+ assertFalse ( run ) ;
596
+ } ) ;
597
+ }
598
+
599
+
600
+ function testRegisteredTaskCallbacksAreDroppedWhenTaskIsCancelled_return ( ) {
601
+ var seen = [ ] ;
602
+ return flow . execute ( function ( ) {
603
+ flow . execute ( throwStubError ) ;
604
+
605
+ flow . execute ( function ( ) {
606
+ seen . push ( 1 ) ;
607
+ } ) . then ( function ( ) {
608
+ seen . push ( 2 ) ;
609
+ } , function ( ) {
610
+ seen . push ( 3 ) ;
611
+ } ) ;
612
+ } ) . then ( fail , function ( e ) {
613
+ assertIsStubError ( e ) ;
614
+ assertArrayEquals ( [ ] , seen ) ;
615
+ } ) ;
616
+ }
617
+
618
+
619
+ function testRegisteredTaskCallbacksAreDroppedWhenTaskIsCancelled_withReturn ( ) {
620
+ var seen = [ ] ;
621
+ return flow . execute ( function ( ) {
622
+ flow . execute ( throwStubError ) ;
623
+
624
+ return flow . execute ( function ( ) {
625
+ seen . push ( 1 ) ;
626
+ } ) . then ( function ( ) {
627
+ seen . push ( 2 ) ;
628
+ } , function ( ) {
629
+ seen . push ( 3 ) ;
630
+ } ) ;
631
+ } ) . then ( fail , function ( e ) {
632
+ assertIsStubError ( e ) ;
633
+ assertArrayEquals ( [ ] , seen ) ;
634
+ } ) ;
635
+ }
636
+
637
+
638
+ function testTaskIsCancelledAfterWaitTimeout ( ) {
639
+ var seen = [ ] ;
640
+ return flow . execute ( function ( ) {
641
+ flow . wait ( function ( ) {
642
+ webdriver . promies . delayed ( 100 ) . then ( goog . nullFunction ) ;
643
+ } , 5 ) ;
644
+
645
+ return flow . execute ( function ( ) {
646
+ seen . push ( 1 ) ;
647
+ } ) . then ( function ( ) {
648
+ seen . push ( 2 ) ;
649
+ } , function ( ) {
650
+ seen . push ( 3 ) ;
651
+ } ) ;
652
+ } ) . then ( fail , function ( e ) {
653
+ assertArrayEquals ( [ ] , seen ) ;
654
+ } ) ;
655
+ }
656
+
657
+
658
+ function testTaskCallbacksGetCancellationErrorIfRegisteredAfterTaskIsCancelled ( ) {
659
+ var task ;
660
+ flow . execute ( function ( ) {
661
+ flow . execute ( throwStubError ) ;
662
+ task = flow . execute ( goog . nullFunction ) ;
663
+ } ) . then ( fail , assertIsStubError ) ;
664
+ return waitForIdle ( ) . then ( function ( ) {
665
+ return task . then ( fail , function ( e ) {
666
+ assertTrue ( e instanceof webdriver . promise . CancellationError ) ;
667
+ } ) ;
668
+ } ) ;
669
+ }
0 commit comments