Index: third_party/WebKit/LayoutTests/fast/events/inputevents/before-input-inputtype.html |
diff --git a/third_party/WebKit/LayoutTests/fast/events/inputevents/before-input-inputtype.html b/third_party/WebKit/LayoutTests/fast/events/inputevents/before-input-inputtype.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ed9c5645b9ddbdd569257c38de4220331cfd69ad |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/fast/events/inputevents/before-input-inputtype.html |
@@ -0,0 +1,50 @@ |
+<!DOCTYPE html> |
+<html> |
+<head> |
+<title>InputEvent: beforeinput inputType</title> |
+<script src="../../../resources/testharness.js"></script> |
+<script src="../../../resources/testharnessreport.js"></script> |
+</head> |
+<body> |
+<input type="text" id="txt"> |
+<script> |
+test(function() { |
+ var lastInputType = ""; |
yosin_UTC9
2016/04/13 06:13:08
Please use single-quote in script fragment since o
chongz
2016/04/13 23:53:08
Done.
|
+ var txt = document.getElementById('txt'); |
+ txt.addEventListener('beforeinput', function(e) { |
yosin_UTC9
2016/04/13 06:13:09
nit: Please avoid to use single-letter variable na
chongz
2016/04/13 23:53:08
Done.
|
+ lastInputType = e.inputType; |
+ }); |
+ if (!window.eventSender) { |
+ document.write('This test requires eventSender'); |
+ } else { |
+ var kNoBeforeInputFired = "noBeforeInputFired"; |
+ function testKeyDownInputType(key, modifiers, inputType) { |
+ lastInputType = kNoBeforeInputFired; |
+ eventSender.keyDown(key, modifiers); |
+ assert_equals(lastInputType, inputType, "${modifiers.toString()}+${key} should produce inputType: ${inputType}"); |
+ } |
+ |
+ txt.focus(); |
+ // Typing |
+ testKeyDownInputType('a', [], 'insertText'); |
+ testKeyDownInputType('6', [], 'insertText'); |
+ testKeyDownInputType('backspace', [], 'deleteContent'); |
+ testKeyDownInputType('l', ['shiftKey'], 'insertText'); |
+ testKeyDownInputType('w', ['shiftKey'], 'insertText'); |
+ |
+ // Keyboard commands |
+ var isMacOS = (navigator.userAgent.indexOf('Mac OS X') != -1); |
+ if (!isMacOS) { |
+ // MacOS's eventSender does not work on hot keys other than arrows. |
+ testKeyDownInputType('z', ['ctrlKey'], 'undo'); |
+ testKeyDownInputType('z', ['ctrlKey', 'shiftKey'], 'redo'); |
+ } |
+ // Move command should not generate input events. |
+ testKeyDownInputType('leftArrow', [], kNoBeforeInputFired); |
+ testKeyDownInputType('leftArrow', ['shiftKey'], kNoBeforeInputFired); |
+ testKeyDownInputType('home', [], kNoBeforeInputFired); |
+ } |
+}, "Testing beforeinput inputType"); |
yosin_UTC9
2016/04/13 06:13:09
Please use single-quote in script fragment since o
chongz
2016/04/13 23:53:08
Done.
|
+</script> |
+</body> |
+</html> |