mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
fix: meta referrer updating to follow spec (#36390)
Previously the referrer policy used tree order but the spec only cares about the most-recently-updated or most-recently-added meta referrer. Testing: change has existing WPT tests --------- Signed-off-by: Sebastian C <sebsebmc@gmail.com>
This commit is contained in:
parent
bfbe464eba
commit
9bdc46d66b
5 changed files with 28 additions and 46 deletions
|
@ -10,7 +10,7 @@ use js::rust::HandleObject;
|
|||
use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::document::{Document, determine_policy_for_token};
|
||||
use crate::dom::document::Document;
|
||||
use crate::dom::element::Element;
|
||||
use crate::dom::htmlelement::HTMLElement;
|
||||
use crate::dom::htmlmetaelement::HTMLMetaElement;
|
||||
|
@ -54,37 +54,6 @@ impl HTMLHeadElement {
|
|||
n
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#meta-referrer>
|
||||
pub(crate) fn set_document_referrer(&self) {
|
||||
let doc = self.owner_document();
|
||||
|
||||
if doc.GetHead().as_deref() != Some(self) {
|
||||
return;
|
||||
}
|
||||
|
||||
let node = self.upcast::<Node>();
|
||||
let candidates = node
|
||||
.traverse_preorder(ShadowIncluding::No)
|
||||
.filter_map(DomRoot::downcast::<Element>)
|
||||
.filter(|elem| elem.is::<HTMLMetaElement>())
|
||||
.filter(|elem| elem.get_name() == Some(atom!("referrer")))
|
||||
.filter(|elem| {
|
||||
elem.get_attribute(&ns!(), &local_name!("content"))
|
||||
.is_some()
|
||||
});
|
||||
|
||||
for meta in candidates {
|
||||
if let Some(ref content) = meta.get_attribute(&ns!(), &local_name!("content")) {
|
||||
let content = content.value();
|
||||
let content_val = content.trim();
|
||||
if !content_val.is_empty() {
|
||||
doc.set_referrer_policy(determine_policy_for_token(content_val));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#attr-meta-http-equiv-content-security-policy>
|
||||
pub(crate) fn set_content_security_policy(&self) {
|
||||
let doc = self.owner_document();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue