From acbfd7b9abdd60cae721850e553d6e21f4ab1471 Mon Sep 17 00:00:00 2001 From: Utsav Oza Date: Wed, 5 Aug 2020 18:44:28 +0530 Subject: [PATCH] Do not load srcdoc iframes synchronously --- components/constellation/constellation.rs | 9 ++++++--- components/script/dom/htmliframeelement.rs | 2 +- components/script/script_thread.rs | 11 +++++++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index a9b114fa7bd..f5ce8ffa837 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -1090,9 +1090,12 @@ where let (event_loop, host) = match sandbox { IFrameSandboxState::IFrameSandboxed => (None, None), IFrameSandboxState::IFrameUnsandboxed => { - // If this is an about:blank load, it must share the creator's event loop. - // This must match the logic in the script thread when determining the proper origin. - if load_data.url.as_str() != "about:blank" { + // If this is an about:blank or about:srcdoc load, it must share the creator's + // event loop. This must match the logic in the script thread when determining + // the proper origin. + if load_data.url.as_str() != "about:blank" && + load_data.url.as_str() != "about:srcdoc" + { match reg_host(&load_data.url) { None => (None, None), Some(host) => { diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index 2e8a37a88d8..60c3e93ece8 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -248,7 +248,7 @@ impl HTMLIFrameElement { load_data.srcdoc = String::from(element.get_string_attribute(&local_name!("srcdoc"))); self.navigate_or_reload_child_browsing_context( load_data, - NavigationType::InitialAboutBlank, + NavigationType::Regular, HistoryEntryReplacement::Disabled, ); return; diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 1b7c137e9a2..16de38f0265 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -1503,10 +1503,13 @@ impl ScriptThread { ScriptThreadEventCategory::AttachLayout, Some(pipeline_id), || { - // If this is an about:blank load, it must share the creator's origin. - // This must match the logic in the constellation when creating a new pipeline - let origin = if new_layout_info.load_data.url.as_str() != "about:blank" - { + // If this is an about:blank or about:srcdoc load, it must share the + // creator's origin. This must match the logic in the constellation + // when creating a new pipeline + let not_an_about_blank_and_about_srcdoc_load = + new_layout_info.load_data.url.as_str() != "about:blank" && + new_layout_info.load_data.url.as_str() != "about:srcdoc"; + let origin = if not_an_about_blank_and_about_srcdoc_load { MutableOrigin::new(new_layout_info.load_data.url.origin()) } else if let Some(parent) = new_layout_info.parent_info.and_then(|pipeline_id| {