summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/fragment-and-encoding.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/fragment-and-encoding.html')
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/fragment-and-encoding.html50
1 files changed, 50 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/fragment-and-encoding.html b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/fragment-and-encoding.html
new file mode 100644
index 0000000000..21fbd4618d
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/fragment-and-encoding.html
@@ -0,0 +1,50 @@
+<!doctype html>
+<meta charset=windows-1252>
+<title>Fragment navigation: encoding</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<div style=height:10000px></div>
+<div id=&#xFF;></div>
+<div id=&#xFEFF;></div>
+<div id=&#x2661;&#x00FF;><div>
+<script>
+function goToTop() {
+ location.hash = "top";
+ assert_equals(self.scrollY, 0, "#top");
+}
+
+test(() => {
+ assert_equals(location.hash, "", "Page must be loaded with no hash");
+
+ location.hash = "\u00FF";
+ assert_equals(location.hash, "#%C3%BF");
+ assert_greater_than(self.scrollY, 1000, "#%C3%BF");
+}, "U+00FF should find U+00FF");
+
+test(() => {
+ goToTop();
+
+ location.hash = "%EF%BB%BF";
+ assert_greater_than(self.scrollY, 1000, "#%EF%BB%BF");
+}, "Percent-encoded UTF-8 BOM should find U+FEFF as BOM is not stripped when decoding");
+
+test(() => {
+ goToTop();
+
+ location.hash = "%FF";
+ assert_equals(self.scrollY, 0, "#%FF");
+}, "%FF should not find U+00FF as decoding it gives U+FFFD");
+
+test(() => {
+ goToTop();
+
+ // U+2661 in UTF-8 + %FF.
+ // Chrome had an issue that the following fragment was decoded as U+2661 U+00FF.
+ // https://github.com/whatwg/html/pull/3111
+ location.hash = "%E2%99%A1%FF";
+ assert_equals(self.scrollY, 0, "%E2%99%A1%FF");
+
+ goToTop();
+}, "Valid UTF-8 + invalid UTF-8 should not be matched to the utf8-decoded former + the isomorphic-decoded latter");
+</script>