From 189faff2a53b4dcc8cd8620dbef7c2abd56bf89d Mon Sep 17 00:00:00 2001 From: Anton Usmansky Date: Sun, 7 Jul 2019 13:17:10 +0300 Subject: [PATCH] feat: send session id on browser session events --- lib/browser-pool/index.js | 2 +- test/lib/browser-pool/index.js | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/browser-pool/index.js b/lib/browser-pool/index.js index e679bcc30..352328ea9 100644 --- a/lib/browser-pool/index.js +++ b/lib/browser-pool/index.js @@ -39,5 +39,5 @@ exports.create = function(config, emitter) { }; function emitSessionEvent(emitter, browser, event) { - return emitter.emitAndWait(event, browser.publicAPI, {browserId: browser.id}); + return emitter.emitAndWait(event, browser.publicAPI, {browserId: browser.id, sessionId: browser.sessionId}); } diff --git a/test/lib/browser-pool/index.js b/test/lib/browser-pool/index.js index 84e0eba26..f33db6135 100644 --- a/test/lib/browser-pool/index.js +++ b/test/lib/browser-pool/index.js @@ -38,9 +38,10 @@ describe('browser-pool', () => { describe('browser manager', () => { const getBrowserManager = () => CoreBrowserPool.create.lastCall.args[0]; - const stubBrowser = (id, publicAPI) => { + const stubBrowser = ({id, sessionId, publicAPI} = {}) => { return { id, + sessionId, publicAPI, init: sandbox.stub(), quit: sandbox.stub() @@ -76,8 +77,14 @@ describe('browser-pool', () => { emitter.on(event, onEvent); - return BrowserManager[method](stubBrowser('bro', {public: 'api'})) - .then(() => assert.calledOnceWith(onEvent, {public: 'api'}, {browserId: 'bro'})); + const browser = stubBrowser({ + id: 'bro', + sessionId: '100500', + publicAPI: {public: 'api'} + }); + + return BrowserManager[method](browser) + .then(() => assert.calledOnceWith(onEvent, {public: 'api'}, {browserId: 'bro', sessionId: '100500'})); }); it('should wait all async listeners', () => {