Skip to content

Commit

Permalink
Fix input type for forward delete input event
Browse files Browse the repository at this point in the history
A |TypingCommand| is created to execute corresponding input command and
and is reused until it is open for typing.
|TypingCommand::ForwardDeleteKeyPressed()| was reusing last typing
command without resetting its input type, which is fixed in this CL.

Bug: 40736701
Change-Id: I5ca6ed8c3028c90cd32a4d206772bcf9a5d48b2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5653570
Reviewed-by: Siye Liu <siliu@microsoft.com>
Reviewed-by: Koji Ishii <kojii@chromium.org>
Reviewed-by: Sanket Joshi <sajos@microsoft.com>
Commit-Queue: Sambamurthy Bandaru <sambamurthy.bandaru@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1321543}
  • Loading branch information
sambandaru authored and chromium-wpt-export-bot committed Jul 1, 2024
1 parent 67f02dc commit 0971d23
Showing 1 changed file with 43 additions and 4 deletions.
47 changes: 43 additions & 4 deletions input-events/input-events-typing.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,45 @@
assert_equals(beforeInputEvent.data, inputEvent.data);
}, 'It triggers beforeinput and input events on typing BACK_SPACE with pre-existing content');

promise_test(async function () {
this.add_cleanup(resetRich);
rich.innerHTML = '<p>Preexisting <i id="caret">C</i>ontent</p>';

const expectedResult = [
// Pressing 'a', 'b'
'insertText',
'insertText',
// Delete twice
'deleteContentForward',
'deleteContentForward',
// Pressing 'c', 'd'
'insertText',
'insertText',
// Backspace
'deleteContentBackward'
];
const result = [];

rich.addEventListener("input", (inputEvent) => {
result.push(inputEvent.inputType);
});

await test_driver.click(document.querySelector('#caret')); // Preexisting |Content
await test_driver.send_keys(rich, "a"); // Preexisting a|Content
await test_driver.send_keys(rich, "b"); // Preexisting ab|Content
// Delete
await test_driver.send_keys(rich, "\uE017"); // Preexisting ab|ontent
// Delete
await test_driver.send_keys(rich, "\uE017"); // Preexisting ab|ntent
await test_driver.send_keys(rich, "c"); // Preexisting abc|ntent
await test_driver.send_keys(rich, "d"); // Preexisting abcd|ntent
// Backspace
await test_driver.send_keys(rich, "\uE003"); // Preexisting abc|ntent

assert_equals(result.length, expectedResult.length);
expectedResult.forEach((er, index) => assert_equals(result[index], er));
}, 'Input events have correct inputType updated when different inputs are typed');

promise_test(async function () {
this.add_cleanup(resetRich);
rich.innerHTML = '<p>Preexisting <i id="caret">c</i>ontent</p>';
Expand Down Expand Up @@ -169,8 +208,8 @@
// Delete
await test_driver.send_keys(rich, "\uE017"); // |

assert_equals(expectedResult.length, result.length);
expectedResult.forEach((er, index) => assert_equals(er, result[index]));
assert_equals(result.length, expectedResult.length);
expectedResult.forEach((er, index) => assert_equals(result[index], er));
}, 'Input events have correct inputType when selected text is removed with Backspace or Delete');

promise_test(async function() {
Expand Down Expand Up @@ -326,7 +365,7 @@
.keyUp('\uE008')
.send();

assert_equals(expectedResult.length, result.length);
expectedResult.forEach((er, index) => assert_equals(er, result[index]));
assert_equals(result.length, expectedResult.length);
expectedResult.forEach((er, index) => assert_equals(result[index], er));
}, 'InputEvents have correct data/order when typing on textarea and contenteditable');
</script>

0 comments on commit 0971d23

Please sign in to comment.