From 5cc8de8067f6511a460abeba84b8631796ec4576 Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Sun, 1 May 2016 03:17:54 -0400 Subject: [PATCH] Ensure that a navigation to the same URL is aborted. Fixes #10952. --- components/script/dom/location.rs | 5 ++++- tests/wpt/metadata/MANIFEST.json | 11 +++++++++- .../empty_fragment.html | 20 +++++++++++++++++++ .../empty_fragment_iframe.html | 11 ++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 tests/wpt/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/empty_fragment.html create mode 100644 tests/wpt/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/empty_fragment_iframe.html diff --git a/components/script/dom/location.rs b/components/script/dom/location.rs index 9fff2a45837..72361193aa3 100644 --- a/components/script/dom/location.rs +++ b/components/script/dom/location.rs @@ -66,7 +66,10 @@ impl LocationMethods for Location { } // 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); } diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json index 9dc86c4804d..1a4452832b9 100644 --- a/tests/wpt/metadata/MANIFEST.json +++ b/tests/wpt/metadata/MANIFEST.json @@ -36263,7 +36263,16 @@ "local_changes": { "deleted": [], "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": { diff --git a/tests/wpt/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/empty_fragment.html b/tests/wpt/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/empty_fragment.html new file mode 100644 index 00000000000..18a6f84c9f5 --- /dev/null +++ b/tests/wpt/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/empty_fragment.html @@ -0,0 +1,20 @@ + + +Navigating to the same URL with an empty fragment aborts the navigation + + + + diff --git a/tests/wpt/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/empty_fragment_iframe.html b/tests/wpt/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/empty_fragment_iframe.html new file mode 100644 index 00000000000..26b28a0d7dc --- /dev/null +++ b/tests/wpt/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/empty_fragment_iframe.html @@ -0,0 +1,11 @@ +