commit 7075a8ced0edc12c972dfdc03444a9ed40e42d8c
parent 4eda36fbb95f550bbf9b6dd1de908afef9aaf4b6
Author: Mike West <mkwst@chromium.org>
Date: Mon, 27 Oct 2025 10:05:51 +0000
Bug 1996014 [wpt PR 55619] - [OriginAPI] Delegate origin extraction for `ExtendableMessageEvent`., a=testonly
Automatic update from web-platform-tests
[OriginAPI] Delegate origin extraction for `ExtendableMessageEvent`.
We can't directly work with an `ExtendableMessageEvent` from within
`DOMOrigin::from()`, as the former is defined in //modules, while the
latter is defined in //core. This CL teaches `Event` (the first ancestor
in `ExtendableMessageEvent`'s prototype chain) to support origin
extraction, and overrides its default no-op implementation in both
`MessageEvent` and `ExtendableMessageEvent`.
Bug: 434131026
Change-Id: I605b770c460ea97ca22545f94bae65bcbab5c01e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7074832
Reviewed-by: Antonio Sartori <antoniosartori@chromium.org>
Commit-Queue: Mike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1534317}
--
wpt-commits: b6c0aa940eb81d0963200e30340a798862b3716b
wpt-pr: 55619
Diffstat:
1 file changed, 38 insertions(+), 0 deletions(-)
diff --git a/testing/web-platform/tests/html/browsers/origin/tentative/api/origin-from-extendablemessageevent.any.js b/testing/web-platform/tests/html/browsers/origin/tentative/api/origin-from-extendablemessageevent.any.js
@@ -0,0 +1,38 @@
+// META: title=`Origin.from(ExtendableMessageEvent)`
+// META: global=serviceworker
+// META: script=/common/get-host-info.sub.js
+
+function WorkerActivationPromise() {
+ return new Promise((resolve) => {
+ if (registration.active) {
+ resolve();
+ return;
+ }
+ self.addEventListener('activate', () => { resolve(); });
+ });
+}
+
+test(t => {
+ const e = new ExtendableMessageEvent("message", { origin: get_host_info().ORIGIN });
+ const origin = Origin.from(e);
+ assert_true(!!origin, "It's not null!");
+ assert_false(origin.opaque, "It's not opaque!");
+ assert_true(origin.isSameOrigin(Origin.from(self)), "It's same-origin with an Origin!");
+}, "Constructed `ExtendableMessageEvent` objects have origins.");
+
+
+promise_test(async t => {
+ await WorkerActivationPromise();
+
+ return new Promise(resolve => {
+ self.addEventListener("message", e => {
+ const origin = Origin.from(e);
+ assert_true(!!origin);
+ assert_false(origin.opaque);
+ assert_true(origin.isSameOrigin(Origin.from(self)));
+ resolve();
+ });
+
+ self.registration.active.postMessage({ type: "Hi" });
+ });
+}, "Posted `ExtendableMessageEvent` objects have origins.");