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

Adapt to Fetch's data URL changes #1782

Merged
merged 2 commits into from
Oct 10, 2016
Merged

Conversation

annevk
Copy link
Member

@annevk annevk commented Sep 14, 2016

The change to Fetch discussed in
whatwg/fetch#381 made it obsolete.

Closes #1243, closes #1778, and closes #1779 as these are all treated
as same-origin now per the change to Fetch.

@annevk annevk added topic: fetch compat Standard is not web compatible or proprietary feature needs standardizing labels Sep 14, 2016
@domenic
Copy link
Member

domenic commented Sep 14, 2016

LGTM (after #1782 lands). Would be nice to either write some WPTs or file a bug with suggestions on what sort of tests to write.

@annevk annevk changed the title Remove Fetch's same-origin data URL flag Adapt to Fetch's data URL changes Sep 15, 2016
Copy link
Member

@mikewest mikewest left a comment

Choose a reason for hiding this comment

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

LGTM with a few tiny nits.

<li><p>If <var>is shared</var> is true and <var>url</var>'s <span
data-x="concept-url-scheme">scheme</span> is "<code>data</code>", then <span>queue a task</span>
to <span>fire a simple event</span> named <code data-x="event-error">error</code> at
<var>worker</var>, and abort these steps.</p></li>

<li id="worker-processing-model-top">
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Probably move this ID up to the new first item (or the ol?)

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 guess that's fine, I wonder who uses that ID...

@@ -97025,6 +97029,11 @@ interface <dfn>AbstractWorker</dfn> {
<li><p>Let <var>worker global scope</var> be <var>realm</var>'s <span
data-x="concept-realm-global">global object</span>.</p></li>

<li><p>Let <var>origin</var> be an <span data-x="concept-origin-opaque">opaque origin</span> if
Copy link
Member

Choose a reason for hiding this comment

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

In https://html.spec.whatwg.org/#concept-origin-opaque, Document objects are assigned "a unique opaque origin". Probably best to remain consistent with that "unique" usage.

data-x="blob protocol">blob:</code> URLs.</p>
<p class="note">Any <span data-x="same origin">same-origin</span> URL, including <code
data-x="blob protocol">blob:</code> URLs, and any <code data-x="data protocol">data:</code> URL
works.</p>
Copy link
Member

Choose a reason for hiding this comment

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

Nit: s/works/can be used/?

data-x="blob protocol">blob:</code> URLs.</p>
<p class="note">Any <span data-x="same origin">same-origin</span> URL, including <code
data-x="blob protocol">blob:</code> URLs, works. <code data-x="data protocol">data:</code> URLs
do not work.</p>
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

annevk added a commit to whatwg/fetch that referenced this pull request Sep 15, 2016
By-and-large browsers treat data URLs as same-origin, though there 
are some inconsistencies. This change will treat all data URLs, 
regardless of origin, as same-origin from the perspective of Fetch.

HTML already assigns a unique opague origin to documents created from
a data URL and the plan of record is to do so for dedicated workers
too.

HTML will likely also forbid shared workers to be created from data 
URLs.

See whatwg/html#1782 for the proposed changes 
to HTML. (This has not landed yet, if that PR is tweaked further the 
note added here might need some tweaks.)

Service workers already prevent anything but HTTP(S) URLs from 
creating them.

Fixes #381.
@annevk
Copy link
Member Author

annevk commented Sep 16, 2016

It seems that given #1243 (comment) we might want to also make this work for shared workers after all. It would require an additional origin slot I think, or something better I have not thought of. All that is pending approval from Chrome so marking this red.

@annevk annevk added the do not merge yet Pull request must not be merged per rationale in comment label Sep 16, 2016
@annevk annevk force-pushed the remove-same-origin-data-url-flag branch 2 times, most recently from 14d1e7a to 7434119 Compare September 30, 2016 14:22
@annevk
Copy link
Member Author

annevk commented Sep 30, 2016

I discussed this with @mikewest again and he's fine with the Firefox model as that allows introducing opaque origin workers going forward even without the use of data URLs.

(We could maybe say that for module workers, data URLs are same-origin, but I'm not sure if we want to go there. But technically the concern that we have with classic workers doesn't apply there.)

The main remaining problem with this patch is that cf0355d badly regressed setting state on SharedWorkerGlobalScope. There's basically no place right now where we set name and constructor url on it. @domenic any suggestions for how to fix that?

Basically wherever we decide setting that state, we should also set constructor origin. That would make everything work and it's not even that much additional complexity.

domenic added a commit that referenced this pull request Oct 4, 2016
cf0355d regressed setting up a SharedWorkerGlobalScope by removing the steps that set its constructor url and name. This was noticed in #1782 (comment).
@domenic
Copy link
Member

domenic commented Oct 4, 2016

Think I fixed that in #1858; unassigning from me. Reassign if you want me to actually review this PR :)

@domenic domenic removed their assignment Oct 4, 2016
@annevk
Copy link
Member Author

annevk commented Oct 5, 2016

Yeah, I'd like review from you both I think. I realize there's a little bit of rebasing that needs to be done, but I'd rather wait with that until #1858 lands and I think this can be reviewed in quite some detail already.

domenic added a commit that referenced this pull request Oct 5, 2016
cf0355d regressed setting up a
SharedWorkerGlobalScope by removing the steps that set its constructor
url and name. This was noticed in
#1782 (comment).

This also changes the constructor url from a string to a URL record, for
consistency with other URLs stored on objects throughout the spec.
@@ -97073,6 +97070,12 @@ interface <dfn>AbstractWorker</dfn> {
<li><p>Let <var>worker global scope</var> be <var>realm</var>'s <span
data-x="concept-realm-global">global object</span>.</p></li>

<li><p>Let <var>origin</var> be a unique <span
Copy link
Member

Choose a reason for hiding this comment

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

It wouldn't impact anything normative, but I think you could inline this algorithm into the origin "getter" below instead of creating a variable for it.

data-x="blob protocol">blob:</code> URLs.</p>
<p class="note">Any <span data-x="same origin">same-origin</span> URL, including <code
data-x="blob protocol">blob:</code> URLs, and any <code data-x="data protocol">data:</code> URL
can be used.</p>
Copy link
Member

Choose a reason for hiding this comment

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

Phrasing is awkward, hmm.

"Any same-origin URL (including blob: URLs) can be used; data: URLs will also work, despite not being same-origin"?

(Here and below, whatever we end up on.)

data-x="concept-SharedWorkerGlobalScope-constructor-url">constructor url</span> is
<var>urlString</var>, and <span data-x="concept-SharedWorkerGlobalScope-name">name</span> is
<var>name</var>, then set <var>worker global scope</var> to that
<code>SharedWorkerGlobalScope</code> object.</p></li>
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 that we should add a note here that explains how it's possible for constructor url to be equal but constructor origin to be different. Something like: "The reason we compare both constructor url and constructor origin is that data: URLs cause the created worker settings object to have a unique opaque origin, instead of one derived from the constructor url. This ensures that using the same data: URL multiple times creates separate SharedWorkerGlobalScope instances, as desired." (Hope I got that right...)

Copy link
Member Author

Choose a reason for hiding this comment

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

That's not quite right. The same data URL can be used to get the same instance, but we don't want to allow that across documents of different origins. Therefore we store the origin of the constructor. So only if the constructor origin is same-origin can the URL be equal.

domenic added a commit that referenced this pull request Oct 6, 2016
cf0355d regressed setting up a
SharedWorkerGlobalScope by removing the steps that set its constructor
url and name. This was noticed in
#1782 (comment).

This also changes the constructor url from a string to a URL record, for
consistency with other URLs stored on objects throughout the spec.
@annevk annevk force-pushed the remove-same-origin-data-url-flag branch from dde4386 to 07b2fc7 Compare October 7, 2016 09:12
@annevk
Copy link
Member Author

annevk commented Oct 7, 2016

@zcorpan do you know if data URLs are already tested? Is the top-level workers/ directory the only place where we have tests? (I guess it's not part of html/ due to forks?)

I also found stuff is wrong, e.g., https://github.com/w3c/web-platform-tests/blob/master/workers/constructors/SharedWorker/URLMismatchError.htm tests for a "URLMismatchError" which if I recall correctly we removed some time ago.

can be used.</p>
<p class="note">Any <span data-x="same origin">same-origin</span> URL (including <code
data-x="blob protocol">blob:</code> URLs) can be used. <code data-x="data protocol">data:</code>
URLs can also be used, but create a worker with an <span data-x="concept-opaque-origin">opaque
Copy link
Member

@domenic domenic Oct 7, 2016

Choose a reason for hiding this comment

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

Nit: "but they create" instead of "but create"; both are correct but the former reads a bit easier. Here and below.

@domenic domenic added needs tests Moving the issue forward requires someone to write tests and removed do not merge yet Pull request must not be merged per rationale in comment labels Oct 7, 2016
annevk added a commit to web-platform-tests/wpt that referenced this pull request Oct 10, 2016
Provide basic tests for whatwg/html#1782.
The change to Fetch discussed in
whatwg/fetch#381 made it obsolete.

Closes #1778, and closes #1779 as these are all treated as
same-origin now per the change to Fetch.
Fixes #1243. Basically, data URLs create (shared) workers that have a
unique opaque origin.
@annevk annevk force-pushed the remove-same-origin-data-url-flag branch from 19272bd to d1088a2 Compare October 10, 2016 10:44
annevk added a commit to web-platform-tests/wpt that referenced this pull request Oct 10, 2016
annevk added a commit to web-platform-tests/wpt that referenced this pull request Oct 10, 2016
See whatwg/html#1782 for pointers to more
context.
@annevk
Copy link
Member Author

annevk commented Oct 10, 2016

I added some tests. This can be landed through "rebase and merge" imo.

@domenic domenic removed the needs tests Moving the issue forward requires someone to write tests label Oct 10, 2016
@domenic domenic merged commit c592f62 into master Oct 10, 2016
@domenic domenic deleted the remove-same-origin-data-url-flag branch October 10, 2016 17:30
@domenic
Copy link
Member

domenic commented Oct 12, 2016

For posterity and tracking purposes, the tests

Do @bzbarsky or @mikewest want to help review those? I hope we can get them merged sooner rather than later; letting tests languish is a bad failure mode for this more-tests push. (/cc @foolip)

annevk added a commit to whatwg/fetch that referenced this pull request Oct 12, 2016
Since #387 landed HTML’s change in
whatwg/html#1782 was adjusted a bit for shared
workers.
@foolip
Copy link
Member

foolip commented Oct 12, 2016

I've taken a look at the tests, but would really like @mikewest to do so as well.

foolip pushed a commit to web-platform-tests/wpt that referenced this pull request Oct 12, 2016
foolip pushed a commit to web-platform-tests/wpt that referenced this pull request Oct 12, 2016
foolip pushed a commit to web-platform-tests/wpt that referenced this pull request Oct 12, 2016
@foolip
Copy link
Member

foolip commented Oct 12, 2016

All three tests reviewed and merged by me, but further review wouldn't hurt.

@bzbarsky
Copy link
Contributor

All three tests look good to me.

alice pushed a commit to alice/html that referenced this pull request Jan 8, 2019
cf0355d regressed setting up a
SharedWorkerGlobalScope by removing the steps that set its constructor
url and name. This was noticed in
whatwg#1782 (comment).

This also changes the constructor url from a string to a URL record, for
consistency with other URLs stored on objects throughout the spec.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compat Standard is not web compatible or proprietary feature needs standardizing topic: fetch
5 participants