Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(486)

Side by Side Diff: LayoutTests/fast/events/ime-composition-events-001.html

Issue 18185002: Use js-test-{pre,post}.js for ime-composition-events LayoutTest (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | LayoutTests/fast/events/ime-composition-events-001-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <title></title> 3 <script src="../js/resources/js-test-pre.js"></script>
4 </head> 4 </head>
5 <body> 5 <body>
6 <p>This tests that calling input-method functions sends Composition Events and T ext Events introduced in DOM Level 3.</p> 6 <input id="test" type="text">
7 <p>To test manually, enable an IME, input CJK characters, and see this page does n't show 'FAILED' lines.</p> 7 <script>
8 <input id="test" type="text"/> 8 description("This tests that calling input-method functions sends Composition Ev ents and Text Events introduced in DOM Level 3. " +
9 <ul id="console"></ul> 9 "To test manually, enable an IME, input CJK characters, and see this page doesn' t show 'FAIL' lines.");
10 <script language="javascript" type="text/javascript"> 10 </script>
11 function log(str) { 11 <script>
12 var li = document.createElement('li'); 12 function logCompositionStart(event) {
13 li.appendChild(document.createTextNode(str)); 13 shouldBeEqualToString("event.type", "compositionstart");
14 var console = document.getElementById('console'); 14 testPassed("event.data is '" + event.data + "'");
15 console.appendChild(li);
16 } 15 }
17 16
18 function logEvent(e) { 17 function logCompositionUpdate(event) {
19 var target = e.target; 18 shouldBeEqualToString("event.type", "compositionupdate");
20 var type = e.type; 19 testPassed("event.data is '" + event.data + "'");
21 if (e.type == 'compositionstart' || e.type == 'compositionupdate' || e.type == 'compositionend' || e.type == 'textInput') 20 }
22 log('SUCCESS: ' + target.tagName + ' - ' + e.type + ' - "' + e.data + '" '); 21
23 else 22 function logCompositionEnd(event) {
24 log('FAILED: ' + target.tagName + ' - ' + e.type + ' - "' + e.data + '"' ); 23 shouldBeEqualToString("event.type", "compositionend");
24 testPassed("event.data is '" + event.data + "'");
25 }
26
27 function logTextInput(event) {
28 shouldBeEqualToString("event.type", "textInput");
29 testPassed("event.data is '" + event.data + "'");
25 } 30 }
26 31
27 var test = document.getElementById('test'); 32 var test = document.getElementById('test');
28 test.focus(); 33 test.focus();
29 34
30 if (window.testRunner) { 35 // Add event listeners to the <input> node.
31 testRunner.dumpAsText(); 36 test.addEventListener("compositionstart", logCompositionStart, false);
37 test.addEventListener("compositionupdate", logCompositionUpdate, false);
38 test.addEventListener("compositionend", logCompositionEnd, false);
39 test.addEventListener("textInput", logTextInput, false);
32 40
33 // Add event listeners to the <input> node. 41 // Case 1: Compose a text and commit it.
34 test.addEventListener("compositionstart", logEvent, false); 42 textInputController.setMarkedText('1', 0, 1);
35 test.addEventListener("compositionupdate", logEvent, false); 43 textInputController.setMarkedText('2', 0, 1);
36 test.addEventListener("compositionend", logEvent, false); 44 textInputController.setMarkedText('3', 0, 1);
37 test.addEventListener("textInput", logEvent, false); 45 textInputController.insertText('4');
38 46
39 // Case 1: Compose a text and commit it. 47 // Case 2: Compose a text but cancel it.
40 textInputController.setMarkedText('1', 0, 1); 48 textInputController.setMarkedText('5', 0, 1);
41 textInputController.setMarkedText('2', 0, 1); 49 textInputController.setMarkedText('6', 0, 1);
42 textInputController.setMarkedText('3', 0, 1); 50 textInputController.setMarkedText('7', 0, 1);
43 textInputController.insertText('4'); 51 textInputController.setMarkedText('', 0, 0);
44 52
45 // Case 2: Compose a text but cancel it. 53 // Case 3: Insert a text without composition.
46 textInputController.setMarkedText('5', 0, 1); 54 textInputController.insertText('8');
47 textInputController.setMarkedText('6', 0, 1);
48 textInputController.setMarkedText('7', 0, 1);
49 textInputController.setMarkedText('', 0, 0);
50 55
51 // Case 3: Insert a text without composition. 56 // Case 4: Compose a text and commit it by removing the mark.
52 textInputController.insertText('8'); 57 textInputController.setMarkedText('9', 0, 1);
58 textInputController.unmarkText();
53 59
54 // Case 4: Compose a text and commit it by removing the mark. 60 // Case 5: Compose a text on selection and commit it.
55 // Only Mac and Chromium ports support unmarkText. 61 test.value = 'I have a pen';
56 if (textInputController.unmarkText) { 62 test.selectionStart = 2;
57 textInputController.setMarkedText('9', 0, 1); 63 test.selectionEnd = 6;
58 textInputController.unmarkText(); 64 textInputController.setMarkedText('lost', 0, 1);
59 } 65 textInputController.insertText('made');
tkent 2013/07/01 05:41:30 This line use '
60 66 shouldBeEqualToString("test.value", "I made a pen");
tkent 2013/07/01 05:41:30 This line use "
61 // Case 5: Compose a text on selection and commit it.
62 test.value = 'I have a pen';
63 test.selectionStart = 2;
64 test.selectionEnd = 6;
65 textInputController.setMarkedText('lost', 0, 1);
66 textInputController.insertText('made');
67 if (test.value == 'I made a pen') {
68 log('SUCCESS: ' + test.value);
69 } else {
70 log('FAILURE: ' + test.value + ' is not "I made a pen".');
71 }
72 }
73 </script> 67 </script>
68 <script src="../js/resources/js-test-post.js"></script>
74 </body> 69 </body>
75 </html> 70 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/events/ime-composition-events-001-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698