Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions url.bs
Original file line number Diff line number Diff line change
Expand Up @@ -3495,6 +3495,11 @@ null-or-<a>scalar value string</a> <var>base</var> (default null), and then runs
</ol>
</div>

<div algorithm>
<p>Objects implementing the {{URL}} interface's <a for="platform object">extract an origin</a> steps are
to return <a>this</a>'s <a for=URL>URL</a>'s <a for=url>origin</a>. [[!HTML]]
Copy link
Member

Choose a reason for hiding this comment

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

I think it's a little weird that we use "this" here, but it's probably okay.

Copy link
Member Author

Choose a reason for hiding this comment

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

This mirrors what we did in HTML (e.g. https://html.spec.whatwg.org/multipage/browsers.html#the-origin-interface:extract-an-origin and https://html.spec.whatwg.org/multipage/webappapis.html#windoworworkerglobalscope-mixin:extract-an-origin). We could replace it with something like "the object's" throughout if that would be preferable?

Copy link
Member

@shannonbooth shannonbooth Dec 8, 2025

Choose a reason for hiding this comment

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

Something that I noticed is not covered by WPT (just incase this case was not considered in the design) is the below case:

let url = new URL('data:text/plain,opaque');
const origin1 = Origin.from(url);
const origin2 = Origin.from(url);
console.log(origin1.isSameOrigin(origin2));

Which from https://url.spec.whatwg.org/#concept-url-origin the result will be false:

-> Otherwise
Return a new opaque origin.

NOTE: This does indeed mean that these URLs cannot be same origin with themselves.

A similar case also happens for https://html.spec.whatwg.org/multipage/links.html#api-for-a-and-area-elements:extract-an-origin I believe.

I can make the updates to WPT, just thought I'd double check I have the right understanding, since I suppose it is possible to hold on to the origin for those objects to have different behaviour if-so desired

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, we should test that and I think it should return false indeed.

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 thought I'd added tests like that to https://wpt.fyi/results/html/browsers/origin/api/origin-comparison.any.html?label=master&label=experimental&aligned, but I didn't. If you have a PR, great! If not, I'll put one up this morning (as I need to fix the IDL test anyway).

Copy link
Member

@shannonbooth shannonbooth Dec 9, 2025

Choose a reason for hiding this comment

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

Nothing comprehensive so far unfortunately sorry! Only have so far the URL & hyperlink element case from hacking around my implementation locally. I haven't built up anything more comprehensive for the other cases like for WindowOrWorkerGlobal scope which seem like would be a bit different in that the ESO returns the same origin origin instance (besides from data URL workers, which create a new opaque one when callef).

Copy link
Member

@shannonbooth shannonbooth Dec 24, 2025

Choose a reason for hiding this comment

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

Sorry for the delay, I have been busy with day-job and other stuff lately rather than hacking on web-platform stuff like I would like to do, finally got around to raising something now web-platform-tests/wpt#56922

Edit: Unrelated question - but will this new section of the specification be linkable somehow? At least locally I can't figure out what such a link will end up being. For the HTML spec it's things like https://html.spec.whatwg.org/multipage/webappapis.html#windoworworkerglobalscope-mixin:extract-an-origin, but I only managed to find that from cross-links which doesn't work in the URL specification at a standalone document. Probably some other method of getting it I am missing though!

</div>

<hr>

<div algorithm>
Expand Down
Loading