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

Ensure that a navigation to the same URL is aborted. Fixes #10952. #11321

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -1833,24 +1833,25 @@ impl ScriptThread {
/// The entry point for content to notify that a new load has been requested
/// for the given pipeline (specifically the "navigate" algorithm).
fn handle_navigate(&self, pipeline_id: PipelineId, subpage_id: Option<SubpageId>, load_data: LoadData) {
// Step 8.
// Step 6.
{
let nurl = &load_data.url;
if let Some(fragment) = nurl.fragment() {
let context = get_browsing_context(&self.root_browsing_context(), pipeline_id);
let document = context.active_document();
let document = document.r();
let url = document.url();
if &url[..Position::AfterQuery] == &nurl[..Position::AfterQuery] &&
load_data.method == Method::Get {
match document.find_fragment_node(fragment) {
Some(ref node) => {
self.scroll_fragment_point(pipeline_id, node.r());
}
None => {}
let context = get_browsing_context(&self.root_browsing_context(), pipeline_id);
let document = context.active_document();
let document = document.r();
let url = document.url();
if &url[..Position::AfterQuery] == &nurl[..Position::AfterQuery] &&
load_data.method == Method::Get {
if let Some(fragment) = nurl.fragment() {
if let Some(ref node) = document.find_fragment_node(fragment) {
self.scroll_fragment_point(pipeline_id, node.r());
}
return;
}
// TODO: Revisit this return statement when a decission is taken
// in https://github.com/whatwg/html/issues/1177.
//
// See #10954 for discussion and background.
return;
}
}

"deleted_reftests": {},
"items": {
"testharness": {
"html/browsers/browsing-the-web/navigating-across-documents/empty_fragment.html": [
{
"path": "html/browsers/browsing-the-web/navigating-across-documents/empty_fragment.html",
"url": "/html/browsers/browsing-the-web/navigating-across-documents/empty_fragment.html"
}
],
"html/semantics/links/links-created-by-a-and-area-elements/htmlanchorelement_attribute-getter-setter.html": [
{
"path": "html/semantics/links/links-created-by-a-and-area-elements/htmlanchorelement_attribute-getter-setter.html",
@@ -0,0 +1,20 @@
<!doctype html>
<meta charset="utf-8">
<title>Navigating to the same URL with an empty fragment aborts the navigation</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<iframe src="empty_fragment_iframe.html"></iframe>
<script>
// If the navigation were not aborted, we would expect multiple load events
// as the page continually reloads itself.
async_test(function(t) {
var count = 0;
var iframe = document.querySelector('iframe');
iframe.onload = t.step_func(function() {
count++;
});
window.child_succeeded = t.step_func_done(function() {
assert_equals(count, 1);
});
});
</script>
@@ -0,0 +1,11 @@
<script>
var timeout;
onload = function() {
location.hash = "";
timeout = setTimeout(function() { parent.child_succeeded() }, 2000);
};

onbeforeunload = function() {
clearTimeout(timeout);
}
</script>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.