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

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

Issue 2704613002: [InputEvent] Make typing and IME related input types non-cancelable (Closed)
Patch Set: yosin's review: Replace == with === Created 3 years, 10 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/EditingUtilities.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-cancelable.html
diff --git a/third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-cancelable.html b/third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-cancelable.html
new file mode 100644
index 0000000000000000000000000000000000000000..94dda10d5df6006785b6a63ef003cc931dec901b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-cancelable.html
@@ -0,0 +1,138 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>InputEvent: cancelable</title>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<style>
+div {
+ width: 100px;
+ height: 100px;
+}
+</style>
+</head>
+<body>
+<div id="editable" contenteditable></div>
+<div id="editable1" contenteditable>EditableText</div>
+<div id="editable2" contenteditable></div>
+<script>
+function simulateDragDrop(dragElement, dropElement) {
+ if (dragElement.select) {
+ dragElement.select();
+ } else {
+ var selection = window.getSelection();
+ selection.collapse(dragElement, 0);
+ selection.extend(dragElement, 1);
+ }
+
+ eventSender.mouseMoveTo(dragElement.offsetLeft + dragElement.offsetWidth / 2,
+ dragElement.offsetTop + dragElement.offsetHeight / 2);
+ eventSender.mouseDown();
+ eventSender.leapForward(600);
+ eventSender.mouseMoveTo(dropElement.offsetLeft + dropElement.offsetWidth / 2,
+ dropElement.offsetTop + dropElement.offsetHeight / 2);
+ eventSender.mouseUp();
+}
+
+async_test(t => {
+ assert_not_equals(window.eventSender, undefined, 'This test requires eventSender.');
+ assert_not_equals(window.testRunner, undefined, 'This test requires testRunner.');
+ assert_not_equals(internals, undefined, 'This test requires internals.');
+ assert_not_equals(textInputController, undefined, 'This test requires textInputController.');
+
+ const editable = document.getElementById('editable');
+ const editable1 = document.getElementById('editable1');
+ const editable2 = document.getElementById('editable2');
+ const kNoncancelableInputTypes = [
+ 'insertText', 'insertLineBreak', 'insertParagraph',
+ 'insertCompositionText', 'insertReplacementText',
+ 'deleteWordBackward', 'deleteWordForward',
+ 'deleteLineBackward', 'deleteLineForward',
+ 'deleteContentBackward', 'deleteContentForward',
+ ];
+
+ let lastBeforeInputType = '';
+ document.addEventListener('beforeinput', t.step_func(event => {
+ lastBeforeInputType = event.inputType;
+ assert_equals(kNoncancelableInputTypes.indexOf(event.inputType) === -1, event.cancelable);
+ }));
+
+ function testKeyDown(key, modifiers, inputType) {
+ lastBeforeInputType = '';
+ eventSender.keyDown(key, modifiers);
+ assert_equals(inputType, lastBeforeInputType, `${modifiers.toString()}+${key} should produce input type: ${inputType}`);
+ }
+
+ function testCommand(command, inputType) {
+ lastBeforeInputType = '';
+ testRunner.execCommand(command);
+ assert_equals(inputType, lastBeforeInputType, `${command} should produce input type: ${inputType}`);
+ }
+
+ // Typing
+ editable.focus();
+ testKeyDown('a', [], 'insertText');
+ testKeyDown('6', [], 'insertText');
+ testKeyDown('l', ['shiftKey'], 'insertText');
+ testKeyDown('w', ['shiftKey'], 'insertText');
+ testKeyDown('Enter', [], 'insertParagraph');
+ testKeyDown('Enter', ['shiftKey'], 'insertLineBreak');
+
+ // Deletion
+ const isMacOS = navigator.platform.indexOf('Mac') === 0;
+ const deleteWordModifier = isMacOS ? 'altKey' : 'ctrlKey';
+ editable.innerHTML = 'abc def</br>123 456';
+ const selection = window.getSelection();
+ selection.collapse(editable, 1); // End of first line.
+ testKeyDown('Backspace', [], 'deleteContentBackward');
+ testKeyDown('Delete', [], 'deleteContentForward');
+ testKeyDown('Backspace', [deleteWordModifier], 'deleteWordBackward');
+ testKeyDown('Delete', [deleteWordModifier], 'deleteWordForward');
+
+ // Format
+ editable.innerHTML = 'abc';
+ selection.collapse(editable, 0);
+ selection.extend(editable, 1);
+ testCommand('bold', 'formatBold');
+ testCommand('italic', 'formatItalic');
+ testCommand('underline', 'formatUnderline');
+ testCommand('strikeThrough', 'formatStrikeThrough');
+ testCommand('superscript', 'formatSuperscript');
+ testCommand('subscript', 'formatSubscript');
+
+ // Cut and paste
+ editable.innerHTML = 'abc';
+ selection.collapse(editable, 0);
+ selection.extend(editable, 1);
+ testKeyDown('Cut', [], 'deleteByCut');
+ testKeyDown('Paste', [], 'insertFromPaste');
+
+ // Drag and drop
+ simulateDragDrop(editable1, editable2);
+ assert_equals('insertFromDrop', lastBeforeInputType);
+
+ // Undo and redo
+ testCommand('undo', 'historyUndo');
+ testCommand('redo', 'historyRedo');
+
+ // Spell-checker
+ editable.innerHTML = 'appla';
+ selection.collapse(editable, 0);
+ selection.extend(editable, 1);
+ internals.setMarker(document, selection.getRangeAt(0), 'Spelling');
+ internals.replaceMisspelled(document, 'apple');
+ assert_equals('insertReplacementText', lastBeforeInputType);
+
+ // IME
+ editable.innerHTML = 'wo';
+ selection.collapse(editable, 0);
+ selection.extend(editable, 1);
+ textInputController.setComposition('word');
+ assert_equals('insertCompositionText', lastBeforeInputType);
+
+ t.done();
+}, 'Text input and IME related input types are non-cancelable.');
+
+</script>
+</body>
+</html>
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/EditingUtilities.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698