Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix input type for forward delete input event #46947

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>