blob: 153193c3a9e7770dc15237d0c3d38e2935375e1c [file] [log] [blame]
<!DOCTYPE html>
<meta charset="utf-8">
<title>InputEvent have correct data/order when typing on textarea and contenteditable</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<p>To manually run this test, please follow the steps below:<br/>
1. Focus the first box and press key 'a' and then Shift-'b'.<br/>
2. Focus the second box and press key 'c' and then Shift-'d'.<br/>
If a "PASS" result appears the test passes, otherwise it fails</p>
<textarea id='plain'></textarea>
<div id='rich' style='border-style: solid;' contenteditable><br></div>
async_test(t => {
const expectedResult = [
// Pressing 'a'.
// Pressing Shift-'b'.
// Pressing 'c'.
// Pressing Shift-'d'.
let eventCounter = 0;
for (const targetId of ['plain', 'rich']) {
for (const eventType of ['beforeinput', 'input', 'keydown', 'keypress', 'keyup']) {
document.getElementById(targetId).addEventListener(eventType, t.step_func(event => {
if (event.key === 'Shift')
assert_equals(`${targetId}-${event.type}-${ || event.key}`, expectedResult[eventCounter]);
if (event instanceof InputEvent) {
assert_equals(event.dataTransfer, null,
'Plain text editing should have null |dataTransfer| field')
if (eventCounter === expectedResult.length)
new test_driver.Actions()
.keyDown('\uE008') // Shift
.then(() => {
new test_driver.Actions()
.keyDown('\uE008') // Shift