Skip to content

Commit a764706

Browse files
authored
chore(bidi): add support for the input.fileDialogOpened event (#38224)
1 parent f26e07f commit a764706

File tree

4 files changed

+13
-20
lines changed

4 files changed

+13
-20
lines changed

packages/playwright-core/src/server/bidi/bidiBrowser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export class BidiBrowser extends Browser {
7070
'network',
7171
'log',
7272
'script',
73+
'input',
7374
],
7475
});
7576

packages/playwright-core/src/server/bidi/bidiPage.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export class BidiPage implements PageDelegate {
8181
eventsHelper.addEventListener(bidiSession, 'browsingContext.downloadEnd', this._onDownloadEnded.bind(this)),
8282
eventsHelper.addEventListener(bidiSession, 'browsingContext.userPromptOpened', this._onUserPromptOpened.bind(this)),
8383
eventsHelper.addEventListener(bidiSession, 'log.entryAdded', this._onLogEntryAdded.bind(this)),
84+
eventsHelper.addEventListener(bidiSession, 'input.fileDialogOpened', this._onFileDialogOpened.bind(this)),
8485
];
8586

8687
// Initialize main frame.
@@ -289,6 +290,17 @@ export class BidiPage implements PageDelegate {
289290
this._page.addConsoleMessage(null, entry.method, entry.args.map(arg => createHandle(context, arg)), location, params.text || undefined);
290291
}
291292

293+
private async _onFileDialogOpened(params: bidi.Input.FileDialogInfo) {
294+
if (!params.element)
295+
return;
296+
const frame = this._page.frameManager.frame(params.context);
297+
if (!frame)
298+
return;
299+
const executionContext = await frame._mainContext();
300+
const handle = await toBidiExecutionContext(executionContext).remoteObjectForNodeId(executionContext, { sharedId: params.element.sharedId });
301+
await this._page._onFileChooserOpened(handle as dom.ElementHandle);
302+
}
303+
292304
async navigateFrame(frame: frames.Frame, url: string, referrer: string | undefined): Promise<frames.GotoResult> {
293305
const { navigation } = await this._session.send('browsingContext.navigate', {
294306
context: frame._id,

tests/bidi/expectations/moz-firefox-nightly-library.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ library/browsercontext-page-event.spec.ts › should have about:blank for empty
55
library/browsertype-connect.spec.ts › launchServer › should be able to connect 20 times to a single server without warnings [timeout]
66
library/browsertype-connect.spec.ts › launchServer › should saveAs videos from remote browser [timeout]
77
library/browsertype-connect.spec.ts › run-server › should saveAs videos from remote browser [timeout]
8-
library/capabilities.spec.ts › should not crash when clicking a label with a <input type="file"/> [timeout]
98
library/channels.spec.ts › should work with the domain module [timeout]
109
library/chromium/chromium.spec.ts › PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1 › serviceWorker(), and fromServiceWorker() work [timeout]
1110
library/chromium/chromium.spec.ts › PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1 › setExtraHTTPHeaders [timeout]

tests/bidi/expectations/moz-firefox-nightly-page.txt

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,6 @@ page/interception.spec.ts › should intercept worker requests when enabled afte
44
page/page-add-init-script.spec.ts › init script should run only once in popup [timeout]
55
page/page-basic.spec.ts › should return null if parent page has been closed [timeout]
66
page/page-event-console.spec.ts › should trigger correct Log [timeout]
7-
page/page-filechooser.spec.ts › should upload multiple large files [timeout]
8-
page/page-filechooser.spec.ts › should emit event once [timeout]
9-
page/page-filechooser.spec.ts › should emit event via prepend [timeout]
10-
page/page-filechooser.spec.ts › should emit event for iframe [timeout]
11-
page/page-filechooser.spec.ts › should emit event on/off [timeout]
12-
page/page-filechooser.spec.ts › should emit event addListener/removeListener [timeout]
13-
page/page-filechooser.spec.ts › should work when file input is attached to DOM [timeout]
14-
page/page-filechooser.spec.ts › should work when file input is not attached to DOM [timeout]
15-
page/page-filechooser.spec.ts › should not throw when filechooser belongs to iframe [timeout]
16-
page/page-filechooser.spec.ts › should work with no timeout [timeout]
17-
page/page-filechooser.spec.ts › should return the same file chooser when there are many watchdogs simultaneously [timeout]
18-
page/page-filechooser.spec.ts › should accept single file [timeout]
19-
page/page-filechooser.spec.ts › should be able to read selected file [timeout]
20-
page/page-filechooser.spec.ts › should be able to reset selected files with empty file list [timeout]
21-
page/page-filechooser.spec.ts › should work for single file pick [timeout]
22-
page/page-filechooser.spec.ts › should work for "multiple" [timeout]
23-
page/page-filechooser.spec.ts › should work for "webkitdirectory" [timeout]
24-
page/page-filechooser.spec.ts › should emit event after navigation [timeout]
25-
page/page-filechooser.spec.ts › should trigger listener added before navigation [timeout]
267
page/page-goto.spec.ts › should work with anchor navigation [timeout]
278
page/page-network-response.spec.ts › should reject response.finished if context closes [timeout]
289
page/page-request-continue.spec.ts › should not throw if request was cancelled by the page [timeout]

0 commit comments

Comments
 (0)