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

Unified Diff: LayoutTests/editing/selection/stay-in-textarea.html

Issue 20572005: Allow selection to skip over contenteditable (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Work around minor platform differences in test Created 7 years, 3 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
Index: LayoutTests/editing/selection/stay-in-textarea.html
diff --git a/LayoutTests/editing/selection/stay-in-textarea.html b/LayoutTests/editing/selection/stay-in-textarea.html
new file mode 100644
index 0000000000000000000000000000000000000000..756bd24bf52e83f2f1419a48f5a9536266a6d166
--- /dev/null
+++ b/LayoutTests/editing/selection/stay-in-textarea.html
@@ -0,0 +1,56 @@
+<!DOCTYPE HTML>
+<html>
+<body>
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+
+<p id="before">Before</p>
+<textarea id="textarea">Text</textarea>
+<p id="after">After</p>
+
+<div id="console"></div>
+<script>
+description("Ensure that extending a selection beyond a textarea does not escape outside its shadow root.");
+
+var before = document.getElementById("before");
+var after = document.getElementById("after");
+var textarea = document.getElementById("textarea");
+
+textarea.setSelectionRange(0, 2);
+var textareaSelection = internals.youngestShadowRoot(textarea).getSelection();
+var initialTextareaFocusNode = textareaSelection.focusNode;
+
+var initialFocusNode = window.getSelection().focusNode;
+var initialFocusOffset = window.getSelection().focusOffset;
+
+shouldBe("textareaSelection.focusOffset", "2");
+
+textareaSelection.modify("extend", "forward", "character");
+shouldBe("textareaSelection.focusNode", "initialTextareaFocusNode");
+shouldBe("textareaSelection.focusOffset", "3");
+
+textareaSelection.modify("extend", "forward", "character");
+shouldBe("textareaSelection.focusNode", "initialTextareaFocusNode");
+shouldBe("textareaSelection.focusOffset", "4");
+
+// We're at the end - none of these should modify the selection any more.
+
+textareaSelection.modify("extend", "forward", "character");
+shouldBe("textareaSelection.focusNode", "initialTextareaFocusNode");
+shouldBe("textareaSelection.focusOffset", "4");
+
+textareaSelection.modify("extend", "forward", "word");
+shouldBe("textareaSelection.focusNode", "initialTextareaFocusNode");
+shouldBe("textareaSelection.focusOffset", "4");
+
+textareaSelection.modify("extend", "forward", "line");
+shouldBe("textareaSelection.focusNode", "initialTextareaFocusNode");
+shouldBe("textareaSelection.focusOffset", "4");
+
+shouldBe("window.getSelection().focusNode", "initialFocusNode");
+shouldBe("window.getSelection().focusOffset", "initialFocusOffset");
+
+</script>
+
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698