Rename 'maxTime' option of Page.navigate into 'timeout'

The motivation behind this rename is to name all the 'timeout' options
across methods similarly.

References #39.
This commit is contained in:
Andrey Lushnikov 2017-07-22 16:25:00 -07:00
parent 98ee35655f
commit 5757bc18f2
4 changed files with 6 additions and 5 deletions

View File

@ -432,7 +432,7 @@ Page is guaranteed to have a main frame which persists during navigations.
#### page.navigate(url, options)
- `url` <[string]> URL to navigate page to
- `options` <[Object]> Navigation parameters which might have the following properties:
- `maxTime` <[number]> Maximum navigation time in milliseconds, defaults to 30 seconds.
- `timeout` <[number]> Maximum navigation time in milliseconds, defaults to 30 seconds.
- `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.
- `networkidle` - consider navigation to be finished when the network activity stays "idle" for at least `networkIdleTimeout`ms.
@ -443,7 +443,7 @@ Page is guaranteed to have a main frame which persists during navigations.
The `page.navigate` will throw an error if:
- there's an SSL error (e.g. in case of self-signed certificates).
- target URL is invalid.
- the `maxTime` is exceeded during navigation.
- the `timeout` is exceeded during navigation.
#### page.pdf(options)
- `options` <[Object]> Options object which might have the following properties:

View File

@ -25,7 +25,7 @@ class NavigatorWatcher {
constructor(client, networkManager, options = {}) {
this._client = client;
this._networkManager = networkManager;
this._maxTime = typeof options['maxTime'] === 'number' ? options['maxTime'] : 30000;
this._timeout = typeof options['timeout'] === 'number' ? options['timeout'] : 30000;
this._idleTime = typeof options['networkIdleTimeout'] === 'number' ? options['networkIdleTimeout'] : 1000;
this._idleInflight = typeof options['networkIdleInflight'] === 'number' ? options['networkIdleInflight'] : 2;
this._waitUntil = typeof options['waitUntil'] === 'string' ? options['waitUntil'] : 'load';
@ -43,7 +43,7 @@ class NavigatorWatcher {
.then(error => new Error('SSL Certiciate error: ' + error.errorType));
let networkIdle = new Promise(fulfill => this._networkIdleCallback = fulfill).then(() => null);
let loadEventFired = new Promise(fulfill => this._client.once('Page.loadEventFired', fulfill)).then(() => null);
let watchdog = new Promise(fulfill => this._maximumTimer = setTimeout(fulfill, this._maxTime)).then(() => new Error('Navigation Timeout Exceeded: ' + this._maxTime + 'ms exceeded'));
let watchdog = new Promise(fulfill => this._maximumTimer = setTimeout(fulfill, this._timeout)).then(() => new Error('Navigation Timeout Exceeded: ' + this._timeout + 'ms exceeded'));
try {
// Await for the command to throw exception in case of illegal arguments.

View File

@ -279,6 +279,7 @@ class Page extends EventEmitter {
const result = watcher.waitForNavigation();
const referrer = this._networkManager.httpHeaders()['referer'];
try {
// Await for the command to throw exception in case of illegal arguments.
await this._client.send('Page.navigate', {url, referrer});
} catch (e) {
watcher.cancel();

View File

@ -371,7 +371,7 @@ describe('Puppeteer', function() {
// Hang for request to the empty.html
server.setRoute('/empty.html', (req, res) => { });
try {
await page.navigate(PREFIX + '/empty.html', {maxTime: 59});
await page.navigate(PREFIX + '/empty.html', {timeout: 59});
} catch (e) {
error = e;
}