mirror of
https://github.com/servo/servo.git
synced 2025-08-10 16:05:43 +01:00
Update web-platform-tests to revision cf261625e2d230ab219eec966f4abe26e3401b64
This commit is contained in:
parent
11a89bcc47
commit
8f98acd0e7
297 changed files with 3396 additions and 1555 deletions
42
tests/wpt/web-platform-tests/url/resources/a-element.js
Normal file
42
tests/wpt/web-platform-tests/url/resources/a-element.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
promise_test(() => fetch("resources/urltestdata.json").then(res => res.json()).then(runURLTests), "Loading data…");
|
||||
|
||||
function setBase(base) {
|
||||
document.getElementById("base").href = base
|
||||
}
|
||||
|
||||
function bURL(url, base) {
|
||||
base = base || "about:blank"
|
||||
setBase(base)
|
||||
var a = document.createElement("a")
|
||||
a.setAttribute("href", url)
|
||||
return a
|
||||
}
|
||||
|
||||
function runURLTests(urltests) {
|
||||
for(var i = 0, l = urltests.length; i < l; i++) {
|
||||
var expected = urltests[i]
|
||||
if (typeof expected === "string") continue // skip comments
|
||||
|
||||
test(function() {
|
||||
var url = bURL(expected.input, expected.base)
|
||||
if(expected.failure) {
|
||||
if(url.protocol !== ':') {
|
||||
assert_unreached("Expected URL to fail parsing")
|
||||
}
|
||||
assert_equals(url.href, expected.input, "failure should set href to input")
|
||||
return
|
||||
}
|
||||
|
||||
assert_equals(url.href, expected.href, "href")
|
||||
assert_equals(url.protocol, expected.protocol, "protocol")
|
||||
assert_equals(url.username, expected.username, "username")
|
||||
assert_equals(url.password, expected.password, "password")
|
||||
assert_equals(url.host, expected.host, "host")
|
||||
assert_equals(url.hostname, expected.hostname, "hostname")
|
||||
assert_equals(url.port, expected.port, "port")
|
||||
assert_equals(url.pathname, expected.pathname, "pathname")
|
||||
assert_equals(url.search, expected.search, "search")
|
||||
assert_equals(url.hash, expected.hash, "hash")
|
||||
}, "Parsing: <" + expected.input + "> against <" + expected.base + ">")
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue