servo/tests/wpt/web-platform-tests/fetch/nosniff/importscripts.js
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

28 lines
689 B
JavaScript

// Testing importScripts()
function log(w) { this.postMessage(w) }
function f() { log("FAIL") }
function p() { log("PASS") }
const get_url = (mime, outcome) => {
let url = "resources/js.py"
if (mime != null) {
url += "?type=" + encodeURIComponent(mime)
}
if (outcome) {
url += "&outcome=p"
}
return url
}
[null, "", "x", "x/x"].forEach(function(mime) {
try {
importScripts(get_url(mime))
} catch(e) {
(e.name == "NetworkError") ? p() : log("FAIL (no NetworkError exception): " + mime)
}
})
importScripts(get_url("text/javascript", true))
importScripts(get_url("text/ecmascript", true))
importScripts(get_url("text/ecmascript;blah", true))
log("END")