Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
feat(screencast): fire start evet for popups (#3600)
Yury Semikhatskyb9d6324d1408
diff --git a/src/server/webkit/wkBrowser.ts b/src/server/webkit/wkBrowser.tsindex 365394e41f..01e1749410 100644--- a/src/server/webkit/wkBrowser.ts+++ b/src/server/webkit/wkBrowser.ts@@ -21,7 +21,6 @@ import { helper, RegisteredListener } from '../helper';import { assert } from '../../utils/utils';import * as network from '../network';import { Page, PageBinding } from '../page';-import * as path from 'path';import { ConnectionTransport } from '../transport';import * as types from '../types';import { Protocol } from './protocol';@@ -252,12 +251,6 @@ export class WKBrowserContext extends BrowserContext {throw result;if (result.isClosed())throw new Error('Page has been closed.');- if (result._browserContext._screencastOptions) {- const contextOptions = result._browserContext._screencastOptions;- const outputFile = path.join(contextOptions.dir, helper.guid() + '.webm');- const options = Object.assign({}, contextOptions, {outputFile});- await wkPage.startScreencast(options);- }return result;}diff --git a/src/server/webkit/wkPage.ts b/src/server/webkit/wkPage.tsindex 9ef1900879..914e489d80 100644--- a/src/server/webkit/wkPage.ts+++ b/src/server/webkit/wkPage.ts@@ -25,6 +25,7 @@ import { WKExecutionContext } from './wkExecutionContext';import { WKInterceptableRequest } from './wkInterceptableRequest';import { WKWorkers } from './wkWorkers';import { Page, PageDelegate, PageBinding } from '../page';+import * as path from 'path';import { Protocol } from './protocol';import * as dialog from '../dialog';import { RawMouseImpl, RawKeyboardImpl } from './wkInput';@@ -114,6 +115,12 @@ export class WKPage implements PageDelegate {for (const [key, value] of this._browserContext._permissions)this._grantPermissions(key, value);}+ if (this._browserContext._screencastOptions) {+ const contextOptions = this._browserContext._screencastOptions;+ const outputFile = path.join(contextOptions.dir, helper.guid() + '.webm');+ const options = Object.assign({}, contextOptions, {outputFile});+ promises.push(this.startScreencast(options));+ }await Promise.all(promises);}@@ -717,7 +724,7 @@ export class WKPage implements PageDelegate {height: options.height,scale: options.scale,});- this._browserContext.emit(BrowserContext.Events.ScreencastStarted, new Screencast(options.outputFile, this._initializedPage!));+ this._browserContext.emit(BrowserContext.Events.ScreencastStarted, new Screencast(options.outputFile, this._page));} catch (e) {this._recordingVideoFile = null;throw e;diff --git a/test/screencast.spec.ts b/test/screencast.spec.tsindex 34c4403c5c..73fb6d69b9 100644--- a/test/screencast.spec.ts+++ b/test/screencast.spec.ts@@ -279,3 +279,26 @@ it.fail(options.CHROMIUM)('should fire start/stop events when page created/closeexpect(stopEvent.page === newPage).toBe(true);await context.close();});++it.fail(options.CHROMIUM)('should fire start event for popups', async({browser, tmpDir, server, toImpl}) => {+ if (!toImpl)+ return;+ // Use server side of the context. All the code below also uses server side APIs.+ const context = toImpl(await browser.newContext());+ await context._enableScreencast({width: 640, height: 480, dir: tmpDir});+ expect(context._screencastOptions).toBeTruthy();++ const page = await context.newPage();+ await page.mainFrame().goto(server.EMPTY_PAGE);+ const [startEvent, popup] = await Promise.all([+ new Promise(resolve => context.on('screencaststarted', resolve)) as Promise<any>,+ new Promise(resolve => context.on('page', resolve)) as Promise<any>,+ page.mainFrame()._evaluateExpression(() => {+ const win = window.open('about:blank');+ win.close();+ }, true)+ ]);+ expect(startEvent.path).toBeTruthy();+ expect(startEvent.page === popup).toBe(true);+ await context.close();+});