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/preload/preconnect-onerror-event.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/preload/preconnect-onerror-event.html')
-rw-r--r-- | testing/web-platform/tests/preload/preconnect-onerror-event.html | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/testing/web-platform/tests/preload/preconnect-onerror-event.html b/testing/web-platform/tests/preload/preconnect-onerror-event.html new file mode 100644 index 0000000000..4ce583d4db --- /dev/null +++ b/testing/web-platform/tests/preload/preconnect-onerror-event.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<html> +<title>Makes sure that preloaded resources trigger the onerror event</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/get-host-info.sub.js"></script> + +<body> +<script> + const {HTTP_REMOTE_ORIGIN} = get_host_info(); + + function test_preconnect(origin, resource, desc) { + promise_test(async t => { + const result = await new Promise(async didLoad => { + const href = `${origin}${resource}`; + for (const rel of ['preconnect', 'preload']) { + const link = document.createElement('link'); + link.href = href; + link.as = 'script'; + link.rel = rel; + link.addEventListener('load', () => didLoad({rel, type: 'load'})); + link.addEventListener('error', () => didLoad({rel, type: 'error'})); + document.head.appendChild(link); + t.step_timeout(() => resolve('timeout'), 200)); + } + }); + assert_equals(result.rel, 'preload'); + }, desc); + } + + test_preconnect(HTTP_REMOTE_ORIGIN, '/preload/resources/dummy.js', 'Preconnect should not fire load events'); + test_preconnect('http://NON-EXISTENT.origin', '/preload/resources/dummy.js', 'Preconnect should not fire error events for non-existent origins'); + test_preconnect('some-scheme://URL', '/preload/resources/dummy.js', 'Preconnect should not fire error events for non-http(s) scheme'); +</script> +</body> +</html> |