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

Implement referrer policy for WorkerGlobalScope #12473

Closed
wants to merge 5 commits into from

Conversation

@aravind-pg
Copy link
Contributor

aravind-pg commented Jul 16, 2016

Adds a new Option<ReferrerPolicy> field to WorkerGlobalScope and sets it appropriately by parsing the header when setting up a ServiceWorkerGlobalScope or a DedicatedWorkerGlobalScope.

Also adds a new referrer policy accessor to GlobalRef and uses it in XMLHttpRequest's constructor.

  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #11863
  • There are tests for these changes

This change is Reviewable

@highfive
Copy link

highfive commented Jul 16, 2016

Heads up! This PR modifies the following files:

  • @KiChjang: components/script/dom/bindings/global.rs, components/script/dom/workerglobalscope.rs, components/script/dom/xmlhttprequest.rs, components/script/dom/dedicatedworkerglobalscope.rs, components/script/script_thread.rs, components/script/dom/serviceworkerglobalscope.rs
@aravind-pg
Copy link
Contributor Author

aravind-pg commented Jul 16, 2016

Only one WPT test was fixed by this PR, so I'm not sure I didn't do something wrong.

r? @jdm cc @rebstar6

@highfive highfive assigned jdm and unassigned wafflespeanut Jul 16, 2016
@jdm
Copy link
Member

jdm commented Jul 17, 2016

I believe all of the worker test infrastructure in referrer-policy is disabled. I haven't looked into why that's the case yet.

@aravind-pg
Copy link
Contributor Author

aravind-pg commented Jul 17, 2016

Ah I vaguely recall reading about this somewhere but can't seem to find it now. Could you point me to where exactly they're being disabled? I wasn't able to find anything in my look-around.

@jdm
Copy link
Member

jdm commented Jul 17, 2016

It's the worker-request thing in spec.src.json. Maybe it's excluded, or just not included.

@aravind-pg aravind-pg force-pushed the aravind-pg:referrer-pol-worker branch from bd7b820 to 17feb71 Jul 18, 2016
@aravind-pg
Copy link
Contributor Author

aravind-pg commented Jul 18, 2016

Updated to re-enable the worker-request tests, a bunch of which did pass :)

@bors-servo
Copy link
Contributor

bors-servo commented Jul 18, 2016

The latest upstream changes (presumably #11727) made this pull request unmergeable. Please resolve the merge conflicts.

@aravind-pg aravind-pg force-pushed the aravind-pg:referrer-pol-worker branch 2 times, most recently from 99942d0 to 8bed635 Jul 21, 2016
@aravind-pg
Copy link
Contributor Author

aravind-pg commented Jul 21, 2016

Rebased.

} else {
(None, None)
};
let referrer_url = Some(global.get_url());

This comment has been minimized.

Copy link
@aravind-pg

aravind-pg Jul 21, 2016

Author Contributor

Note that now the field referrer_url is always Some, so I don't think it needs to stay an option any more?

This comment has been minimized.

Copy link
@jdm

jdm Jul 25, 2016

Member

Seems reasonable!

@bors-servo
Copy link
Contributor

bors-servo commented Jul 21, 2016

The latest upstream changes (presumably #12468) made this pull request unmergeable. Please resolve the merge conflicts.

@aravind-pg aravind-pg force-pushed the aravind-pg:referrer-pol-worker branch from 8bed635 to 0c2343e Jul 23, 2016
@aravind-pg
Copy link
Contributor Author

aravind-pg commented Jul 23, 2016

Rebased.

@jdm
Copy link
Member

jdm commented Jul 23, 2016

I'll review this on Monday. Sorry for the wait!

@aravind-pg
Copy link
Contributor Author

aravind-pg commented Jul 23, 2016

No problem at all.

@jdm
Copy link
Member

jdm commented Jul 25, 2016

The fact that we're failing tests like http-http/worker-request/insecure-protocol.keep-origin-redirect.http.html.ini make me suspect that either the tests aren't working right or our implementation isn't right. The changes in this PR look like what I expected to see, but we should track down the source of the test failure before moving ahead with merging this.

@aravind-pg
Copy link
Contributor Author

aravind-pg commented Jul 26, 2016

Yeah I'm a bit surprised by it too. Will try to look into it more and come back if I have questions.

@bors-servo
Copy link
Contributor

bors-servo commented Jul 27, 2016

The latest upstream changes (presumably #12582) made this pull request unmergeable. Please resolve the merge conflicts.

@aravind-pg
Copy link
Contributor Author

aravind-pg commented Aug 1, 2016

@jdm Sorry for the delay here, I've been a bit busy with things and will continue to be for a few days more. If you have any suggestions (just high-level stuff off the top of your head) for where to start poking around to see why the tests are failing that would be super useful, but no problem at all if not, I'll just poke around myself (in a few days).

@jdm
Copy link
Member

jdm commented Aug 4, 2016

Aha!

  1. we removed generic/subresources/worker.py from the forked tests
  2. we need to reinstate it with a change like https://dxr.mozilla.org/servo/source/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/document.py#4
    That should give us much more meaningful results.
@aravind-pg aravind-pg force-pushed the aravind-pg:referrer-pol-worker branch from 0c2343e to fe7cbad Sep 4, 2016
@aravind-pg
Copy link
Contributor Author

aravind-pg commented Sep 4, 2016

@jdm Really sorry for vanishing for so long, was a busy time for me.

So I reinstated worker.py as per your suggestion, but unfortunately it seems not to have made any difference. I'm really not sure what's going on here, but I'll try to dig some more.

@jdm
Copy link
Member

jdm commented Sep 4, 2016

Does worker.js.template exist? If not we need to reinstate it as well.

@aravind-pg
Copy link
Contributor Author

aravind-pg commented Sep 4, 2016

Does look like it does: worker.js.template.

@jdm
Copy link
Member

jdm commented Sep 5, 2016

I took a look at the branch locally and figured out what's going on. b423496 isn't necessary any more since we're enabling the worker tests in the upstream tests, rather than our local fork. The reason why the tests are failing is that they are testing the reported referrer for the initial worker object that is created, while the changes in 33007c2 and 53cdc62 are in support of referrers for requests created from a worker script. Fixing the tests should only require modifiying the WorkerScriptLoadOrigin object in Worker::Constructor to use the document's referrer policy; however, we should add a new set of tests that initiates requests via XMLHttpRequest inside of a worker to ensure that the changes in this PR actually work.

@bors-servo
Copy link
Contributor

bors-servo commented Sep 6, 2016

The latest upstream changes (presumably #13174) made this pull request unmergeable. Please resolve the merge conflicts.

@aravind-pg
Copy link
Contributor Author

aravind-pg commented Oct 23, 2016

Very sorry for the extend to which this stagnated, @jdm. I think I'll just close this PR for now and perhaps open a new one when I find some time. Thanks a lot for your help, and I'll keep your last comment in mind when I reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

5 participants
You can’t perform that action at this time.