url icon indicating copy to clipboard operation
url copied to clipboard

Define the "extract an origin" operation.

Open mikewest opened this issue 2 weeks ago • 3 comments

https://github.com/whatwg/html/pull/11846 added an Origin interface, which relies on an "extract an origin" operation to support the creation of new Origin objects via Origin.from(...). This PR defines that operation for URL objects.

Addresses a remaining portion of https://github.com/whatwg/html/issues/11534.

  • [X] At least two implementers are interested (and none opposed):
    • https://github.com/whatwg/html/pull/11846 records the support for the underlying change.
  • [X] Tests are written and can be reviewed and commented upon at:
    • https://wpt.fyi/results/html/browsers/origin/tentative/api/origin-from-url.any.html?label=experimental&label=master&aligned (will be non-tentative shortly).
  • [X] Implementation bugs are filed:
    • This work is part of the work necessary for the bugs recorded in the HTML PR above.
  • [X] MDN issue is filed: Same as the HTML PR above.
  • [X] The top of this comment includes a clear commit message to use.

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


Preview | Diff

mikewest avatar Dec 04 '25 08:12 mikewest

WPT comments:

  • You can't create new content in WPT /interfaces/. That directory is managed automatically. It should probably be tested as part of other html.idl APIs, though perhaps it can be split, but it'll have to load html.idl.
  • It seems like we don't have tests for <a> and <area> without href attributes. From a quick skim I suspect this might not be implemented correctly.

annevk avatar Dec 04 '25 16:12 annevk

You can't create new content in WPT /interfaces/. That directory is managed automatically. It should probably be tested as part of other html.idl APIs, though perhaps it can be split, but it'll have to load html.idl.

You're right, I didn't think about this when we moved Origin into HTML. I'll fix it up once the file's updated (https://github.com/w3c/webref/blob/main/ed/idl/html.idl is up to date, but hasn't been pulled in yet...).

It seems like we don't have tests for <a> and <area> without href attributes. From a quick skim I suspect this might not be implemented correctly.

I can add those, thanks for the suggestion!

mikewest avatar Dec 05 '25 06:12 mikewest

It seems like we don't have tests for <a> and <area> without href attributes. From a quick skim I suspect this might not be implemented correctly.

I can add those, thanks for the suggestion!

You were right; Chromium's implementation was returning an opaque origin rather than throwing on Origin.from(<a>). Fixing that and updating the tests in https://chromium-review.googlesource.com/c/chromium/src/+/7231346.

mikewest avatar Dec 05 '25 06:12 mikewest