OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta charset=utf-8> |
| 3 <title>CharacterData.appendData</title> |
| 4 <link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-appenddata"> |
| 5 <link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-data"> |
| 6 <script src="../../../../resources/testharness.js"></script> |
| 7 <script src="../../../../resources/testharnessreport.js"></script> |
| 8 <div id="log"></div> |
| 9 <script> |
| 10 function testNode(create, type) { |
| 11 test(function() { |
| 12 var node = create() |
| 13 assert_equals(node.data, "test") |
| 14 |
| 15 node.appendData("bar") |
| 16 assert_equals(node.data, "testbar") |
| 17 }, type + ".appendData('bar')") |
| 18 |
| 19 test(function() { |
| 20 var node = create() |
| 21 assert_equals(node.data, "test") |
| 22 |
| 23 node.appendData("") |
| 24 assert_equals(node.data, "test") |
| 25 }, type + ".appendData('')") |
| 26 |
| 27 test(function() { |
| 28 var node = create() |
| 29 assert_equals(node.data, "test") |
| 30 node.appendData(", append more 資料,測試資料"); |
| 31 assert_equals(node.data, "test, append more 資料,測試資料"); |
| 32 assert_equals(node.length, 25); |
| 33 }, type + ".appendData(non-ASCII)") |
| 34 |
| 35 test(function() { |
| 36 var node = create() |
| 37 assert_equals(node.data, "test") |
| 38 |
| 39 node.appendData(null) |
| 40 assert_equals(node.data, "testnull") |
| 41 }, type + ".appendData(null)") |
| 42 |
| 43 test(function() { |
| 44 var node = create() |
| 45 assert_equals(node.data, "test") |
| 46 |
| 47 node.appendData(undefined) |
| 48 assert_equals(node.data, "testundefined") |
| 49 }, type + ".appendData(undefined)") |
| 50 |
| 51 test(function() { |
| 52 var node = create() |
| 53 assert_equals(node.data, "test") |
| 54 |
| 55 node.appendData("", "bar") |
| 56 assert_equals(node.data, "test") |
| 57 }, type + ".appendData('', 'bar')") |
| 58 |
| 59 test(function() { |
| 60 var node = create() |
| 61 assert_equals(node.data, "test") |
| 62 |
| 63 assert_throws(new TypeError(), function() { node.appendData() }); |
| 64 assert_equals(node.data, "test") |
| 65 }, type + ".appendData()") |
| 66 } |
| 67 |
| 68 testNode(function() { return document.createTextNode("test") }, "Text") |
| 69 testNode(function() { return document.createComment("test") }, "Comment") |
| 70 </script> |
OLD | NEW |