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
browser(firefox): fix file chooser in iframes #8510 (#8510)
Andrey Lushnikov5901cb321dd2
diff --git a/browser_patches/firefox-beta/BUILD_NUMBER b/browser_patches/firefox-beta/BUILD_NUMBERindex b867a00f2f..a3b3d6261f 100644--- a/browser_patches/firefox-beta/BUILD_NUMBER+++ b/browser_patches/firefox-beta/BUILD_NUMBER@@ -1,2 +1,2 @@-1284-Changed: [email protected] Wed 25 Aug 2021 08:50:22 AM PDT+1285+Changed: [email protected] Fri 27 Aug 2021 09:23:19 AM PDTdiff --git a/browser_patches/firefox-beta/juggler/content/PageAgent.js b/browser_patches/firefox-beta/juggler/content/PageAgent.jsindex a007fdb853..234c6b0801 100644--- a/browser_patches/firefox-beta/juggler/content/PageAgent.js+++ b/browser_patches/firefox-beta/juggler/content/PageAgent.js@@ -246,9 +246,9 @@ class PageAgent {}_filePickerShown(inputElement) {- if (inputElement.ownerGlobal.docShell !== this._docShell)- return;const frame = this._findFrameForNode(inputElement);+ if (!frame)+ return;this._browserPage.emit('pageFileChooserOpened', {executionContextId: frame.mainExecutionContext().id(),element: frame.mainExecutionContext().rawValueToRemoteObject(inputElement)diff --git a/browser_patches/firefox/BUILD_NUMBER b/browser_patches/firefox/BUILD_NUMBERindex c7950901a1..bde0a84273 100644--- a/browser_patches/firefox/BUILD_NUMBER+++ b/browser_patches/firefox/BUILD_NUMBER@@ -1,2 +1,2 @@-1288-Changed: [email protected] Wed 25 Aug 2021 08:41:36 AM PDT+1289+Changed: [email protected] Fri 27 Aug 2021 09:23:19 AM PDTdiff --git a/browser_patches/firefox/juggler/content/PageAgent.js b/browser_patches/firefox/juggler/content/PageAgent.jsindex a007fdb853..234c6b0801 100644--- a/browser_patches/firefox/juggler/content/PageAgent.js+++ b/browser_patches/firefox/juggler/content/PageAgent.js@@ -246,9 +246,9 @@ class PageAgent {}_filePickerShown(inputElement) {- if (inputElement.ownerGlobal.docShell !== this._docShell)- return;const frame = this._findFrameForNode(inputElement);+ if (!frame)+ return;this._browserPage.emit('pageFileChooserOpened', {executionContextId: frame.mainExecutionContext().id(),element: frame.mainExecutionContext().rawValueToRemoteObject(inputElement)diff --git a/tests/page/page-set-input-files.spec.ts b/tests/page/page-set-input-files.spec.tsindex 66feef9aa2..5d2a8aba55 100644--- a/tests/page/page-set-input-files.spec.ts+++ b/tests/page/page-set-input-files.spec.ts@@ -16,6 +16,7 @@*/import { test as it, expect } from './pageTest';+import { attachFrame } from '../config/utils';import path from 'path';import fs from 'fs';@@ -69,6 +70,17 @@ it('should emit event once', async ({page, server}) => {expect(chooser).toBeTruthy();});+it('should emit event for iframe', async ({page, server, browserName}) => {+ it.skip(browserName === 'firefox');+ const frame = await attachFrame(page, 'frame1', server.EMPTY_PAGE);+ await frame.setContent(`<input type=file>`);+ const [chooser] = await Promise.all([+ new Promise(f => page.once('filechooser', f)),+ frame.click('input'),+ ]);+ expect(chooser).toBeTruthy();+});+it('should emit event on/off', async ({page, server}) => {await page.setContent(`<input type=file>`);const [chooser] = await Promise.all([