Skip to content

Commit

Permalink
Merge pull request #579 from GoogleChrome/simplify
Browse files Browse the repository at this point in the history
delete page reload/navigate logic since we always navigate
  • Loading branch information
brendankenny authored Aug 12, 2016
2 parents 88ad999 + 1810c61 commit 0a03e18
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions lighthouse-core/gather/drivers/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,28 +218,22 @@ class Driver {
});
}

/**
* Navigate to the given URL. Use of this method directly isn't advised: if
* the current page is already at the given URL, navigation will not occur and
* so the returned promise will never resolve. See https://github.com/GoogleChrome/lighthouse/pull/185
* for one possible workaround.
* @param {string} url
* @param {!Object} options
* @return {!Promise}
*/
gotoURL(url, options) {
const waitForLoad = (options && options.waitForLoad) || false;
const disableJavaScript = (options && options.disableJavaScript) || false;
return this.sendCommand('Page.enable')
.then(_ => this.sendCommand('Emulation.setScriptExecutionDisabled', {value: disableJavaScript}))
.then(_ => this.sendCommand('Page.getNavigationHistory'))
.then(navHistory => {
const currentURL = navHistory.entries[navHistory.currentIndex].url;

// Because you can give https://example.com and the browser will
// silently redirect to https://example.com/ we need to check the match
// with a trailing slash on it.
//
// If the URL matches then we need to issue a reload not navigate
// @see https://github.com/GoogleChrome/lighthouse/issues/183
const shouldReload = (currentURL === url || currentURL === url + '/');
if (shouldReload) {
return this.sendCommand('Page.reload', {ignoreCache: true});
}

return this.sendCommand('Page.navigate', {url});
}).then(_ => {
.then(_ => this.sendCommand('Page.navigate', {url}))
.then(_ => {
return new Promise((resolve, reject) => {
this.url = url;

Expand Down

0 comments on commit 0a03e18

Please sign in to comment.