Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace initial about:blank on navigation #16848

Closed
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Replace initial about:blank on navigation

Add test for initial about:blank replacement
  • Loading branch information
cbrewster committed May 17, 2017
commit d35778352048a87147b93a7fdae7539e3d3ad166
@@ -87,6 +87,7 @@ pub struct HTMLIFrameElement {
frame_id: FrameId,
pipeline_id: Cell<Option<PipelineId>>,
pending_pipeline_id: Cell<Option<PipelineId>>,
inital_about_blank: Cell<Option<PipelineId>>,
sandbox: MutNullableJS<DOMTokenList>,
sandbox_allowance: Cell<Option<SandboxAllowance>>,
load_blocker: DOMRefCell<Option<LoadBlocker>>,
@@ -179,6 +180,7 @@ impl HTMLIFrameElement {
layout_threads: PREFS.get("layout.threads").as_u64().expect("count") as usize,
};

self.inital_about_blank.set(Some(new_pipeline_id));
self.pipeline_id.set(Some(new_pipeline_id));
ScriptThread::process_attach_layout(new_layout_info, document.origin().clone());
},
@@ -220,15 +222,15 @@ impl HTMLIFrameElement {

// TODO: check ancestor browsing contexts for same URL

let creator_pipeline_id = if url.as_str() == "about:blank" {
Some(window.upcast::<GlobalScope>().pipeline_id())
} else {
None
};
let creator_pipeline_id = Some(window.upcast::<GlobalScope>().pipeline_id());

// If we are navigating from the initial about:blank document, replacement must be enabled.
let initial_about_blank = self.inital_about_blank.get();
let replace = initial_about_blank.is_some() && initial_about_blank == self.pipeline_id.get();

let document = document_from_node(self);
let load_data = LoadData::new(url, creator_pipeline_id, document.get_referrer_policy(), Some(document.url()));
self.navigate_or_reload_child_browsing_context(Some(load_data), NavigationType::Regular, false);
self.navigate_or_reload_child_browsing_context(Some(load_data), NavigationType::Regular, replace);
}

#[allow(unsafe_code)]
@@ -280,6 +282,7 @@ impl HTMLIFrameElement {
frame_id: FrameId::new(),
pipeline_id: Cell::new(None),
pending_pipeline_id: Cell::new(None),
inital_about_blank: Cell::new(None),
sandbox: Default::default(),
sandbox_allowance: Cell::new(None),
load_blocker: DOMRefCell::new(None),
@@ -783,6 +786,7 @@ impl VirtualMethods for HTMLIFrameElement {
// confused.
self.pipeline_id.set(None);
self.pending_pipeline_id.set(None);
self.inital_about_blank.set(None);
}
}

{}
]
],
"html/semantics/embedded-content/the-iframe-element/initial_about_blank_replace.html": [
[
"/html/semantics/embedded-content/the-iframe-element/initial_about_blank_replace.html",
{}
]
],
"html/semantics/embedded-content/the-iframe-element/move_iframe_in_dom_01.html": [
[
"/html/semantics/embedded-content/the-iframe-element/move_iframe_in_dom_01.html",
"aea637881bfc46b3bc9a277a11a41cbd4b0582ba",
"testharness"
],
"html/semantics/embedded-content/the-iframe-element/initial_about_blank_replace.html": [
"602c2f10f5d0f9d5e59605d2b2d5bd0d8d92acbf",
"testharness"
],
"html/semantics/embedded-content/the-iframe-element/move_iframe_in_dom_01.html": [
"6dcbd6cb4509403f03ce4b9df63d064305618e51",
"testharness"
@@ -0,0 +1,19 @@
<!doctype html>
<meta charset="utf-8">
<title>Initial about:blank should be replaced when navigated from</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<iframe id="iframe"></iframe>
</body>
<script>
async_test(function(t) {
var iframe = document.getElementById("iframe");
var history_length = window.history.length;
iframe.onload = t.step_func(function() {
assert_equals(history_length, window.history.length);
t.done();
});
iframe.src = "support/blank.htm";
});
</script>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.