summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/shadow-tree-exposure.html
blob: c1b1eb8d52a52849fc72b2d68e01f42ec604167d (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("Test to make sure shadow nodes are not exposed.");

var container = document.createElement("p");
document.body.appendChild(container);

container.appendChild(document.createTextNode("Some text: "));

shouldBe("getSelection().anchorNode", "null");
shouldBe("getSelection().anchorOffset", "0");
shouldBe("getSelection().focusNode", "null");
shouldBe("getSelection().focusOffset", "0");
shouldBe("getSelection().isCollapsed", "true");
shouldBe("getSelection().rangeCount", "0");

shouldBe("getSelection().baseNode", "null");
shouldBe("getSelection().baseOffset", "0");
shouldBe("getSelection().extentNode", "null");
shouldBe("getSelection().extentOffset", "0");
shouldBe("getSelection().type", "'None'");

debug("\nAdd an input element.\n");

var input = document.createElement("input");
container.appendChild(input);
input.value = "text";
input.focus();
input.select();

shouldBe("getSelection().anchorNode", "container");
shouldBe("getSelection().anchorOffset", "1");
shouldBe("getSelection().focusNode", "container");
shouldBe("getSelection().focusOffset", "1");
shouldBe("getSelection().isCollapsed", "true");
shouldBe("getSelection().rangeCount", "1");
shouldBe("getSelection().getRangeAt(0).startContainer", "container");
shouldBe("getSelection().getRangeAt(0).startOffset", "1");
shouldBe("getSelection().getRangeAt(0).endContainer", "container");
shouldBe("getSelection().getRangeAt(0).endOffset", "1");

shouldBe("getSelection().baseNode", "container");
shouldBe("getSelection().baseOffset", "1");
shouldBe("getSelection().extentNode", "container");
shouldBe("getSelection().extentOffset", "1");
shouldBe("getSelection().type", "'Range'");

debug("\nAdd a textarea element.\n");

var textarea = document.createElement("textarea");
container.appendChild(textarea);
textarea.value = "text";
textarea.focus();
textarea.select();

shouldBe("getSelection().anchorNode", "container");
shouldBe("getSelection().anchorOffset", "2");
shouldBe("getSelection().focusNode", "container");
shouldBe("getSelection().focusOffset", "2");
shouldBe("getSelection().isCollapsed", "true");
shouldBe("getSelection().rangeCount", "1");
shouldBe("getSelection().getRangeAt(0).startContainer", "container");
shouldBe("getSelection().getRangeAt(0).startOffset", "2");
shouldBe("getSelection().getRangeAt(0).endContainer", "container");
shouldBe("getSelection().getRangeAt(0).endOffset", "2");

shouldBe("getSelection().baseNode", "container");
shouldBe("getSelection().baseOffset", "2");
shouldBe("getSelection().extentNode", "container");
shouldBe("getSelection().extentOffset", "2");
shouldBe("getSelection().type", "'Range'");

document.body.removeChild(container);

debug("");
</script>
</body>
</html>