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

Unified 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: Fix quotation fix leaks;( Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/events/ime-composition-events-001-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/events/ime-composition-events-001.html
diff --git a/LayoutTests/fast/events/ime-composition-events-001.html b/LayoutTests/fast/events/ime-composition-events-001.html
index 1a5e59625fcdc3b5791e6babe3c3be81efd5125e..209bf56c0dd8bc01beeae2249c65204734060c53 100644
--- a/LayoutTests/fast/events/ime-composition-events-001.html
+++ b/LayoutTests/fast/events/ime-composition-events-001.html
@@ -1,75 +1,70 @@
<html>
<head>
-<title></title>
+<script src="../js/resources/js-test-pre.js"></script>
</head>
<body>
-<p>This tests that calling input-method functions sends Composition Events and Text Events introduced in DOM Level 3.</p>
-<p>To test manually, enable an IME, input CJK characters, and see this page doesn't show 'FAILED' lines.</p>
-<input id="test" type="text"/>
-<ul id="console"></ul>
-<script language="javascript" type="text/javascript">
-function log(str) {
- var li = document.createElement('li');
- li.appendChild(document.createTextNode(str));
- var console = document.getElementById('console');
- console.appendChild(li);
+<input id="test" type="text">
+<script>
+description('This tests that calling input-method functions sends Composition Events and Text Events introduced in DOM Level 3. ' +
+'To test manually, enable an IME, input CJK characters, and see this page doesn\'t show \'FAIL\' lines.');
+</script>
+<script>
+function logCompositionStart(event) {
+ shouldBeEqualToString('event.type', 'compositionstart');
+ testPassed('event.data is "' + event.data + '"');
+}
+
+function logCompositionUpdate(event) {
+ shouldBeEqualToString('event.type', 'compositionupdate');
+ testPassed('event.data is "' + event.data + '"');
}
-function logEvent(e) {
- var target = e.target;
- var type = e.type;
- if (e.type == 'compositionstart' || e.type == 'compositionupdate' || e.type == 'compositionend' || e.type == 'textInput')
- log('SUCCESS: ' + target.tagName + ' - ' + e.type + ' - "' + e.data + '"');
- else
- log('FAILED: ' + target.tagName + ' - ' + e.type + ' - "' + e.data + '"');
+function logCompositionEnd(event) {
+ shouldBeEqualToString('event.type', 'compositionend');
+ testPassed('event.data is "' + event.data + '"');
+}
+
+function logTextInput(event) {
+ shouldBeEqualToString('event.type', 'textInput');
+ testPassed('event.data is "' + event.data + '"');
}
var test = document.getElementById('test');
test.focus();
-if (window.testRunner) {
- testRunner.dumpAsText();
-
- // Add event listeners to the <input> node.
- test.addEventListener("compositionstart", logEvent, false);
- test.addEventListener("compositionupdate", logEvent, false);
- test.addEventListener("compositionend", logEvent, false);
- test.addEventListener("textInput", logEvent, false);
+// Add event listeners to the <input> node.
+test.addEventListener('compositionstart', logCompositionStart, false);
+test.addEventListener('compositionupdate', logCompositionUpdate, false);
+test.addEventListener('compositionend', logCompositionEnd, false);
+test.addEventListener('textInput', logTextInput, false);
- // Case 1: Compose a text and commit it.
- textInputController.setMarkedText('1', 0, 1);
- textInputController.setMarkedText('2', 0, 1);
- textInputController.setMarkedText('3', 0, 1);
- textInputController.insertText('4');
+// Case 1: Compose a text and commit it.
+textInputController.setMarkedText('1', 0, 1);
+textInputController.setMarkedText('2', 0, 1);
+textInputController.setMarkedText('3', 0, 1);
+textInputController.insertText('4');
- // Case 2: Compose a text but cancel it.
- textInputController.setMarkedText('5', 0, 1);
- textInputController.setMarkedText('6', 0, 1);
- textInputController.setMarkedText('7', 0, 1);
- textInputController.setMarkedText('', 0, 0);
+// Case 2: Compose a text but cancel it.
+textInputController.setMarkedText('5', 0, 1);
+textInputController.setMarkedText('6', 0, 1);
+textInputController.setMarkedText('7', 0, 1);
+textInputController.setMarkedText('', 0, 0);
- // Case 3: Insert a text without composition.
- textInputController.insertText('8');
+// Case 3: Insert a text without composition.
+textInputController.insertText('8');
- // Case 4: Compose a text and commit it by removing the mark.
- // Only Mac and Chromium ports support unmarkText.
- if (textInputController.unmarkText) {
- textInputController.setMarkedText('9', 0, 1);
- textInputController.unmarkText();
- }
+// Case 4: Compose a text and commit it by removing the mark.
+textInputController.setMarkedText('9', 0, 1);
+textInputController.unmarkText();
- // Case 5: Compose a text on selection and commit it.
- test.value = 'I have a pen';
- test.selectionStart = 2;
- test.selectionEnd = 6;
- textInputController.setMarkedText('lost', 0, 1);
- textInputController.insertText('made');
- if (test.value == 'I made a pen') {
- log('SUCCESS: ' + test.value);
- } else {
- log('FAILURE: ' + test.value + ' is not "I made a pen".');
- }
-}
+// Case 5: Compose a text on selection and commit it.
+test.value = 'I have a pen';
+test.selectionStart = 2;
+test.selectionEnd = 6;
+textInputController.setMarkedText('lost', 0, 1);
+textInputController.insertText('made');
+shouldBeEqualToString('test.value', 'I made a pen');
</script>
+<script src="../js/resources/js-test-post.js"></script>
</body>
</html>
« 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