Index: LayoutTests/fast/dom/characterdata-api-arguments.html |
diff --git a/LayoutTests/fast/dom/characterdata-api-arguments.html b/LayoutTests/fast/dom/characterdata-api-arguments.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..858795ce8ca99502bac7dd9d3bb06ccfc2342af9 |
--- /dev/null |
+++ b/LayoutTests/fast/dom/characterdata-api-arguments.html |
@@ -0,0 +1,68 @@ |
+<!DOCTYPE html> |
+<html> |
+<head> |
+<link rel="help" href="http://www.w3.org/TR/2012/WD-dom-20121206/#interface-characterdata" /> |
+<script src="../js/resources/js-test-pre.js"></script> |
+</head> |
+<body> |
+<script> |
+description("Tests that the CharacterData API arguments are correctly validated."); |
+ |
+var text = document.createTextNode("abcd"); |
+shouldBeEqualToString("text.data", "abcd"); |
+shouldBe("text.__proto__.__proto__", "CharacterData.prototype"); |
+ |
+// appendData() |
+shouldNotThrow("text.appendData('efg')"); |
+shouldBeEqualToString("text.data", "abcdefg"); |
+shouldThrow("text.appendData()", "'TypeError: Not enough arguments'"); // Missing argument. |
arv (Not doing code reviews)
2013/08/01 13:47:45
useless comment
|
+shouldBeEqualToString("text.data", "abcdefg"); |
+ |
+// insertData() |
+text.data = "efg"; |
+shouldNotThrow("text.insertData(0, 'abcd')"); |
+shouldBeEqualToString("text.data", "abcdefg"); |
+shouldThrow("text.insertData()", "'TypeError: Not enough arguments'"); // Missing arguments. |
+shouldBeEqualToString("text.data", "abcdefg"); |
+shouldThrow("text.insertData(0)", "'TypeError: Not enough arguments'"); // Missing second argument. |
+shouldBeEqualToString("text.data", "abcdefg"); |
+shouldThrow("text.insertData(999, 'test')", "'IndexSizeError: Index or size was negative, or greater than the allowed value.'"); // offset greater than length. |
+shouldBeEqualToString("text.data", "abcdefg"); |
+shouldThrow("text.insertData(-1, 'test')"); // First argument should be unsigned. |
+shouldBeEqualToString("text.data", "abcdefg"); |
+ |
+// deleteData() |
+text.data = "abcdefg"; |
+shouldNotThrow("text.deleteData(4, 3)"); |
+shouldBeEqualToString("text.data", "abcd"); |
+shouldThrow("text.deleteData()", "'TypeError: Not enough arguments'"); // Missing arguments. |
+shouldBeEqualToString("text.data", "abcd"); |
+shouldThrow("text.deleteData(0)", "'TypeError: Not enough arguments'"); // Missing second argument. |
+shouldBeEqualToString("text.data", "abcd"); |
+shouldThrow("text.deleteData(999, 3)", "'IndexSizeError: Index or size was negative, or greater than the allowed value.'"); // offset greater than length. |
+shouldBeEqualToString("text.data", "abcd"); |
+shouldThrow("text.deleteData(-1, 3)"); // First argument is an index. |
+shouldBeEqualToString("text.data", "abcd"); |
+shouldNotThrow("text.deleteData(1, 999)"); // Length argument is too large, should be adjusted. |
+shouldBeEqualToString("text.data", "a"); |
+ |
+// ReplaceData() |
+text.data = "efg"; |
+shouldNotThrow("text.replaceData(0, 0, 'abcd')"); |
+shouldBeEqualToString("text.data", "abcdefg"); |
+shouldThrow("text.replaceData()", "'TypeError: Not enough arguments'"); // Missing arguments. |
+shouldBeEqualToString("text.data", "abcdefg"); |
+shouldThrow("text.replaceData(0)", "'TypeError: Not enough arguments'"); // Missing arguments. |
+shouldBeEqualToString("text.data", "abcdefg"); |
+shouldThrow("text.replaceData(0, 0)", "'TypeError: Not enough arguments'"); // Missing argument. |
+shouldBeEqualToString("text.data", "abcdefg"); |
+shouldThrow("text.replaceData(999, 3, 'test')", "'IndexSizeError: Index or size was negative, or greater than the allowed value.'"); // offset greater than length. |
+shouldBeEqualToString("text.data", "abcdefg"); |
+shouldThrow("text.deleteData(-1, 3, 'test')"); // First argument is an index. |
+shouldBeEqualToString("text.data", "abcdefg"); |
+shouldNotThrow("text.replaceData(1, 999, 'aaa')"); // Length argument is too large, should be adjusted. |
+shouldBeEqualToString("text.data", "aaaa"); |
+</script> |
+<script src="../js/resources/js-test-post.js"></script> |
+</body> |
+</html> |