Commit 5a4419d5 authored by Ryan Landay's avatar Ryan Landay Committed by Commit Bot

Add inputType field to beforeinput events in inputevent-ime.html

In InputMethodController, the beforeinput and input events are fired separately
for most (all?) commands, so our JavaScript event test case should be checking
separately that they both have the correct inputType.

Change-Id: I13e2abf23af657fc2ecd5c0427d8bc57fc6fbeb8
Reviewed-on: https://chromium-review.googlesource.com/872611
Commit-Queue: Ryan Landay <rlanday@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarXiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#530327}
parent f9d2806b
......@@ -7,7 +7,8 @@
document.addEventListener('beforeinput', event => {
const logString =
`beforeinput: isComposing=${event.isComposing}, data="${event.data}"`;
`beforeinput: isComposing=${event.isComposing}, data="${event.data}", `
+ `inputType=${event.inputType}`;
eventLog.push(logString);
});
......@@ -75,7 +76,8 @@
resetEventLog();
textInputController.setComposition('');
assert_array_equals(eventLog, [
'beforeinput: isComposing=false, data="null"',
'beforeinput: isComposing=false, data="null", '
+ 'inputType=deleteContentBackward',
'input: isComposing=false, data="null", inputType=deleteContentBackward',
]);
}, 'setComposition with no composition open, empty text replacing selection');
......@@ -105,7 +107,8 @@
textInputController.setComposition('hello');
assert_array_equals(eventLog, [
'compositionstart',
'beforeinput: isComposing=true, data="hello"',
'beforeinput: isComposing=true, data="hello", '
+ 'inputType=insertCompositionText',
'compositionupdate: data="hello"',
'input: isComposing=true, data="hello", inputType=insertCompositionText',
]);
......@@ -123,7 +126,7 @@
textInputController.setComposition('');
assert_array_equals(eventLog, [
'beforeinput: isComposing=true, data=""',
'beforeinput: isComposing=true, data="", inputType=insertCompositionText',
'compositionupdate: data=""',
'textInput: data=""',
'input: isComposing=true, data="null", inputType=insertCompositionText',
......@@ -143,7 +146,8 @@
textInputController.setComposition('hello world');
assert_array_equals(eventLog, [
'beforeinput: isComposing=true, data="hello world"',
'beforeinput: isComposing=true, data="hello world", '
+ 'inputType=insertCompositionText',
'compositionupdate: data="hello world"',
'input: isComposing=true, data="hello world", '
+ 'inputType=insertCompositionText',
......@@ -162,7 +166,8 @@
textInputController.insertText('hello world');
assert_array_equals(eventLog, [
'beforeinput: isComposing=true, data="hello world"',
'beforeinput: isComposing=true, data="hello world", '
+ 'inputType=insertCompositionText',
'compositionupdate: data="hello world"',
'textInput: data="hello world"',
'input: isComposing=true, data="hello world", '
......@@ -183,7 +188,7 @@
textInputController.insertText('');
assert_array_equals(eventLog, [
'beforeinput: isComposing=true, data=""',
'beforeinput: isComposing=true, data="", inputType=insertCompositionText',
'compositionupdate: data=""',
'textInput: data=""',
'input: isComposing=true, data="null", inputType=insertCompositionText',
......@@ -202,7 +207,7 @@
textInputController.insertText('hello');
assert_array_equals(eventLog, [
'beforeinput: isComposing=false, data="hello"',
'beforeinput: isComposing=false, data="hello", inputType=insertText',
'textInput: data="hello"',
'input: isComposing=false, data="hello", inputType=insertText',
]);
......@@ -250,7 +255,8 @@
textInputController.unmarkText();
assert_array_equals(eventLog, [
'beforeinput: isComposing=true, data="hello"',
'beforeinput: isComposing=true, data="hello", '
+ 'inputType=insertCompositionText',
'compositionupdate: data="hello"',
'textInput: data="h"',
'input: isComposing=true, data="h", inputType=insertCompositionText',
......@@ -287,7 +293,8 @@
textInputController.unmarkAndUnselectText();
assert_array_equals(eventLog, [
'beforeinput: isComposing=true, data="hello"',
'beforeinput: isComposing=true, data="hello", '
+ 'inputType=insertCompositionText',
'compositionupdate: data="hello"',
'textInput: data="h"',
'input: isComposing=true, data="h", inputType=insertCompositionText',
......@@ -308,7 +315,8 @@
textInputController.extendSelectionAndDelete(1, 1);
assert_array_equals(eventLog, [
'beforeinput: isComposing=false, data="null"',
'beforeinput: isComposing=false, data="null", '
+ 'inputType=deleteContentBackward',
'input: isComposing=false, data="null", inputType=deleteContentBackward',
]);
}, 'extendSelectionAndDelete, no composition open');
......@@ -327,7 +335,8 @@
textInputController.extendSelectionAndDelete(1, 1);
assert_array_equals(eventLog, [
'beforeinput: isComposing=false, data="null"',
'beforeinput: isComposing=false, data="null", '
+ 'inputType=deleteContentBackward',
'input: isComposing=false, data="null", inputType=deleteContentBackward',
]);
}, 'extendSelectionAndDelete, composition open');
......@@ -345,9 +354,11 @@
textInputController.deleteSurroundingText(1, 1);
assert_array_equals(eventLog, [
'beforeinput: isComposing=false, data="null"',
'beforeinput: isComposing=false, data="null", '
+ 'inputType=deleteContentBackward',
'input: isComposing=false, data="null", inputType=deleteContentBackward',
'beforeinput: isComposing=false, data="null"',
'beforeinput: isComposing=false, data="null", '
+ 'inputType=deleteContentBackward',
'input: isComposing=false, data="null", inputType=deleteContentBackward',
]);
}, 'deleteSurroundingText, no composition open');
......@@ -366,9 +377,11 @@
textInputController.deleteSurroundingText(1, 1);
assert_array_equals(eventLog, [
'beforeinput: isComposing=false, data="null"',
'beforeinput: isComposing=false, data="null", '
+ 'inputType=deleteContentBackward',
'input: isComposing=false, data="null", inputType=deleteContentBackward',
'beforeinput: isComposing=false, data="null"',
'beforeinput: isComposing=false, data="null", '
+ 'inputType=deleteContentBackward',
'input: isComposing=false, data="null", inputType=deleteContentBackward',
]);
}, 'deleteSurroundingText, composition open');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment