feat(electron): emit dialog event for main-process dialog API#40911
feat(electron): emit dialog event for main-process dialog API#40911yury-s wants to merge 2 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Adds two events on ElectronApplication for intercepting the Electron main-process dialog API: - `filechooser` (ElectronFileChooser) for `dialog.showOpenDialog` and `dialog.showSaveDialog`, with `setFiles(paths)` / `cancel()`. - `dialog` (ElectronDialog) for `dialog.showMessageBox` and `dialog.showCertificateTrustDialog`, with `accept(result)` / `dismiss()`. The hook is installed via CDP `Runtime.evaluate` against the Node session, so it works for both packaged and non-packaged apps. The patched dialog methods stream call payloads back via a `Runtime.addBinding` binding and await results from the Playwright server. Fixes microsoft#8278
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| return this._initializer.method; | ||
| } | ||
|
|
||
| options(): any { |
There was a problem hiding this comment.
Why do we need to return options? Are there any particular options we care about? Perhaps explicit isMultiple() to match the browser API?
There was a problem hiding this comment.
The list of options is pretty reach in electron, it might be useful for asserting behavior/filtering the dialogs, things like defaultPath, filters, openFiles etc. We can drop that completely and expose isMultiple() to match web api, or just wait for user reports.
Test results for "MCP"7181 passed, 1113 skipped Merge workflow run. |
Test results for "tests 1"4 flaky42060 passed, 850 skipped Merge workflow run. |
For simple cases yes, but for more complex where the users my want to have some logic in playwright we are currently missing out on |
|
Docs-only approach: #40952. |
Summary
Adds two events on
ElectronApplicationfor intercepting Electron's main-process dialog API:filechooser(ElectronFileChooser) fordialog.showOpenDialog/dialog.showSaveDialog—setFiles(paths)/cancel().dialog(ElectronDialog) fordialog.showMessageBox/dialog.showCertificateTrustDialog—accept(result)/dismiss().The hook is installed via CDP
Runtime.evaluateagainst the Node session, so it works for both packaged and non-packaged Electron apps. Patched dialog methods stream call payloads back through aRuntime.addBindingbinding and await results from the Playwright server.Fixes #8278