summaryrefslogtreecommitdiff
path: root/test/fixtures
diff options
context:
space:
mode:
authorDaijiro Wachi <daijiro.wachi@gmail.com>2017-04-03 17:48:32 +0900
committerDaijiro Wachi <daijiro.wachi@gmail.com>2017-04-03 18:12:05 +0900
commit843b7e68ca0df4c493557a1452e55323c543e872 (patch)
tree3af70e89882ce593414073b735d0a98873eec316 /test/fixtures
parent50bfef66f0f66daf7054baa1b250255d62a885c9 (diff)
downloadnode-new-843b7e68ca0df4c493557a1452e55323c543e872.tar.gz
test: synchronize WPT url setter test data
Updates: + Bring tests url-setter-tests from WPT, and put it as JavaScript + Comment out unpassed tests Refs: https://github.com/w3c/web-platform-tests/pull/5112 Refs: https://github.com/nodejs/node/pull/11887 PR-URL: https://github.com/nodejs/node/pull/12058 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Diffstat (limited to 'test/fixtures')
-rw-r--r--test/fixtures/url-setter-tests.js (renamed from test/fixtures/url-setter-tests.json)545
1 files changed, 533 insertions, 12 deletions
diff --git a/test/fixtures/url-setter-tests.json b/test/fixtures/url-setter-tests.js
index 4def18e772..8c15a3cc5a 100644
--- a/test/fixtures/url-setter-tests.json
+++ b/test/fixtures/url-setter-tests.js
@@ -1,6 +1,12 @@
+'use strict';
+
+/* WPT Refs:
+ https://github.com/w3c/web-platform-tests/blob/e48dd15/url/setters_tests.json
+ License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html
+*/
+module.exports =
{
"comment": [
- "License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html",
"## Tests for setters of https://url.spec.whatwg.org/#urlutils-members",
"",
"This file contains a JSON object.",
@@ -41,6 +47,14 @@
}
},
{
+ "href": "javascript:alert(1)",
+ "new_value": "defuse",
+ "expected": {
+ "href": "defuse:alert(1)",
+ "protocol": "defuse:"
+ }
+ },
+ {
"comment": "Upper-case ASCII is lower-cased",
"href": "a://example.net",
"new_value": "B",
@@ -103,11 +117,11 @@
}
},
{
- "comment": "Can’t switch from special scheme to non-special",
- "href": "http://example.net",
- "new_value": "b",
+ "comment": "Can’t switch from URL containing username/password/port to file",
+ "href": "http://test@example.net",
+ "new_value": "file",
"expected": {
- "href": "http://example.net/",
+ "href": "http://test@example.net/",
"protocol": "http:"
}
},
@@ -153,6 +167,15 @@
}
},
{
+ "comment": "Can’t switch from special scheme to non-special",
+ "href": "http://example.net",
+ "new_value": "b",
+ "expected": {
+ "href": "http://example.net/",
+ "protocol": "http:"
+ }
+ },
+ {
"href": "file://hi/path",
"new_value": "s",
"expected": {
@@ -274,6 +297,14 @@
}
},
{
+ "href": "javascript:alert(1)",
+ "new_value": "wario",
+ "expected": {
+ "href": "javascript:alert(1)",
+ "username": ""
+ }
+ },
+ {
"href": "http://example.net",
"new_value": "me",
"expected": {
@@ -322,7 +353,31 @@
"href": "http://%c3%89t%C3%A9@example.net/",
"username": "%c3%89t%C3%A9"
}
- }
+ },
+ {
+ "href": "sc:///",
+ "new_value": "x",
+ "expected": {
+ "href": "sc:///",
+ "username": ""
+ }
+ },
+ {
+ "href": "javascript://x/",
+ "new_value": "wario",
+ "expected": {
+ "href": "javascript://wario@x/",
+ "username": "wario"
+ }
+ },
+ // {
+ // "href": "file://test/",
+ // "new_value": "test",
+ // "expected": {
+ // "href": "file://test/",
+ // "username": ""
+ // }
+ // }
],
"password": [
{
@@ -401,10 +456,135 @@
"href": "http://:%c3%89t%C3%A9@example.net/",
"password": "%c3%89t%C3%A9"
}
- }
+ },
+ {
+ "href": "sc:///",
+ "new_value": "x",
+ "expected": {
+ "href": "sc:///",
+ "password": ""
+ }
+ },
+ {
+ "href": "javascript://x/",
+ "new_value": "bowser",
+ "expected": {
+ "href": "javascript://:bowser@x/",
+ "password": "bowser"
+ }
+ },
+ // {
+ // "href": "file://test/",
+ // "new_value": "test",
+ // "expected": {
+ // "href": "file://test/",
+ // "password": ""
+ // }
+ // }
],
"host": [
{
+ "comment": "Non-special scheme",
+ "href": "sc://x/",
+ "new_value": "\u0000",
+ "expected": {
+ "href": "sc://x/",
+ "host": "x",
+ "hostname": "x"
+ }
+ },
+ // {
+ // "href": "sc://x/",
+ // "new_value": "\u0009",
+ // "expected": {
+ // "href": "sc:///",
+ // "host": "",
+ // "hostname": ""
+ // }
+ // },
+ // {
+ // "href": "sc://x/",
+ // "new_value": "\u000A",
+ // "expected": {
+ // "href": "sc:///",
+ // "host": "",
+ // "hostname": ""
+ // }
+ // },
+ // {
+ // "href": "sc://x/",
+ // "new_value": "\u000D",
+ // "expected": {
+ // "href": "sc:///",
+ // "host": "",
+ // "hostname": ""
+ // }
+ // },
+ {
+ "href": "sc://x/",
+ "new_value": " ",
+ "expected": {
+ "href": "sc://x/",
+ "host": "x",
+ "hostname": "x"
+ }
+ },
+ // {
+ // "href": "sc://x/",
+ // "new_value": "#",
+ // "expected": {
+ // "href": "sc:///",
+ // "host": "",
+ // "hostname": ""
+ // }
+ // },
+ // {
+ // "href": "sc://x/",
+ // "new_value": "/",
+ // "expected": {
+ // "href": "sc:///",
+ // "host": "",
+ // "hostname": ""
+ // }
+ // },
+ // {
+ // "href": "sc://x/",
+ // "new_value": "?",
+ // "expected": {
+ // "href": "sc:///",
+ // "host": "",
+ // "hostname": ""
+ // }
+ // },
+ {
+ "href": "sc://x/",
+ "new_value": "@",
+ "expected": {
+ "href": "sc://x/",
+ "host": "x",
+ "hostname": "x"
+ }
+ },
+ // {
+ // "href": "sc://x/",
+ // "new_value": "ß",
+ // "expected": {
+ // "href": "sc://%C3%9F/",
+ // "host": "%C3%9F",
+ // "hostname": "%C3%9F"
+ // }
+ // },
+ {
+ "comment": "IDNA Nontransitional_Processing",
+ "href": "https://x/",
+ "new_value": "ß",
+ "expected": {
+ "href": "https://xn--zca/",
+ "host": "xn--zca",
+ "hostname": "xn--zca"
+ }
+ },
+ {
"comment": "Cannot-be-a-base means no host",
"href": "mailto:me@example.net",
"new_value": "example.com",
@@ -625,7 +805,7 @@
}
},
{
- "comment": "\\ is not a delimiter for non-special schemes, and it’s invalid in a domain",
+ "comment": "\\ is not a delimiter for non-special schemes, but still forbidden in hosts",
"href": "view-source+http://example.net/path",
"new_value": "example.com\\stuff",
"expected": {
@@ -689,10 +869,188 @@
"hostname": "example.com",
"port": ""
}
- }
+ },
+ {
+ "comment": "Broken IPv6",
+ "href": "http://example.net/",
+ "new_value": "[google.com]",
+ "expected": {
+ "href": "http://example.net/",
+ "host": "example.net",
+ "hostname": "example.net"
+ }
+ },
+ // {
+ // "href": "http://example.net/",
+ // "new_value": "[::1.2.3.4x]",
+ // "expected": {
+ // "href": "http://example.net/",
+ // "host": "example.net",
+ // "hostname": "example.net"
+ // }
+ // },
+ // {
+ // "href": "http://example.net/",
+ // "new_value": "[::1.2.3.]",
+ // "expected": {
+ // "href": "http://example.net/",
+ // "host": "example.net",
+ // "hostname": "example.net"
+ // }
+ // },
+ // {
+ // "href": "http://example.net/",
+ // "new_value": "[::1.2.]",
+ // "expected": {
+ // "href": "http://example.net/",
+ // "host": "example.net",
+ // "hostname": "example.net"
+ // }
+ // },
+ // {
+ // "href": "http://example.net/",
+ // "new_value": "[::1.]",
+ // "expected": {
+ // "href": "http://example.net/",
+ // "host": "example.net",
+ // "hostname": "example.net"
+ // }
+ // },
+ // {
+ // "href": "file://y/",
+ // "new_value": "x:123",
+ // "expected": {
+ // "href": "file://y/",
+ // "host": "y",
+ // "hostname": "y",
+ // "port": ""
+ // }
+ // },
+ // {
+ // "href": "file://y/",
+ // "new_value": "loc%41lhost",
+ // "expected": {
+ // "href": "file:///",
+ // "host": "",
+ // "hostname": "",
+ // "port": ""
+ // }
+ // },
+ // {
+ // "href": "file://hi/x",
+ // "new_value": "",
+ // "expected": {
+ // "href": "file:///x",
+ // "host": "",
+ // "hostname": "",
+ // "port": ""
+ // }
+ // },
+ // {
+ // "href": "sc://test@test/",
+ // "new_value": "",
+ // "expected": {
+ // "href": "sc://test@test/",
+ // "host": "test",
+ // "hostname": "test",
+ // "username": "test"
+ // }
+ // },
+ // {
+ // "href": "sc://test:12/",
+ // "new_value": "",
+ // "expected": {
+ // "href": "sc://test:12/",
+ // "host": "test:12",
+ // "hostname": "test",
+ // "port": "12"
+ // }
+ // }
],
"hostname": [
{
+ "comment": "Non-special scheme",
+ "href": "sc://x/",
+ "new_value": "\u0000",
+ "expected": {
+ "href": "sc://x/",
+ "host": "x",
+ "hostname": "x"
+ }
+ },
+ // {
+ // "href": "sc://x/",
+ // "new_value": "\u0009",
+ // "expected": {
+ // "href": "sc:///",
+ // "host": "",
+ // "hostname": ""
+ // }
+ // },
+ // {
+ // "href": "sc://x/",
+ // "new_value": "\u000A",
+ // "expected": {
+ // "href": "sc:///",
+ // "host": "",
+ // "hostname": ""
+ // }
+ // },
+ // {
+ // "href": "sc://x/",
+ // "new_value": "\u000D",
+ // "expected": {
+ // "href": "sc:///",
+ // "host": "",
+ // "hostname": ""
+ // }
+ // },
+ {
+ "href": "sc://x/",
+ "new_value": " ",
+ "expected": {
+ "href": "sc://x/",
+ "host": "x",
+ "hostname": "x"
+ }
+ },
+ // {
+ // "href": "sc://x/",
+ // "new_value": "#",
+ // "expected": {
+ // "href": "sc:///",
+ // "host": "",
+ // "hostname": ""
+ // }
+ // },
+ // {
+ // "href": "sc://x/",
+ // "new_value": "/",
+ // "expected": {
+ // "href": "sc:///",
+ // "host": "",
+ // "hostname": ""
+ // }
+ // },
+ // {
+ // "href": "sc://x/",
+ // "new_value": "?",
+ // "expected": {
+ // "href": "sc:///",
+ // "host": "",
+ // "hostname": ""
+ // }
+ // },
+ {
+ "href": "sc://x/",
+ "new_value": "@",
+ "expected": {
+ "href": "sc://x/",
+ "host": "x",
+ "hostname": "x"
+ }
+ },
+ {
"comment": "Cannot-be-a-base means no host",
"href": "mailto:me@example.net",
"new_value": "example.com",
@@ -836,7 +1194,7 @@
}
},
{
- "comment": "\\ is not a delimiter for non-special schemes, and it’s invalid in a domain",
+ "comment": "\\ is not a delimiter for non-special schemes, but still forbidden in hosts",
"href": "view-source+http://example.net/path",
"new_value": "example.com\\stuff",
"expected": {
@@ -845,7 +1203,103 @@
"hostname": "example.net",
"port": ""
}
- }
+ },
+ {
+ "comment": "Broken IPv6",
+ "href": "http://example.net/",
+ "new_value": "[google.com]",
+ "expected": {
+ "href": "http://example.net/",
+ "host": "example.net",
+ "hostname": "example.net"
+ }
+ },
+ // {
+ // "href": "http://example.net/",
+ // "new_value": "[::1.2.3.4x]",
+ // "expected": {
+ // "href": "http://example.net/",
+ // "host": "example.net",
+ // "hostname": "example.net"
+ // }
+ // },
+ // {
+ // "href": "http://example.net/",
+ // "new_value": "[::1.2.3.]",
+ // "expected": {
+ // "href": "http://example.net/",
+ // "host": "example.net",
+ // "hostname": "example.net"
+ // }
+ // },
+ // {
+ // "href": "http://example.net/",
+ // "new_value": "[::1.2.]",
+ // "expected": {
+ // "href": "http://example.net/",
+ // "host": "example.net",
+ // "hostname": "example.net"
+ // }
+ // },
+ // {
+ // "href": "http://example.net/",
+ // "new_value": "[::1.]",
+ // "expected": {
+ // "href": "http://example.net/",
+ // "host": "example.net",
+ // "hostname": "example.net"
+ // }
+ // },
+ // {
+ // "href": "file://y/",
+ // "new_value": "x:123",
+ // "expected": {
+ // "href": "file://y/",
+ // "host": "y",
+ // "hostname": "y",
+ // "port": ""
+ // }
+ // },
+ // {
+ // "href": "file://y/",
+ // "new_value": "loc%41lhost",
+ // "expected": {
+ // "href": "file:///",
+ // "host": "",
+ // "hostname": "",
+ // "port": ""
+ // }
+ // },
+ // {
+ // "href": "file://hi/x",
+ // "new_value": "",
+ // "expected": {
+ // "href": "file:///x",
+ // "host": "",
+ // "hostname": "",
+ // "port": ""
+ // }
+ // },
+ // {
+ // "href": "sc://test@test/",
+ // "new_value": "",
+ // "expected": {
+ // "href": "sc://test@test/",
+ // "host": "test",
+ // "hostname": "test",
+ // "username": "test"
+ // }
+ // },
+ // {
+ // "href": "sc://test:12/",
+ // "new_value": "",
+ // "expected": {
+ // "href": "sc://test:12/",
+ // "host": "test:12",
+ // "hostname": "test",
+ // "port": "12"
+ // }
+ // }
],
"port": [
{
@@ -1000,6 +1454,65 @@
"hostname": "example.net",
"port": "8080"
}
+ },
+ {
+ "comment": "Port numbers are 16 bit integers, overflowing is an error",
+ "href": "non-special://example.net:8080/path",
+ "new_value": "65536",
+ "expected": {
+ "href": "non-special://example.net:8080/path",
+ "host": "example.net:8080",
+ "hostname": "example.net",
+ "port": "8080"
+ }
+ },
+ {
+ "href": "file://test/",
+ "new_value": "12",
+ "expected": {
+ "href": "file://test/",
+ "port": ""
+ }
+ },
+ {
+ "href": "file://localhost/",
+ "new_value": "12",
+ "expected": {
+ "href": "file:///",
+ "port": ""
+ }
+ },
+ {
+ "href": "non-base:value",
+ "new_value": "12",
+ "expected": {
+ "href": "non-base:value",
+ "port": ""
+ }
+ },
+ {
+ "href": "sc:///",
+ "new_value": "12",
+ "expected": {
+ "href": "sc:///",
+ "port": ""
+ }
+ },
+ {
+ "href": "sc://x/",
+ "new_value": "12",
+ "expected": {
+ "href": "sc://x:12/",
+ "port": "12"
+ }
+ },
+ {
+ "href": "javascript://x/",
+ "new_value": "12",
+ "expected": {
+ "href": "javascript://x:12/",
+ "port": "12"
+ }
}
],
"pathname": [
@@ -1259,6 +1772,14 @@
"href": "http://example.net/#%c3%89t%C3%A9",
"hash": "#%c3%89t%C3%A9"
}
- }
+ },
+ // {
+ // "href": "javascript:alert(1)",
+ // "new_value": "castle",
+ // "expected": {
+ // "href": "javascript:alert(1)#castle",
+ // "hash": "#castle"
+ // }
+ // }
]
}