diff options
Diffstat (limited to 'testing/web-platform/tests/url/resources/a-element-origin.js')
-rw-r--r-- | testing/web-platform/tests/url/resources/a-element-origin.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/testing/web-platform/tests/url/resources/a-element-origin.js b/testing/web-platform/tests/url/resources/a-element-origin.js new file mode 100644 index 0000000000..cb7d4a895c --- /dev/null +++ b/testing/web-platform/tests/url/resources/a-element-origin.js @@ -0,0 +1,27 @@ +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" || !("origin" in expected)) continue + // skip without base because you cannot unset the baseURL of a document + if (expected.base === null) continue; + + test(function() { + var url = bURL(expected.input, expected.base) + assert_equals(url.origin, expected.origin, "origin") + }, "Parsing origin: <" + expected.input + "> against <" + expected.base + ">") + } +} |