Skip to content

Commit

Permalink
Bug 1919972 [wpt PR 48244] - WebHID: Add support for dedicated worker…
Browse files Browse the repository at this point in the history
…s, a=testonly

Automatic update from web-platform-tests
WebHID: Add support for dedicated workers

This CL exposes the WebHID API to dedicated workers behind the blink
runtime feature WebHIDOnDedicatedWorkers.

Intent to prototype: https://groups.google.com/a/chromium.org/g/blink-dev/c/y__BOYfZWzI
Spec PR: WICG/webhid#121
Spec issue: WICG/webhid#120
Demo: https://webhid-worker.glitch.me/

Change-Id: If145f34faf9211a54c8b4a15fbe7e903411b8d1d
Bug: 365932453
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5841991
Reviewed-by: Arthur Sonzogni <arthursonzognichromium.org>
Reviewed-by: Yoav Weiss (Shopify) <yoavweisschromium.org>
Reviewed-by: Matt Reynolds <mattreynoldschromium.org>
Commit-Queue: Fr <beaufort.francoisgmail.com>
Cr-Commit-Position: refs/heads/main{#1357046}

--

wpt-commits: f3a05bb7fe21b6e6d8fbf5923d53abfc7c04fd66
wpt-pr: 48244

UltraBlame original commit: 091c9c912077b35fe3eb0526c59790da67a80a9a
  • Loading branch information
marco-c committed Sep 26, 2024
1 parent 4ff0beb commit cab5a38
Show file tree
Hide file tree
Showing 12 changed files with 1,713 additions and 52 deletions.
18 changes: 17 additions & 1 deletion testing/web-platform/tests/interfaces/webhid.idl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ hid
[
Exposed
=
(
DedicatedWorker
ServiceWorker
)
SecureContext
]
partial
Expand All @@ -92,8 +95,9 @@ hid
Exposed
=
(
Window
DedicatedWorker
ServiceWorker
Window
)
SecureContext
]
Expand Down Expand Up @@ -183,7 +187,11 @@ usage
[
Exposed
=
(
DedicatedWorker
ServiceWorker
Window
)
SecureContext
]
interface
Expand Down Expand Up @@ -297,7 +305,11 @@ reportId
[
Exposed
=
(
DedicatedWorker
ServiceWorker
Window
)
SecureContext
]
interface
Expand Down Expand Up @@ -337,7 +349,11 @@ device
[
Exposed
=
(
DedicatedWorker
ServiceWorker
Window
)
SecureContext
]
interface
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<
script
>
'
use
strict
'
;
let
worker
=
new
Worker
(
'
permissions
-
policy
-
hid
-
worker
.
js
'
)
;
worker
.
onmessage
=
event
=
>
{
window
.
parent
.
postMessage
(
event
.
data
'
*
'
)
;
}
;
worker
.
postMessage
(
{
type
:
'
ready
'
}
)
;
<
/
script
>
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
'
use
strict
'
;
if
(
typeof
postMessage
=
=
=
'
function
'
)
{
onmessage
=
event
=
>
{
switch
(
event
.
data
.
type
)
{
case
'
ready
'
:
navigator
.
hid
.
getDevices
(
)
.
then
(
(
)
=
>
postMessage
(
{
type
:
'
availability
-
result
'
enabled
:
true
}
)
error
=
>
postMessage
(
{
type
:
'
availability
-
result
'
enabled
:
false
}
)
)
;
break
;
}
}
;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<
script
>
'
use
strict
'
;
Promise
.
resolve
(
)
.
then
(
(
)
=
>
navigator
.
hid
.
getDevices
(
)
)
.
then
(
devices
=
>
{
window
.
parent
.
postMessage
(
{
type
:
'
availability
-
result
'
enabled
:
true
}
'
*
'
)
;
}
error
=
>
{
window
.
parent
.
postMessage
(
{
type
:
'
availability
-
result
'
enabled
:
false
}
'
*
'
)
;
}
)
;
<
/
script
>
Loading

0 comments on commit cab5a38

Please sign in to comment.