Skip to content

Commit

Permalink
Rewrite CharacterData-insertData.html to be more extensible.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ms2ger committed Apr 29, 2015
1 parent 03ee0be commit a4a64b7
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions dom/nodes/CharacterData-insertData.html
Expand Up @@ -7,22 +7,32 @@
<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")

assert_throws("INDEX_SIZE_ERR", function() { node.insertData(5, "x") })
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")
assert_equals(node.data, "teXst")
})
}, type + ".insertData() in the middle")

test(function() {
node.data = "test"
var node = create()
assert_equals(node.data, "test")

node.insertData(4, "ing")
assert_equals(node.data, "testing")
})
}, type + ".insertData() at the end")
}
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 comments on commit a4a64b7

Please sign in to comment.