Skip to content

Commit

Permalink
url: update wpt tests to pull in tests for URL idempotency (see #601)
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed Aug 24, 2020
1 parent 0587063 commit 3f91606
Show file tree
Hide file tree
Showing 2 changed files with 312 additions and 6 deletions.
85 changes: 80 additions & 5 deletions url/tests/setters_tests.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"comment": [
"AS OF https://github.com/jsdom/whatwg-url/commit/35f04dfd3048cf6362f4398745bb13375c5020c2",
"## Tests for setters of https://url.spec.whatwg.org/#urlutils-members",
"AS OF https://github.com/web-platform-tests/wpt/commit/551c9d604fb8b97d3f8c65793bb047d15baddbc2",
"",
"This file contains a JSON object.",
"Other than 'comment', each key is an attribute of the `URL` interface",
Expand Down Expand Up @@ -120,11 +120,11 @@
}
},
{
"href": "gopher://example.net:1234",
"href": "https://example.net:1234",
"new_value": "file",
"expected": {
"href": "gopher://example.net:1234",
"protocol": "gopher:"
"href": "https://example.net:1234/",
"protocol": "https:"
}
},
{
Expand All @@ -146,7 +146,7 @@
},
{
"href": "file:///test",
"new_value": "gopher",
"new_value": "https",
"expected": {
"href": "file:///test",
"protocol": "file:"
Expand Down Expand Up @@ -962,6 +962,16 @@
"port": ""
}
},
{
"href": "file://hi/x",
"new_value": "",
"expected": {
"href": "file:///x",
"host": "",
"hostname": "",
"port": ""
}
},
{
"href": "sc://test@test/",
"new_value": "",
Expand Down Expand Up @@ -1286,6 +1296,16 @@
"port": ""
}
},
{
"href": "file://hi/x",
"new_value": "",
"expected": {
"href": "file:///x",
"host": "",
"hostname": "",
"port": ""
}
},
{
"href": "sc://test@test/",
"new_value": "",
Expand All @@ -1305,6 +1325,27 @@
"hostname": "test",
"port": "12"
}
},
{
"comment": "Drop /. from path",
"href": "non-spec:/.//p",
"new_value": "h",
"expected": {
"href": "non-spec://h//p",
"host": "h",
"hostname": "h",
"pathname": "//p"
}
},
{
"href": "non-spec:/.//p",
"new_value": "",
"expected": {
"href": "non-spec:////p",
"host": "",
"hostname": "",
"pathname": "//p"
}
}
],
"port": [
Expand Down Expand Up @@ -1653,6 +1694,40 @@
"href": "file:///",
"pathname": "/"
}
},
{
"comment": "Serialize /. in path",
"href": "non-spec:/",
"new_value": "/.//p",
"expected": {
"href": "non-spec:/.//p",
"pathname": "//p"
}
},
{
"href": "non-spec:/",
"new_value": "/..//p",
"expected": {
"href": "non-spec:/.//p",
"pathname": "//p"
}
},
{
"href": "non-spec:/",
"new_value": "//p",
"expected": {
"href": "non-spec:/.//p",
"pathname": "//p"
}
},
{
"comment": "Drop /. from path",
"href": "non-spec:/.//",
"new_value": "p",
"expected": {
"href": "non-spec:/p",
"pathname": "/p"
}
}
],
"search": [
Expand Down
233 changes: 232 additions & 1 deletion url/tests/urltestdata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[

"# Based on http://trac.webkit.org/browser/trunk/LayoutTests/fast/url/script-tests/segments.js",
"# AS OF https://github.com/jsdom/whatwg-url/commit/35f04dfd3048cf6362f4398745bb13375c5020c2",
"# AS OF https://github.com/web-platform-tests/wpt/commit/551c9d604fb8b97d3f8c65793bb047d15baddbc2",
{
"input": "http://example\t.\norg",
"base": "http://example.org/foo/bar",
Expand Down Expand Up @@ -6446,6 +6447,190 @@
"search": "",
"hash": ""
},
"Serialize /. in path",
{
"input": "non-spec:/.//",
"base": "about:blank",
"href": "non-spec:/.//",
"protocol": "non-spec:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "//",
"search": "",
"hash": ""
},
{
"input": "non-spec:/..//",
"base": "about:blank",
"href": "non-spec:/.//",
"protocol": "non-spec:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "//",
"search": "",
"hash": ""
},
{
"input": "non-spec:/a/..//",
"base": "about:blank",
"href": "non-spec:/.//",
"protocol": "non-spec:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "//",
"search": "",
"hash": ""
},
{
"input": "non-spec:/.//path",
"base": "about:blank",
"href": "non-spec:/.//path",
"protocol": "non-spec:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "//path",
"search": "",
"hash": ""
},
{
"input": "non-spec:/..//path",
"base": "about:blank",
"href": "non-spec:/.//path",
"protocol": "non-spec:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "//path",
"search": "",
"hash": ""
},
{
"input": "non-spec:/a/..//path",
"base": "about:blank",
"href": "non-spec:/.//path",
"protocol": "non-spec:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "//path",
"search": "",
"hash": ""
},
{
"input": "/.//path",
"base": "non-spec:/p",
"href": "non-spec:/.//path",
"protocol": "non-spec:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "//path",
"search": "",
"hash": ""
},
{
"input": "/..//path",
"base": "non-spec:/p",
"href": "non-spec:/.//path",
"protocol": "non-spec:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "//path",
"search": "",
"hash": ""
},
{
"input": "..//path",
"base": "non-spec:/p",
"href": "non-spec:/.//path",
"protocol": "non-spec:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "//path",
"search": "",
"hash": ""
},
{
"input": "a/..//path",
"base": "non-spec:/p",
"href": "non-spec:/.//path",
"protocol": "non-spec:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "//path",
"search": "",
"hash": ""
},
{
"input": "",
"base": "non-spec:/..//p",
"href": "non-spec:/.//p",
"protocol": "non-spec:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "//p",
"search": "",
"hash": ""
},
{
"input": "path",
"base": "non-spec:/..//p",
"href": "non-spec:/.//path",
"protocol": "non-spec:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "//path",
"search": "",
"hash": ""
},
"Do not serialize /. in path",
{
"input": "../path",
"base": "non-spec:/.//p",
"href": "non-spec:/path",
"protocol": "non-spec:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "/path",
"search": "",
"hash": ""
},
"# percent encoded hosts in non-special-URLs",
{
"input": "non-special://%E2%80%A0/",
Expand Down Expand Up @@ -6987,5 +7172,51 @@
"pathname": "/",
"search": "",
"hash": "#link"
},
"UTF-8 percent-encode of C0 control percent-encode set and supersets",
{
"input": "non-special:cannot-be-a-base-url-\u0000\u0001\u001F\u001E\u007E\u007F\u0080",
"base": "about:blank",
"hash": "",
"host": "",
"hostname": "",
"href": "non-special:cannot-be-a-base-url-%00%01%1F%1E~%7F%C2%80",
"origin": "null",
"password": "",
"pathname": "cannot-be-a-base-url-%00%01%1F%1E~%7F%C2%80",
"port": "",
"protocol": "non-special:",
"search": "",
"username": ""
},
{
"input": "https://www.example.com/path{\u007Fpath.html?query'\u007F=query#fragment<\u007Ffragment",
"base": "about:blank",
"hash": "#fragment%3C%7Ffragment",
"host": "www.example.com",
"hostname": "www.example.com",
"href": "https://www.example.com/path%7B%7Fpath.html?query%27%7F=query#fragment%3C%7Ffragment",
"origin": "https://www.example.com",
"password": "",
"pathname": "/path%7B%7Fpath.html",
"port": "",
"protocol": "https:",
"search": "?query%27%7F=query",
"username": ""
},
{
"input": "https://user:pass[\u007F@foo/bar",
"base": "http://example.org",
"hash": "",
"host": "foo",
"hostname": "foo",
"href": "https://user:pass%5B%7F@foo/bar",
"origin": "https://foo",
"password": "pass%5B%7F",
"pathname": "/bar",
"port": "",
"protocol": "https:",
"search": "",
"username": "user"
}
]

0 comments on commit 3f91606

Please sign in to comment.