commit d87dbf1c3e421032bd5539cd4064843c67eee8d9
parent 44191ea0c0d98add008fcf98585e7be57e924e98
Author: Mike West <mkwst@chromium.org>
Date: Mon, 8 Dec 2025 12:28:13 +0000
Bug 2004425 [wpt PR 56522] - [Origin API] `.from()` should throw on `<a>` and `<area>`., a=testonly
Automatic update from web-platform-tests
[Origin API] `.from()` should throw on `<a>` and `<area>`.
When extracting an origin from `<a>` and `<area>` elements without an
`href` attribute, we're currently returning an opaque `Origin`. We
should throw instead, as there's not an origin to extract from these
elements (see [1]). Thanks to @annevk for pointing this out in [2].
[1]: https://html.spec.whatwg.org/multipage/links.html#api-for-a-and-area-elements:extract-an-origin
[2]: https://github.com/whatwg/url/pull/892#issuecomment-3613108673
Bug: 434131026
Change-Id: I136cc0ff24355e29418e060ab384938f3615a60e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7231346
Commit-Queue: Mike West <mkwst@chromium.org>
Reviewed-by: Antonio Sartori <antoniosartori@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1554582}
--
wpt-commits: 97bfa0053605daefab920aded71c705030ff7f39
wpt-pr: 56522
Diffstat:
1 file changed, 10 insertions(+), 0 deletions(-)
diff --git a/testing/web-platform/tests/html/browsers/origin/api/origin-from-htmlhyperlinkelementutils.window.js b/testing/web-platform/tests/html/browsers/origin/api/origin-from-htmlhyperlinkelementutils.window.js
@@ -1,6 +1,16 @@
// META: title=`Origin.from(HTMLHyperlinkElementUtils)`
// META: script=resources/serializations.js
+test(t => {
+ const invalid = document.createElement("a");
+ assert_throws_js(TypeError, _ => Origin.from(invalid));
+}, `Origin.from(<a>) throws.`);
+
+test(t => {
+ const invalid = document.createElement("area");
+ assert_throws_js(TypeError, _ => Origin.from(invalid));
+}, `Origin.from(<area>) throws.`);
+
for (const opaque of urls.opaque) {
// <a>
test(t => {