From c175dad2900bf7bfe32b4ebfc62f360552c91d9b Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Fri, 11 Sep 2020 23:40:49 +0200 Subject: [PATCH] chore: fix compatibility to the domain module (#3851) --- src/client/channelOwner.ts | 2 ++ test/channels.spec.ts | 22 +++++++++++++++++++++- test/playwright.fixtures.ts | 1 + 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/client/channelOwner.ts b/src/client/channelOwner.ts index 0df0ebeb67..c29c8d9370 100644 --- a/src/client/channelOwner.ts +++ b/src/client/channelOwner.ts @@ -62,6 +62,8 @@ export abstract class ChannelOwner this._connection.sendMessageToServer(this._type, guid, String(prop), params); }, }); diff --git a/test/channels.spec.ts b/test/channels.spec.ts index 18c19a5cec..0ec3aa1c34 100644 --- a/test/channels.spec.ts +++ b/test/channels.spec.ts @@ -15,9 +15,21 @@ * limitations under the License. */ -import { it, expect, options } from './playwright.fixtures'; +import domain from 'domain'; +import { it, expect, options, playwrightFixtures } from './playwright.fixtures'; import type { ChromiumBrowser } from '..'; +playwrightFixtures.defineWorkerFixture('domain', async ({ }, test) => { + const local = domain.create(); + local.run(() => { }); + let err; + local.on('error', e => err = e); + local.enter(); + await test(null); + if (err) + throw err; +}); + it('should work', async ({browser}) => { expect(!!browser['_connection']).toBeTruthy(); }); @@ -144,6 +156,14 @@ it('should scope browser handles', async ({browserType, defaultBrowserOptions}) await expectScopeState(browserType, GOLDEN_PRECONDITION); }); +it('should work with the domain module', async ({ domain, browserType }) => { + const browser = await browserType.launch(); + const page = await browser.newPage(); + const result = await page.evaluate(() => 1 + 1); + expect(result).toBe(2); + await browser.close(); +}); + async function expectScopeState(object, golden) { golden = trimGuids(golden); const remoteState = trimGuids(await object._channel.debugScopeState()); diff --git a/test/playwright.fixtures.ts b/test/playwright.fixtures.ts index 4751a1c7ba..a4f854f208 100644 --- a/test/playwright.fixtures.ts +++ b/test/playwright.fixtures.ts @@ -38,6 +38,7 @@ type PlaywrightWorkerFixtures = { browserType: BrowserType; browser: Browser; httpService: {server: TestServer, httpsServer: TestServer} + domain: void; toImpl: (rpcObject: any) => any; isChromium: boolean; isFirefox: boolean;