Revision 910cbe6357ce4edfe2b10c74dbd3920b26e6144d authored by Mike West on 23 February 2015, 10:47:11 UTC, committed by Mike West on 23 February 2015, 10:47:11 UTC
These tests (generally) don't work under `testharness.js`, but they provide a good basis upon which a reasonably cross-browser test suite could be built. We should get started on that work.
1 parent 06dfcf8
a-element.html
<!doctype html>
<base id=base>
<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 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(raw) {
var urltests = URLTestParser(raw)
for(var i = 0, l = urltests.length; i < l; i++) {
var expected = urltests[i]
test(function() {
var url = bURL(expected.input, expected.base)
if(expected.protocol === ':' && url.protocol !== ':')
assert_unreached('Expected URL to fail parsing')
assert_equals(url.protocol, expected.protocol, "scheme")
assert_equals(url.hostname, expected.host, "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>
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...