|
13 | 13 | window.jsTestIsAsync = true;
|
14 | 14 |
|
15 | 15 | let input = document.getElementById("input");
|
| 16 | +let inputDidFocus = false; |
| 17 | +let inputEventCount = 0; |
16 | 18 |
|
17 | 19 | function appendANewline()
|
18 | 20 | {
|
|
22 | 24 |
|
23 | 25 | async function runTest()
|
24 | 26 | {
|
25 |
| - if (window.testRunner) |
| 27 | + input.addEventListener("focus", () => inputDidFocus = true); |
| 28 | + input.addEventListener("input", () => ++inputEventCount); |
| 29 | + |
| 30 | + if (window.testRunner) { |
26 | 31 | await UIHelper.setHardwareKeyboardAttached(false);
|
| 32 | + console.log("Activating element and waiting for input session."); |
| 33 | + await UIHelper.activateElementAndWaitForInputSession(input); |
| 34 | + } |
| 35 | + |
| 36 | + console.log("Waiting for element focus."); |
| 37 | + await new Promise(resolve => shouldBecomeEqual("inputDidFocus", "true", resolve)); |
27 | 38 |
|
28 |
| - await UIHelper.callFunctionAndWaitForEvent(() => window.testRunner && UIHelper.activateElement(input), input, "focus"); |
| 39 | + console.log("Typing 'w'."); |
| 40 | + if (window.testRunner) |
| 41 | + await UIHelper.keyDown("w"); |
29 | 42 |
|
30 |
| - await UIHelper.callFunctionAndWaitForEvent(() => window.testRunner && UIHelper.keyDown("w"), input, "input"); |
| 43 | + console.log("Waiting for first input event."); |
| 44 | + await new Promise(resolve => shouldBecomeEqual("inputEventCount", "1", resolve)); |
31 | 45 | shouldBeEqualToString('document.getElementById("input").value', "w");
|
32 | 46 |
|
33 |
| - await UIHelper.callFunctionAndWaitForEvent(() => window.testRunner && UIHelper.keyDown("\b"), input, "input"); |
| 47 | + console.log("Hitting backspace."); |
| 48 | + if (window.testRunner) |
| 49 | + await UIHelper.keyDown("\b"); |
| 50 | + |
| 51 | + console.log("Waiting for second input event."); |
| 52 | + await new Promise(resolve => shouldBecomeEqual("inputEventCount", "2", resolve)); |
34 | 53 | shouldBeEqualToString('document.getElementById("input").value', "");
|
35 | 54 |
|
| 55 | + console.log("Test complete."); |
36 | 56 | document.body.removeChild(document.getElementById("test-container"));
|
37 | 57 | finishJSTest();
|
38 | 58 | }
|
39 | 59 |
|
40 |
| -description("This tests using the software keyboard and pressing 'w' then <kbd>backspace</kbd> deletes the 'w' and does not cause an assertion failure in a debug build.") |
| 60 | +description("This tests using the software keyboard and pressing 'w' then <kbd>backspace</kbd> deletes the 'w' and does not cause an assertion failure in a debug build."); |
41 | 61 | input.addEventListener("keydown", appendANewline);
|
42 | 62 |
|
43 | 63 | runTest();
|
|
0 commit comments