Retain the referrer policy when loading an about:blank iframe. (#34432)

This allows the referrer policy to be inherited correctly by the iframe.

Signed-off-by: Shane Handley <shanehandley@fastmail.com>
This commit is contained in:
shanehandley 2024-11-30 17:15:36 +11:00 committed by GitHub
parent 096439b35e
commit 82bbff45b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 4 additions and 41 deletions

View file

@ -2985,7 +2985,7 @@ impl ScriptThread {
load_data.inherited_secure_context, load_data.inherited_secure_context,
); );
if load_data.url.as_str() == "about:blank" { if load_data.url.as_str() == "about:blank" {
self.start_page_load_about_blank(new_load, load_data.js_eval_result); self.start_page_load_about_blank(new_load, load_data);
} else if load_data.url.as_str() == "about:srcdoc" { } else if load_data.url.as_str() == "about:srcdoc" {
self.page_load_about_srcdoc(new_load, load_data); self.page_load_about_srcdoc(new_load, load_data);
} else { } else {
@ -4207,11 +4207,7 @@ impl ScriptThread {
/// Synchronously fetch `about:blank`. Stores the `InProgressLoad` /// Synchronously fetch `about:blank`. Stores the `InProgressLoad`
/// argument until a notification is received that the fetch is complete. /// argument until a notification is received that the fetch is complete.
fn start_page_load_about_blank( fn start_page_load_about_blank(&self, incomplete: InProgressLoad, load_data: LoadData) {
&self,
incomplete: InProgressLoad,
js_eval_result: Option<JsEvalResult>,
) {
let id = incomplete.pipeline_id; let id = incomplete.pipeline_id;
self.incomplete_loads.borrow_mut().push(incomplete); self.incomplete_loads.borrow_mut().push(incomplete);
@ -4221,10 +4217,11 @@ impl ScriptThread {
let mut meta = Metadata::default(url); let mut meta = Metadata::default(url);
meta.set_content_type(Some(&mime::TEXT_HTML)); meta.set_content_type(Some(&mime::TEXT_HTML));
meta.set_referrer_policy(load_data.referrer_policy);
// If this page load is the result of a javascript scheme url, map // If this page load is the result of a javascript scheme url, map
// the evaluation result into a response. // the evaluation result into a response.
let chunk = match js_eval_result { let chunk = match load_data.js_eval_result {
Some(JsEvalResult::Ok(content)) => content, Some(JsEvalResult::Ok(content)) => content,
Some(JsEvalResult::NoContent) => { Some(JsEvalResult::NoContent) => {
meta.status = http::StatusCode::NO_CONTENT.into(); meta.status = http::StatusCode::NO_CONTENT.into();

View file

@ -1,7 +1,3 @@
[iframe-inheritance-about-blank.html] [iframe-inheritance-about-blank.html]
[The value of document.referrer in an about:blank iframe is the outer document's full URL, regardless of referrer policy] [The value of document.referrer in an about:blank iframe is the outer document's full URL, regardless of referrer policy]
expected: FAIL expected: FAIL
[The fetch() API in an about:blank iframe with a custom URL referrer is fetched with a 'Referer` header that uses the outer document's URL along with its referrer policy]
expected: FAIL

View file

@ -1,9 +1,3 @@
[iframe-inheritance-javascript-child.html] [iframe-inheritance-javascript-child.html]
[Referrer Policy: iframes with javascript url reuse referrer policy 1]
expected: FAIL
[Referrer Policy: iframes with javascript url reuse referrer policy 2] [Referrer Policy: iframes with javascript url reuse referrer policy 2]
expected: FAIL expected: FAIL
[Referrer Policy: iframes with javascript url reuse referrer policy]
expected: FAIL

View file

@ -1,3 +0,0 @@
[iframe-inheritance-javascript.html]
[Referrer Policy: iframes with javascript url reuse referrer policy 1]
expected: FAIL

View file

@ -1,7 +1,3 @@
[popup-inheritance-about-blank.html] [popup-inheritance-about-blank.html]
[The fetch() API in an about:blank popup with a custom URL referrer is fetched with a 'Referer` header that uses the outer document's URL along with its referrer policy]
expected: FAIL
[The value of document.referrer in an about:blank popup is the outer document's full URL, regardless of referrer policy] [The value of document.referrer in an about:blank popup is the outer document's full URL, regardless of referrer policy]
expected: FAIL expected: FAIL

View file

@ -1,7 +1,3 @@
[iframe-inheritance-about-blank.html] [iframe-inheritance-about-blank.html]
[The value of document.referrer in an about:blank iframe is the outer document's full URL, regardless of referrer policy] [The value of document.referrer in an about:blank iframe is the outer document's full URL, regardless of referrer policy]
expected: FAIL expected: FAIL
[The fetch() API in an about:blank iframe with a custom URL referrer is fetched with a 'Referer` header that uses the outer document's URL along with its referrer policy]
expected: FAIL

View file

@ -1,9 +1,3 @@
[iframe-inheritance-javascript-child.html] [iframe-inheritance-javascript-child.html]
[Referrer Policy: iframes with javascript url reuse referrer policy 1]
expected: FAIL
[Referrer Policy: iframes with javascript url reuse referrer policy 2] [Referrer Policy: iframes with javascript url reuse referrer policy 2]
expected: FAIL expected: FAIL
[Referrer Policy: iframes with javascript url reuse referrer policy]
expected: FAIL

View file

@ -1,3 +0,0 @@
[iframe-inheritance-javascript.html]
[Referrer Policy: iframes with javascript url reuse referrer policy 1]
expected: FAIL

View file

@ -1,7 +1,3 @@
[popup-inheritance-about-blank.html] [popup-inheritance-about-blank.html]
[The fetch() API in an about:blank popup with a custom URL referrer is fetched with a 'Referer` header that uses the outer document's URL along with its referrer policy]
expected: FAIL
[The value of document.referrer in an about:blank popup is the outer document's full URL, regardless of referrer policy] [The value of document.referrer in an about:blank popup is the outer document's full URL, regardless of referrer policy]
expected: FAIL expected: FAIL