-
Notifications
You must be signed in to change notification settings - Fork 9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add Page.waitForDevicePrompt #9299
Conversation
To further test this interface with the devtools protocol additions, without mocking them, a test environment with a specific hardware setup like bluetooth hardware with nearby reliable devices or some degree of detailed virtualization. Chromium uses Mojo services to fake parts of its WebBluetooth implementation in tests. Tests here could use that as well but these features are not normally shipped, to my knowledge, because the size of the released build they add. But I am thinking that would be "too much" here to automate testting this code, so I've used a mock session object here to test it. The commit log https://chromium-review.googlesource.com/c/chromium/src/+/3933844 isn't merged yet, so I used a npm-linked version of devtools-protocol I've pushed to https://github.com/mzgoddard/devtools-protocol/tree/device-access-device-request-prompted while writing this change and testing it. |
@mzgoddard thanks for the PR. Would you mind rebasing? |
f07310e
to
b45e5ae
Compare
b45e5ae
to
d945b6d
Compare
d945b6d
to
f92c95e
Compare
Add Page.waitForDevicePrompt() and DeviceRequestPrompt. Page.waitForDevicePrompt resolves to a DeviceRequestPrompt when the next DeviceAccess.deviceRequestPrompted events are emitted by the session. DeviceRequestPrompt.select and DeviceRequestPrompt.cancel can be be called to respond to the prompt.
f92c95e
to
0b1a599
Compare
I rebased onto As I understand it, puppeteer tracks Chrome's Beta release. So, this PR will wait until then when the dependency on |
@mzgoddard yes, that's right. We can land it once we rolled the Chromium binary version that supports this feature. |
packages/puppeteer/src/types.ts
Outdated
@@ -0,0 +1,77 @@ | |||
// AUTOGENERATED - Use `npm run generate:sources` to regenerate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be committed. I think the file has been removed from the tree but accidentally pushed here.
@mzgoddard let me know if need help rebasing this. We can land it now. |
@mzgoddard could you please run |
Also, the docs need to be re-generated |
Only call `deviceRequestPromptManager()` if the parent frame is not null. Follow-up-of: #9299
devices: [], | ||
}); | ||
|
||
expect(manager).toBeTruthy(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mzgoddard, sorry for quite a late comment. But what's the purpose of this expect
?
How the manager
won't be truthy?
What kind of change does this PR introduce?
Add a feature through
Page.waitForDevicePrompt()
andDeviceRequestPrompt
to respond toDeviceAccess.deviceRequestPrompted
protocol events.Did you add tests for your changes?
This change adds tests for the interface that simulate interaction with a mock session object.
These tests cover the added code except for
Page.waitForDevicePrompt
itself.If relevant, did you update the documentation?
Page.waitForDevicePrompt
includes a jsdoc with a comment with a likely common use case:Summary
Page.waitForDevicePrompt
resolves to aDeviceRequestPrompt
when the nextDeviceAccess.deviceRequestPrompted
events are emitted by the session.DeviceRequestPrompt.select
andDeviceRequestPrompt.cancel
can be be called to respond to the prompt.DeviceRequestPrompt.waitForDevice
resolves to the first device in the prompt that matches a given filter. That device can be listed inDeviceRequestPrompt.devices
whenwaitForDevice
is called or from futureDeviceAccess.deviceRequestPrompted
events.This wraps devtools protocol events and methods added in
https://chromium-review.googlesource.com/c/chromium/src/+/3933844. That commit log integrates those events with WebBluetooth. When WebBluetooth's requestDevice is called, after some steps are performed, if they succeed, a prompt for the user is opened to select a device. This interface and the protocol additions it depends on add a way to automate responding to that prompt.