GatherRunner

GatherRunner

Class that drives browser to load the page and runs gatherer lifecycle hooks. Execution sequence when GatherRunner.run() is called:

  1. Setup A. navigate to about:blank B. driver.connect() C. GatherRunner.setupDriver() i. assertNoSameOriginServiceWorkerClients ii. beginEmulation iii. enableRuntimeEvents iv. evaluateScriptOnLoad rescue native Promise from potential polyfill v. register a performance observer vi. register dialog dismisser vii. clearDataForOrigin

  2. For each pass in the config: A. GatherRunner.beforePass() i. navigate to about:blank ii. Enable network request blocking for specified patterns iii. all gatherers' beforePass() B. GatherRunner.pass() i. cleanBrowserCaches() (if it's a perf run) ii. beginDevtoolsLog() iii. beginTrace (if requested) iv. GatherRunner.loadPage() a. navigate to options.url (and wait for onload) v. all gatherers' pass() C. GatherRunner.afterPass() i. endTrace (if requested) & endDevtoolsLog & endThrottling ii. all gatherers' afterPass()

  3. Teardown A. GatherRunner.disposeDriver() B. collect all artifacts and return them i. collectArtifacts() from completed passes on each gatherer ii. add trace data and computed artifact methods

Constructor

new GatherRunner()

Source:

Methods

(static) afterPass(optionsnon-null, gathererResultsnon-null) → (non-null) {Promise}

Ends tracing and collects trace data (if requested for this pass), and runs afterPass() on gatherers with trace data passed in. Promise resolves with object containing trace and network data.

Source:
Parameters:
Name Type Description
options Object
gathererResults GathererResults
Returns:
Type:
Promise

(static) assertPageLoaded(url, driver, networkRecordsnon-null)

Throws an error if the original network request failed or wasn't found.

Source:
Parameters:
Name Type Description
url string

The URL of the original requested page.

driver Object
networkRecords Array.<WebInspector.NetworkRequest>

(static) beforePass(optionsnon-null, gathererResultsnon-null) → (non-null) {Promise}

Navigates to about:blank and calls beforePass() on gatherers before tracing has started and before navigation to the target page.

Source:
Parameters:
Name Type Description
options Object
gathererResults GathererResults
Returns:
Type:
Promise

(static) collectArtifacts(gathererResultsnon-null) → (non-null) {Promise.<!Artifacts>}

Takes the results of each gatherer phase for each gatherer and uses the last produced value (that's not undefined) as the artifact for that gatherer. If a non-fatal error was rejected from a gatherer phase, uses that error object as the artifact instead.

Source:
Parameters:
Name Type Description
gathererResults GathererResults
Returns:
Type:
Promise.<!Artifacts>

(static) loadBlank(drivernon-null, urlopt, durationopt) → (non-null) {Promise}

Loads about:blank and waits there briefly. Since a Page.reload command does not let a service worker take over, we navigate away and then come back to reload. We do not waitForLoad on about:blank since a page load event is never fired on it.

Source:
Parameters:
Name Type Attributes Default Description
driver Driver
url url <optional>
about:blank
duration number <optional>
300
Returns:
Type:
Promise

(static) loadPage(drivernon-null, optionsnon-null) → (non-null) {Promise}

Loads options.url with specified options. If the main document URL redirects, options.url will be updated accordingly. As such, options.url will always represent the post-redirected URL. options.initialUrl is the pre-redirect starting URL.

Source:
Parameters:
Name Type Description
driver Driver
options Object
Returns:
Type:
Promise

(static) pass(optionsnon-null, gathererResultsnon-null) → (non-null) {Promise}

Navigates to requested URL and then runs pass() on gatherers while trace (if requested) is still being recorded.

Source:
Parameters:
Name Type Description
options Object
gathererResults GathererResults
Returns:
Type:
Promise

(static) recoverOrThrow(promisenon-null) → (non-null) {Promise.<*>}

Test any error output from the promise, absorbing non-fatal errors and throwing on fatal ones so that run is stopped.

Source:
Parameters:
Name Type Description
promise Promise.<*>
Returns:
Type:
Promise.<*>

(static) setupDriver(drivernon-null, gathererResultsnon-null, optionsnon-null) → (non-null) {Promise}

Source:
Parameters:
Name Type Description
driver Driver
gathererResults GathererResults
options Object
Returns:
Type:
Promise