mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #11468 - rebstar6:refPol4, r=nox
Implement meta referrer policy delivery (3) <!-- Please describe your changes on the following line: --> --- <!-- 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 #10311 (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11468) <!-- Reviewable:end -->
This commit is contained in:
commit
530b5a649e
56 changed files with 136 additions and 263 deletions
|
@ -148,10 +148,20 @@ pub struct XMLHttpRequest {
|
|||
fetch_time: Cell<i64>,
|
||||
generation_id: Cell<GenerationId>,
|
||||
response_status: Cell<Result<(), ()>>,
|
||||
referrer_url: Option<Url>,
|
||||
referrer_policy: Option<ReferrerPolicy>,
|
||||
}
|
||||
|
||||
impl XMLHttpRequest {
|
||||
fn new_inherited(global: GlobalRef) -> XMLHttpRequest {
|
||||
//TODO - update this when referrer policy implemented for workers
|
||||
let (referrer_url, referrer_policy) = if let GlobalRef::Window(window) = global {
|
||||
let document = window.Document();
|
||||
(Some(document.url().clone()), document.get_referrer_policy())
|
||||
} else {
|
||||
(None, None)
|
||||
};
|
||||
|
||||
XMLHttpRequest {
|
||||
eventtarget: XMLHttpRequestEventTarget::new_inherited(),
|
||||
ready_state: Cell::new(XMLHttpRequestState::Unsent),
|
||||
|
@ -183,6 +193,8 @@ impl XMLHttpRequest {
|
|||
fetch_time: Cell::new(0),
|
||||
generation_id: Cell::new(GenerationId(0)),
|
||||
response_status: Cell::new(Ok(())),
|
||||
referrer_url: referrer_url,
|
||||
referrer_policy: referrer_policy,
|
||||
}
|
||||
}
|
||||
pub fn new(global: GlobalRef) -> Root<XMLHttpRequest> {
|
||||
|
@ -297,10 +309,10 @@ impl XMLHttpRequest {
|
|||
|
||||
impl LoadOrigin for XMLHttpRequest {
|
||||
fn referrer_url(&self) -> Option<Url> {
|
||||
None
|
||||
return self.referrer_url.clone();
|
||||
}
|
||||
fn referrer_policy(&self) -> Option<ReferrerPolicy> {
|
||||
None
|
||||
return self.referrer_policy;
|
||||
}
|
||||
fn request_source(&self) -> RequestSource {
|
||||
if self.sync.get() {
|
||||
|
@ -592,11 +604,12 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
|||
|
||||
// Step 5
|
||||
let global = self.global();
|
||||
//TODO - set referrer_policy/referrer_url in load_data
|
||||
|
||||
let mut load_data =
|
||||
LoadData::new(LoadContext::Browsing,
|
||||
self.request_url.borrow().clone().unwrap(),
|
||||
self);
|
||||
|
||||
if load_data.url.origin().ne(&global.r().get_url().origin()) {
|
||||
load_data.credentials_flag = self.WithCredentials();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue