Bug 1463382 [wpt PR 8723] - Navigation fragment decode and encodings, a=testonly

Automatic update from web-platform-testsNavigation fragment decode and encodings (#8723)

* Navigation fragment decode and encodings

See https://github.com/whatwg/html/pull/3111 for context.

* make tests more usable

* address review feedback

--

wpt-commits: 5b878a1e5de29aa4e68c48e0122878f983f036ff
wpt-pr: 8723
This commit is contained in:
Anne van Kesteren 2018-05-31 19:17:42 +00:00 коммит произвёл James Graham
Родитель 33e5646a68
Коммит b678a50dc8
3 изменённых файлов: 98 добавлений и 0 удалений

Просмотреть файл

@ -335042,6 +335042,18 @@
{}
]
],
"html/browsers/browsing-the-web/scroll-to-fragid/fragment-and-encoding-2.html": [
[
"/html/browsers/browsing-the-web/scroll-to-fragid/fragment-and-encoding-2.html",
{}
]
],
"html/browsers/browsing-the-web/scroll-to-fragid/fragment-and-encoding.html": [
[
"/html/browsers/browsing-the-web/scroll-to-fragid/fragment-and-encoding.html",
{}
]
],
"html/browsers/browsing-the-web/scroll-to-fragid/replacement-enabled.html": [
[
"/html/browsers/browsing-the-web/scroll-to-fragid/replacement-enabled.html",
@ -567015,6 +567027,14 @@
"fb63063e0ff1ca6aaa350fae9b8f01bed5f9771f",
"testharness"
],
"html/browsers/browsing-the-web/scroll-to-fragid/fragment-and-encoding-2.html": [
"62b3f908914b6b49c9b695f544a7e6489d3b9ec7",
"testharness"
],
"html/browsers/browsing-the-web/scroll-to-fragid/fragment-and-encoding.html": [
"9ba63dfc8f2a9310830b6b5073d994a821369c01",
"testharness"
],
"html/browsers/browsing-the-web/scroll-to-fragid/navigate-helpers.js": [
"5b318196cb31c35e1b39eccd9e6a131a882f1a90",
"support"

Просмотреть файл

@ -0,0 +1,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>

Просмотреть файл

@ -0,0 +1,37 @@
<!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>
<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");
</script>