Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore(bidi): add support for the input.fileDialogOpened event (#38224)

Holger Benla764706d68cc
diff --git a/packages/playwright-core/src/server/bidi/bidiBrowser.ts b/packages/playwright-core/src/server/bidi/bidiBrowser.ts
index b9d3ce3496..4b4a7d906d 100644
--- a/packages/playwright-core/src/server/bidi/bidiBrowser.ts
+++ b/packages/playwright-core/src/server/bidi/bidiBrowser.ts
@@ -70,6 +70,7 @@ export class BidiBrowser extends Browser {
'network',
'log',
'script',
+ 'input',
],
});
diff --git a/packages/playwright-core/src/server/bidi/bidiPage.ts b/packages/playwright-core/src/server/bidi/bidiPage.ts
index d46623448d..14064efb43 100644
--- a/packages/playwright-core/src/server/bidi/bidiPage.ts
+++ b/packages/playwright-core/src/server/bidi/bidiPage.ts
@@ -81,6 +81,7 @@ export class BidiPage implements PageDelegate {
eventsHelper.addEventListener(bidiSession, 'browsingContext.downloadEnd', this._onDownloadEnded.bind(this)),
eventsHelper.addEventListener(bidiSession, 'browsingContext.userPromptOpened', this._onUserPromptOpened.bind(this)),
eventsHelper.addEventListener(bidiSession, 'log.entryAdded', this._onLogEntryAdded.bind(this)),
+ eventsHelper.addEventListener(bidiSession, 'input.fileDialogOpened', this._onFileDialogOpened.bind(this)),
];
// Initialize main frame.
@@ -289,6 +290,17 @@ export class BidiPage implements PageDelegate {
this._page.addConsoleMessage(null, entry.method, entry.args.map(arg => createHandle(context, arg)), location, params.text || undefined);
}
+ private async _onFileDialogOpened(params: bidi.Input.FileDialogInfo) {
+ if (!params.element)
+ return;
+ const frame = this._page.frameManager.frame(params.context);
+ if (!frame)
+ return;
+ const executionContext = await frame._mainContext();
+ const handle = await toBidiExecutionContext(executionContext).remoteObjectForNodeId(executionContext, { sharedId: params.element.sharedId });
+ await this._page._onFileChooserOpened(handle as dom.ElementHandle);
+ }
+
async navigateFrame(frame: frames.Frame, url: string, referrer: string | undefined): Promise<frames.GotoResult> {
const { navigation } = await this._session.send('browsingContext.navigate', {
context: frame._id,
diff --git a/tests/bidi/expectations/moz-firefox-nightly-library.txt b/tests/bidi/expectations/moz-firefox-nightly-library.txt
index 9b99223966..89a4d5528d 100644
--- a/tests/bidi/expectations/moz-firefox-nightly-library.txt
+++ b/tests/bidi/expectations/moz-firefox-nightly-library.txt
@@ -5,7 +5,6 @@ library/browsercontext-page-event.spec.ts › should have about:blank for empty
library/browsertype-connect.spec.ts › launchServer › should be able to connect 20 times to a single server without warnings [timeout]
library/browsertype-connect.spec.ts › launchServer › should saveAs videos from remote browser [timeout]
library/browsertype-connect.spec.ts › run-server › should saveAs videos from remote browser [timeout]
-library/capabilities.spec.ts › should not crash when clicking a label with a <input type="file"/> [timeout]
library/channels.spec.ts › should work with the domain module [timeout]
library/chromium/chromium.spec.ts › PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1 › serviceWorker(), and fromServiceWorker() work [timeout]
library/chromium/chromium.spec.ts › PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1 › setExtraHTTPHeaders [timeout]
diff --git a/tests/bidi/expectations/moz-firefox-nightly-page.txt b/tests/bidi/expectations/moz-firefox-nightly-page.txt
index e553b9a48b..57a63997b4 100644
--- a/tests/bidi/expectations/moz-firefox-nightly-page.txt
+++ b/tests/bidi/expectations/moz-firefox-nightly-page.txt
@@ -4,25 +4,6 @@ page/interception.spec.ts › should intercept worker requests when enabled afte
page/page-add-init-script.spec.ts › init script should run only once in popup [timeout]
page/page-basic.spec.ts › should return null if parent page has been closed [timeout]
page/page-event-console.spec.ts › should trigger correct Log [timeout]
-page/page-filechooser.spec.ts › should upload multiple large files [timeout]
-page/page-filechooser.spec.ts › should emit event once [timeout]
-page/page-filechooser.spec.ts › should emit event via prepend [timeout]
-page/page-filechooser.spec.ts › should emit event for iframe [timeout]
-page/page-filechooser.spec.ts › should emit event on/off [timeout]
-page/page-filechooser.spec.ts › should emit event addListener/removeListener [timeout]
-page/page-filechooser.spec.ts › should work when file input is attached to DOM [timeout]
-page/page-filechooser.spec.ts › should work when file input is not attached to DOM [timeout]
-page/page-filechooser.spec.ts › should not throw when filechooser belongs to iframe [timeout]
-page/page-filechooser.spec.ts › should work with no timeout [timeout]
-page/page-filechooser.spec.ts › should return the same file chooser when there are many watchdogs simultaneously [timeout]
-page/page-filechooser.spec.ts › should accept single file [timeout]
-page/page-filechooser.spec.ts › should be able to read selected file [timeout]
-page/page-filechooser.spec.ts › should be able to reset selected files with empty file list [timeout]
-page/page-filechooser.spec.ts › should work for single file pick [timeout]
-page/page-filechooser.spec.ts › should work for "multiple" [timeout]
-page/page-filechooser.spec.ts › should work for "webkitdirectory" [timeout]
-page/page-filechooser.spec.ts › should emit event after navigation [timeout]
-page/page-filechooser.spec.ts › should trigger listener added before navigation [timeout]
page/page-goto.spec.ts › should work with anchor navigation [timeout]
page/page-network-response.spec.ts › should reject response.finished if context closes [timeout]
page/page-request-continue.spec.ts › should not throw if request was cancelled by the page [timeout]