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 28375 - The global object has an origin in implementations, we should acknowledge this. Specifications also routinely assume it has one, e.g. IDB.
Summary: The global object has an origin in implementations, we should acknowledge thi...
Status: RESOLVED WORKSFORME
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: Other other
: P3 normal
Target Milestone: Unsorted
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL: https://html.spec.whatwg.org/#origin
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-30 13:55 UTC by contributor
Modified: 2016-03-16 14:02 UTC (History)
5 users (show)

See Also:


Attachments

Description contributor 2015-03-30 13:55:33 UTC
Specification: https://html.spec.whatwg.org/multipage/browsers.html
Multipage: https://html.spec.whatwg.org/multipage/#origin
Complete: https://html.spec.whatwg.org/#origin
Referrer: 

Comment:
The global object has an origin in implementations, we should acknowledge
this. Specifications also routinely assume it has one, e.g. IDB.

Posted from: 77.57.114.240 by annevk@annevk.nl
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:39.0) Gecko/20100101 Firefox/39.0
Comment 1 Ian 'Hixie' Hickson 2015-03-30 23:26:37 UTC
It's in the environment settings object, no?
Comment 2 Anne 2015-03-31 06:57:04 UTC
Boris, Hixie is right, origin is part of the environment settings object. Which at the moment is always 1:1 with a global object. I guess the question is what happens with new Realm(), but maybe we should revisit at that point.
Comment 3 Boris Zbarsky 2015-03-31 14:05:02 UTC
OK.  So can we define "the origin of global X" to be "the origin stored in the environment settings object corresponding to global X"?  Because pretty much no spec writer will think to write the latter....
Comment 4 Ian 'Hixie' Hickson 2015-04-07 22:27:14 UTC
We could, but if those spec writers haven't read enough to understand the basics of the Web's security model (such as where the origin is defined) then shouldn't we have much bigger worries?

The reason the origin is on the environment settings object is that a particular environment settings object can actually have two different global objects (the document.open() case). Doing things based on the global isn't a good idea IMHO as it has very subtle implications.
Comment 5 Boris Zbarsky 2015-04-07 22:32:39 UTC
> but if those spec writers haven't read enough to understand the basics of the
> Web's security model

We have problems like that, sure.  But even people who _have_ read it are not likely to remember "the origin stored in the environment settings object corresponding to global X".  Whereas remembering "the origin of global X" is much more straightforward, happens to match how at least the UAs I'm aware of implement this better, and is generally clearer all around.  Just a matter of ergonomics.

> The reason the origin is on the environment settings object is that a
> particular environment settings object can actually have two different global
> objects (the document.open() case)

Sure.  But in that case, the "origin of the global" makes perfect sense; both globals share it, right?  If we had the _reverse_ situation, where a single global could have multiple environment settings objects, that would be a bigger issue.

> Doing things based on the global isn't a good idea IMHO

What do implementations do, I wonder, and is it detectable?  Presumably it's only detectable via some combination of document.domain and document.open() and then seeing which objects have which effective script origin associated with them or something?
Comment 6 Boris Zbarsky 2015-04-07 22:34:50 UTC
One other thing.  Just to be clear, "the Web's security model" as it applies to whether origins are associated with globals or settigs objects may or may not mean anything, since historically the web has had no concept of settings objects, so it's more or less a specification device to explain something.  What I'm trying to understand is, for the document.open case, what behavior UAs have right now prompted this particular specification device.
Comment 7 Ian 'Hixie' Hickson 2015-04-09 19:08:28 UTC
The settings objects originated as part of speccing the "incumbent script" stack, IIRC.

Anyway, I guess it's fine for us to add some prose somewhere saying that when specs refer to the origin of a global, they really mean the origin of the global's environment settings object. It just seems a bit annoying to have all this indirection everywhere. I think it'd be better to submit feedback to the relevant specs to have them fixed.
Comment 8 Boris Zbarsky 2015-04-09 19:52:10 UTC
I disagree about the cost/benefit analysis here.  It's better to have one single indirection that rigorously defines a concept everyone intuitively understands anyway than to have lots of specs have language that no one can understand without following a bunch of convoluted language in other specs.
Comment 9 Ian 'Hixie' Hickson 2015-04-16 22:03:50 UTC
If anyone thinks they "intuitively understand" the security model here, then they almost certainly don't. Thus I think that the current situation, where editors who haven't understood the model end up using language like "origin of the Window", acts as an interesting way to flag specs whose authors haven't fully grokked the security model and whose specs therefore might need even closer scrutiny than normal.

I don't understand how _adding_ a level of indirection can possibly make things simpler to understand. You still have to follow all the links, there's just one more to follow.
Comment 10 Boris Zbarsky 2015-04-16 23:08:37 UTC
I'm not sure what it is you think people don't understand in the security model.  The origin of a Window is pretty clear; the fact that it's stored in the script settings object instead of the Window only matters for the effective script origin, not the origin, yes?  And even then it's not clear to me that the model the spec describes is what UAs do in practice.  I haven't had a chance to write testcases to verify whether it is, but if you have some I'd love to see them.

In any case, unless effective script origins get involved, the fact that the origin lives on the script settings object is a pure specification device which is just unnecessary complication imo.
Comment 11 Ian 'Hixie' Hickson 2015-04-20 20:57:37 UTC
Effective script origins are always involved. Windows aren't always involved. There's not always a global object (since scripting support is optional). These are just three of the subtleties that I would fear people don't understand if they just refer to "the origin of the global object" despite this not being a defined term currently. We can certainly define the term and paper over this lack of deep understanding. It's just that that would remove this flag we have now, which lets us quickly determine how carefully the spec author has read the specs the spec author is referencing.
Comment 12 Boris Zbarsky 2015-04-20 21:03:48 UTC
> Effective script origins are always involved.

That's just not true.  Various things only examine the origin, not the effective script origin.

> Windows aren't always involved.

Sure.  Except for APIs that are only exposed on Window, of course.  More on this below.

> There's not always a global object (since scripting support is optional).

Hmm.  There's always an object there that acts as the global for scripting purposes when scripting is supported, but ok.

And more importantly, for most cases where people are worrying about origins they're defining an IDL API, and then scripting support not existing simply means their code is unreachable anyway.

> which lets us quickly determine how carefully the spec author has read the
> specs the spec author is referencing

No other spec author has read the HTML spec on this matter, except perhaps Anne.  We don't need a flag to know that.

And since no one is checking this flag anyway, its value is pretty low.  :(
Comment 13 Anne 2016-02-14 17:25:38 UTC
There is a very easy way now to get to a settings object from a platform object (including a global object). It's called "relevant settings object". Things still get a little verbose at times, but it doesn't seem that bad to me.
Comment 14 Anne 2016-03-16 14:02:50 UTC
I think this is pretty good now. Hopefully we'll be able to simplify more going forward.