-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ExtendableMessageEvent.ports should return the same object
https://bugs.webkit.org/show_bug.cgi?id=273542 rdar://127350353 Reviewed by Chris Dumez. Reuse what was done for MessageEvent.ports in ExtendableMessageEvent.ports. We use a JSValueInWrappedObject to store the JS ports object so that we always return the same JS object. * LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/message-event-ports-worker.js: Added. * LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/message-event-ports.https-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/message-event-ports.https.html: Added. * Source/WebCore/bindings/js/JSExtendableMessageEventCustom.cpp: (WebCore::JSExtendableMessageEvent::ports const): (WebCore::JSExtendableMessageEvent::visitAdditionalChildren): * Source/WebCore/workers/service/ExtendableMessageEvent.h: * Source/WebCore/workers/service/ExtendableMessageEvent.idl: Originally-landed-as: bb2720bcf112. https://bugs.webkit.org/show_bug.cgi?id=273542 Canonical link: https://commits.webkit.org/278690@main
- Loading branch information
Showing
6 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
...sts/service-workers/service-worker/ServiceWorkerGlobalScope/message-event-ports-worker.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
self.onmessage = e => { | ||
e.source.postMessage(e.ports === e.ports ? "same ports array" : "different ports array"); | ||
}; |
3 changes: 3 additions & 0 deletions
3
...ce-workers/service-worker/ServiceWorkerGlobalScope/message-event-ports.https-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
PASS Verify MessageEvent.ports getter returns the same object | ||
|
43 changes: 43 additions & 0 deletions
43
...ts/service-workers/service-worker/ServiceWorkerGlobalScope/message-event-ports.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Service Worker GlobalScope onerror event</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
<body> | ||
<canvas id=canvas></canvas> | ||
<script> | ||
var registration; | ||
|
||
async function registerServiceWorker() | ||
{ | ||
const registration = await navigator.serviceWorker.register("message-event-ports-worker.js", { scope : "." }); | ||
let activeWorker = registration.active; | ||
if (activeWorker) | ||
return registration; | ||
activeWorker = registration.installing; | ||
return new Promise(resolve => { | ||
activeWorker.addEventListener('statechange', () => { | ||
if (activeWorker.state === "activated") | ||
resolve(registration); | ||
}); | ||
}); | ||
} | ||
|
||
promise_test(async (test) => { | ||
registration = await registerServiceWorker(); | ||
|
||
registration.active.postMessage("test"); | ||
let result = await new Promise(resolve => navigator.serviceWorker.onmessage = e => resolve(e.data)); | ||
assert_equals(result, "same ports array", "empty array"); | ||
|
||
const channel = new MessageChannel();; | ||
const port = channel.port1; | ||
registration.active.postMessage({ port }, [port]); | ||
result = await new Promise(resolve => navigator.serviceWorker.onmessage = e => resolve(e.data)); | ||
assert_equals(result, "same ports array", "not empty array"); | ||
}, "Verify MessageEvent.ports getter returns the same object"); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters