servo/tests/wpt/web-platform-tests/fetch/nosniff/image.html
Fabrice Desré 990b85049e Ignore mime type parameters in nosniff
This patch implements the following changes:
- Only check for the toplevel/sublevel part of the mime type when
  deciding if it's a js or css resource, ignoring the mime parameters.
- Fix the wpt tests that did not escape url parameters properly and
  also used an invalid syntax for the mime parameter.
- Update the wpt manifest.
2017-05-15 14:43:45 +02:00

27 lines
822 B
HTML

<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
var passes = [null, "", "x", "x/x", "image/gif", "image/png", "image/png;blah"]
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>