mirror of
https://github.com/servo/servo.git
synced 2025-09-07 21:48:21 +01:00
Update web-platform-tests.
This commit is contained in:
parent
74afd086d2
commit
71008d816d
62 changed files with 793 additions and 150 deletions
29
tests/wpt/web-platform-tests/fetch/nosniff/image.html
Normal file
29
tests/wpt/web-platform-tests/fetch/nosniff/image.html
Normal file
|
@ -0,0 +1,29 @@
|
|||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
var fails = ["", "?type=", "?type=x", "?type=x/x"],
|
||||
passes = ["?type=image/gif", "?type=image/png", "?type=image/png;blah"]
|
||||
|
||||
fails.forEach(function(urlpart) {
|
||||
async_test(function(t) {
|
||||
var img = document.createElement("img")
|
||||
img.onerror = t.step_func_done(function(){})
|
||||
img.onload = t.unreached_func("Unexpected load event")
|
||||
img.src = "resources/image.py" + urlpart
|
||||
document.body.appendChild(img)
|
||||
}, "URL query: " + urlpart)
|
||||
})
|
||||
|
||||
passes.forEach(function(urlpart) {
|
||||
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 = "resources/image.py" + urlpart
|
||||
document.body.appendChild(img)
|
||||
}, "URL query: " + urlpart)
|
||||
})
|
||||
</script>
|
|
@ -0,0 +1,14 @@
|
|||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var w = new Worker("importscripts.js")
|
||||
w.onmessage = t.step_func(function(e) {
|
||||
if(e.data == "END")
|
||||
t.done()
|
||||
else
|
||||
assert_equals(e.data, "PASS")
|
||||
})
|
||||
}, "Test importScripts()")
|
||||
</script>
|
17
tests/wpt/web-platform-tests/fetch/nosniff/importscripts.js
Normal file
17
tests/wpt/web-platform-tests/fetch/nosniff/importscripts.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
// Testing importScripts()
|
||||
function log(w) { this.postMessage(w) }
|
||||
function f() { log("FAIL") }
|
||||
function p() { log("PASS") }
|
||||
|
||||
["", "?type=", "?type=x", "?type=x/x"].forEach(function(urlpart) {
|
||||
try {
|
||||
importScripts("resources/js.py" + urlpart)
|
||||
} catch(e) {
|
||||
(e.name == "NetworkError") ? p() : log("FAIL (no NetworkError exception): " + urlpart)
|
||||
}
|
||||
|
||||
})
|
||||
importScripts("resources/js.py?type=text/javascript&outcome=p")
|
||||
importScripts("resources/js.py?type=text/ecmascript&outcome=p")
|
||||
importScripts("resources/js.py?type=text/ecmascript;blah&outcome=p")
|
||||
log("END")
|
|
@ -0,0 +1,28 @@
|
|||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
var fails = ["first", "uppercase"],
|
||||
passes = ["last", "quoted", "quoted-single", "no-x"]
|
||||
|
||||
fails.forEach(function(urlpart) {
|
||||
async_test(function(t) {
|
||||
var script = document.createElement("script")
|
||||
script.onerror = t.step_func_done(function(){})
|
||||
script.onload = t.unreached_func("Unexpected load event")
|
||||
script.src = "resources/nosniff-" + urlpart + ".asis"
|
||||
document.body.appendChild(script)
|
||||
}, "URL query: " + urlpart)
|
||||
})
|
||||
|
||||
passes.forEach(function(urlpart) {
|
||||
async_test(function(t) {
|
||||
var script = document.createElement("script")
|
||||
script.onerror = t.unreached_func("Unexpected error event")
|
||||
script.onload = t.step_func_done(function(){})
|
||||
script.src = "resources/nosniff-" + urlpart + ".asis"
|
||||
document.body.appendChild(script)
|
||||
}, "URL query: " + urlpart)
|
||||
})
|
||||
|
||||
</script>
|
15
tests/wpt/web-platform-tests/fetch/nosniff/resources/css.py
Normal file
15
tests/wpt/web-platform-tests/fetch/nosniff/resources/css.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
def main(request, response):
|
||||
outcome = request.GET.first("outcome", "f")
|
||||
type = request.GET.first("type", None)
|
||||
|
||||
content = "/* nothing to see here */"
|
||||
|
||||
response.add_required_headers = False
|
||||
response.writer.write_status(200)
|
||||
response.writer.write_header("x-content-type-options", "nosniff")
|
||||
response.writer.write_header("content-length", len(content))
|
||||
if(type != None):
|
||||
response.writer.write_header("content-type", type)
|
||||
response.writer.end_headers()
|
||||
|
||||
response.writer.write(content)
|
|
@ -0,0 +1,16 @@
|
|||
import os.path
|
||||
|
||||
def main(request, response):
|
||||
type = request.GET.first("type", None)
|
||||
|
||||
body = open(os.path.join(os.path.dirname(__file__), "../../../images/blue96x96.png")).read()
|
||||
|
||||
response.add_required_headers = False
|
||||
response.writer.write_status(200)
|
||||
response.writer.write_header("x-content-type-options", "nosniff")
|
||||
response.writer.write_header("content-length", len(body))
|
||||
if(type != None):
|
||||
response.writer.write_header("content-type", type)
|
||||
response.writer.end_headers()
|
||||
|
||||
response.writer.write(body)
|
17
tests/wpt/web-platform-tests/fetch/nosniff/resources/js.py
Normal file
17
tests/wpt/web-platform-tests/fetch/nosniff/resources/js.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
def main(request, response):
|
||||
outcome = request.GET.first("outcome", "f")
|
||||
type = request.GET.first("type", "Content-Type missing")
|
||||
|
||||
content = "// nothing to see here"
|
||||
content += "\n"
|
||||
content += "log('FAIL: " + type + "')" if (outcome == "f") else "p()"
|
||||
|
||||
response.add_required_headers = False
|
||||
response.writer.write_status(200)
|
||||
response.writer.write_header("x-content-type-options", "nosniff")
|
||||
response.writer.write_header("content-length", len(content))
|
||||
if(type != "Content-Type missing"):
|
||||
response.writer.write_header("content-type", type)
|
||||
response.writer.end_headers()
|
||||
|
||||
response.writer.write(content)
|
|
@ -0,0 +1,7 @@
|
|||
HTTP/1.1 200 YOU HAVE NO POWER HERE
|
||||
Content-Length: 22
|
||||
Content-Type: x/x
|
||||
X-Content-Type-options: nosniff
|
||||
X-Content-Type-Options: no
|
||||
|
||||
// nothing to see here
|
|
@ -0,0 +1,7 @@
|
|||
HTTP/1.1 200 YOU HAVE NO POWER HERE
|
||||
Content-Length: 22
|
||||
Content-Type: x/x
|
||||
X-Content-Type-Options: no
|
||||
X-Content-Type-options: nosniff
|
||||
|
||||
// nothing to see here
|
|
@ -0,0 +1,6 @@
|
|||
HTTP/1.1 200 YOU HAVE NO POWER HERE
|
||||
Content-Length: 22
|
||||
Content-Type: x/x
|
||||
Content-Type-Options: nosniff
|
||||
|
||||
// nothing to see here
|
|
@ -0,0 +1,6 @@
|
|||
HTTP/1.1 200 YOU HAVE NO POWER HERE
|
||||
Content-Length: 22
|
||||
Content-Type: x/x
|
||||
X-Content-Type-Options: 'NosniFF'
|
||||
|
||||
// nothing to see here
|
|
@ -0,0 +1,6 @@
|
|||
HTTP/1.1 200 YOU HAVE NO POWER HERE
|
||||
Content-Length: 22
|
||||
Content-Type: x/x
|
||||
X-Content-Type-Options: "nosniFF"
|
||||
|
||||
// nothing to see here
|
|
@ -0,0 +1,6 @@
|
|||
HTTP/1.1 200 YOU HAVE NO POWER HERE
|
||||
Content-Length: 22
|
||||
Content-Type: x/x
|
||||
X-Content-Type-Options: NOSNIFF
|
||||
|
||||
// nothing to see here
|
|
@ -0,0 +1,16 @@
|
|||
def main(request, response):
|
||||
type = request.GET.first("type", None)
|
||||
|
||||
content = "// nothing to see here"
|
||||
content += "\n"
|
||||
content += "this.postMessage('hi')"
|
||||
|
||||
response.add_required_headers = False
|
||||
response.writer.write_status(200)
|
||||
response.writer.write_header("x-content-type-options", "nosniff")
|
||||
response.writer.write_header("content-length", len(content))
|
||||
if(type != None):
|
||||
response.writer.write_header("content-type", type)
|
||||
response.writer.end_headers()
|
||||
|
||||
response.writer.write(content)
|
32
tests/wpt/web-platform-tests/fetch/nosniff/script.html
Normal file
32
tests/wpt/web-platform-tests/fetch/nosniff/script.html
Normal file
|
@ -0,0 +1,32 @@
|
|||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
var log = function() {}, // see comment below
|
||||
p = function() {}, // see comment below
|
||||
fails = ["", "?type=", "?type=x", "?type=x/x"],
|
||||
passes = ["?type=text/javascript", "?type=text/ecmascript", "?type=text/ecmascript;blah"]
|
||||
|
||||
// Ideally we'd also check whether the scripts in fact execute, but that would involve
|
||||
// timers and might get a bit racy without cross-browser support for the execute events.
|
||||
|
||||
fails.forEach(function(urlpart) {
|
||||
async_test(function(t) {
|
||||
var script = document.createElement("script")
|
||||
script.onerror = t.step_func_done(function(){})
|
||||
script.onload = t.unreached_func("Unexpected load event")
|
||||
script.src = "resources/js.py" + urlpart
|
||||
document.body.appendChild(script)
|
||||
}, "URL query: " + urlpart)
|
||||
})
|
||||
|
||||
passes.forEach(function(urlpart) {
|
||||
async_test(function(t) {
|
||||
var script = document.createElement("script")
|
||||
script.onerror = t.unreached_func("Unexpected error event")
|
||||
script.onload = t.step_func_done(function(){})
|
||||
script.src = "resources/js.py" + urlpart + "&outcome=p"
|
||||
document.body.appendChild(script)
|
||||
}, "URL query: " + urlpart)
|
||||
})
|
||||
</script>
|
34
tests/wpt/web-platform-tests/fetch/nosniff/stylesheet.html
Normal file
34
tests/wpt/web-platform-tests/fetch/nosniff/stylesheet.html
Normal file
|
@ -0,0 +1,34 @@
|
|||
<!-- quirks mode is important, text/css is already required otherwise -->
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
var fails = ["", "?type=", "?type=x", "?type=x/x"],
|
||||
passes = ["?type=text/css", "?type=text/css;blah"]
|
||||
|
||||
fails.forEach(function(urlpart) {
|
||||
async_test(function(t) {
|
||||
var link = document.createElement("link")
|
||||
link.rel = "stylesheet"
|
||||
link.onerror = t.step_func_done(function(){})
|
||||
link.onload = t.unreached_func("Unexpected load event")
|
||||
link.href = "resources/css.py" + urlpart
|
||||
document.body.appendChild(link)
|
||||
}, "URL query: " + urlpart)
|
||||
})
|
||||
|
||||
passes.forEach(function(urlpart) {
|
||||
async_test(function(t) {
|
||||
var link = document.createElement("link")
|
||||
link.rel = "stylesheet"
|
||||
link.onerror = t.unreached_func("Unexpected error event")
|
||||
link.onload = t.step_func_done(function(){
|
||||
if(passes[passes.length-1] == urlpart) {
|
||||
assert_equals(document.styleSheets.length, passes.length)
|
||||
}
|
||||
})
|
||||
link.href = "resources/css.py" + urlpart
|
||||
document.body.appendChild(link)
|
||||
}, "URL query: " + urlpart)
|
||||
})
|
||||
</script>
|
28
tests/wpt/web-platform-tests/fetch/nosniff/worker.html
Normal file
28
tests/wpt/web-platform-tests/fetch/nosniff/worker.html
Normal file
|
@ -0,0 +1,28 @@
|
|||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
var workers = [],
|
||||
fails = ["", "?type=", "?type=x", "?type=x/x"],
|
||||
passes = ["?type=text/javascript", "?type=text/ecmascript", "?type=text/ecmascript;yay"]
|
||||
|
||||
fails.forEach(function(urlpart) {
|
||||
async_test(function(t) {
|
||||
var w = new Worker("resources/worker.py" + urlpart)
|
||||
w.onmessage = t.unreached_func("Unexpected message event")
|
||||
w.onerror = t.step_func_done(function(){})
|
||||
workers.push(w) // avoid GC
|
||||
}, "URL query: " + urlpart)
|
||||
})
|
||||
|
||||
passes.forEach(function(urlpart) {
|
||||
async_test(function(t) {
|
||||
var w = new Worker("resources/worker.py" + urlpart)
|
||||
w.onmessage = t.step_func_done(function(e){
|
||||
assert_equals(e.data, "hi")
|
||||
})
|
||||
w.onerror = t.unreached_func("Unexpected error event")
|
||||
workers.push(w) // avoid GC
|
||||
}, "URL query: " + urlpart)
|
||||
})
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue