Auto merge of #11934 - jdm:navigatefragment, r=emilio

Special-case setting location.hash to the empty string

This avoids endless redirect loops on facebook and makes us compliant with https://github.com/whatwg/html/pull/1318.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #10952
- [X] There are tests for these changes OR

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11934)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-06-29 17:39:58 -05:00 committed by GitHub
commit e30b288ed6
4 changed files with 45 additions and 2 deletions

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>