Auto merge of #16508 - brainlessdeveloper:fetch-set-origin, r=asajeffrey

Properly set origin of fetch requests

<!-- Please describe your changes on the following line: -->

These changes aim to fix #15247

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #15247 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes
- [x] These changes do not require tests because cors is already tested with different origins

These changes require changes in tests, but I need help with that (see comments below).

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16508)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-07-17 08:29:23 -07:00 committed by GitHub
commit 2bb4f65100
32 changed files with 173 additions and 529 deletions

View file

@ -1928,6 +1928,12 @@ impl ScriptThread {
ROUTER.route_ipc_receiver_to_mpsc_sender(ipc_timer_event_port,
self.timer_event_chan.clone());
let origin = if final_url.as_str() == "about:blank" {
incomplete.origin.clone()
} else {
MutableOrigin::new(final_url.origin())
};
// Create the window and document objects.
let window = Window::new(self.js_runtime.clone(),
MainThreadScriptChan(sender.clone()),
@ -1951,7 +1957,7 @@ impl ScriptThread {
incomplete.pipeline_id,
incomplete.parent_info,
incomplete.window_size,
incomplete.origin.clone(),
origin,
self.webvr_thread.clone());
// Initialize the browsing context for the window.
@ -2283,13 +2289,13 @@ impl ScriptThread {
destination: Destination::Document,
credentials_mode: CredentialsMode::Include,
use_url_credentials: true,
origin: load_data.url.clone(),
pipeline_id: Some(id),
referrer_url: load_data.referrer_url,
referrer_policy: load_data.referrer_policy,
headers: load_data.headers,
body: load_data.data,
redirect_mode: RedirectMode::Manual,
origin: incomplete.origin.immutable().clone(),
.. RequestInit::default()
};