summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fetch/nosniff/image.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/fetch/nosniff/image.html
parentInitial commit. (diff)
downloadfirefox-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/fetch/nosniff/image.html')
-rw-r--r--testing/web-platform/tests/fetch/nosniff/image.html39
1 files changed, 39 insertions, 0 deletions
diff --git a/testing/web-platform/tests/fetch/nosniff/image.html b/testing/web-platform/tests/fetch/nosniff/image.html
new file mode 100644
index 0000000000..9dfdb94cf6
--- /dev/null
+++ b/testing/web-platform/tests/fetch/nosniff/image.html
@@ -0,0 +1,39 @@
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id=log></div>
+<script>
+ // Note: images get always sniffed, nosniff doesn't do anything
+ // (but note the tentative Cross-Origin Read Blocking (CORB) tests
+ // - for example wpt/fetch/corb/img-mime-types-coverage.tentative.sub.html).
+ var passes = [
+ // Empty or non-sensical MIME types
+ null, "", "x", "x/x",
+
+ // Image MIME types
+ "image/gif", "image/png", "image/png;blah", "image/svg+xml",
+
+ // CORB-protected MIME types (but note that CORB doesn't apply here,
+ // because CORB ignores same-origin requests).
+ "text/html", "application/xml", "application/blah+xml"
+ ]
+
+ const get_url = (mime) => {
+ let url = "resources/image.py"
+ if (mime != null) {
+ url += "?type=" + encodeURIComponent(mime)
+ }
+ return url
+ }
+
+ passes.forEach(function(mime) {
+ async_test(function(t) {
+ var img = document.createElement("img")
+ img.onerror = t.unreached_func("Unexpected error event")
+ img.onload = t.step_func_done(function(){
+ assert_equals(img.width, 96)
+ })
+ img.src = get_url(mime)
+ document.body.appendChild(img)
+ }, "URL query: " + mime)
+ })
+</script>