diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/preload/preload-with-type.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/preload/preload-with-type.html')
-rw-r--r-- | testing/web-platform/tests/preload/preload-with-type.html | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/testing/web-platform/tests/preload/preload-with-type.html b/testing/web-platform/tests/preload/preload-with-type.html new file mode 100644 index 0000000000..7f92606cb7 --- /dev/null +++ b/testing/web-platform/tests/preload/preload-with-type.html @@ -0,0 +1,84 @@ +<!DOCTYPE html> +<title>Makes sure that preloaded resources with a type attribute 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 src="/common/media.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 = 0; + var getFormat = function(url) { + var dot = url.lastIndexOf('.'); + if (dot != -1) { + var extension = url.substring(dot + 1); + if (extension.startsWith("og")) + return "ogg"; + return extension; + } + return null; + }; + var videoURL = getVideoURI("resources/A4"); + var audioURL = getAudioURI("resources/sound_5"); + var videoFormat = getFormat(videoURL); + var audioFormat = getFormat(audioURL); +</script> +<link rel=preload href="resources/dummy.js" as=script type="text/javascript" onload="scriptLoaded = true;"> +<link rel=preload href="resources/dummy.css" as=style type="text/css" onload="styleLoaded = true;"> +<link rel=preload href="resources/square.png" as=image type="image/png" onload="imageLoaded = true;"> +<link rel=preload href="/fonts/CanvasTest.ttf" as=font type="font/ttf" crossorigin onload="fontLoaded = true;"> +<script> + document.write('<link rel=preload href="' + videoURL + '" as=video type="video/' + videoFormat + '" onload="videoLoaded = true;">'); + document.write('<link rel=preload href="' + audioURL + '" as=audio type="audio/' + audioFormat + '" onload="audioLoaded = true;">'); +</script> +<link rel=preload href="resources/foo.vtt" as=track type="text/vtt" onload="trackLoaded = true;"> +<link rel=preload href="resources/dummy.js" as=script type="application/foobar" onload="gibberishLoaded++;"> +<link rel=preload href="resources/dummy.css" as=style type="text/foobar" onload="gibberishLoaded++;"> +<link rel=preload href="resources/square.png" as=image type="image/foobar" onload="gibberishLoaded++;"> +<link rel=preload href="/fonts/CanvasTest.ttf" as=font type="font/foobar" crossorigin onload="gibberishLoaded++;"> +<script> + document.write('<link rel=preload href="' + videoURL + '" as=video type="video/foobar" onload="gibberishLoaded++;">'); + document.write('<link rel=preload href="' + audioURL + '" as=audio type="audio/foobar" onload="gibberishLoaded++;">'); +</script> +<link rel=preload href="resources/foo.vtt" as=track type="text/foobar" onload="gibberishLoaded++;"> +<body> +<script> + setup({single_test: true}); + + var iterations = 0; + + function check_finished() { + if (styleLoaded && scriptLoaded && imageLoaded && fontLoaded && videoLoaded && audioLoaded && + trackLoaded && gibberishLoaded == 0) { + 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_equals(gibberishLoaded, 0, "resources with gibberish type should not be loaded"); + done(); + } else { + step_timeout(check_finished, 500); + } + } + + window.addEventListener("load", function() { + verifyPreloadAndRTSupport(); + step_timeout(check_finished, 500); + }); +</script> +</body> +</html> |