mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Rewrite CharacterData-insertData.html to be more extensible.
This commit is contained in:
parent
51b06bcbaf
commit
61e8351f28
1 changed files with 18 additions and 8 deletions
|
@ -7,22 +7,32 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<div id="log"></div>
|
<div id="log"></div>
|
||||||
<script>
|
<script>
|
||||||
function testNode(node) {
|
function testNode(create, type) {
|
||||||
test(function() {
|
test(function() {
|
||||||
|
var node = create()
|
||||||
|
assert_equals(node.data, "test")
|
||||||
|
|
||||||
assert_throws("INDEX_SIZE_ERR", function() { node.insertData(5, "x") })
|
assert_throws("INDEX_SIZE_ERR", function() { node.insertData(5, "x") })
|
||||||
assert_throws("INDEX_SIZE_ERR", function() { node.insertData(5, "") })
|
assert_throws("INDEX_SIZE_ERR", function() { node.insertData(5, "") })
|
||||||
|
}, type + ".insertData() out of bounds")
|
||||||
|
|
||||||
|
test(function() {
|
||||||
|
var node = create()
|
||||||
|
assert_equals(node.data, "test")
|
||||||
|
|
||||||
node.insertData(2, "X")
|
node.insertData(2, "X")
|
||||||
assert_equals(node.data, "teXst")
|
assert_equals(node.data, "teXst")
|
||||||
})
|
}, type + ".insertData() in the middle")
|
||||||
|
|
||||||
test(function() {
|
test(function() {
|
||||||
node.data = "test"
|
var node = create()
|
||||||
assert_equals(node.data, "test")
|
assert_equals(node.data, "test")
|
||||||
|
|
||||||
node.insertData(4, "ing")
|
node.insertData(4, "ing")
|
||||||
assert_equals(node.data, "testing")
|
assert_equals(node.data, "testing")
|
||||||
})
|
}, type + ".insertData() at the end")
|
||||||
}
|
}
|
||||||
test(function() {
|
|
||||||
testNode(document.createTextNode("test"))
|
testNode(function() { return document.createTextNode("test") }, "Text")
|
||||||
testNode(document.createComment("test"))
|
testNode(function() { return document.createComment("test") }, "Comment")
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue