Skip to content

Conversation

@mikewest
Copy link
Member

@mikewest mikewest commented Oct 29, 2025

This patch adds the Origin interface to HTML by shifting the normative
portions of https://mikewest.github.io/origin-api/ into this document.

As a followup, this will require changes to [[URL]] and [[ServiceWorker]] as well to define the "extract an origin" for relevant objects.

See discussion in w3ctag/design-reviews#1130, WebKit/standards-positions#538, and mozilla/standards-positions#1280.

(See WHATWG Working Mode: Changes for more details.)


/browsers.html ( diff )
/comms.html ( diff )
/index.html ( diff )
/links.html ( diff )
/webappapis.html ( diff )
/workers.html ( diff )

@zcorpan
Copy link
Member

zcorpan commented Nov 5, 2025

I would like to see mikewest/origin-api#6 addressed.

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some editorial comments. Generally this looks good to me.

philwo pushed a commit to philwo/chromium that referenced this pull request Nov 7, 2025
whatwg/html#11846 (comment) noted
that we should verify schemeful same-site comparison; this CL adds that
test.

Bug: 434131026
Change-Id: I48878979fc0f8c3dab2caefbe788a14d367e053b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7130621
Reviewed-by: Antonio Sartori <[email protected]>
Commit-Queue: Mike West <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1541759}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Nov 7, 2025
whatwg/html#11846 (comment) noted
that we should verify schemeful same-site comparison; this CL adds that
test.

Bug: 434131026
Change-Id: I48878979fc0f8c3dab2caefbe788a14d367e053b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7130621
Reviewed-by: Antonio Sartori <[email protected]>
Commit-Queue: Mike West <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1541759}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Nov 7, 2025
whatwg/html#11846 (comment) noted
that we should verify schemeful same-site comparison; this CL adds that
test.

Bug: 434131026
Change-Id: I48878979fc0f8c3dab2caefbe788a14d367e053b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7130621
Reviewed-by: Antonio Sartori <[email protected]>
Commit-Queue: Mike West <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1541759}
lando-prod-mozilla bot pushed a commit to mozilla-firefox/firefox that referenced this pull request Nov 11, 2025
… schemeful., a=testonly

Automatic update from web-platform-tests
[Origin API] Verify that comparisons are schemeful.

whatwg/html#11846 (comment) noted
that we should verify schemeful same-site comparison; this CL adds that
test.

Bug: 434131026
Change-Id: I48878979fc0f8c3dab2caefbe788a14d367e053b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7130621
Reviewed-by: Antonio Sartori <[email protected]>
Commit-Queue: Mike West <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1541759}

--

wpt-commits: 08b913918dd419fe48d01ef685781a69ced0a111
wpt-pr: 55938
i3roly pushed a commit to i3roly/firefox-dynasty that referenced this pull request Nov 12, 2025
… schemeful., a=testonly

Automatic update from web-platform-tests
[Origin API] Verify that comparisons are schemeful.

whatwg/html#11846 (comment) noted
that we should verify schemeful same-site comparison; this CL adds that
test.

Bug: 434131026
Change-Id: I48878979fc0f8c3dab2caefbe788a14d367e053b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7130621
Reviewed-by: Antonio Sartori <[email protected]>
Commit-Queue: Mike West <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1541759}

--

wpt-commits: 08b913918dd419fe48d01ef685781a69ced0a111
wpt-pr: 55938
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Nov 12, 2025
… schemeful., a=testonly

Automatic update from web-platform-tests
[Origin API] Verify that comparisons are schemeful.

whatwg/html#11846 (comment) noted
that we should verify schemeful same-site comparison; this CL adds that
test.

Bug: 434131026
Change-Id: I48878979fc0f8c3dab2caefbe788a14d367e053b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7130621
Reviewed-by: Antonio Sartori <antoniosartorichromium.org>
Commit-Queue: Mike West <mkwstchromium.org>
Cr-Commit-Position: refs/heads/main{#1541759}

--

wpt-commits: 08b913918dd419fe48d01ef685781a69ced0a111
wpt-pr: 55938

UltraBlame original commit: 313ef5bf80f71a4e57fc5bebfd0d784dd667b024
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Nov 13, 2025
… schemeful., a=testonly

Automatic update from web-platform-tests
[Origin API] Verify that comparisons are schemeful.

whatwg/html#11846 (comment) noted
that we should verify schemeful same-site comparison; this CL adds that
test.

Bug: 434131026
Change-Id: I48878979fc0f8c3dab2caefbe788a14d367e053b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7130621
Reviewed-by: Antonio Sartori <antoniosartorichromium.org>
Commit-Queue: Mike West <mkwstchromium.org>
Cr-Commit-Position: refs/heads/main{#1541759}

--

wpt-commits: 08b913918dd419fe48d01ef685781a69ced0a111
wpt-pr: 55938

UltraBlame original commit: 313ef5bf80f71a4e57fc5bebfd0d784dd667b024
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Nov 13, 2025
… schemeful., a=testonly

Automatic update from web-platform-tests
[Origin API] Verify that comparisons are schemeful.

whatwg/html#11846 (comment) noted
that we should verify schemeful same-site comparison; this CL adds that
test.

Bug: 434131026
Change-Id: I48878979fc0f8c3dab2caefbe788a14d367e053b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7130621
Reviewed-by: Antonio Sartori <antoniosartorichromium.org>
Commit-Queue: Mike West <mkwstchromium.org>
Cr-Commit-Position: refs/heads/main{#1541759}

--

wpt-commits: 08b913918dd419fe48d01ef685781a69ced0a111
wpt-pr: 55938

UltraBlame original commit: 313ef5bf80f71a4e57fc5bebfd0d784dd667b024
This patch shifts the normative portions of
https://mikewest.github.io/origin-api/ into a patch against HTML
for discussion.

As a followup, this will require changes to [[URL]] and
[[ServiceWorker]] as well to define the "extract an origin" for relevant
objects.

See discussion in w3ctag/design-reviews#1130,
WebKit/standards-positions#538, and
mozilla/standards-positions#1280.
source Outdated
Comment on lines 92529 to 92533
<p class="note">Note that same-site checks might return different values for the same origins in
different user agents, or even in the same user agent at different times, as the public suffix
list is updated and distributed in implementation-defined ways. <span
data-x="dom-Origin-isSameSite">isSameSite()</span> reflects the user agent's current understanding
of the relationship between two origins, but makes no promises about the future.</p>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this note in response to @erik-anderson's suggestion in mikewest/origin-api#11. Otherwise, I think this PR is pretty good to go.

If @annevk and @zcorpan are happy-enough, I'll go file bugs against browsers, and see if Chromium folks will let me get it out the door.

WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a big fan of this as there's quite a number of APIs this applies to and I don't think we want to call this out all over. I could maybe see adding it to URL (or even better would be the Public Suffix standard once we finally rescue that project from its current state).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I've taken it back out, and I'll put it up as a PR against URL.

source Outdated
<p>The <dfn method for="Origin"><code
data-x="dom-Origin-isSameOrigin">isSameOrigin(other)</code></dfn> method returns true if
<span>this</span>'s <span data-x="dom-Origin-origin">origin</span> is <span>same origin</span>
with <var>other</var>'s <span data-x="dom-Origin-origin">origin</span>, and false otherwise.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
with <var>other</var>'s <span data-x="dom-Origin-origin">origin</span>, and false otherwise.</p>
with <var>other</var>'s <span data-x="dom-Origin-origin">origin</span>; otherwise false.</p>

source Outdated
Comment on lines 92529 to 92533
<p class="note">Note that same-site checks might return different values for the same origins in
different user agents, or even in the same user agent at different times, as the public suffix
list is updated and distributed in implementation-defined ways. <span
data-x="dom-Origin-isSameSite">isSameSite()</span> reflects the user agent's current understanding
of the relationship between two origins, but makes no promises about the future.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a big fan of this as there's quite a number of APIs this applies to and I don't think we want to call this out all over. I could maybe see adding it to URL (or even better would be the Public Suffix standard once we finally rescue that project from its current state).

Copy link
Member Author

@mikewest mikewest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

source Outdated
Comment on lines 92529 to 92533
<p class="note">Note that same-site checks might return different values for the same origins in
different user agents, or even in the same user agent at different times, as the public suffix
list is updated and distributed in implementation-defined ways. <span
data-x="dom-Origin-isSameSite">isSameSite()</span> reflects the user agent's current understanding
of the relationship between two origins, but makes no promises about the future.</p>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I've taken it back out, and I'll put it up as a PR against URL.

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was looking at this again today thinking about Document vs Window and now I wonder about Location and WorkerLocation.

I followed blame back to https://bugzilla.mozilla.org/show_bug.cgi?id=931884#c10 (starting at 6bdba31) which suggests to me that obtaining an Origin from Location or WorkerLocation is not something we should offer by default. You can still do it by passing location.href, if you really know what you're doing, but in general those objects don't really hold the authority and so we shouldn't encourage that.

For a moment I thought they'd work anyway because of the string overload, but because we take any it's different I think and we won't attempt to coerce any argument to a string. Which in this case seems for the best.

@mikewest
Copy link
Member Author

I followed blame back to https://bugzilla.mozilla.org/show_bug.cgi?id=931884#c10 (starting at 6bdba31) which suggests to me that obtaining an Origin from Location or WorkerLocation is not something we should offer by default. You can still do it by passing location.href, if you really know what you're doing, but in general those objects don't really hold the authority and so we shouldn't encourage that.

I understand your point, but it seems unlikely we're going to be able to get rid of location.origin given its usage, it would be slightly odd for this to be the only interface with an origin property that Origin.from() wouldn't support. I think I'd suggest erring on the side of consistency, but I don't hold that opinion too strongly.

@annevk
Copy link
Member

annevk commented Nov 21, 2025

Right, I don't mean to suggest we get rid of that. Each URL-like object should support that, but I do think it's worth trying to hold the line here and get people to adopt the pattern that'll do the right thing in sandboxed environments and the like. We can always relent later. I'm also not entirely sure about <a> and <area>. The use cases for strings, globals, and message events seem clear though.

@mikewest
Copy link
Member Author

Ah, got it. Sandboxed contexts in which the origin differs between Location and Window seem like a sufficiently sharp edge that I think I'm convinced that dropping Location to start with is pretty reasonable. If we decide to add it later, it's trivial.

I don't know of any particularly valuable use cases for HTMLHyperlinkElementUtils, but it seems non-harmful in the same way strings and URLs are. 🤷 I'd just drop Location.

@annevk
Copy link
Member

annevk commented Nov 21, 2025

That works for me. I wonder how much longer we want to wait with feedback. Perhaps the Wednesday after Thanksgiving week (Dec 3) is a reasonable time to merge this if nothing else comes up (modulo the Location change)?

@mikewest
Copy link
Member Author

I took care of dropping Location and WorkerLocation in 2d77ad2, and I'll up a CL against Chromium to do the same. I'm fine with giving folks a little more time to weigh in. No rush.

@annevk
Copy link
Member

annevk commented Nov 21, 2025

One other thing we need by that date is a WPT PR to make the tests non-tentative and account for the recent changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants