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

This commit is contained in:
Josh Matthews 2016-05-01 03:17:54 -04:00
parent 810735a846
commit 5cc8de8067
4 changed files with 45 additions and 2 deletions

View file

@ -66,7 +66,10 @@ impl LocationMethods for Location {
} }
// https://html.spec.whatwg.org/multipage/#dom-location-hash // https://html.spec.whatwg.org/multipage/#dom-location-hash
fn SetHash(&self, value: USVString) { fn SetHash(&self, mut value: USVString) {
if value.0.is_empty() {
value = USVString("#".to_owned());
}
self.set_url_component(value, UrlHelper::SetHash); self.set_url_component(value, UrlHelper::SetHash);
} }

View file

@ -36263,7 +36263,16 @@
"local_changes": { "local_changes": {
"deleted": [], "deleted": [],
"deleted_reftests": {}, "deleted_reftests": {},
"items": {}, "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"
}
]
}
},
"reftest_nodes": {} "reftest_nodes": {}
}, },
"reftest_nodes": { "reftest_nodes": {

View file

@ -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>

View file

@ -0,0 +1,11 @@
<script>
var timeout;
onload = function() {
location.hash = "";
timeout = setTimeout(function() { parent.child_succeeded() }, 2000);
};
onbeforeunload = function() {
clearTimeout(timeout);
}
</script>