Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=697842 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 697842</title> |
michael@0 | 8 | <script type="application/javascript" src="/MochiKit/packed.js"></script> |
michael@0 | 9 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 11 | <link rel="stylesheet" type="text/css" |
michael@0 | 12 | href="chrome://mochikit/content/tests/SimpleTest/test.css" /> |
michael@0 | 13 | </head> |
michael@0 | 14 | <body> |
michael@0 | 15 | <div id="display"> |
michael@0 | 16 | <p id="editor" contenteditable style="min-height: 1.5em;"></p> |
michael@0 | 17 | </div> |
michael@0 | 18 | <div id="content" style="display: none"> |
michael@0 | 19 | |
michael@0 | 20 | </div> |
michael@0 | 21 | <pre id="test"> |
michael@0 | 22 | </pre> |
michael@0 | 23 | |
michael@0 | 24 | <script class="testbody" type="application/javascript"> |
michael@0 | 25 | |
michael@0 | 26 | /** Test for Bug 697842 **/ |
michael@0 | 27 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 28 | SimpleTest.waitForFocus(runTests); |
michael@0 | 29 | |
michael@0 | 30 | function runTests() |
michael@0 | 31 | { |
michael@0 | 32 | var editor = document.getElementById("editor"); |
michael@0 | 33 | editor.focus(); |
michael@0 | 34 | |
michael@0 | 35 | SimpleTest.executeSoon(function() { |
michael@0 | 36 | var composingString = ""; |
michael@0 | 37 | |
michael@0 | 38 | function handler(aEvent) { |
michael@0 | 39 | if (aEvent.type != "text") { |
michael@0 | 40 | is(aEvent.data, composingString, "mismatch composition string"); |
michael@0 | 41 | } |
michael@0 | 42 | aEvent.stopPropagation(); |
michael@0 | 43 | aEvent.preventDefault(); |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | editor.addEventListener("compositionstart", handler, true); |
michael@0 | 47 | editor.addEventListener("compositionend", handler, true); |
michael@0 | 48 | editor.addEventListener("compositionupdate", handler, true); |
michael@0 | 49 | editor.addEventListener("text", handler, true); |
michael@0 | 50 | |
michael@0 | 51 | // start composition |
michael@0 | 52 | synthesizeComposition({ type: "compositionstart" }); |
michael@0 | 53 | |
michael@0 | 54 | // input first character |
michael@0 | 55 | composingString = "\u306B"; |
michael@0 | 56 | synthesizeComposition({ type: "compositionupdate", data: composingString }); |
michael@0 | 57 | synthesizeText( |
michael@0 | 58 | { "composition": |
michael@0 | 59 | { "string": composingString, |
michael@0 | 60 | "clauses": |
michael@0 | 61 | [ |
michael@0 | 62 | { "length": 1, "attr": COMPOSITION_ATTR_RAWINPUT } |
michael@0 | 63 | ] |
michael@0 | 64 | }, |
michael@0 | 65 | "caret": { "start": 1, "length": 0 } |
michael@0 | 66 | }); |
michael@0 | 67 | |
michael@0 | 68 | // input second character |
michael@0 | 69 | composingString = "\u306B\u3085"; |
michael@0 | 70 | synthesizeComposition({ type: "compositionupdate", data: composingString }); |
michael@0 | 71 | synthesizeText( |
michael@0 | 72 | { "composition": |
michael@0 | 73 | { "string": composingString, |
michael@0 | 74 | "clauses": |
michael@0 | 75 | [ |
michael@0 | 76 | { "length": 2, "attr": COMPOSITION_ATTR_RAWINPUT } |
michael@0 | 77 | ] |
michael@0 | 78 | }, |
michael@0 | 79 | "caret": { "start": 2, "length": 0 } |
michael@0 | 80 | }); |
michael@0 | 81 | |
michael@0 | 82 | // convert them |
michael@0 | 83 | synthesizeText( |
michael@0 | 84 | { "composition": |
michael@0 | 85 | { "string": composingString, |
michael@0 | 86 | "clauses": |
michael@0 | 87 | [ |
michael@0 | 88 | { "length": 2, |
michael@0 | 89 | "attr": COMPOSITION_ATTR_SELECTEDCONVERTEDTEXT } |
michael@0 | 90 | ] |
michael@0 | 91 | }, |
michael@0 | 92 | "caret": { "start": 2, "length": 0 } |
michael@0 | 93 | }); |
michael@0 | 94 | |
michael@0 | 95 | // commit |
michael@0 | 96 | synthesizeText( |
michael@0 | 97 | { "composition": |
michael@0 | 98 | { "string": composingString, |
michael@0 | 99 | "clauses": |
michael@0 | 100 | [ |
michael@0 | 101 | { "length": 0, "attr": 0 } |
michael@0 | 102 | ] |
michael@0 | 103 | }, |
michael@0 | 104 | "caret": { "start": 2, "length": 0 } |
michael@0 | 105 | }); |
michael@0 | 106 | |
michael@0 | 107 | synthesizeComposition({ type: "compositionend", data: composingString }); |
michael@0 | 108 | |
michael@0 | 109 | is(editor.innerHTML, composingString, |
michael@0 | 110 | "editor has unexpected result"); |
michael@0 | 111 | |
michael@0 | 112 | editor.removeEventListener("compositionstart", handler, true); |
michael@0 | 113 | editor.removeEventListener("compositionend", handler, true); |
michael@0 | 114 | editor.removeEventListener("compositionupdate", handler, true); |
michael@0 | 115 | editor.removeEventListener("text", handler, true); |
michael@0 | 116 | |
michael@0 | 117 | SimpleTest.finish(); |
michael@0 | 118 | }); |
michael@0 | 119 | } |
michael@0 | 120 | |
michael@0 | 121 | |
michael@0 | 122 | </script> |
michael@0 | 123 | </body> |
michael@0 | 124 | |
michael@0 | 125 | </html> |