This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 23406 - location.origin, origin of the document or origin of location.href?
Summary: location.origin, origin of the document or origin of location.href?
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: DOM (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Anne
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-01 09:04 UTC by Simon Pieters
Modified: 2013-10-28 16:55 UTC (History)
3 users (show)

See Also:


Attachments

Description Simon Pieters 2013-10-01 09:04:31 UTC
http://url.spec.whatwg.org/#dom-url-origin

[[
Return the Unicode serialization of url's origin.
]]

It looks like currently, location.origin gives the origin of the location.href URL. This can be different from the document's origin, e.g. if document.domain is set, or if the origin is inherited (e.g. about:blank or javascript: URL in an iframe).

IIRC a use case for location.origin is checking e.origin in cross-document messaging. For that case it seems like you want the document's origin.
Comment 1 Anne 2013-10-01 15:59:19 UTC
We should have document.origin for that. We could add it to the DOM.

Adding Ian just in case he has a different opinion.
Comment 2 Ian 'Hixie' Hickson 2013-10-07 20:57:57 UTC
LGTM.
Comment 4 Anne 2013-10-28 16:55:31 UTC
And serializing it is this commit because I'm an idiot: https://github.com/whatwg/dom/commit/b5dcd1560f4c19a70f2dfc7eb1e00289809554e2