mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: allow timeouts of be 0 (#1964)
This patch fixes timeouts for `puppeteer.launch` and `page.waitForFunction` to be `0`. Fixes #1960 .
This commit is contained in:
parent
37a1e17461
commit
bc6902623a
@ -618,7 +618,7 @@ class Frame {
|
|||||||
* @return {!Promise}
|
* @return {!Promise}
|
||||||
*/
|
*/
|
||||||
waitForFunction(pageFunction, options = {}, ...args) {
|
waitForFunction(pageFunction, options = {}, ...args) {
|
||||||
const timeout = options.timeout || 30000;
|
const timeout = helper.isNumber(options.timeout) ? options.timeout : 30000;
|
||||||
const polling = options.polling || 'raf';
|
const polling = options.polling || 'raf';
|
||||||
return new WaitTask(this, pageFunction, polling, timeout, ...args).promise;
|
return new WaitTask(this, pageFunction, polling, timeout, ...args).promise;
|
||||||
}
|
}
|
||||||
@ -637,11 +637,10 @@ class Frame {
|
|||||||
* @return {!Promise}
|
* @return {!Promise}
|
||||||
*/
|
*/
|
||||||
_waitForSelectorOrXPath(selectorOrXPath, isXPath, options = {}) {
|
_waitForSelectorOrXPath(selectorOrXPath, isXPath, options = {}) {
|
||||||
const timeout = options.timeout || 30000;
|
|
||||||
const waitForVisible = !!options.visible;
|
const waitForVisible = !!options.visible;
|
||||||
const waitForHidden = !!options.hidden;
|
const waitForHidden = !!options.hidden;
|
||||||
const polling = waitForVisible || waitForHidden ? 'raf' : 'mutation';
|
const polling = waitForVisible || waitForHidden ? 'raf' : 'mutation';
|
||||||
return this.waitForFunction(predicate, {timeout, polling}, selectorOrXPath, isXPath, waitForVisible, waitForHidden);
|
return this.waitForFunction(predicate, {timeout: options.timeout, polling}, selectorOrXPath, isXPath, waitForVisible, waitForHidden);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} selectorOrXPath
|
* @param {string} selectorOrXPath
|
||||||
|
@ -136,8 +136,9 @@ class Launcher {
|
|||||||
/** @type {?Connection} */
|
/** @type {?Connection} */
|
||||||
let connection = null;
|
let connection = null;
|
||||||
try {
|
try {
|
||||||
|
const timeout = helper.isNumber(options.timeout) ? options.timeout : 30000;
|
||||||
const connectionDelay = options.slowMo || 0;
|
const connectionDelay = options.slowMo || 0;
|
||||||
const browserWSEndpoint = await waitForWSEndpoint(chromeProcess, options.timeout || 30 * 1000);
|
const browserWSEndpoint = await waitForWSEndpoint(chromeProcess, timeout);
|
||||||
connection = await Connection.create(browserWSEndpoint, connectionDelay);
|
connection = await Connection.create(browserWSEndpoint, connectionDelay);
|
||||||
return Browser.create(connection, options, chromeProcess, killChrome);
|
return Browser.create(connection, options, chromeProcess, killChrome);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user