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

Commit

Permalink
fix(navigation): use empty html data urls for page resets instead of …
Browse files Browse the repository at this point in the history
…about:blank

Except on internet explorer, which does not allow data urls.

Closes #1023.
  • Loading branch information
juliemr committed Jul 8, 2014
1 parent f0e7984 commit 1198dde
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/protractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ var STACK_SUBSTRINGS_TO_FILTER = [
'protractor/lib/'
];

var DEFAULT_RESET_URL = 'data:text/html,<html></html>';

/*
* Mix in other webdriver functionality to be accessible via protractor.
*/
Expand Down Expand Up @@ -841,6 +843,11 @@ var Protractor = function(webdriverInstance, opt_baseUrl, opt_rootElement) {
*/
this.params = {};

/**
* The reset URL to use between page loads.
*/
this.resetUrl = DEFAULT_RESET_URL;

/**
* Information about mock modules that will be installed during every
* get().
Expand Down Expand Up @@ -981,7 +988,7 @@ Protractor.prototype.get = function(destination, opt_timeout) {
return this.driver.get(destination);
}

this.driver.get('about:blank');
this.driver.get(this.resetUrl);
this.driver.executeScript(
'window.name = "' + DEFER_LABEL + '" + window.name;' +
'window.location.replace("' + destination + '");');
Expand All @@ -991,7 +998,7 @@ Protractor.prototype.get = function(destination, opt_timeout) {
this.driver.wait(function() {
return self.driver.executeScript('return window.location.href;').
then(function(url) {
return url !== 'about:blank';
return url !== self.resetUrl;
}, function(err) {
if (err.code == 13) {
// Ignore the error, and continue trying. This is because IE
Expand Down
8 changes: 8 additions & 0 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ Runner.prototype.setupGlobals_ = function(driver) {
browser.params = this.config_.params;
protractor.setInstance(browser);

driver.getCapabilities().then(function(caps) {
// Internet Explorer does not accept data URLs, which are the default
// reset URL for Protractor.
if (caps.get('browserName') === 'internet explorer') {
browser.resetUrl = 'about:blank';
}
});

// Export protractor to the global namespace to be used in tests.
global.protractor = protractor;
global.browser = browser;
Expand Down

0 comments on commit 1198dde

Please sign in to comment.