Skip to content

Commit

Permalink
Bug 1558184 [wpt PR 17246] - service worker: Drop postMessage() to re…
Browse files Browse the repository at this point in the history
…dundant workers silently., a=testonly

Automatic update from web-platform-tests
service worker: Drop postMessage() to redundant workers silently.

Update the WPT and fix behavior. Per spec change at
w3c/ServiceWorker#1146.

Bug: 972461
Change-Id: Id4bac3fbe1996382952e54d46cb405de9eb951b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1650685
Reviewed-by: Hayato Ito <hayatochromium.org>
Reviewed-by: Kenichi Ishibashi <bashichromium.org>
Commit-Queue: Matt Falkenhagen <falkenchromium.org>
Cr-Commit-Position: refs/heads/master{#667523}

--

wp5At-commits: 0ea1346335e30ab897ee5124aeeafcae663b5f49
wpt-pr: 17246

UltraBlame original commit: 5212e992eae1bd2c5c287946cd79bd489b9cba27
  • Loading branch information
marco-c committed Oct 4, 2019
1 parent 4af6830 commit 682e823
Show file tree
Hide file tree
Showing 2 changed files with 283 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -338,85 +338,6 @@
;
}
)
.
then
(
(
)
=
>
{
return
wait_for_state
(
t
worker
'
redundant
'
)
;
}
)
.
then
(
(
)
=
>
{
assert_equals
(
worker
.
state
'
redundant
'
)
;
assert_throws
(
{
name
:
'
InvalidStateError
'
}
function
(
)
{
worker
.
postMessage
(
'
'
)
;
}
'
Calling
postMessage
on
a
redundant
ServiceWorker
should
'
+
'
throw
InvalidStateError
.
'
)
;
}
)
;
}
'
Expand Down Expand Up @@ -1510,6 +1431,264 @@
'
)
;
promise_test
(
async
t
=
>
{
const
firstScript
=
'
resources
/
postmessage
-
echo
-
worker
.
js
?
one
'
;
const
secondScript
=
'
resources
/
postmessage
-
echo
-
worker
.
js
?
two
'
;
const
scope
=
'
resources
/
'
;
const
registration
=
await
service_worker_unregister_and_register
(
t
firstScript
scope
)
;
t
.
add_cleanup
(
(
)
=
>
registration
.
unregister
(
)
)
;
const
firstWorker
=
registration
.
installing
;
const
messagePromise
=
new
Promise
(
resolve
=
>
{
navigator
.
serviceWorker
.
addEventListener
(
'
message
'
(
event
)
=
>
{
resolve
(
event
.
data
)
;
}
{
once
:
true
}
)
;
}
)
;
await
wait_for_state
(
t
firstWorker
'
activated
'
)
;
await
navigator
.
serviceWorker
.
register
(
secondScript
{
scope
}
)
;
const
secondWorker
=
registration
.
installing
;
await
wait_for_state
(
t
firstWorker
'
redundant
'
)
;
/
/
postMessage
(
)
to
a
redundant
worker
should
be
dropped
silently
.
/
/
Historically
this
threw
an
exception
.
firstWorker
.
postMessage
(
'
firstWorker
'
)
;
/
/
To
test
somewhat
that
it
was
not
received
send
a
message
to
another
/
/
worker
and
check
that
we
get
a
reply
for
that
one
.
secondWorker
.
postMessage
(
'
secondWorker
'
)
;
const
data
=
await
messagePromise
;
assert_equals
(
data
'
secondWorker
'
)
;
}
'
postMessage
to
a
redundant
worker
'
)
;
<
/
script
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
self
.
addEventListener
(
'
message
'
event
=
>
{
event
.
source
.
postMessage
(
event
.
data
)
;
}
)
;

0 comments on commit 682e823

Please sign in to comment.