diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/preload/onload-event.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/preload/onload-event.html')
-rw-r--r-- | testing/web-platform/tests/preload/onload-event.html | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/testing/web-platform/tests/preload/onload-event.html b/testing/web-platform/tests/preload/onload-event.html new file mode 100644 index 0000000000..2e1e8d3900 --- /dev/null +++ b/testing/web-platform/tests/preload/onload-event.html @@ -0,0 +1,66 @@ +<!DOCTYPE html> +<title>Makes sure that preloaded resources trigger the onload event</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/preload/resources/preload_helper.js"></script> +<script> + var scriptLoaded = false; + var styleLoaded = false; + var imageLoaded = false; + var fontLoaded = false; + var videoLoaded = false; + var audioLoaded = false; + var trackLoaded = false; + var gibberishLoaded = false; + var gibberishErrored = false; + var noTypeLoaded = false; + var fetchLoaded = false; +</script> +<link rel=preload href="resources/dummy.js" as=script onload="scriptLoaded = true;"> +<link rel=preload href="resources/dummy.css" as=style onload="styleLoaded = true;"> +<link rel=preload href="resources/square.png" as=image onload="imageLoaded = true;"> +<link rel=preload href="/fonts/CanvasTest.ttf" as=font crossorigin onload="fontLoaded = true;"> +<link rel=preload href="resources/white.mp4" as=video onload="videoLoaded = true;"> +<link rel=preload href="resources/sound_5.oga" as=audio onload="audioLoaded = true;"> +<link rel=preload href="resources/foo.vtt" as=track onload="trackLoaded = true;"> +<link rel=preload href="resources/dummy.xml?foo=bar" as=foobarxmlthing onload="gibberishLoaded = true;" onerror="gibberishErrored = true;"> +<link rel=preload href="resources/dummy.xml?fetch" as=fetch onload="fetchLoaded = true;"> +<link rel=preload href="resources/dummy.xml" onload="noTypeLoaded = true;"> +<body> +<script> + setup({single_test: true}); + + var iterations = 0; + + function check_finished() { + if (styleLoaded && scriptLoaded && imageLoaded && fontLoaded && videoLoaded && audioLoaded && + trackLoaded && !gibberishLoaded && !gibberishErrored && fetchLoaded && !noTypeLoaded) { + done(); + } + iterations++; + if (iterations == 10) { + // At least one is expected to fail, but this should give details to the exact failure(s). + assert_true(styleLoaded, "style triggered load event"); + assert_true(scriptLoaded, "script triggered load event"); + assert_true(imageLoaded, "image triggered load event"); + assert_true(fontLoaded, "font triggered load event"); + assert_true(videoLoaded, "video triggered load event"); + assert_true(audioLoaded, "audio triggered load event"); + assert_true(trackLoaded, "track triggered load event"); + assert_false(gibberishLoaded, "gibberish as value triggered load event"); + assert_false(gibberishErrored, "gibberish as value triggered error event"); + assert_true(fetchLoaded, "fetch as value triggered load event"); + assert_false(noTypeLoaded, "empty as triggered load event"); + done(); + } else { + step_timeout(check_finished, 500); + } + } + + window.addEventListener("load", function() { + verifyPreloadAndRTSupport(); + step_timeout(check_finished, 500); + }); +</script> +</body> |