Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate reloadForCleanStateIfNeeded #816

Merged
merged 1 commit into from
Oct 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions lighthouse-core/gather/drivers/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,22 +340,6 @@ class Driver {
.then(_ => waitForLoad && this._waitForFullyLoaded(pauseAfterLoadMs));
}

/**
* @param {!Object} options
* @return {!Promise}
*/
reloadForCleanStateIfNeeded(options) {
if (!options.restoreCleanState) {
return Promise.resolve();
}

const status = 'Reloading page to reset state';
log.log('status', status);
return this.gotoURL(options.url).then(_ => {
log.log('statusEnd', status);
});
}

/**
* @param {string} selector Selector to find in the DOM
* @return {!Promise<Element>} The found element, or null, resolved in a promise
Expand Down
2 changes: 2 additions & 0 deletions lighthouse-core/gather/drivers/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class ExtensionConnection extends Connection {
if (chrome.runtime.lastError) {
return reject(chrome.runtime.lastError);
}
// Reload the target page to restore its state.
chrome.tabs.reload(tabId);
resolve();
});
}).then(_ => this._detachCleanup());
Expand Down
16 changes: 5 additions & 11 deletions lighthouse-core/gather/gather-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ const path = require('path');
* ii. all gatherer's afterPass()
*
* 3. Teardown
* A. reloadForCleanStateIfNeeded
* B. driver.disconnect()
* C. collect all artifacts and return them
* A. driver.disconnect()
* B. collect all artifacts and return them
*/
class GatherRunner {
/**
Expand Down Expand Up @@ -243,14 +242,9 @@ class GatherRunner {
});
})
.then(_ => {
// We dont need to hold up the reporting for the reload/disconnect,
// so we will not return a promise in here.
driver.reloadForCleanStateIfNeeded(options).then(_ => {
log.log('status', 'Disconnecting from browser...');
driver.disconnect();
});
})
.then(_ => {
log.log('status', 'Disconnecting from browser...');
return driver.disconnect();
}).then(_ => {
// Collate all the gatherer results.
const computedArtifacts = this.instantiateComputedArtifacts();
const artifacts = Object.assign({}, computedArtifacts, tracingData);
Expand Down
3 changes: 0 additions & 3 deletions lighthouse-core/test/gather/fake-driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ module.exports = {
},
cleanAndDisableBrowserCaches() {},
clearDataForOrigin() {},
reloadForCleanStateIfNeeded() {
return Promise.resolve();
},
beginTrace() {
return Promise.resolve();
},
Expand Down