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

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

Issue 2117543003: [InputEvent] Fill |data| field for 'input' event InsertText (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed |dataFromCommand()| helper function Created 4 years, 5 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-data-keyboard.html
diff --git a/third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-data-keyboard.html b/third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-data-keyboard.html
new file mode 100644
index 0000000000000000000000000000000000000000..edeb17c951f9dd58a884de4b6e7d86e62881e5f4
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-data-keyboard.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>InputEvent: data field from keyboard</title>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+</head>
+<body>
+<p id="txt" contenteditable></p>
+<script>
+test(function() {
+ assert_not_equals(window.eventSender, undefined, 'This test requires eventSender.');
+
+ const NOT_FIRED = 'NOT_FIRED';
+ var beforeinputData = NOT_FIRED;
+ var inputData = NOT_FIRED;
+
+ var txt = document.getElementById('txt');
+ txt.addEventListener('beforeinput', event => beforeinputData = event.data);
+ txt.addEventListener('input', event => inputData = event.data);
+
+ function testKeyDownData(key, modifiers, data) {
+ beforeinputData = NOT_FIRED;
+ inputData = NOT_FIRED;
+ eventSender.keyDown(key, modifiers);
+ assert_equals(beforeinputData, data, `${modifiers.toString()}+${key} should produce beforeinput data: ${data}`);
+ assert_equals(inputData, data, `${modifiers.toString()}+${key} should produce input data: ${data}`);
+ }
+
+ txt.focus();
+ // Typing
+ testKeyDownData('a', [], 'a');
+ testKeyDownData('4', [], '4');
+ testKeyDownData('Backspace', [], '');
+ testKeyDownData('L', ['shiftKey'], 'L');
+ testKeyDownData('^', ['shiftKey'], '^');
+ testKeyDownData(' ', [], ' ');
+}, 'Testing data field from keyboard');
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698