Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / selection / stay-in-textarea.html
blob3d1b0008f9e73d889fbb1d2efe43fdf9273bd48f
1 <!DOCTYPE HTML>
2 <html>
3 <body>
4 <script src="../../resources/js-test.js"></script>
6 <p id="before">Before</p>
7 <textarea id="textarea">Text</textarea>
8 <p id="after">After</p>
10 <div id="console"></div>
11 <script>
12 description("Ensure that extending a selection beyond a textarea does not escape outside its shadow root.");
14 var before = document.getElementById("before");
15 var after = document.getElementById("after");
16 var textarea = document.getElementById("textarea");
18 textarea.setSelectionRange(0, 2);
19 var textareaSelection = internals.youngestShadowRoot(textarea).getSelection();
20 var initialTextareaFocusNode = textareaSelection.focusNode;
22 var initialFocusNode = window.getSelection().focusNode;
23 var initialFocusOffset = window.getSelection().focusOffset;
25 shouldBe("textareaSelection.focusOffset", "2");
27 textareaSelection.modify("extend", "forward", "character");
28 shouldBe("textareaSelection.focusNode", "initialTextareaFocusNode");
29 shouldBe("textareaSelection.focusOffset", "3");
31 textareaSelection.modify("extend", "forward", "character");
32 shouldBe("textareaSelection.focusNode", "initialTextareaFocusNode");
33 shouldBe("textareaSelection.focusOffset", "4");
35 // We're at the end - none of these should modify the selection any more.
37 textareaSelection.modify("extend", "forward", "character");
38 shouldBe("textareaSelection.focusNode", "initialTextareaFocusNode");
39 shouldBe("textareaSelection.focusOffset", "4");
41 textareaSelection.modify("extend", "forward", "word");
42 shouldBe("textareaSelection.focusNode", "initialTextareaFocusNode");
43 shouldBe("textareaSelection.focusOffset", "4");
45 textareaSelection.modify("extend", "forward", "line");
46 shouldBe("textareaSelection.focusNode", "initialTextareaFocusNode");
47 shouldBe("textareaSelection.focusOffset", "4");
49 shouldBe("window.getSelection().focusNode", "initialFocusNode");
50 shouldBe("window.getSelection().focusOffset", "initialFocusOffset");
52 </script>
54 </body>
55 </html>