Skip to content

Commit

Permalink
fix: allow timeouts of be 0 (#1964)
Browse files Browse the repository at this point in the history
This patch fixes timeouts for `puppeteer.launch` and `page.waitForFunction`
to be `0`.

Fixes #1960 .
  • Loading branch information
alixaxel authored and aslushnikov committed Feb 5, 2018
1 parent 37a1e17 commit bc69026
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
5 changes: 2 additions & 3 deletions lib/FrameManager.js
Expand Up @@ -618,7 +618,7 @@ class Frame {
* @return {!Promise}
*/
waitForFunction(pageFunction, options = {}, ...args) {
const timeout = options.timeout || 30000;
const timeout = helper.isNumber(options.timeout) ? options.timeout : 30000;
const polling = options.polling || 'raf';
return new WaitTask(this, pageFunction, polling, timeout, ...args).promise;
}
Expand All @@ -637,11 +637,10 @@ class Frame {
* @return {!Promise}
*/
_waitForSelectorOrXPath(selectorOrXPath, isXPath, options = {}) {
const timeout = options.timeout || 30000;
const waitForVisible = !!options.visible;
const waitForHidden = !!options.hidden;
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
Expand Down
3 changes: 2 additions & 1 deletion lib/Launcher.js
Expand Up @@ -136,8 +136,9 @@ class Launcher {
/** @type {?Connection} */
let connection = null;
try {
const timeout = helper.isNumber(options.timeout) ? options.timeout : 30000;
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);
return Browser.create(connection, options, chromeProcess, killChrome);
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion test/test.js
Expand Up @@ -54,7 +54,7 @@ const defaultBrowserOptions = {
args: ['--no-sandbox', '--disable-dev-shm-usage']
};

const timeout = slowMo ? 0 : 10 * 1000;
const timeout = slowMo ? 0 : 10 * 1000;
let parallel = 1;
if (process.env.PPTR_PARALLEL_TESTS)
parallel = parseInt(process.env.PPTR_PARALLEL_TESTS.trim(), 10);
Expand Down
2 changes: 1 addition & 1 deletion utils/testrunner/TestRunner.js
Expand Up @@ -265,7 +265,7 @@ class TestRunner extends EventEmitter {
this._currentSuite = this._rootSuite;
this._tests = [];
// Default timeout is 10 seconds.
this._timeout = options.timeout === 0 ? 2147483647 : options.timeout || 10 * 1000;
this._timeout = options.timeout === 0 ? 2147483647 : options.timeout || 10 * 1000;
this._parallel = options.parallel || 1;
this._retryFailures = !!options.retryFailures;

Expand Down

0 comments on commit bc69026

Please sign in to comment.