mirror of
https://github.com/servo/servo.git
synced 2025-09-06 21:18:20 +01:00
Update web-platform-tests.
This commit is contained in:
parent
74afd086d2
commit
71008d816d
62 changed files with 793 additions and 150 deletions
|
@ -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>
|
||||
|
|
|
@ -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>
|
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue