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/#text"> | 4 <link rel="help" href="http://www.w3.org/TR/2012/WD-dom-20121206/#text"> |
5 <script src="../../resources/js-test.js"></script> | 5 <script src="../../resources/js-test.js"></script> |
6 </head> | 6 </head> |
7 <body> | 7 <body> |
8 <script> | 8 <script> |
9 description("Tests that the Text API arguments are correctly validated."); | 9 description("Tests that the Text API arguments are correctly validated."); |
10 | 10 |
11 var text = document.createTextNode("abcdefg"); | 11 var text = document.createTextNode("abcdefg"); |
12 shouldBeEqualToString("text.data", "abcdefg"); | 12 shouldBeEqualToString("text.data", "abcdefg"); |
13 shouldBe("text.__proto__", "Text.prototype"); | 13 shouldBe("text.__proto__", "Text.prototype"); |
14 | 14 |
15 // Text splitText(unsigned long offset) | 15 // Text splitText(unsigned long offset) |
16 shouldBeEqualToString("text.splitText(4).data", "efg"); | 16 shouldBeEqualToString("text.splitText(4).data", "efg"); |
17 shouldBeEqualToString("text.data", "abcd"); | 17 shouldBeEqualToString("text.data", "abcd"); |
18 shouldThrow("text.splitText()", '"TypeError: Failed to execute \'splitText\' on
\'Text\': 1 argument required, but only 0 present."'); | 18 shouldThrow("text.splitText()", '"TypeError: Failed to execute \'splitText\' on
\'Text\': 1 argument required, but only 0 present."'); |
19 shouldBeEqualToString("text.data", "abcd"); | 19 shouldBeEqualToString("text.data", "abcd"); |
20 shouldThrow("text.splitText(999)", '"IndexSizeError: Failed to execute \'splitTe
xt\' on \'Text\': The offset 999 is larger than the Text node\'s length."'); //
offset greater than length | 20 shouldThrow("text.splitText(999)", '"IndexSizeError: Failed to execute \'splitTe
xt\' on \'Text\': The offset 999 is larger than the Text node\'s length."'); //
offset greater than length |
21 shouldBeEqualToString("text.data", "abcd"); | 21 shouldBeEqualToString("text.data", "abcd"); |
22 shouldThrow("text.splitText(-1)", '"IndexSizeError: Failed to execute \'splitTex
t\' on \'Text\': The offset 4294967295 is larger than the Text node\'s length."'
); // offset greater than length (after wrapping) | 22 shouldThrow("text.splitText(-1)", '"IndexSizeError: Failed to execute \'splitTex
t\' on \'Text\': The offset 4294967295 is larger than the Text node\'s length."'
); // offset greater than length (after wrapping) |
23 shouldBeEqualToString("text.data", "abcd"); | 23 shouldBeEqualToString("text.data", "abcd"); |
24 shouldBeEqualToString("text.splitText(-4294967294).data", "cd"); // Wraps to 2,
which is a valid offset. | 24 shouldBeEqualToString("text.splitText(-4294967294).data", "cd"); // Wraps to 2,
which is a valid offset. |
25 shouldBeEqualToString("text.data", "ab"); | 25 shouldBeEqualToString("text.data", "ab"); |
26 | |
27 // Text replaceWholeText(DOMString content) | |
28 text.data = "abcdefg"; | |
29 shouldBe("text.replaceWholeText('test')", "text"); | |
30 shouldBeEqualToString("text.data", "test"); | |
31 shouldBeNull("text.replaceWholeText('')"); | |
32 shouldBeEqualToString("text.data", "test"); | |
33 shouldThrow("text.replaceWholeText()", '"TypeError: Failed to execute \'replaceW
holeText\' on \'Text\': 1 argument required, but only 0 present."'); | |
34 shouldBeEqualToString("text.data", "test"); | |
35 shouldBe("text.replaceWholeText(null)", "text"); | |
36 shouldBeEqualToString("text.data", "null"); | |
37 shouldBe("text.replaceWholeText(undefined)", "text"); | |
38 shouldBeEqualToString("text.data", "undefined"); | |
39 </script> | 26 </script> |
40 </body> | 27 </body> |
41 </html> | 28 </html> |
OLD | NEW |