Update web-platform-tests.

This commit is contained in:
Ms2ger 2015-04-09 13:39:50 +02:00
parent 74afd086d2
commit 71008d816d
62 changed files with 793 additions and 150 deletions

View file

@ -2,3 +2,4 @@
type: testharness
[Shadows are not drawn for transparent parts of canvases]
expected: FAIL

View file

@ -2,3 +2,4 @@
type: testharness
[Shadows are not drawn for transparent parts of images]
expected: FAIL

View file

@ -8955,10 +8955,6 @@
"path": "IndexedDB/key_invalid.htm",
"url": "/IndexedDB/key_invalid.htm"
},
{
"path": "IndexedDB/key_valid.html",
"url": "/IndexedDB/key_valid.html"
},
{
"path": "IndexedDB/keygenerator-constrainterror.htm",
"url": "/IndexedDB/keygenerator-constrainterror.htm"
@ -9819,38 +9815,6 @@
"path": "content-security-policy/img-src/img-src-4_1.html",
"url": "/content-security-policy/img-src/img-src-4_1.html"
},
{
"path": "content-security-policy/media-src/media-src-7_1.html",
"url": "/content-security-policy/media-src/media-src-7_1.html"
},
{
"path": "content-security-policy/media-src/media-src-7_1_2.html",
"url": "/content-security-policy/media-src/media-src-7_1_2.html"
},
{
"path": "content-security-policy/media-src/media-src-7_2.html",
"url": "/content-security-policy/media-src/media-src-7_2.html"
},
{
"path": "content-security-policy/media-src/media-src-7_2_2.html",
"url": "/content-security-policy/media-src/media-src-7_2_2.html"
},
{
"path": "content-security-policy/media-src/media-src-7_3.html",
"url": "/content-security-policy/media-src/media-src-7_3.html"
},
{
"path": "content-security-policy/media-src/media-src-7_3_2.html",
"url": "/content-security-policy/media-src/media-src-7_3_2.html"
},
{
"path": "content-security-policy/object-src/object-src-2_1.html",
"url": "/content-security-policy/object-src/object-src-2_1.html"
},
{
"path": "content-security-policy/object-src/object-src-2_2.html",
"url": "/content-security-policy/object-src/object-src-2_2.html"
},
{
"path": "content-security-policy/script-src/script-src-1_1.html",
"url": "/content-security-policy/script-src/script-src-1_1.html"
@ -10311,6 +10275,10 @@
"path": "dom/nodes/CharacterData-replaceData.html",
"url": "/dom/nodes/CharacterData-replaceData.html"
},
{
"path": "dom/nodes/CharacterData-substringData.html",
"url": "/dom/nodes/CharacterData-substringData.html"
},
{
"path": "dom/nodes/Comment-constructor.html",
"url": "/dom/nodes/Comment-constructor.html"
@ -11271,6 +11239,30 @@
"path": "ext-xhtml-pubid/the-xhtml-syntax/parsing-xhtml-documents/xhtml-pubid-1.html",
"url": "/ext-xhtml-pubid/the-xhtml-syntax/parsing-xhtml-documents/xhtml-pubid-1.html"
},
{
"path": "fetch/nosniff/image.html",
"url": "/fetch/nosniff/image.html"
},
{
"path": "fetch/nosniff/importscripts.html",
"url": "/fetch/nosniff/importscripts.html"
},
{
"path": "fetch/nosniff/parsing-nosniff.html",
"url": "/fetch/nosniff/parsing-nosniff.html"
},
{
"path": "fetch/nosniff/script.html",
"url": "/fetch/nosniff/script.html"
},
{
"path": "fetch/nosniff/stylesheet.html",
"url": "/fetch/nosniff/stylesheet.html"
},
{
"path": "fetch/nosniff/worker.html",
"url": "/fetch/nosniff/worker.html"
},
{
"path": "gamepad/idlharness.html",
"url": "/gamepad/idlharness.html"
@ -18798,6 +18790,11 @@
"timeout": "long",
"url": "/IndexedDB/idbobjectstore_createIndex8-valid_keys.htm"
},
{
"path": "IndexedDB/key_valid.html",
"timeout": "long",
"url": "/IndexedDB/key_valid.html"
},
{
"path": "IndexedDB/keypath_maxsize.htm",
"timeout": "long",
@ -18823,6 +18820,46 @@
"timeout": "long",
"url": "/ambient-light/AmbientLight_tests.html"
},
{
"path": "content-security-policy/media-src/media-src-7_1.html",
"timeout": "long",
"url": "/content-security-policy/media-src/media-src-7_1.html"
},
{
"path": "content-security-policy/media-src/media-src-7_1_2.html",
"timeout": "long",
"url": "/content-security-policy/media-src/media-src-7_1_2.html"
},
{
"path": "content-security-policy/media-src/media-src-7_2.html",
"timeout": "long",
"url": "/content-security-policy/media-src/media-src-7_2.html"
},
{
"path": "content-security-policy/media-src/media-src-7_2_2.html",
"timeout": "long",
"url": "/content-security-policy/media-src/media-src-7_2_2.html"
},
{
"path": "content-security-policy/media-src/media-src-7_3.html",
"timeout": "long",
"url": "/content-security-policy/media-src/media-src-7_3.html"
},
{
"path": "content-security-policy/media-src/media-src-7_3_2.html",
"timeout": "long",
"url": "/content-security-policy/media-src/media-src-7_3_2.html"
},
{
"path": "content-security-policy/object-src/object-src-2_1.html",
"timeout": "long",
"url": "/content-security-policy/object-src/object-src-2_1.html"
},
{
"path": "content-security-policy/object-src/object-src-2_2.html",
"timeout": "long",
"url": "/content-security-policy/object-src/object-src-2_2.html"
},
{
"path": "cors/status-async.htm",
"timeout": "long",
@ -25034,7 +25071,7 @@
}
]
},
"rev": "0d318188757a9c996e20b82db201fd04de5aa255",
"rev": "2a9fd810bb18610b422dbc3998ab74aa1bffae95",
"url_base": "/",
"version": 2
}

