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>
This commit is contained in:
parent
50bfef66f0
commit
843b7e68ca
@ -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.",
|
||||
@ -40,6 +46,14 @@
|
||||
"protocol": "b:"
|
||||
}
|
||||
},
|
||||
{
|
||||
"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",
|
||||
@ -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:"
|
||||
}
|
||||
},
|
||||
@ -152,6 +166,15 @@
|
||||
"protocol": "file:"
|
||||
}
|
||||
},
|
||||
{
|
||||
"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",
|
||||
@ -273,6 +296,14 @@
|
||||
"username": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"href": "javascript:alert(1)",
|
||||
"new_value": "wario",
|
||||
"expected": {
|
||||
"href": "javascript:alert(1)",
|
||||
"username": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"href": "http://example.net",
|
||||
"new_value": "me",
|
||||
@ -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,9 +456,134 @@
|
||||
"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",
|
||||
@ -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,9 +869,187 @@
|
||||
"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",
|
||||
@ -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"
|
||||
// }
|
||||
// }
|
||||
]
|
||||
}
|
@ -15,7 +15,7 @@ if (!common.hasIntl) {
|
||||
}
|
||||
|
||||
const request = {
|
||||
response: require(path.join(common.fixturesDir, 'url-setter-tests.json'))
|
||||
response: require(path.join(common.fixturesDir, 'url-setter-tests'))
|
||||
};
|
||||
|
||||
/* eslint-disable */
|
||||
|
Loading…
x
Reference in New Issue
Block a user