mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Remove referrer policy from document (#34263)
* Remove the referrer policy from document and rely on its policy container Signed-off-by: Shane Handley <shanehandley@fastmail.com> * Make ReferrerPolicy non-optional, instead using a new enum value to represent the empty string case Signed-off-by: Shane Handley <shanehandley@fastmail.com> * Fix clippy issue Signed-off-by: Shane Handley <shanehandley@fastmail.com> * Fix usage of Option<ReferrerPolicy> in unit test Signed-off-by: Shane Handley <shanehandley@fastmail.com> --------- Signed-off-by: Shane Handley <shanehandley@fastmail.com>
This commit is contained in:
parent
83f8e88818
commit
975e2ae859
108 changed files with 171 additions and 1509 deletions
|
@ -12,6 +12,7 @@ use std::sync::{Arc, Mutex};
|
|||
use std::{mem, ptr};
|
||||
|
||||
use encoding_rs::UTF_8;
|
||||
use headers::{HeaderMapExt, ReferrerPolicy as ReferrerPolicyHeader};
|
||||
use html5ever::local_name;
|
||||
use hyper_serde::Serde;
|
||||
use indexmap::IndexSet;
|
||||
|
@ -1189,6 +1190,19 @@ impl FetchResponseListener for ModuleContext {
|
|||
return Err(NetworkError::Internal("No MIME type".into()));
|
||||
}
|
||||
|
||||
// Step 13.4: Let referrerPolicy be the result of parsing the `Referrer-Policy` header
|
||||
// given response.
|
||||
let referrer_policy = meta
|
||||
.headers
|
||||
.and_then(|headers| headers.typed_get::<ReferrerPolicyHeader>())
|
||||
.into();
|
||||
|
||||
// Step 13.5: If referrerPolicy is not the empty string, set options's referrer policy
|
||||
// to referrerPolicy.
|
||||
if referrer_policy != ReferrerPolicy::EmptyString {
|
||||
self.options.referrer_policy = referrer_policy;
|
||||
}
|
||||
|
||||
// Step 10.
|
||||
let (source_text, _, _) = UTF_8.decode(&self.data);
|
||||
Ok(ScriptOrigin::external(
|
||||
|
@ -1364,7 +1378,7 @@ pub struct ScriptFetchOptions {
|
|||
#[no_trace]
|
||||
pub parser_metadata: ParserMetadata,
|
||||
#[no_trace]
|
||||
pub referrer_policy: Option<ReferrerPolicy>,
|
||||
pub referrer_policy: ReferrerPolicy,
|
||||
}
|
||||
|
||||
impl ScriptFetchOptions {
|
||||
|
@ -1376,7 +1390,7 @@ impl ScriptFetchOptions {
|
|||
referrer: global.get_referrer(),
|
||||
parser_metadata: ParserMetadata::NotParserInserted,
|
||||
credentials_mode: CredentialsMode::CredentialsSameOrigin,
|
||||
referrer_policy: None,
|
||||
referrer_policy: ReferrerPolicy::EmptyString,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1741,6 +1755,7 @@ fn fetch_single_module_script(
|
|||
.parser_metadata(options.parser_metadata)
|
||||
.integrity_metadata(options.integrity_metadata.clone())
|
||||
.credentials_mode(options.credentials_mode)
|
||||
.referrer_policy(options.referrer_policy)
|
||||
.mode(mode);
|
||||
|
||||
let context = Arc::new(Mutex::new(ModuleContext {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue