@@ -212,7 +212,7 @@ var Protractor = function(webdriverInstance, opt_baseUrl, opt_rootElement) {
212
212
* when running element explorer.
213
213
* @private {number}
214
214
*/
215
- this . debuggerServerPort_ ;
215
+ this . debuggerServerPort_ ;
216
216
} ;
217
217
218
218
/**
@@ -448,11 +448,14 @@ Protractor.prototype.get = function(destination, opt_timeout) {
448
448
return this . driver . get ( destination ) ;
449
449
}
450
450
451
- this . driver . get ( this . resetUrl ) ;
451
+ var deferred = webdriver . promise . defer ( ) ;
452
+
453
+ this . driver . get ( this . resetUrl ) . then ( null , deferred . reject ) ;
452
454
this . executeScript_ (
453
455
'window.name = "' + DEFER_LABEL + '" + window.name;' +
454
456
'window.location.replace("' + destination + '");' ,
455
- msg ( 'reset url' ) ) ;
457
+ msg ( 'reset url' ) )
458
+ . then ( null , deferred . reject ) ;
456
459
457
460
// We need to make sure the new url has loaded before
458
461
// we try to execute any asynchronous scripts.
@@ -473,7 +476,8 @@ Protractor.prototype.get = function(destination, opt_timeout) {
473
476
}
474
477
} ) ;
475
478
} , timeout ,
476
- 'waiting for page to load for ' + timeout + 'ms' ) ;
479
+ 'waiting for page to load for ' + timeout + 'ms' )
480
+ . then ( null , deferred . reject ) ;
477
481
478
482
// Make sure the page is an Angular page.
479
483
self . executeAsyncScript_ ( clientSideScripts . testForAngular ,
@@ -488,7 +492,8 @@ Protractor.prototype.get = function(destination, opt_timeout) {
488
492
}
489
493
} , function ( err ) {
490
494
throw 'Error while running testForAngular: ' + err . message ;
491
- } ) ;
495
+ } )
496
+ . then ( null , deferred . reject ) ;
492
497
493
498
// At this point, Angular will pause for us until angular.resumeBootstrap
494
499
// is called.
@@ -503,13 +508,17 @@ Protractor.prototype.get = function(destination, opt_timeout) {
503
508
then ( null , function ( err ) {
504
509
throw 'Error while running module script ' + name +
505
510
': ' + err . message ;
506
- } ) ;
511
+ } )
512
+ . then ( null , deferred . reject ) ;
507
513
}
508
514
509
- return this . executeScript_ (
515
+ this . executeScript_ (
510
516
'angular.resumeBootstrap(arguments[0]);' ,
511
517
msg ( 'resume bootstrap' ) ,
512
- moduleNames ) ;
518
+ moduleNames )
519
+ . then ( deferred . fulfill , deferred . reject ) ;
520
+
521
+ return deferred ;
513
522
} ;
514
523
515
524
/**
@@ -627,14 +636,14 @@ Protractor.prototype.initDebugger_ = function(debuggerClientPath, opt_debugPort)
627
636
webdriver . promise . ControlFlow . prototype . getControlFlowText = function ( ) {
628
637
var controlFlowText = this . getSchedule ( /* opt_includeStackTraces */ true ) ;
629
638
// This filters the entire control flow text, not just the stack trace, so
630
- // unless we maintain a good (i.e. non-generic) set of keywords in
631
- // STACK_SUBSTRINGS_TO_FILTER, we run the risk of filtering out non stack
632
- // trace. The alternative though, which is to reimplement
639
+ // unless we maintain a good (i.e. non-generic) set of keywords in
640
+ // STACK_SUBSTRINGS_TO_FILTER, we run the risk of filtering out non stack
641
+ // trace. The alternative though, which is to reimplement
633
642
// webdriver.promise.ControlFlow.prototype.getSchedule() here is much
634
643
// hackier, and involves messing with the control flow's internals / private
635
- // variables.
644
+ // variables.
636
645
return helper . filterStackTrace ( controlFlowText ) ;
637
-
646
+
638
647
} ;
639
648
640
649
if ( opt_debugPort ) {
@@ -677,7 +686,7 @@ Protractor.prototype.initDebugger_ = function(debuggerClientPath, opt_debugPort)
677
686
} ) ;
678
687
} ;
679
688
var sandbox = vm_ . createContext ( context ) ;
680
-
689
+
681
690
var browserUnderDebug = this ;
682
691
683
692
// Helper used only by debuggers at './debugger/modes/*.js' to insert code
@@ -734,11 +743,11 @@ Protractor.prototype.initDebugger_ = function(debuggerClientPath, opt_debugPort)
734
743
return undefined ;
735
744
} else {
736
745
// The '' forces res to be expanded into a string instead of just
737
- // '[Object]'. Then we remove the extra space caused by the '' using
738
- // substring.
746
+ // '[Object]'. Then we remove the extra space caused by the '' using
747
+ // substring.
739
748
return util . format . apply ( this , [ '' , res ] ) . substring ( 1 ) ;
740
749
}
741
- } ) ;
750
+ } ) ;
742
751
} ;
743
752
this . execute_ ( execFn_ ) ;
744
753
} ,
0 commit comments