-
Notifications
You must be signed in to change notification settings - Fork 159
Define the "extract an origin" operation. #892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3495,6 +3495,11 @@ null-or-<a>scalar value string</a> <var>base</var> (default null), and then runs | |
| </ol> | ||
| </div> | ||
|
|
||
| <div algorithm="URL/extract an origin"> | ||
| <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]] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
|
|
||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?