summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/dom/text-api-arguments.html
blob: 67703c4ea15d16fa58d8bb3c0e16c2ee74031079 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
!DOCTYPE html>
<html>
<head>
<link rel="help" href="http://www.w3.org/TR/2012/WD-dom-20121206/#text">
<script src="../../resources/js-test.js"></script>
</head>
<body>
<script>
description("Tests that the Text API arguments are correctly validated.");

var text = document.createTextNode("abcdefg");
shouldBeEqualToString("text.data", "abcdefg");
shouldBe("text.__proto__", "Text.prototype");

// Text splitText(unsigned long offset)
shouldBeEqualToString("text.splitText(4).data", "efg");
shouldBeEqualToString("text.data", "abcd");
shouldThrow("text.splitText()", '"TypeError: Failed to execute \'splitText\' on \'Text\': 1 argument required, but only 0 present."');
shouldBeEqualToString("text.data", "abcd");
shouldThrow("text.splitText(999)", '"IndexSizeError: Failed to execute \'splitText\' on \'Text\': The offset 999 is larger than the Text node\'s length."'); // offset greater than length
shouldBeEqualToString("text.data", "abcd");
shouldThrow("text.splitText(-1)", '"IndexSizeError: Failed to execute \'splitText\' on \'Text\': The offset 4294967295 is larger than the Text node\'s length."'); // offset greater than length (after wrapping)
shouldBeEqualToString("text.data", "abcd");
shouldBeEqualToString("text.splitText(-4294967294).data", "cd"); // Wraps to 2, which is a valid offset.
shouldBeEqualToString("text.data", "ab");
</script>
</body>
</html>