From 8d2502ee62e22b00e38c0bd2a1390e08f9ba47ec Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Fri, 7 Apr 2023 17:20:49 -0700 Subject: [PATCH] test: make page-leaks tests pass in electron (#22277) They've been failing https://devops.playwright.dev/flakiness.html#filter_spec=page%2Fpage-leaks.spec.ts&test_parameter_filters=%5B%5D×tamp=1680901928195 --- packages/playwright-core/src/server/electron/electron.ts | 3 ++- tests/page/page-leaks.spec.ts | 2 +- tests/playwright-test/reporter-list.spec.ts | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/playwright-core/src/server/electron/electron.ts b/packages/playwright-core/src/server/electron/electron.ts index 39339c4fbb..ee9f9faec9 100644 --- a/packages/playwright-core/src/server/electron/electron.ts +++ b/packages/playwright-core/src/server/electron/electron.ts @@ -71,7 +71,8 @@ export class ElectronApplication extends SdkObject { this._nodeSession.on('Runtime.executionContextCreated', async (event: any) => { if (event.context.auxData && event.context.auxData.isDefault) { this._nodeExecutionContext = new js.ExecutionContext(this, new CRExecutionContext(this._nodeSession, event.context), 'electron'); - f(await js.evaluate(this._nodeExecutionContext, false /* returnByValue */, `process.mainModule.require('electron')`)); + const source = `process.mainModule.require('electron')`; + f(await this._nodeExecutionContext.rawEvaluateHandle(source).then(objectId => new js.JSHandle(this._nodeExecutionContext!, 'object', 'ElectronModule', objectId))); } }); }); diff --git a/tests/page/page-leaks.spec.ts b/tests/page/page-leaks.spec.ts index 436df82184..d04bb4dc6d 100644 --- a/tests/page/page-leaks.spec.ts +++ b/tests/page/page-leaks.spec.ts @@ -21,7 +21,7 @@ function leakedJSHandles(): string { const map = new MultiMap(); for (const [h, e] of (globalThis as any).leakedJSHandles) { const name = `[${h.worldNameForTest()}] ${h.preview()}`; - if (name === '[main] UtilityScript' || name === '[utility] UtilityScript' || name === '[main] InjectedScript' || name === '[utility] InjectedScript') + if (name === '[main] UtilityScript' || name === '[utility] UtilityScript' || name === '[electron] UtilityScript' || name === '[main] InjectedScript' || name === '[utility] InjectedScript' || name === '[electron] ElectronModule') continue; map.set(e.stack, name); } diff --git a/tests/playwright-test/reporter-list.spec.ts b/tests/playwright-test/reporter-list.spec.ts index 549488c9e7..068765f3f6 100644 --- a/tests/playwright-test/reporter-list.spec.ts +++ b/tests/playwright-test/reporter-list.spec.ts @@ -68,7 +68,6 @@ test('render steps', async ({ runInlineTest }) => { `, }, { reporter: 'list' }, { PW_TEST_DEBUG_REPORTERS: '1', PW_TEST_DEBUG_REPORTERS_PRINT_STEPS: '1', PWTEST_TTY_WIDTH: '80' }); const text = result.output; - console.log(result.output) const lines = text.split('\n').filter(l => l.match(/^\d :/)).map(l => l.replace(/\d+ms/, 'Xms')); lines.pop(); // Remove last item that contains [v] and time in ms. expect(lines).toEqual([