@@ -483,21 +483,42 @@ Protractor.prototype.get = function(destination, timeout) {
483
483
'window.name = "' + DEFER_LABEL + '" + window.name;' +
484
484
'window.location.href = "' + destination + '"' ) ;
485
485
486
+ var angularTestHandler = function ( arr ) {
487
+ var hasAngular = arr [ 0 ] ;
488
+ if ( ! hasAngular ) {
489
+ var message = arr [ 1 ] ;
490
+ throw new Error ( 'Angular could not be found on the page ' +
491
+ destination + " : " + message ) ;
492
+ }
493
+ } ;
494
+
486
495
// Make sure the page is an Angular page.
487
- this . driver . executeAsyncScript ( clientSideScripts . testForAngular , timeout ) .
488
- then ( function ( arr ) {
489
- var hasAngular = arr [ 0 ] ;
490
- if ( ! hasAngular ) {
491
- var message = arr [ 1 ] ;
492
- throw new Error ( 'Angular could not be found on the page ' +
493
- destination + " : " + message ) ;
496
+ var me = this ;
497
+ me . driver . executeAsyncScript ( clientSideScripts . testForAngular , timeout ) .
498
+ then ( angularTestHandler , function ( err ) {
499
+ if ( / r e l o a d d e t e c t e d d u r i n g a s y n c s c r i p t / . test ( err . message ) ) {
500
+ // Sometimes IE will fail to run scripts right after a location change
501
+ // Let's try it once more
502
+ me . driver . executeAsyncScript ( clientSideScripts . testForAngular , timeout ) .
503
+ then ( angularTestHandler , function ( err ) {
504
+ if ( / r e l o a d d e t e c t e d d u r i n g a s y n c s c r i p t / . test ( err . message ) ) {
505
+ throw "Persistent async reload interrupt problem: " + err . message ;
506
+ } else {
507
+ throw "While running testForAngular: " + err . message ;
508
+ }
509
+ } ) ;
510
+ } else {
511
+ throw "While running testForAngular: " + err . message ;
494
512
}
495
513
} ) ;
496
514
497
515
// At this point, Angular will pause for us, until angular.resumeBootstrap
498
516
// is called.
499
517
for ( var i = 0 ; i < this . moduleScripts_ . length ; ++ i ) {
500
- this . driver . executeScript ( this . moduleScripts_ [ i ] ) ;
518
+ this . driver . executeScript ( this . moduleScripts_ [ i ] ) .
519
+ then ( null , function ( err ) {
520
+ throw "While running module script: " + err . message ;
521
+ } ) ;
501
522
}
502
523
503
524
return this . driver . executeScript ( function ( ) {
0 commit comments