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
fix(extensions): do not enable screencast for background pages (#4919)
Yury Semikhatsky0a2fe62cb709
diff --git a/src/server/chromium/crPage.ts b/src/server/chromium/crPage.tsindex 9cf91bf5d9..fc0ede9ede 100644--- a/src/server/chromium/crPage.ts+++ b/src/server/chromium/crPage.ts@@ -461,7 +461,7 @@ class FrameSession {promises.push(this._evaluateOnNewDocument(source, 'main'));for (const source of this._crPage._page._evaluateOnNewDocumentSources)promises.push(this._evaluateOnNewDocument(source, 'main'));- if (this._isMainFrame() && this._crPage._browserContext._options.recordVideo) {+ if (this._isMainFrame() && this._crPage._browserContext._options.recordVideo && hasUIWindow) {const size = this._crPage._browserContext._options.recordVideo.size || this._crPage._browserContext._options.viewport || { width: 1280, height: 720 };const screencastId = createGuid();const outputFile = path.join(this._crPage._browserContext._options.recordVideo.dir, screencastId + '.webm');diff --git a/test/chromium/launcher.spec.ts b/test/chromium/launcher.spec.tsindex 712e1d7d2d..0a2c27c6b1 100644--- a/test/chromium/launcher.spec.ts+++ b/test/chromium/launcher.spec.ts@@ -77,6 +77,32 @@ it('should return background pages', (test, { browserName }) => {await context.close();});+it('should return background pages when recording video', (test, { browserName }) => {+ test.skip(browserName !== 'chromium');+}, async ({browserType, testInfo, browserOptions, createUserDataDir}) => {+ const userDataDir = await createUserDataDir();+ const extensionPath = path.join(__dirname, '..', 'assets', 'simple-extension');+ const extensionOptions = {...browserOptions,+ headless: false,+ args: [+ `--disable-extensions-except=${extensionPath}`,+ `--load-extension=${extensionPath}`,+ ],+ recordVideo: {+ dir: testInfo.outputPath(''),+ },+ };+ const context = await browserType.launchPersistentContext(userDataDir, extensionOptions) as ChromiumBrowserContext;+ const backgroundPages = context.backgroundPages();+ const backgroundPage = backgroundPages.length+ ? backgroundPages[0]+ : await context.waitForEvent('backgroundpage');+ expect(backgroundPage).toBeTruthy();+ expect(context.backgroundPages()).toContain(backgroundPage);+ expect(context.pages()).not.toContain(backgroundPage);+ await context.close();+});+it('should not create pages automatically', (test, { browserName }) => {test.skip(browserName !== 'chromium');}, async ({browserType, browserOptions}) => {