Editing tests should use testRunner instead of layoutTestController
[WebKit-https.git] / LayoutTests / platform / mac / editing / input / kotoeri-enter-to-confirm-and-newline.html
1 <div>
2     This tests a subset of pseudo-kotoeri behaviour:
3     <ul>
4         <li>All keydown events never result in keypress during composition</li>
5         <li>During composition all keydown events should have keyCode 229, this is necessary to match the behaviour of windows browsers, including WebKit/Win</li>
6     </ul>
7     To test this manually switch to the Kotoeri/Hiragana input method, and type 'toukyou'&lt;enter&gt;&lt;enter&gt;.<br />
8     You should see only a single keypress event, as the very last reported event.
9 </div>
10 <input id="targetInput" onkeydown="keyDown()" onkeypress="keyPress()">
11 <ul id="console"></console>
12
13 <script src="logger.js"></script>
14 <script src="kotoeri.js"></script>
15 <script>
16     var shouldBeCompositionEvent = false;
17     function keyDown() {
18         if (!window.testRunner) {
19             log("keydown : keyCode == " + event.keyCode);
20             return;
21         }
22         if (shouldBeCompositionEvent && event.keyCode != 229)
23             log("FAILURE: received keyCode " + event.keyCode + " in a keydown when VK_PROCESSKEY is expected");
24         else if (!shouldBeCompositionEvent && event.keyCode == 229)
25             log("FAILURE: received a keyDown with VK_PROCESSKEY as the keyCode, when an actual key code was expected.");
26         else
27             log("Received valid keydown event");
28     }
29     
30     function keyPress() {
31         if (!window.testRunner) {
32             log("keypress : keyCode == " + event.keyCode);
33             return;
34         }
35         if (shouldBeCompositionEvent)
36             log("FAILURE: received keypress event during composition");
37         else
38             log("Received valid keypress event");
39     }
40     
41     var targetInput = document.getElementById('targetInput');
42     targetInput.focus();
43     if (window.testRunner) {
44         testRunner.dumpAsText();
45         textInputController.setInputMethodHandler(kotoeri);
46         shouldBeCompositionEvent = true;
47         eventSender.keyDown('t');
48         eventSender.keyDown('o');
49         eventSender.keyDown('u');
50         eventSender.keyDown('k');
51         eventSender.keyDown('y');
52         eventSender.keyDown('o');
53         eventSender.keyDown('u');
54         eventSender.keyDown('\n');
55         shouldBeCompositionEvent = false;
56         eventSender.keyDown('\n');
57         if (targetInput.value != "toukyou")
58             log("FAILED: Input field should countain the text 'toukyou'");
59         else
60             log("PASSED: Successfully typed 'toukyou'");
61     }
62 </script>