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

Unified Diff: third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-drag-drop.html

Issue 2851363003: [InputEvent] Update EndingSelection when appending UndoStep (Closed)
Patch Set: Created 3 years, 8 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/events/inputevents/inputevent-drag-drop.html
diff --git a/third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-drag-drop.html b/third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-drag-drop.html
index 40769a55063ff6d136a486bf21ab80b1b0cf473d..db6f4bd23840677074ba0320f76e35a1a7b534e4 100644
--- a/third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-drag-drop.html
+++ b/third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-drag-drop.html
@@ -16,10 +16,17 @@ div {
<div id="editable2" contenteditable></div>
<textarea id="textarea1">Text</textarea>
<textarea id="barrier"></textarea>
+<input id="input_drag">
+<input id="input_drop">
<script>
-function simulateDragDrop(dragElement, dropElement) {
+function simulateDragDrop(dragElement, dropElement, start, end) {
if (dragElement.select) {
- dragElement.select();
+ if (typeof start === 'undefined' || typeof end === 'undefined') {
+ dragElement.select();
+ } else {
+ dragElement.focus();
+ dragElement.setSelectionRange(start, end);
+ }
} else {
var selection = window.getSelection();
selection.collapse(dragElement, 0);
@@ -298,6 +305,27 @@ test(function() {
testRunner.execCommand('undo');
document.body.appendChild(editable1);
}, 'Testing element removed by event handler');
+
+test(() => {
+ assert_not_equals(window.eventSender, undefined, 'This test requires eventSender.');
+ assert_not_equals(window.testRunner, undefined, 'This test requires testRunner.');
+
+ const input_drag = document.getElementById('input_drag');
+ const input_drop = document.getElementById('input_drop');
+
+ input_drag.value = "12345678";
yosin_UTC9 2017/05/08 04:01:05 nit: Could you use single-quote since other parts
chongz 2017/05/08 23:37:53 Done.
+ input_drop.value = "4";
+
+ simulateDragDrop(input_drag, input_drop, 1, 8);
+
+ assert_equals(input_drag.value, '1');
+ assert_equals(input_drop.value, '42345678');
+
+ testRunner.execCommand('undo');
+
+ assert_equals(input_drag.value, '12345678');
+ assert_equals(input_drop.value, '4');
+}, 'Undo drag&drop should update input.value');
</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698