Skip to content
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

Globalutils and self.origin #951

Merged
merged 2 commits into from
Apr 6, 2016
Merged

Globalutils and self.origin #951

merged 2 commits into from
Apr 6, 2016

Conversation

annevk
Copy link
Member

@annevk annevk commented Mar 28, 2016

See commit messages for details.

@@ -87428,6 +87428,8 @@ interface <dfn>DocumentAndElementEventHandlers</dfn> {

[NoInterfaceObject, Exposed=(Window,Worker)]
interface <dfn>GlobalUtils</dfn> {
[Replaceable] readonly attribute USVString <span data-x="dom-origin">origin</span>;
Copy link
Member

Choose a reason for hiding this comment

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

Why Replaceable?

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 figured new short properties on the global object need to be replaceable to ease compatibility concerns. If @bzbarsky thinks otherwise I'd be happy to drop it. bz was also who I had in mind as implementer interest from the Gecko side (though not necessarily the person implementing).

@domenic domenic added the addition/proposal New features or enhancements label Mar 29, 2016
@domenic
Copy link
Member

domenic commented Mar 29, 2016

Can we get some implementer commitments for this new feature?

<p>The <code data-x="dom-windowbase64-atob">atob()</code> and <code
data-x="dom-windowbase64-btoa">btoa()</code> methods allow authors to transform content to and from
the base64 encoding.</p>
<h3 id="globalutils-mixin">The <code>GlobalUtils</code> mixin</h3>
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 WindowWorkerUtils is probably better, given Worklets...

@domenic domenic added the needs implementer interest Moving the issue forward requires implementers to express interest label Mar 29, 2016
@bzbarsky
Copy link
Contributor

Looks ok to me for the "origin" part, as long as we actualy define the origin of every global. I didn't really look at the other pieces.

@annevk annevk assigned domenic and unassigned bzbarsky Apr 1, 2016
@annevk
Copy link
Member Author

annevk commented Apr 1, 2016

Thanks.

@domenic
Copy link
Member

domenic commented Apr 1, 2016

Let's move to WindowOrWorkerUtils and then we can merge the first commit. The second commit needs more implementer interest though. @mikewest, @jeisinger, you guys do origin stuff in Blink; any interest in adding self.origin?


<!-- v2: actual binary support -->
[NoInterfaceObject, Exposed=(Window,Worker)]
interface <dfn>GlobalUtils</dfn> {
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 don't like WindowOrWorkerUtils. I suggest WindowOrWorkerGlobalScope. That's more consistent with DOM mixins. Waiting with fixing this though until we heard back from Googlers, not entirely sure how to merge a single commit.

Copy link
Member

Choose a reason for hiding this comment

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

WindowOrWorkerGlobalScope works for me. I can merge a single commit (or walk you through it) if you want.

@jeisinger
Copy link
Member

Just to clarify, the attribute should return the origin, not the effective origin?

@annevk
Copy link
Member Author

annevk commented Apr 2, 2016

@jeisinger correct (also, note I merged effective script origin into origin with #925 so the specification no longer has that concept).

@mikewest
Copy link
Member

mikewest commented Apr 2, 2016

I don't have any objection to exposing the global object's origin. Would we drop document.origin when we do so? There's probably no harm in having both, but it seems a bit redundant.

@jeisinger
Copy link
Member

k, should be easy to implement

@annevk
Copy link
Member Author

annevk commented Apr 3, 2016

@mikewest see https://bugzilla.mozilla.org/show_bug.cgi?id=931884#c11 where I asked about that. In reply @bzbarsky suggested to have both. (And to try to get folks to not use location.origin for security checks.)

@annevk
Copy link
Member Author

annevk commented Apr 3, 2016

Renamed the mixin to WindowOrWorkerGlobalScope.

@domenic
Copy link
Member

domenic commented Apr 5, 2016

So we'll have three origins, right? location.origin, document.origin, and origin? Will they always return the same value, or not? Should we add examples of how they could differ? Should we add warnings to the two that we don't like?

@annevk
Copy link
Member Author

annevk commented Apr 5, 2016

I think document.origin and self.origin will always be identical. location.origin can be different. E.g., <iframe onload=alert(this.contentWindow.location.origin)></iframe> gives "null", which can be very misleading since that window/document will share the origin of its parent.

@domenic
Copy link
Member

domenic commented Apr 5, 2016

So interestingly, document.origin is only implemented in Blink, and sort of in WebKit. In Safari on my iPad http://jsbin.com/velohejexi/edit?html,console returns "http_null.jsbin.com_0". (In Chrome it returns "http://null.jsbin.com".)

So maybe we should remove document.origin.

@domenic
Copy link
Member

domenic commented Apr 5, 2016

Regardless I think we should add the example you showed to make it clear how origin and location.origin differ.

@annevk
Copy link
Member Author

annevk commented Apr 5, 2016

Yeah, I would be okay with removing document.origin if @bzbarsky, @jeisinger, et al, are on board with that. That's a simple change to the DOM Standard.

I will add an example contrasting self.origin and location.origin later and ping this thread.

@bzbarsky
Copy link
Contributor

bzbarsky commented Apr 5, 2016

Will they always return the same value, or not?

We actually have four things: document.origin, bareword origin, self.origin, and location.origin. I believe document.origin (written exactly like that) and bareword origin will always return the same thing. self.origin will NOT necessarily return the same thing in cases when the code is running in a navigated-away-from window, because then self is a WindowProxy to the new Window; it will either return the same thing, throw, or return a different thing, depending on whether the navigation was cross-origin or not and depending on what happened with document.domain.

I guess the behavior of bareword origin isn't quite defined by specs either (but of course neither is self.origin), and may well not even be interoperable across browsers in the navigated-away-from case....

@annevk
Copy link
Member Author

annevk commented Apr 5, 2016

Bareword origin being a side effect of adding self.origin, I take it? That difference we should maybe call out under Window/WindowProxy.

@bzbarsky
Copy link
Contributor

bzbarsky commented Apr 5, 2016

Bareword origin being a side effect of adding self.origin, I take it?

If you want to view it that way, yes.

<p>The <code data-x="dom-windowbase64-atob">atob()</code> and <code
data-x="dom-windowbase64-btoa">btoa()</code> methods allow authors to transform content to and from
the base64 encoding.</p>
<h3 id="windoworworkerglobalscope-mixin">The <code>WindowOrWorkerGlobalScope</code> mixin</h3>
Copy link
Member

Choose a reason for hiding this comment

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

This probably should get an intro paragraph explaining what it is and that other specs can extend it. Just a section with an IDL block kind of sucks.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, also added an example.

This makes the following editorial changes:

* Groups base64, timer, and ImageBitmap properties on a single mixin.
* Removes overloading of timer methods in favor of a union type

It is expected that other standards will make use of this mixin,
e.g., Fetch will use it to define fetch().
@domenic
Copy link
Member

domenic commented Apr 6, 2016

OK cool, this looks good to me; merging. Still unsure about whether [Replaceable] is a great idea, but I guess it's safer that way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest
Development

Successfully merging this pull request may close these issues.

6 participants