in protractor_spec.js [32:66]
var waitForTest = function(done, fail, tries) {
// The default retrial policy.
if (typeof tries === 'undefined') {
tries = FLAKY_TEST_RETRIAL;
}
// executeScript runs the passed method in the "window" context of
// the current test. JSUnit exposes hooks into the test's status through
// the "G_testRunner" global object.
browser.executeScript(function() {
if (window['G_testRunner'] && window['G_testRunner']['isFinished']()) {
return {
isFinished: true,
isSuccess: window['G_testRunner']['isSuccess'](),
report: window['G_testRunner']['getReport']()
};
} else {
return {'isFinished': false};
}
}).then(function(status) {
// Tests completed on the page but something failed. Retry a certain
// number of times in case of flakiness.
if (status && status.isFinished && !status.isSuccess && tries > 1) {
// Try again in a few ms.
setTimeout(waitForTest.bind(undefined, done, fail, tries - 1), 300);
} else if (status && status.isFinished) {
done(status);
} else {
// Try again in a few ms.
setTimeout(waitForTest.bind(undefined, done, fail, tries), 300);
}
}, function(err) {
// This can happen if the webdriver had an issue executing the script.
fail(err);
});
};