blob: ad2c241fe120191abf00cad59d6798e7b6a8831e [file] [log] [blame]
<!doctype html>
<meta charset=utf-8>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=urltestparser.js></script>
<div id=log></div>
<script>
var setup = async_test("Loading data…")
setup.step(function() {
var request = new XMLHttpRequest()
request.open("GET", "urltestdata.txt")
request.send()
request.responseType = "text"
request.onload = setup.step_func(function() {
runURLTests(request.response);
setup.done()
})
})
function bURL(url, base) {
return new URL(url, base || "about:blank");
}
function runURLTests(raw) {
var urltests = URLTestParser(raw)
for(var i = 0, l = urltests.length; i < l; i++) {
var expected = urltests[i]
test(function() {
if (expected.protocol === ':') {
assert_throws(new TypeError(), function() {
bURL(expected.input, expected.base)
});
return;
}
var url = bURL(expected.input, expected.base)
assert_equals(url.protocol, expected.protocol, "scheme")
assert_equals(url.hostname, expected.hostname, "host")
assert_equals(url.port, expected.port, "port")
assert_equals(url.pathname, expected.path, "path")
assert_equals(url.search, expected.search, "search")
assert_equals(url.hash, expected.hash, "hash")
assert_equals(url.href, expected.href, "href")
}, "Parsing: <" + expected.input + "> against <" + expected.base + ">")
}
}
</script>