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:
shanehandley 2024-11-19 23:45:10 +11:00 committed by GitHub
parent 83f8e88818
commit 975e2ae859
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
108 changed files with 171 additions and 1509 deletions

View file

@ -69,7 +69,7 @@ use net_traits::request::{
};
use net_traits::storage_thread::StorageType;
use net_traits::{
FetchMetadata, FetchResponseListener, FetchResponseMsg, Metadata, NetworkError, ReferrerPolicy,
FetchMetadata, FetchResponseListener, FetchResponseMsg, Metadata, NetworkError,
ResourceFetchTiming, ResourceThreads, ResourceTimingType,
};
use percent_encoding::percent_decode;
@ -3822,12 +3822,6 @@ impl ScriptThread {
.as_ref()
.map(|referrer| referrer.clone().into_string());
let referrer_policy = metadata
.headers
.as_deref()
.and_then(|h| h.typed_get::<ReferrerPolicyHeader>())
.map(ReferrerPolicy::from);
let document = Document::new(
&window,
HasBrowsingContext::Yes,
@ -3840,11 +3834,18 @@ impl ScriptThread {
DocumentSource::FromParser,
loader,
referrer,
referrer_policy,
Some(metadata.status.raw_code()),
incomplete.canceller,
can_gc,
);
let referrer_policy = metadata
.headers
.as_deref()
.and_then(|h| h.typed_get::<ReferrerPolicyHeader>())
.into();
document.set_referrer_policy(referrer_policy);
document.set_ready_state(DocumentReadyState::Loading, can_gc);
self.documents