diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/url/failure.html | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/url/failure.html')
-rw-r--r-- | testing/web-platform/tests/url/failure.html | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/testing/web-platform/tests/url/failure.html b/testing/web-platform/tests/url/failure.html new file mode 100644 index 0000000000..c22357b6c1 --- /dev/null +++ b/testing/web-platform/tests/url/failure.html @@ -0,0 +1,54 @@ +<!doctype html> +<meta charset=utf-8> +<title>Test URL parser failure consistency</title> +<meta name=timeout content=long> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<iframe></iframe> +<script> +promise_test(() => fetch("resources/urltestdata.json").then(res => res.json()).then(runTests), "Loading data…") + +function runTests(testData) { + for(const test of testData) { + if (typeof test === "string" || !test.failure || test.base !== "about:blank") { + continue + } + + const name = test.input + " should throw" + + self.test(() => { // URL's constructor's first argument is tested by url-constructor.html + // If a URL fails to parse with any valid base, it must also fail to parse with no base, i.e. + // when used as a base URL itself. + assert_throws_js(TypeError, () => new URL("about:blank", test.input)); + }, "URL's constructor's base argument: " + name) + + self.test(() => { + const url = new URL("about:blank") + assert_throws_js(TypeError, () => url.href = test.input) + }, "URL's href: " + name) + + // The following use cases resolve the URL input relative to the current + // document's URL. If this test input could be construed as a valid URL + // when resolved against a base URL, skip these cases. + if (!test.inputCanBeRelative) { + self.test(() => { + const client = new XMLHttpRequest() + assert_throws_dom("SyntaxError", () => client.open("GET", test.input)) + }, "XHR: " + name) + + self.test(() => { + assert_throws_js(TypeError, () => self.navigator.sendBeacon(test.input)) + }, "sendBeacon(): " + name) + + self.test(() => { + assert_throws_js(self[0].TypeError, () => self[0].location = test.input) + }, "Location's href: " + name) + + self.test(() => { + assert_throws_dom("SyntaxError", () => self.open(test.input).close()) + }, "window.open(): " + name) + } + } +} +</script> |