Update WPT tests for css-writing-modes
[WebKit-https.git] / LayoutTests / editing / deleting / ios / backspace-last-character.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 <script src="../../../resources/ui-helper.js"></script>
6 </head>
7 <body>
8 <div id="test-container">
9     <textarea id="input"></textarea>
10     <textarea id="output" readonly></textarea>
11 </div>
12 <script>
13 window.jsTestIsAsync = true;
14
15 let input = document.getElementById("input");
16 let inputDidFocus = false;
17 let inputEventCount = 0;
18
19 function appendANewline()
20 {
21     let outputElement = document.getElementById("output");
22     outputElement.value = outputElement.value + "\n";
23 }
24
25 async function runTest()
26 {
27     input.addEventListener("focus", () => inputDidFocus = true);
28     input.addEventListener("input", () => ++inputEventCount);
29
30     if (window.testRunner) {
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));
38
39     console.log("Typing 'w'.");
40     if (window.testRunner)
41         await UIHelper.keyDown("w");
42
43     console.log("Waiting for first input event.");
44     await new Promise(resolve => shouldBecomeEqual("inputEventCount", "1", resolve));
45     shouldBeEqualToString('document.getElementById("input").value', "w");
46
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));
53     shouldBeEqualToString('document.getElementById("input").value', "");
54
55     console.log("Test complete.");
56     document.body.removeChild(document.getElementById("test-container"));
57     finishJSTest();
58 }
59
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.");
61 input.addEventListener("keydown", appendANewline);
62
63 runTest();
64 </script>
65 </body>
66 </html>