Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit 81501c5

Browse files
David Simonjuliemr
David Simon
authored andcommitted
fix(clientsidescripts): workaround for IE 8 "async page reload" init problem
1 parent bac36d2 commit 81501c5

File tree

2 files changed

+36
-11
lines changed

2 files changed

+36
-11
lines changed

lib/clientsidescripts.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ clientSideScripts.waitForAngular = function() {
2222
angular.element(el).injector().get('$browser').
2323
notifyWhenNoOutstandingRequests(callback);
2424
} catch (e) {
25-
callback(e.toString());
25+
callback(e);
2626
}
2727
};
2828

@@ -386,12 +386,16 @@ clientSideScripts.testForAngular = function() {
386386
if (window.angular && window.angular.resumeBootstrap) {
387387
callback([true, null]);
388388
} else if (n < 1) {
389-
callback([false, "timeout exceeded"]);
389+
if (window.angular) {
390+
callback([false, "angular never provided resumeBootstrap"]);
391+
} else {
392+
callback([false, "timeout exceeded"]);
393+
}
390394
} else {
391395
window.setTimeout(function() {check(n - 1)}, 1000);
392396
}
393397
} catch (e) {
394-
callback([false, e.toString()]);
398+
callback([false, e]);
395399
}
396400
};
397401
check(attempts);

lib/protractor.js

+29-8
Original file line numberDiff line numberDiff line change
@@ -483,21 +483,42 @@ Protractor.prototype.get = function(destination, timeout) {
483483
'window.name = "' + DEFER_LABEL + '" + window.name;' +
484484
'window.location.href = "' + destination + '"');
485485

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+
486495
// 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 (/reload detected during async script/.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 (/reload detected during async script/.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;
494512
}
495513
});
496514

497515
// At this point, Angular will pause for us, until angular.resumeBootstrap
498516
// is called.
499517
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+
});
501522
}
502523

503524
return this.driver.executeScript(function() {

0 commit comments

Comments
 (0)