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

Unified Diff: third_party/WebKit/LayoutTests/fast/forms/selection-setSelectionRange-frameselection.html

Issue 2270663002: Selection API of INPUT/TEXTAREA should not update FrameSelection without focusing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adjust more tests Created 4 years, 4 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: third_party/WebKit/LayoutTests/fast/forms/selection-setSelectionRange-frameselection.html
diff --git a/third_party/WebKit/LayoutTests/fast/forms/selection-setSelectionRange-frameselection.html b/third_party/WebKit/LayoutTests/fast/forms/selection-setSelectionRange-frameselection.html
new file mode 100644
index 0000000000000000000000000000000000000000..deee5194a60b2ee8392b1f5aae57dc738bb84573
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/forms/selection-setSelectionRange-frameselection.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<body>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<input id="notFocused" value="foo">
+<input id="focused" value="a">
+<script>
+test(() => {
+ var notFocused = document.getElementById('notFocused');
+ var focused = document.getElementById('focused');
+ var selection = window.getSelection();
+ selection.removeAllRanges();
+ focused.focus();
+
+ var originalAnchorNode = selection.anchorNode;
+ var originalAnchorOffset = selection.anchorOffset;
+ notFocused.setSelectionRange(3, 3);
+ assert_equals(selection.anchorNode, originalAnchorNode);
+ assert_equals(selection.anchorOffset, originalAnchorOffset);
+}, 'setSelectionRange() should not update FrameSelection if the target element is not focused.');
+
+test(() => {
+ var notFocused = document.getElementById('notFocused');
+ var focused = document.getElementById('focused');
+ var selection = window.getSelection();
+ selection.removeAllRanges();
+ focused.focus();
+
+ var originalAnchorNode = selection.anchorNode;
+ var originalAnchorOffset = selection.anchorOffset;
+ notFocused.setRangeText('barrr', 0, 3, 'select');
+ assert_equals(selection.anchorNode, originalAnchorNode);
+ assert_equals(selection.anchorOffset, originalAnchorOffset);
+}, 'setRangeText() should not update FrameSelection if the target element is not focused.');
+</script>
+</body>

Powered by Google App Engine
This is Rietveld 408576698