Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Unified Diff: LayoutTests/fast/dom/characterdata-api-arguments.html

Issue 21542002: Make CharacterData::insertData() / deleteData() / replaceData() arguments mandatory (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebaseline fast/dom/characterdata-appendData-argument.html Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/dom/characterdata-api-arguments-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..fec0c18f61eb954c8c84a749cc8e238ad2658f24
--- /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'");
+shouldBeEqualToString("text.data", "abcdefg");
+
+// insertData()
+text.data = "efg";
+shouldNotThrow("text.insertData(0, 'abcd')");
+shouldBeEqualToString("text.data", "abcdefg");
+shouldThrow("text.insertData()", "'TypeError: Not enough arguments'");
+shouldBeEqualToString("text.data", "abcdefg");
+shouldThrow("text.insertData(0)", "'TypeError: Not enough arguments'");
+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");
+shouldNotThrow("text.insertData(-4294967294, 'test')");
+shouldBeEqualToString("text.data", "abtestcdefg");
+
+// deleteData()
+text.data = "abcdefg";
+shouldNotThrow("text.deleteData(4, 3)");
+shouldBeEqualToString("text.data", "abcd");
+shouldThrow("text.deleteData()", "'TypeError: Not enough arguments'");
+shouldBeEqualToString("text.data", "abcd");
+shouldThrow("text.deleteData(0)", "'TypeError: Not enough arguments'");
+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");
+shouldNotThrow("text.deleteData(-4294967294, 2)");
+shouldBeEqualToString("text.data", "ab");
+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'");
+shouldBeEqualToString("text.data", "abcdefg");
+shouldThrow("text.replaceData(0)", "'TypeError: Not enough arguments'");
+shouldBeEqualToString("text.data", "abcdefg");
+shouldThrow("text.replaceData(0, 0)", "'TypeError: Not enough arguments'");
+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");
+shouldNotThrow("text.replaceData(-4294967294, 0, 'test')");
+shouldBeEqualToString("text.data", "abtestcdefg");
+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>
« no previous file with comments | « no previous file | LayoutTests/fast/dom/characterdata-api-arguments-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698