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

Side by Side 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: Add tests for InputEvent.data 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>InputEvent: data field from keyboard</title>
5 <script src="../../../resources/testharness.js"></script>
6 <script src="../../../resources/testharnessreport.js"></script>
7 </head>
8 <body>
9 <p id="txt" contenteditable></p>
10 <script>
11 test(function() {
12 if (!window.eventSender) {
yosin_UTC9 2016/07/05 01:22:07 Let's use |assert_not_equal(window.eventSender, un
chongz 2016/07/05 20:33:27 Done.
13 document.write('This test requires eventSender');
14 return;
15 }
16
17 const NOT_FIRED = 'NOT_FIRED';
18 var beforeinputData = NOT_FIRED;
19 var inputData = NOT_FIRED;
20
21 var txt = document.getElementById('txt');
22 txt.addEventListener('beforeinput', event => beforeinputData = event.data);
23 txt.addEventListener('input', event => inputData = event.data);
24
25 function testKeyDownData(key, modifiers, data) {
26 beforeinputData = NOT_FIRED;
27 inputData = NOT_FIRED;
28 eventSender.keyDown(key, modifiers);
29 assert_equals(beforeinputData, data, `${modifiers.toString()}+${key} sho uld produce beforeinput data: ${data}`);
30 assert_equals(inputData, data, `${modifiers.toString()}+${key} should pr oduce input data: ${data}`);
31 }
32
33 txt.focus();
34 // Typing
35 testKeyDownData('a', [], 'a');
36 testKeyDownData('4', [], '4');
37 testKeyDownData('Backspace', [], '');
38 testKeyDownData('L', ['shiftKey'], 'L');
39 testKeyDownData('^', ['shiftKey'], '^');
40 testKeyDownData(' ', [], ' ');
41 }, 'Testing data field from keyboard');
42 </script>
43 </body>
44 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698