| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <link rel="help" href="http://www.w3.org/TR/2012/WD-dom-20121206/#interface-char
acterdata"> | 4 <link rel="help" href="http://www.w3.org/TR/2012/WD-dom-20121206/#interface-char
acterdata"> |
| 5 <script src="../js/resources/js-test-pre.js"></script> | 5 <script src="../js/resources/js-test-pre.js"></script> |
| 6 </head> | 6 </head> |
| 7 <body> | 7 <body> |
| 8 <script> | 8 <script> |
| 9 description("Tests that the CharacterData API arguments are correctly validated.
"); | 9 description("Tests that the CharacterData API arguments are correctly validated.
"); |
| 10 | 10 |
| 11 var text = document.createTextNode("abcd"); | 11 var text = document.createTextNode("abcd"); |
| 12 shouldBeEqualToString("text.data", "abcd"); | 12 shouldBeEqualToString("text.data", "abcd"); |
| 13 shouldBe("text.__proto__.__proto__", "CharacterData.prototype"); | 13 shouldBe("text.__proto__.__proto__", "CharacterData.prototype"); |
| 14 | 14 |
| 15 // appendData() | 15 // appendData() |
| 16 shouldNotThrow("text.appendData('efg')"); | 16 shouldNotThrow("text.appendData('efg')"); |
| 17 shouldBeEqualToString("text.data", "abcdefg"); | 17 shouldBeEqualToString("text.data", "abcdefg"); |
| 18 shouldThrow("text.appendData()", "'TypeError: Not enough arguments'"); | 18 shouldThrow("text.appendData()", "'TypeError: Not enough arguments'"); |
| 19 shouldBeEqualToString("text.data", "abcdefg"); | 19 shouldBeEqualToString("text.data", "abcdefg"); |
| 20 | 20 |
| 21 // insertData() | 21 // insertData() |
| 22 text.data = "efg"; | 22 text.data = "efg"; |
| 23 shouldNotThrow("text.insertData(0, 'abcd')"); | 23 shouldNotThrow("text.insertData(0, 'abcd')"); |
| 24 shouldBeEqualToString("text.data", "abcdefg"); | 24 shouldBeEqualToString("text.data", "abcdefg"); |
| 25 shouldThrow("text.insertData()", "'TypeError: Not enough arguments'"); | 25 shouldThrow("text.insertData()", "'TypeError: Not enough arguments'"); |
| 26 shouldBeEqualToString("text.data", "abcdefg"); | 26 shouldBeEqualToString("text.data", "abcdefg"); |
| 27 shouldThrow("text.insertData(0)", "'TypeError: Not enough arguments'"); | 27 shouldThrow("text.insertData(0)", "'TypeError: Not enough arguments'"); |
| 28 shouldBeEqualToString("text.data", "abcdefg"); | 28 shouldBeEqualToString("text.data", "abcdefg"); |
| 29 shouldThrow("text.insertData(999, 'test')", "'IndexSizeError: Index or size was
negative, or greater than the allowed value.'"); // offset greater than length. | 29 shouldThrow("text.insertData(999, 'test')", '"IndexSizeError: Failed to execute
\'insertData\' on \'CharacterData\': The offset 999 is greater than the node\'s
length (7)."'); |
| 30 shouldBeEqualToString("text.data", "abcdefg"); | 30 shouldBeEqualToString("text.data", "abcdefg"); |
| 31 shouldNotThrow("text.insertData(-4294967294, 'test')"); // Wraps to 2, which is
a valid offset. | 31 shouldNotThrow("text.insertData(-4294967294, 'test')"); // Wraps to 2, which is
a valid offset. |
| 32 shouldBeEqualToString("text.data", "abtestcdefg"); | 32 shouldBeEqualToString("text.data", "abtestcdefg"); |
| 33 | 33 |
| 34 // deleteData() | 34 // deleteData() |
| 35 text.data = "abcdefg"; | 35 text.data = "abcdefg"; |
| 36 shouldNotThrow("text.deleteData(4, 3)"); | 36 shouldNotThrow("text.deleteData(4, 3)"); |
| 37 shouldBeEqualToString("text.data", "abcd"); | 37 shouldBeEqualToString("text.data", "abcd"); |
| 38 shouldThrow("text.deleteData()", "'TypeError: Not enough arguments'"); | 38 shouldThrow("text.deleteData()", "'TypeError: Not enough arguments'"); |
| 39 shouldBeEqualToString("text.data", "abcd"); | 39 shouldBeEqualToString("text.data", "abcd"); |
| 40 shouldThrow("text.deleteData(0)", "'TypeError: Not enough arguments'"); | 40 shouldThrow("text.deleteData(0)", "'TypeError: Not enough arguments'"); |
| 41 shouldBeEqualToString("text.data", "abcd"); | 41 shouldBeEqualToString("text.data", "abcd"); |
| 42 shouldThrow("text.deleteData(999, 3)", "'IndexSizeError: Index or size was negat
ive, or greater than the allowed value.'"); // offset greater than length. | 42 shouldThrow("text.deleteData(999, 3)", '"IndexSizeError: Failed to execute \'del
eteData\' on \'CharacterData\': The offset 999 is greater than the node\'s lengt
h (4)."'); |
| 43 shouldBeEqualToString("text.data", "abcd"); | 43 shouldBeEqualToString("text.data", "abcd"); |
| 44 shouldThrow("text.deleteData(-1, 3)", "'IndexSizeError: Index or size was negati
ve, or greater than the allowed value.'"); // Wraps to 4294967295 which is great
er than the data length | 44 shouldThrow("text.deleteData(-1, 3)", '"IndexSizeError: Failed to execute \'dele
teData\' on \'CharacterData\': The offset 4294967295 is greater than the node\'s
length (4)."'); // Wraps to 4294967295 which is greater than the data length |
| 45 shouldBeEqualToString("text.data", "abcd"); | 45 shouldBeEqualToString("text.data", "abcd"); |
| 46 shouldNotThrow("text.deleteData(-4294967294, 2)"); // Wraps to 2, which is a val
id offset. | 46 shouldNotThrow("text.deleteData(-4294967294, 2)"); // Wraps to 2, which is a val
id offset. |
| 47 shouldBeEqualToString("text.data", "ab"); | 47 shouldBeEqualToString("text.data", "ab"); |
| 48 shouldNotThrow("text.deleteData(1, 999)"); // Length argument is too large, shou
ld be adjusted. | 48 shouldNotThrow("text.deleteData(1, 999)"); // Length argument is too large, shou
ld be adjusted. |
| 49 shouldBeEqualToString("text.data", "a"); | 49 shouldBeEqualToString("text.data", "a"); |
| 50 | 50 |
| 51 // ReplaceData() | 51 // ReplaceData() |
| 52 text.data = "efg"; | 52 text.data = "efg"; |
| 53 shouldNotThrow("text.replaceData(0, 0, 'abcd')"); | 53 shouldNotThrow("text.replaceData(0, 0, 'abcd')"); |
| 54 shouldBeEqualToString("text.data", "abcdefg"); | 54 shouldBeEqualToString("text.data", "abcdefg"); |
| 55 shouldThrow("text.replaceData()", "'TypeError: Not enough arguments'"); | 55 shouldThrow("text.replaceData()", "'TypeError: Not enough arguments'"); |
| 56 shouldBeEqualToString("text.data", "abcdefg"); | 56 shouldBeEqualToString("text.data", "abcdefg"); |
| 57 shouldThrow("text.replaceData(0)", "'TypeError: Not enough arguments'"); | 57 shouldThrow("text.replaceData(0)", "'TypeError: Not enough arguments'"); |
| 58 shouldBeEqualToString("text.data", "abcdefg"); | 58 shouldBeEqualToString("text.data", "abcdefg"); |
| 59 shouldThrow("text.replaceData(0, 0)", "'TypeError: Not enough arguments'"); | 59 shouldThrow("text.replaceData(0, 0)", "'TypeError: Not enough arguments'"); |
| 60 shouldBeEqualToString("text.data", "abcdefg"); | 60 shouldBeEqualToString("text.data", "abcdefg"); |
| 61 shouldThrow("text.replaceData(999, 3, 'test')", "'IndexSizeError: Index or size
was negative, or greater than the allowed value.'"); // offset greater than leng
th. | 61 shouldThrow("text.replaceData(999, 3, 'test')", '"IndexSizeError: Failed to exec
ute \'replaceData\' on \'CharacterData\': The offset 999 is greater than the nod
e\'s length (7)."'); |
| 62 shouldBeEqualToString("text.data", "abcdefg"); | 62 shouldBeEqualToString("text.data", "abcdefg"); |
| 63 shouldThrow("text.replaceData(-1, 3, 'test')", "'IndexSizeError: Index or size w
as negative, or greater than the allowed value.'"); // Wraps to 4294967295 which
is greater than the data length | 63 shouldThrow("text.replaceData(-1, 3, 'test')", '"IndexSizeError: Failed to execu
te \'replaceData\' on \'CharacterData\': The offset 4294967295 is greater than t
he node\'s length (7)."'); // Wraps to 4294967295 which is greater than the data
length |
| 64 shouldBeEqualToString("text.data", "abcdefg"); | 64 shouldBeEqualToString("text.data", "abcdefg"); |
| 65 shouldNotThrow("text.replaceData(-4294967294, 0, 'test')"); // Wraps to 2, which
is a valid offset. | 65 shouldNotThrow("text.replaceData(-4294967294, 0, 'test')"); // Wraps to 2, which
is a valid offset. |
| 66 shouldBeEqualToString("text.data", "abtestcdefg"); | 66 shouldBeEqualToString("text.data", "abtestcdefg"); |
| 67 shouldNotThrow("text.replaceData(1, 999, 'aaa')"); // Length argument is too lar
ge, should be adjusted. | 67 shouldNotThrow("text.replaceData(1, 999, 'aaa')"); // Length argument is too lar
ge, should be adjusted. |
| 68 shouldBeEqualToString("text.data", "aaaa"); | 68 shouldBeEqualToString("text.data", "aaaa"); |
| 69 | 69 |
| 70 // substringData() | 70 // substringData() |
| 71 text.data = "abcdefg"; | 71 text.data = "abcdefg"; |
| 72 shouldBeEqualToString("text.substringData(4, 3)", "efg"); | 72 shouldBeEqualToString("text.substringData(4, 3)", "efg"); |
| 73 shouldThrow("text.substringData()", "'TypeError: Not enough arguments'"); | 73 shouldThrow("text.substringData()", "'TypeError: Not enough arguments'"); |
| 74 shouldThrow("text.substringData(0)", "'TypeError: Not enough arguments'"); | 74 shouldThrow("text.substringData(0)", "'TypeError: Not enough arguments'"); |
| 75 shouldBeEqualToString("text.substringData(4, 999)", "efg"); // Length argument i
s too large, should be adjusted. | 75 shouldBeEqualToString("text.substringData(4, 999)", "efg"); // Length argument i
s too large, should be adjusted. |
| 76 shouldBeEqualToString("text.substringData(4, -1)", "efg"); // Length argument is
too large (after wrapping), should be adjusted. | 76 shouldBeEqualToString("text.substringData(4, -1)", "efg"); // Length argument is
too large (after wrapping), should be adjusted. |
| 77 shouldThrow("text.substringData(-1, 2)", "'IndexSizeError: Index or size was neg
ative, or greater than the allowed value.'"); // Wraps to 4294967295 which is gr
eater than the data length | 77 shouldThrow("text.substringData(-1, 2)", '"IndexSizeError: Failed to execute \'s
ubstringData\' on \'CharacterData\': The offset 4294967295 is greater than the n
ode\'s length (7)."'); // Wraps to 4294967295 which is greater than the data len
gth |
| 78 shouldBeEqualToString("text.substringData(-4294967294, 3)", "cde"); // Wraps to
2, which is a valid offset. | 78 shouldBeEqualToString("text.substringData(-4294967294, 3)", "cde"); // Wraps to
2, which is a valid offset. |
| 79 | 79 |
| 80 </script> | 80 </script> |
| 81 <script src="../js/resources/js-test-post.js"></script> | 81 <script src="../js/resources/js-test-post.js"></script> |
| 82 </body> | 82 </body> |
| 83 </html> | 83 </html> |
| OLD | NEW |