View file

@ -1,5 +0,0 @@
[getresponseheader-chunked-trailer.htm]
type: testharness
[XMLHttpRequest: getResponseHeader() and HTTP trailer]
expected: FAIL

View file

@ -1,6 +1,5 @@
[timeout-cors-async.htm]
type: testharness
expected: OK
[XMLHttpRequest: timeout event and cross-origin request]
expected: FAIL

View file

@ -0,0 +1,3 @@
[CharacterData-substringData.html]
type: testharness
expected: CRASH

View file

@ -89,3 +89,4 @@
[paras[4\].nextElementSibling]
expected: FAIL

View file

@ -1,6 +1,5 @@
[frameElement.sub.html]
type: testharness
expected: OK
[The window\'s frameElement attribute must return its container element if it is a nested browsing context]
expected: FAIL

View file

@ -20,3 +20,4 @@
[A disabled <input[type=radio\]> should not be focusable]
expected: FAIL

View file

@ -705,3 +705,6 @@
["data:,a 1w \\x011h" (leading U+0001)]
expected: FAIL
["data:,a 1w"]
expected: FAIL

View file

@ -2,3 +2,4 @@
type: testharness
[members of WorkerLocation]
expected: FAIL

View file

@ -1,6 +1,7 @@
<!DOCTYPE html>
<!-- Submitted from TestTWF Paris -->
<meta charset=utf-8">
<meta name="timeout" content="long">
<title>Valid key</title>
<link rel=help href="http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#key-construct">
<link rel=assert title="A value is said to be a valid key if it is one of the following types: Array JavaScript objects [ECMA-262], DOMString [WEBIDL], Date [ECMA-262] or float [WEBIDL]. However Arrays are only valid keys if every item in the array is defined and is a valid key (i.e. sparse arrays can not be valid keys) and if the Array doesn't directly or indirectly contain itself. Any non-numeric properties are ignored, and thus does not affect whether the Array is a valid key. Additionally, if the value is of type float, it is only a valid key if it is not NaN, and if the value is of type Date it is only a valid key if its [[PrimitiveValue]] internal property, as defined by [ECMA-262], is not NaN. Conforming user agents must support all valid keys as keys.">

View file

@ -1,8 +1,16 @@
The Web Platform Tests Project [![IRC chat](https://goo.gl/6nCIks)](http://irc.w3.org/?channels=testing)
==============================
These are test suites for 60+ Web-platform specifications, along
with test-infrastructure code for running the tests.
The Web Platform Tests Project is a W3C-coordinated attempt to build a
cross-browser testsuite for the Web-platform stack. Writing tests in a
way that allows them to be run in all browsers gives browser projects
confidence that they are shipping software that is compatible with other
implementations, and that later implementations will be compatible with
their implementations. This in turn gives Web authors/developers
confidence that they can actually rely on the Web platform to deliver on
the promise of working across browsers and devices without needing extra
layers of abstraction to paper over the gaps left by specification
editors and implementors.
Running the Tests
=================

View file

@ -10,7 +10,7 @@ def main(request, response):
response.write_status_headers()
for value in chunks:
response.writer.write("%d\r\n" % len(value))
response.writer.write("%x\r\n" % len(value))
response.writer.write(value)
response.writer.write("\r\n")
response.writer.write("0\r\n")

View file

@ -2,6 +2,7 @@
<html>
<head>
<title>Video element src attribute must match src list - positive test</title>
<meta name=timeout content=long>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>

View file

@ -2,6 +2,7 @@
<html>
<head>
<title>Video element src attribute must match src list - negative test</title>
<meta name=timeout content=long>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>

View file

@ -2,6 +2,7 @@
<html>
<head>
<title>Audio element src attribute must match src list - positive test</title>
<meta name=timeout content=long>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>

View file

@ -2,6 +2,7 @@
<html>
<head>
<title>Audio element src attribute must match src list - negative test</title>
<meta name=timeout content=long>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>

View file

@ -2,6 +2,7 @@
<html>
<head>
<title>Video track src attribute must match src list - positive test</title>
<meta name=timeout content=long>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>

View file

@ -2,6 +2,7 @@
<html>
<head>
<title>Video track src attribute must match src list - negative test</title>
<meta name=timeout content=long>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>

View file

@ -2,6 +2,7 @@
<html>
<head>
<title>Objects loaded using data attribute of &lt;object&gt; tag are blocked unless their host is listed as an allowed source in the object-src directive</title>
<meta name=timeout content=long>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>

View file

@ -2,6 +2,7 @@
<html>
<head>
<title>Objects loaded using src attribute of &lt;embed&gt; tag are blocked unless their host is listed as an allowed source in the object-src directive</title>
<meta name=timeout content=long>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>

View file

@ -31,7 +31,8 @@
}
}
var reportLocation = location.protocol + "//" + location.host + "/content-security-policy/support/report.py?op=take&timeout=5&reportID=" + reportID;
var timeout = document.querySelector("meta[name=timeout][content=long]") ? 50 : 5;
var reportLocation = location.protocol + "//" + location.host + "/content-security-policy/support/report.py?op=take&timeout=" + timeout + "&reportID=" + reportID;
var reportTest = async_test("Violation report status OK.");
reportTest.step(function () {

View file

@ -2,23 +2,20 @@ import time
import json
def main(request, response):
op = request.GET.first("op");
key = request.GET.first("reportID")
if op == "take":
timeout = float(request.GET.first("timeout"))
t0 = time.time()
while time.time() - t0 < timeout:
time.sleep(0.5)
value = request.server.stash.take(key=key)
if value is not None:
return [("Content-Type", "application/json")], value
else:
time.sleep(timeout)
value = request.server.stash.take(key=key)
if value is not None:
return [("Content-Type", "application/json")], value
else:
return [("Content-Type", "application/json")], json.dumps({'error': 'No such report.' , 'guid' : key})
else:
report = request.body
report.rstrip()
request.server.stash.take(key=key)

View file

@ -7,15 +7,56 @@
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
function testNode(node) {
function testNode(create, type) {
test(function() {
var node = create()
assert_equals(node.data, "test")
node.appendData("test")
assert_equals(node.data, "testtest")
})
node.appendData("bar")
assert_equals(node.data, "testbar")
}, type + ".appendData('bar')")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.appendData("")
assert_equals(node.data, "test")
}, type + ".appendData('')")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.appendData(null)
assert_equals(node.data, "testnull")
}, type + ".appendData(null)")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.appendData(undefined)
assert_equals(node.data, "testundefined")
}, type + ".appendData(undefined)")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.appendData("", "bar")
assert_equals(node.data, "test")
}, type + ".appendData('', 'bar')")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_throws(new TypeError(), function() { node.appendData() });
assert_equals(node.data, "test")
}, type + ".appendData()")
}
test(function() {
testNode(document.createTextNode("test"))
testNode(document.createComment("test"))
})
testNode(function() { return document.createTextNode("test") }, "Text")
testNode(function() { return document.createComment("test") }, "Comment")
</script>

View file

@ -0,0 +1,108 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>CharacterData.substringData</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-substringdata">
<link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-data">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
// TODO: non-ASCII strings
function testNode(create, type) {
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_throws(new TypeError(), function() { node.substringData() })
assert_throws(new TypeError(), function() { node.substringData(0) })
}, type + ".substringData() with too few arguments")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData(0, 1, "test"), "t")
}, type + ".substringData() with too many arguments")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_throws("IndexSizeError", function() { node.substringData(5, 0) })
assert_throws("IndexSizeError", function() { node.substringData(6, 0) })
assert_throws("IndexSizeError", function() { node.substringData(-1, 0) })
}, type + ".substringData() with invalid offset")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData(0, 1), "t")
assert_equals(node.substringData(1, 1), "e")
assert_equals(node.substringData(2, 1), "s")
assert_equals(node.substringData(3, 1), "t")
assert_equals(node.substringData(4, 1), "")
}, type + ".substringData() with in-bounds offset")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData(0x100000000 + 0, 1), "t")
assert_equals(node.substringData(0x100000000 + 1, 1), "e")
assert_equals(node.substringData(0x100000000 + 2, 1), "s")
assert_equals(node.substringData(0x100000000 + 3, 1), "t")
assert_equals(node.substringData(0x100000000 + 4, 1), "")
}, type + ".substringData() with very large offset")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData(-0x100000000 + 2, 1), "s")
}, type + ".substringData() with negative offset")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData("test", 3), "tes")
}, type + ".substringData() with string offset")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData(0, 1), "t")
assert_equals(node.substringData(0, 2), "te")
assert_equals(node.substringData(0, 3), "tes")
assert_equals(node.substringData(0, 4), "test")
}, type + ".substringData() with in-bounds count")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData(0, 5), "test")
assert_equals(node.substringData(2, 20), "st")
}, type + ".substringData() with large count")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData(2, 0x100000000 + 1), "s")
}, type + ".substringData() with very large count")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_equals(node.substringData(0, -1), "test")
assert_equals(node.substringData(0, -0x100000000 + 2), "te")
}, type + ".substringData() with negative count")
}
testNode(function() { return document.createTextNode("test") }, "Text")
testNode(function() { return document.createComment("test") }, "Comment")
</script>

View file

@ -385,4 +385,13 @@ test(function() {
el.removeAttributeNS(null, "pre:fix")
assert_equals(el.attributes[0], unprefixed)
}, "Attribute with prefix in local name")
test(function() {
var el = document.createElement("div")
el.setAttribute("foo", "bar")
var attr = el.attributes[0]
assert_equals(attr.ownerElement, el)
el.removeAttribute("foo")
assert_equals(attr.ownerElement, null)
}, "Attribute loses its owner when removed")
</script>

View 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>

View file

@ -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>

View 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")

View file

@ -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>

View 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)

View file

@ -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)

View 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)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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)

View 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>

View 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>

View 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>

View file

@ -58,12 +58,13 @@
<img srcset='data:,a 1w 1w' data-expect=''>
<img srcset='data:,a 1w 1x' data-expect=''>
<img srcset='data:,a 1x 1w' data-expect=''>
<img srcset='data:,a 1w 1h' data-expect='data:,a'>
<img srcset='data:,a 1h 1w' data-expect='data:,a'>
<img srcset='data:,a 1w 1h' data-expect='data:,a'><!-- should fail for x-only impl -->
<img srcset='data:,a 1h 1w' data-expect='data:,a'><!-- should fail for x-only impl -->
<img srcset='data:,a 1h 1h' data-expect=''>
<img srcset='data:,a 1h 1x' data-expect=''>
<img srcset='data:,a 1h 1w 1x' data-expect=''>
<img srcset='data:,a 1x 1w 1h' data-expect=''>
<img srcset='data:,a 1w' data-expect='data:,a'><!-- should fail for x-only impl -->
<img srcset='data:,a 1h' data-expect=''>
<img srcset='data:,a 1h foo' data-expect=''>
<img srcset='data:,a foo 1h' data-expect=''>

View file

@ -1,6 +1,8 @@
#!/usr/bin/env python
import os
import sys
from tools.manifest import update
update.main()
update.main(default_tests_root=
os.path.abspath(os.path.dirname(__file__)))

View file

@ -147,6 +147,42 @@ with a TypeError:
return promise_rejects(t, new TypeError(), bar);
}, "Another example");
`EventWatcher` is a constructor function that allows DOM events to be handled
using Promises, which can make it a lot easier to test a very specific series
of events, including ensuring that unexpected events are not fired at any point.
Here's an example of how to use `EventWatcher`:
var t = async_test("Event order on animation start");
var animation = watchedNode.getAnimations()[0];
var eventWatcher = new EventWatcher(watchedNode, ['animationstart',
'animationiteration',
'animationend']);
eventWatcher.wait_for(t, 'animationstart').then(t.step_func(function() {
assertExpectedStateAtStartOfAnimation();
animation.currentTime = END_TIME; // skip to end
// We expect two animationiteration events then an animationend event on
// skipping to the end of the animation.
return eventWatcher.wait_for(['animationiteration',
'animationiteration',
'animationend']);
})).then(t.step_func(function() {
assertExpectedStateAtEndOfAnimation();
test.done();
}));
`wait_for` either takes the name of a single event and returns a Promise that
will resolve after that event is fired at the watched node, or else it takes an
array of the names of a series of events and returns a Promise that will
resolve after that specific series of events has been fired at the watched node.
`EventWatcher` will assert if an event occurs while there is no `wait_for`()
created Promise waiting to be fulfilled, or if the event is of a different type
to the type currently expected. This ensures that only the events that are
expected occur, in the correct order, and with the correct timing.
## Single Page Tests ##
Sometimes, particularly when dealing with asynchronous behaviour,

View file

@ -470,6 +470,74 @@ policies and contribution forms [3].
});
}
/**
* This constructor helper allows DOM events to be handled using Promises,
* which can make it a lot easier to test a very specific series of events,
* including ensuring that unexpected events are not fired at any point.
*/
function EventWatcher(test, watchedNode, eventTypes)
{
if (typeof eventTypes == 'string') {
eventTypes = [eventTypes];
}
var waitingFor = null;
var eventHandler = test.step_func(function(evt) {
assert_true(!!waitingFor,
'Not expecting event, but got ' + evt.type + ' event');
assert_equals(evt.type, waitingFor.types[0],
'Expected ' + waitingFor.types[0] + ' event, but got ' +
evt.type + ' event instead');
if (waitingFor.types.length > 1) {
// Pop first event from array
waitingFor.types.shift();
return;
}
// We need to null out waitingFor before calling the resolve function
// since the Promise's resolve handlers may call wait_for() which will
// need to set waitingFor.
var resolveFunc = waitingFor.resolve;
waitingFor = null;
resolveFunc(evt);
});
for (var i = 0; i < eventTypes.length; i++) {
watchedNode.addEventListener(eventTypes[i], eventHandler);
}
/**
* Returns a Promise that will resolve after the specified event or
* series of events has occured.
*/
this.wait_for = function(types) {
if (waitingFor) {
return Promise.reject('Already waiting for an event or events');
}
if (typeof types == 'string') {
types = [types];
}
return new Promise(function(resolve, reject) {
waitingFor = {
types: types,
resolve: resolve,
reject: reject
};
});
};
function stop_watching() {
for (var i = 0; i < eventTypes.length; i++) {
watchedNode.removeEventListener(eventTypes[i], eventHandler);
}
};
test.add_cleanup(stop_watching);
return this;
}
expose(EventWatcher, 'EventWatcher');
function setup(func_or_properties, maybe_properties)
{
var func = null;

View file

@ -0,0 +1,6 @@
*#
*.py[co]
*.sw[po]
*~
\#*

View file

@ -2,6 +2,7 @@
import argparse
import imp
import os
import sys
import manifest
import vcs
@ -82,11 +83,32 @@ def create_parser():
return parser
def main():
def find_top_repo():
path = here
rv = None
while path != "/":
if vcs.is_git_repo(path):
rv = path
path = os.path.abspath(os.path.join(path, os.pardir))
return rv
def main(default_tests_root=None):
opts = create_parser().parse_args()
if opts.tests_root is None:
opts.tests_root = vcs.get_repo_root()
tests_root = None
if default_tests_root is not None:
tests_root = default_tests_root
else:
tests_root = find_top_repo()
if tests_root is None:
print >> sys.stderr, """No git repo found; could not determine test root.
Run again with --test-root"""
sys.exit(1)
opts.tests_root = tests_root
if opts.path is None:
opts.path = os.path.join(opts.tests_root, "MANIFEST.json")

View file

@ -13,9 +13,13 @@ def is_git_repo(tests_root):
_repo_root = None
def get_repo_root():
def get_repo_root(initial_dir=None):
global _repo_root
if initial_dir is None:
initial_dir = os.path.dirname(__file__)
if _repo_root is None:
git = get_git_func(os.path.dirname(__file__))
git = get_git_func(initial_dir)
_repo_root = git("rev-parse", "--show-toplevel").rstrip()
return _repo_root

View file

@ -10,13 +10,13 @@
<div id="log"></div>
<script type="text/javascript">
var test = async_test("W3C WebSocket API - Create WebSocket - Close the Connection - close(undefined) - INVALID_ACCESS_ERR is thrown");
var test = async_test();
var wsocket = CreateWebSocket(false, false, false);
var isOpenCalled = false;
wsocket.addEventListener('open', test.step_func(function (evt) {
assert_throws("INVALID_ACCESS_ERR", function () { wsocket.close(undefined) });
wsocket.close(undefined);
test.done();
}), true);
</script>

View file

@ -10,13 +10,13 @@
<div id="log"></div>
<script type="text/javascript">
var test = async_test("W3C WebSocket API - Create Secure WebSocket - Close the Connection - close(undefined) - INVALID_ACCESS_ERR is thrown");
var test = async_test();
var wsocket = CreateWebSocket(true, false, false);
var isOpenCalled = false;
wsocket.addEventListener('open', test.step_func(function (evt) {
assert_throws("INVALID_ACCESS_ERR", function () { wsocket.close(undefined) });
wsocket.close(undefined);
test.done();
}), true);
</script>

View file

@ -10,6 +10,10 @@ async_test(function(t) {
if (window.WebSocket) {
document.cookie = 'ws_test_'+cookie_id+'=test; Path=/';
}
t.add_cleanup(function() {
// remove cookie
document.cookie = 'ws_test_'+cookie_id+'=; Path=/; Expires=Sun, 06 Nov 1994 08:49:37 GMT';
});
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo-cookie');
ws.onmessage = t.step_func(function(e) {
assert_regexp_match(e.data, new RegExp('ws_test_'+cookie_id+'=test'));
@ -18,6 +22,4 @@ async_test(function(t) {
});
ws.onerror = ws.onclose = t.step_func(function(e) {assert_unreached(e.type)});
});
// remove cookie
document.cookie = 'ws_test_'+cookie_id+'=; Path=/; Expires=Sun, 06 Nov 1994 08:49:37 GMT';
</script>

View file

@ -7,11 +7,13 @@
<script>
var cookie_id = ((new Date())-0) + '.' + Math.random();
async_test(function(t) {
t.add_cleanup(function() {
// remove cookie
document.cookie = 'ws_test_'+cookie_id+'=; Path=/; Expires=Sun, 06 Nov 1994 08:49:37 GMT';
});
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/set-cookie?'+cookie_id);
ws.onopen = t.step_func(function(e) {
assert_regexp_match(document.cookie, new RegExp('ws_test_'+cookie_id+'=test'));
// remove cookie
document.cookie = 'ws_test_'+cookie_id+'=; Path=/; Expires=Sun, 06 Nov 1994 08:49:37 GMT';
ws.close();
t.done();
});

View file

@ -9,25 +9,22 @@ setup({explict_done:true})
var cookie_id = ((new Date())-0) + '.' + Math.random();
var t = async_test(function(t) {
var iframe = document.createElement('iframe');
iframe.src = 'support/set-cookie.py?'+encodeURIComponent('ws_test_'+cookie_id+'=test; Path=/; HttpOnly');
iframe.onload = t.step_func(function() {
var iframe = document.createElement('iframe');
t.add_cleanup(function() {
// remove cookie
iframe.src = 'support/set-cookie.py?'+encodeURIComponent('ws_test_'+cookie_id+'=; Path=/; HttpOnly; Expires=Sun, 06 Nov 1994 08:49:37 GMT');
iframe.onload = done;
});
iframe.src = 'support/set-cookie.py?'+encodeURIComponent('ws_test_'+cookie_id+'=test; Path=/; HttpOnly');
iframe.onload = t.step_func(function() {
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo-cookie');
ws.onmessage = t.step_func(function(e) {
ws.close();
assert_regexp_match(e.data, new RegExp('ws_test_'+cookie_id+'=test'));
t.done();;
t.done();
});
ws.onclose = function() { deleteCookie(false, e.type); }
});
var cookie_removed = false;
add_result_callback(function() {
iframe.src = 'support/set-cookie.py?'+encodeURIComponent('ws_test_'+cookie_id+'=; Path=/; HttpOnly; Expires=Sun, 06 Nov 1994 08:49:37 GMT');
iframe.onload = done;
});
document.body.appendChild(iframe);
ws.onerror = ws.onclose = t.step_func(function(e) {assert_unreached(e.type)});
});
document.body.appendChild(iframe);
}, null, {timeout:9900});
</script>

View file

@ -10,6 +10,11 @@ var cookie_id = ((new Date())-0) + '.' + Math.random();
var t = async_test(function(t) {
var iframe = document.createElement('iframe');
t.add_cleanup(function() {
// remove cookie
iframe.src = 'support/set-cookie.py?'+encodeURIComponent('ws_test_'+cookie_id+'=; Path=/; HttpOnly; Expires=Sun, 06 Nov 1994 08:49:37 GMT');
iframe.onload = done;
});
var url = SCHEME_DOMAIN_PORT+'/set-cookie_http?'+cookie_id;
var ws = new WebSocket(url);
ws.onopen = t.step_func(function(e) {
@ -17,13 +22,7 @@ var t = async_test(function(t) {
assert_false(new RegExp('ws_test_'+cookie_id+'=test').test(document.cookie));
t.done();
});
ws.onclose = t.step_func(function(e) {assert_unreached()});
add_result_callback(function() {
iframe.src = 'support/set-cookie.py?'+encodeURIComponent('ws_test_'+cookie_id+'=; Path=/; HttpOnly; Expires=Sun, 06 Nov 1994 08:49:37 GMT');
iframe.onload = done;
});
ws.onerror = ws.onclose = t.step_func(function(e) {assert_unreached(e.type)});
document.body.appendChild(iframe);
}, null, {timeout:9900})
</script>

View file

@ -11,6 +11,11 @@ var cookie_id = ((new Date())-0) + '.' + Math.random();
var t = async_test(function(t) {
var iframe = document.createElement('iframe');
t.add_cleanup(function() {
// remove cookie
iframe.src = 'support/set-cookie.py?'+encodeURIComponent('ws_test_'+cookie_id+'=; Path=/; HttpOnly; Expires=Sun, 06 Nov 1994 08:49:37 GMT');
iframe.onload = done;
});
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/set-cookie_http?'+cookie_id);
ws.onopen = t.step_func(function(e) {
var ws2 = new WebSocket(SCHEME_DOMAIN_PORT+'/echo-cookie');
@ -21,12 +26,7 @@ var t = async_test(function(t) {
t.done();
});
});
ws.onclose = t.step_func(function() {assert_unreached()});
add_result_callback(function() {
iframe.src = 'support/set-cookie.py?'+encodeURIComponent('ws_test_'+cookie_id+'=; Path=/; HttpOnly; Expires=Sun, 06 Nov 1994 08:49:37 GMT');
iframe.onload = done;
});
ws.onerror = ws.onclose = t.step_func(function(e) {assert_unreached(e.type)});
document.body.appendChild(iframe);
})
</script>

View file

@ -10,6 +10,10 @@ async_test(function(t) {
if (window.WebSocket) {
document.cookie = 'ws_test_'+cookie_id+'=test; Path=/; Secure';
}
t.add_cleanup(function() {
// remove cookie
document.cookie = 'ws_test_'+cookie_id+'=; Path=/; Secure; Expires=Sun, 06 Nov 1994 08:49:37 GMT';
});
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo-cookie');
ws.onmessage = t.step_func(function(e) {
ws.close();
@ -20,8 +24,6 @@ async_test(function(t) {
}
t.done();
})
ws.onclose = t.step_func(function() {assert_unreached()});
ws.onerror = ws.onclose = t.step_func(function(e) {assert_unreached(e.type)});
});
// remove cookie
document.cookie = 'ws_test_'+cookie_id+'; Path=/; Secure; Expires=Sun, 06 Nov 1994 08:49:37 GMT';
</script>

View file

@ -8,15 +8,17 @@
<script>
var cookie_id = ((new Date())-0) + '.' + Math.random();
async_test(function(t) {
t.add_cleanup(function() {
// remove cookie
document.cookie = 'ws_test_'+cookie_id+'; Path=/; Expires=Sun, 06 Nov 1994 08:49:37 GMT';
});
var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/set-cookie?'+cookie_id);
ws.onopen = t.step_func(function(e) {
ws.close();
assert_regexp_match(document.cookie, new RegExp('ws_test_'+cookie_id+'=test'));
// remove cookie
document.cookie = 'ws_test_'+cookie_id+'; Path=/; Expires=Sun, 06 Nov 1994 08:49:37 GMT';
t.done();
});
ws.onclose = t.step_func(function() {assert_unreached()});
ws.onerror = ws.onclose = t.step_func(function() {assert_unreached()});
// sleep for 2 seconds with sync xhr
var sleep = new XMLHttpRequest();

View file

@ -9,8 +9,10 @@ var events = ['onclose', 'onopen', 'onerror', 'onmessage'];
for (var i = 0; i < events.length; ++i) {
test(function(t) {
var ws = new WebSocket(SCHEME_AND_DOMAIN+'/');
ws[events[i]] = {handleEvent:function(){}};
assert_equals(ws[events[i]], null);
var obj = {handleEvent:this.unreached_func("handleEvent was called")};
ws[events[i]] = obj;
assert_equals(ws[events[i]], obj);
ws.dispatchEvent(new Event(events[i].substr(2)));
}, events[i]);
};
</script>

View file

@ -2,7 +2,7 @@ var __SERVER__NAME = "{{host}}";
var __PORT = {{ports[ws][0]}};
var __SECURE__PORT = null; //{{ports[ws][0]}}; //Should be wss
var __NEW__PORT = __PORT; //All ports are non-default for now
var __NEW_SECURE_PORT = __PORT; //All ports are non-default for now
var __NEW__SECURE__PORT = __PORT; //All ports are non-default for now
var __PATH = "echo";
var __CONTROLPATH = "control";
var __PROTOCOL = "echo";