From ad0edd0788048e419f3fa296c0c6a29554e19760 Mon Sep 17 00:00:00 2001 From: Bob Jamison Date: Mon, 18 Nov 2019 10:36:43 -0600 Subject: [PATCH 1/3] fix(Launcher): launcher.launch should pass 'timeout' option to browser.waitForTarget --- lib/Launcher.js | 2 +- test/launcher.spec.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/Launcher.js b/lib/Launcher.js index 41dc1e5da3ce5..53644a3acd5fc 100644 --- a/lib/Launcher.js +++ b/lib/Launcher.js @@ -181,7 +181,7 @@ class Launcher { connection = new Connection('', transport, slowMo); } const browser = await Browser.create(connection, [], ignoreHTTPSErrors, defaultViewport, chromeProcess, gracefullyCloseChrome); - await browser.waitForTarget(t => t.type() === 'page'); + await browser.waitForTarget(t => t.type() === 'page', { timeout }); return browser; } catch (e) { killChrome(); diff --git a/test/launcher.spec.js b/test/launcher.spec.js index 990c35da35da7..5a23be45779a6 100644 --- a/test/launcher.spec.js +++ b/test/launcher.spec.js @@ -16,6 +16,7 @@ const fs = require('fs'); const os = require('os'); const path = require('path'); +const {Browser} = require('../lib/Browser'); const {helper} = require('../lib/helper'); const rmAsync = helper.promisify(require('rimraf')); const mkdtempAsync = helper.promisify(fs.mkdtemp); @@ -239,6 +240,23 @@ module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, p expect(page.url()).toBe(server.EMPTY_PAGE); await browser.close(); }); + it('should pass the timeout parameter to browser.waitForTarget', async () => { + const expectedTimeout = 100000; + const options = Object.assign({}, defaultBrowserOptions, { + timeout: expectedTimeout + }); + const originalProto = Browser.prototype.waitForTarget; + let resTimeout = 0; + // function() because we want Browser's 'this' + Browser.prototype.waitForTarget = async function (predicate, options) { + resTimeout = options.timeout; + await originalProto.call(this, predicate, options); + }; + const browser = await puppeteer.launch(options); + Browser.prototype.waitForTarget = originalProto; + expect(resTimeout).toBe(expectedTimeout); + await browser.close(); + }); it('should set the default viewport', async() => { const options = Object.assign({}, defaultBrowserOptions, { defaultViewport: { From b9d9709e45f5313bc2f1f1897661499048eeaf17 Mon Sep 17 00:00:00 2001 From: ishmal Date: Mon, 18 Nov 2019 10:43:05 -0600 Subject: [PATCH 2/3] fix(Launcher): launcher.launch should pass 'timeout' option to browser.waitForTarget --- test/launcher.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/launcher.spec.js b/test/launcher.spec.js index 5a23be45779a6..b54224fb1a8fd 100644 --- a/test/launcher.spec.js +++ b/test/launcher.spec.js @@ -246,8 +246,8 @@ module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, p timeout: expectedTimeout }); const originalProto = Browser.prototype.waitForTarget; - let resTimeout = 0; - // function() because we want Browser's 'this' + let resTimeout = 0; + // function() because we want Browser's 'this' Browser.prototype.waitForTarget = async function (predicate, options) { resTimeout = options.timeout; await originalProto.call(this, predicate, options); From 61301743bbeb2d364c12cc67d3c2b2276eeeadba Mon Sep 17 00:00:00 2001 From: ishmal Date: Mon, 18 Nov 2019 11:21:43 -0600 Subject: [PATCH 3/3] ishmal-launcher-pass-timeout: eslint --- test/launcher.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/launcher.spec.js b/test/launcher.spec.js index b54224fb1a8fd..71ab215c003ea 100644 --- a/test/launcher.spec.js +++ b/test/launcher.spec.js @@ -240,7 +240,7 @@ module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, p expect(page.url()).toBe(server.EMPTY_PAGE); await browser.close(); }); - it('should pass the timeout parameter to browser.waitForTarget', async () => { + it('should pass the timeout parameter to browser.waitForTarget', async() => { const expectedTimeout = 100000; const options = Object.assign({}, defaultBrowserOptions, { timeout: expectedTimeout @@ -248,7 +248,7 @@ module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, p const originalProto = Browser.prototype.waitForTarget; let resTimeout = 0; // function() because we want Browser's 'this' - Browser.prototype.waitForTarget = async function (predicate, options) { + Browser.prototype.waitForTarget = async function(predicate, options) { resTimeout = options.timeout; await originalProto.call(this, predicate, options); };