@@ -93,8 +93,11 @@ var buildElementHelper = function(ptor) {
93
93
* @param {string= } opt_baseUrl A base URL to run get requests against.
94
94
* @param {string= } opt_rootElement Selector element that has an ng-app in
95
95
* scope.
96
+ * @param {boolean= } opt_untrackOutstandingTimeouts Whether Protractor should
97
+ * stop tracking outstanding $timeouts.
96
98
*/
97
- var Protractor = function ( webdriverInstance , opt_baseUrl , opt_rootElement ) {
99
+ var Protractor = function ( webdriverInstance , opt_baseUrl , opt_rootElement ,
100
+ opt_untrackOutstandingTimeouts ) {
98
101
// These functions should delegate to the webdriver instance, but should
99
102
// wait for Angular to sync up before performing the action. This does not
100
103
// include functions which are overridden by protractor below.
@@ -216,6 +219,13 @@ var Protractor = function(webdriverInstance, opt_baseUrl, opt_rootElement) {
216
219
}
217
220
} ) ;
218
221
222
+ /**
223
+ * If true, Protractor will track outstanding $timeouts and report them in the
224
+ * error message if Protractor fails to synchronize with Angular in time.
225
+ * @private {boolean}
226
+ */
227
+ this . trackOutstandingTimeouts_ = ! opt_untrackOutstandingTimeouts ;
228
+
219
229
/**
220
230
* Information about mock modules that will be installed during every
221
231
* get().
@@ -382,10 +392,15 @@ Protractor.prototype.waitForAngular = function(opt_description) {
382
392
var errMsg = 'Timed out waiting for Protractor to synchronize with ' +
383
393
'the page after ' + timeout + '. Please see ' +
384
394
'https://github.com/angular/protractor/blob/master/docs/faq.md' ;
385
- var pendingTimeoutsPromise = self . executeScript_ (
386
- 'return window.NG_PENDING_TIMEOUTS' ,
387
- 'Protractor.waitForAngular() - getting pending timeouts' + description
388
- ) ;
395
+ var pendingTimeoutsPromise ;
396
+ if ( self . trackOutstandingTimeouts_ ) {
397
+ pendingTimeoutsPromise = self . executeScript_ (
398
+ 'return window.NG_PENDING_TIMEOUTS' ,
399
+ 'Protractor.waitForAngular() - getting pending timeouts' + description
400
+ ) ;
401
+ } else {
402
+ pendingTimeoutsPromise = webdriver . promise . fulfilled ( { } ) ;
403
+ }
389
404
var pendingHttpsPromise = self . executeScript_ (
390
405
clientSideScripts . getPendingHttpRequests ,
391
406
'Protractor.waitForAngular() - getting pending https' + description ,
@@ -518,14 +533,15 @@ Protractor.prototype.getRegisteredMockModules = function() {
518
533
* @private
519
534
*/
520
535
Protractor . prototype . addBaseMockModules_ = function ( ) {
521
- this . addMockModule ( 'protractorBaseModule_' , function ( ) {
522
- angular . module ( 'protractorBaseModule_' , [ ] ) .
536
+ this . addMockModule ( 'protractorBaseModule_' , function ( trackOutstandingTimeouts ) {
537
+ var ngMod = angular . module ( 'protractorBaseModule_' , [ ] ) .
523
538
config ( [ '$compileProvider' , function ( $compileProvider ) {
524
539
if ( $compileProvider . debugInfoEnabled ) {
525
540
$compileProvider . debugInfoEnabled ( true ) ;
526
541
}
527
- } ] ) .
528
- config ( [ '$provide' , function ( $provide ) {
542
+ } ] ) ;
543
+ if ( trackOutstandingTimeouts ) {
544
+ ngMod . config ( [ '$provide' , function ( $provide ) {
529
545
$provide . decorator ( '$timeout' , [ '$delegate' , function ( $delegate ) {
530
546
var $timeout = $delegate ;
531
547
@@ -567,7 +583,8 @@ Protractor.prototype.addBaseMockModules_ = function() {
567
583
return extendedTimeout ;
568
584
} ] ) ;
569
585
} ] ) ;
570
- } ) ;
586
+ }
587
+ } , this . trackOutstandingTimeouts_ ) ;
571
588
} ;
572
589
573
590
/**
@@ -1041,8 +1058,12 @@ Protractor.prototype.pause = function(opt_debugPort) {
1041
1058
*
1042
1059
* @param {webdriver.WebDriver } webdriver The configured webdriver instance.
1043
1060
* @param {string= } opt_baseUrl A URL to prepend to relative gets.
1061
+ * @param {boolean= } opt_untrackOutstandingTimeouts Whether Protractor should
1062
+ * stop tracking outstanding $timeouts.
1044
1063
* @return {Protractor }
1045
1064
*/
1046
- exports . wrapDriver = function ( webdriver , opt_baseUrl , opt_rootElement ) {
1047
- return new Protractor ( webdriver , opt_baseUrl , opt_rootElement ) ;
1065
+ exports . wrapDriver = function ( webdriver , opt_baseUrl , opt_rootElement ,
1066
+ opt_untrackOutstandingTimeouts ) {
1067
+ return new Protractor ( webdriver , opt_baseUrl , opt_rootElement ,
1068
+ opt_untrackOutstandingTimeouts ) ;
1048
1069
} ;
0 commit comments