Rename navigation option 'waitFor' into 'waitUntil'.

This patch renames navigation option 'waitFor' into 'waitUntil' to
avoid confusion with 'page.waitFor' call.

References #39.
This commit is contained in:
Andrey Lushnikov 2017-07-14 13:59:36 -07:00
parent 76415e1be5
commit 34a96a8462
3 changed files with 8 additions and 8 deletions

View File

@ -232,11 +232,11 @@ Page is guaranteed to have a main frame which persists during navigations.
- `url` <[string]> URL to navigate page to - `url` <[string]> URL to navigate page to
- `options` <[Object]> Navigation parameters which might have the following properties: - `options` <[Object]> Navigation parameters which might have the following properties:
- `maxTime` <[number]> Maximum navigation time in milliseconds, defaults to 30 seconds. - `maxTime` <[number]> Maximum navigation time in milliseconds, defaults to 30 seconds.
- `waitFor` <[string]> When to consider navigation succeeded, defaults to `load`. Could be either: - `waitUntil` <[string]> When to consider navigation succeeded, defaults to `load`. Could be either:
- `load` - consider navigation to be finished when the `load` event is fired. - `load` - consider navigation to be finished when the `load` event is fired.
- `networkidle` - consider navigation to be finished when the network activity stays "idle" for at least `networkIdleTimeout`ms. - `networkidle` - consider navigation to be finished when the network activity stays "idle" for at least `networkIdleTimeout`ms.
- `networkIdleInflight` <[number]> Maximum amount of inflight requests which are considered "idle". Takes effect only with `waitFor: 'networkidle'` parameter. - `networkIdleInflight` <[number]> Maximum amount of inflight requests which are considered "idle". Takes effect only with `waitUntil: 'networkidle'` parameter.
- `networkIdleTimeout` <[number]> A timeout to wait before completing navigation. Takes effect only with `waitFor: 'networkidle'` parameter. - `networkIdleTimeout` <[number]> A timeout to wait before completing navigation. Takes effect only with `waitUntil: 'networkidle'` parameter.
- returns: <[Promise]<[Response]>> Promise which resolves to the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect. - returns: <[Promise]<[Response]>> Promise which resolves to the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect.
The `page.navigate` will throw an error if: The `page.navigate` will throw an error if:

View File

@ -28,9 +28,9 @@ class Navigator {
this._maxTime = typeof options['maxTime'] === 'number' ? options['maxTime'] : 30000; this._maxTime = typeof options['maxTime'] === 'number' ? options['maxTime'] : 30000;
this._idleTime = typeof options['networkIdleTimeout'] === 'number' ? options['networkIdleTimeout'] : 1000; this._idleTime = typeof options['networkIdleTimeout'] === 'number' ? options['networkIdleTimeout'] : 1000;
this._idleInflight = typeof options['networkIdleInflight'] === 'number' ? options['networkIdleInflight'] : 2; this._idleInflight = typeof options['networkIdleInflight'] === 'number' ? options['networkIdleInflight'] : 2;
this._waitFor = typeof options['waitFor'] === 'string' ? options['waitFor'] : 'load'; this._waitUntil = typeof options['waitUntil'] === 'string' ? options['waitUntil'] : 'load';
console.assert(this._waitFor === 'load' || this._waitFor === 'networkidle', 'Unknown value for options.waitFor: ' + this._waitFor); console.assert(this._waitUntil === 'load' || this._waitUntil === 'networkidle', 'Unknown value for options.waitUntil: ' + this._waitUntil);
} }
/** /**
@ -52,7 +52,7 @@ class Navigator {
throw e; throw e;
} }
const error = await Promise.race([certificateError, watchdog, this._waitFor === 'load' ? loadEventFired : networkIdle]); const error = await Promise.race([certificateError, watchdog, this._waitUntil === 'load' ? loadEventFired : networkIdle]);
this._cleanup(); this._cleanup();
if (error) if (error)
throw error; throw error;

View File

@ -274,7 +274,7 @@ describe('Puppeteer', function() {
// Navigate to a page which loads immediately and then does a bunch of // Navigate to a page which loads immediately and then does a bunch of
// requests via javascript's fetch method. // requests via javascript's fetch method.
let navigationPromise = page.navigate(PREFIX + '/networkidle.html', { let navigationPromise = page.navigate(PREFIX + '/networkidle.html', {
waitFor: 'networkidle', waitUntil: 'networkidle',
networkIdleTimeout: 100, networkIdleTimeout: 100,
networkIdleInflight: 0, // Only be idle when there are 0 inflight requests networkIdleInflight: 0, // Only be idle when there are 0 inflight requests
}); });
@ -324,7 +324,7 @@ describe('Puppeteer', function() {
// Navigate to a page which loads immediately and then opens a bunch of // Navigate to a page which loads immediately and then opens a bunch of
// websocket connections and then a fetch request. // websocket connections and then a fetch request.
let navigationPromise = page.navigate(PREFIX + '/websocket.html', { let navigationPromise = page.navigate(PREFIX + '/websocket.html', {
waitFor: 'networkidle', waitUntil: 'networkidle',
networkIdleTimeout: 100, networkIdleTimeout: 100,
networkIdleInflight: 0, // Only be idle when there are 0 inflight requests/connections networkIdleInflight: 0, // Only be idle when there are 0 inflight requests/connections
}); });