Skip to content

Commit

Permalink
delete page reload/navigate logic since we always navigate
Browse files Browse the repository at this point in the history
  • Loading branch information
brendankenny committed Aug 12, 2016
1 parent 46dad7d commit 1810c61
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 1810c61

Please sign in to comment.