summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/browsers/browsing-the-web/scroll-to-fragid/fragment-and-encoding-2.html
blob: cd2502ab1cba09430b3422fa1f1542f3cd37e15c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!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=&#xFFFD;></div>
<div id=&#xFEFF;&#xFFFD;></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 = "%C2";
  assert_equals(location.hash, "#%C2");
  assert_greater_than(self.scrollY, 1000, "#%C2");
}, "Invalid percent-encoded UTF-8 byte should decode as U+FFFD");

test(() => {
  goToTop();

  location.hash = "%EF%BB%BF%C2";
  assert_equals(location.hash, "#%EF%BB%BF%C2");
  assert_greater_than(self.scrollY, 1000, "#%EF%BB%BF%C2");
}, "Percent-encoded UTF-8 BOM followed by invalid UTF-8 byte should decode as U+FEFF U+FFFD");

test(() => {
  goToTop();

  location.hash = "%EF%BF%BD";
  assert_equals(location.hash, "#%EF%BF%BD");
  assert_greater_than(self.scrollY, 1000, "#%EF%BF%BD");

  goToTop();
}, "Percent-encoded UTF-8 byte sequence for U+FFFD should decode as U+FFFD");
</script>