fragment-and-encoding.html (1441B)
1 <!doctype html> 2 <meta charset=windows-1252> 3 <title>Fragment navigation: encoding</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <div id="log"></div> 7 <div style=height:10000px></div> 8 <div id=ÿ></div> 9 <div id=></div> 10 <div id=♡ÿ><div> 11 <script> 12 function goToTop() { 13 location.hash = "top"; 14 assert_equals(self.scrollY, 0, "#top"); 15 } 16 17 test(() => { 18 assert_equals(location.hash, "", "Page must be loaded with no hash"); 19 20 location.hash = "\u00FF"; 21 assert_equals(location.hash, "#%C3%BF"); 22 assert_greater_than(self.scrollY, 1000, "#%C3%BF"); 23 }, "U+00FF should find U+00FF"); 24 25 test(() => { 26 goToTop(); 27 28 location.hash = "%EF%BB%BF"; 29 assert_greater_than(self.scrollY, 1000, "#%EF%BB%BF"); 30 }, "Percent-encoded UTF-8 BOM should find U+FEFF as BOM is not stripped when decoding"); 31 32 test(() => { 33 goToTop(); 34 35 location.hash = "%FF"; 36 assert_equals(self.scrollY, 0, "#%FF"); 37 }, "%FF should not find U+00FF as decoding it gives U+FFFD"); 38 39 test(() => { 40 goToTop(); 41 42 // U+2661 in UTF-8 + %FF. 43 // Chrome had an issue that the following fragment was decoded as U+2661 U+00FF. 44 // https://github.com/whatwg/html/pull/3111 45 location.hash = "%E2%99%A1%FF"; 46 assert_equals(self.scrollY, 0, "%E2%99%A1%FF"); 47 48 goToTop(); 49 }, "Valid UTF-8 + invalid UTF-8 should not be matched to the utf8-decoded former + the isomorphic-decoded latter"); 50 </script>