layout/base/tests/bug613807-1.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <head>
michael@0 4 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
michael@0 5 </head>
michael@0 6 <body>
michael@0 7 <textarea id="t" rows="4" style="-moz-appearance: none"></textarea>
michael@0 8 <script>
michael@0 9 if (typeof(addLoadEvent) == 'undefined') {
michael@0 10 _newCallStack = function(path) {
michael@0 11 var rval = function () {
michael@0 12 var callStack = arguments.callee.callStack;
michael@0 13 for (var i = 0; i < callStack.length; i++) {
michael@0 14 if (callStack[i].apply(this, arguments) === false) {
michael@0 15 break;
michael@0 16 }
michael@0 17 }
michael@0 18 try {
michael@0 19 this[path] = null;
michael@0 20 } catch (e) {
michael@0 21 // pass
michael@0 22 }
michael@0 23 };
michael@0 24 rval.callStack = [];
michael@0 25 return rval;
michael@0 26 };
michael@0 27 function addLoadEvent(func) {
michael@0 28 var existing = window["onload"];
michael@0 29 var regfunc = existing;
michael@0 30 if (!(typeof(existing) == 'function'
michael@0 31 && typeof(existing.callStack) == "object"
michael@0 32 && existing.callStack !== null)) {
michael@0 33 regfunc = _newCallStack("onload");
michael@0 34 if (typeof(existing) == 'function') {
michael@0 35 regfunc.callStack.push(existing);
michael@0 36 }
michael@0 37 window["onload"] = regfunc;
michael@0 38 }
michael@0 39 regfunc.callStack.push(func);
michael@0 40 };
michael@0 41 }
michael@0 42
michael@0 43 addLoadEvent(function() {
michael@0 44 var area = document.getElementById('t');
michael@0 45 area.focus();
michael@0 46
michael@0 47 var domWindowUtils = SpecialPowers.getDOMWindowUtils(window);
michael@0 48
michael@0 49 // start composition
michael@0 50 synthesizeComposition({ type: "compositionstart" });
michael@0 51
michael@0 52 // input raw characters
michael@0 53 synthesizeComposition({ type: "compositionupdate", data: "\u306D" });
michael@0 54 synthesizeText(
michael@0 55 { composition:
michael@0 56 { string: "\u306D",
michael@0 57 clauses: [
michael@0 58 { length: 1, attr: domWindowUtils.COMPOSITION_ATTR_RAWINPUT }
michael@0 59 ]
michael@0 60 },
michael@0 61 caret: { start: 1, length: 0 }
michael@0 62 });
michael@0 63 synthesizeComposition({ type: "compositionupdate", data: "\u306D\u3053" });
michael@0 64 synthesizeText(
michael@0 65 { composition:
michael@0 66 { string: "\u306D\u3053",
michael@0 67 clauses: [
michael@0 68 { length: 2, attr: domWindowUtils.COMPOSITION_ATTR_RAWINPUT }
michael@0 69 ]
michael@0 70 },
michael@0 71 caret: { start: 2, length: 0 }
michael@0 72 });
michael@0 73
michael@0 74 // convert
michael@0 75 synthesizeComposition({ type: "compositionupdate", data: "\u732B" });
michael@0 76 synthesizeText(
michael@0 77 { composition:
michael@0 78 { string: "\u732B",
michael@0 79 clauses: [
michael@0 80 { length: 1, attr: domWindowUtils.COMPOSITION_ATTR_SELECTEDCONVERTEDTEXT }
michael@0 81 ]
michael@0 82 },
michael@0 83 caret: { start: 1, length: 0 }
michael@0 84 });
michael@0 85
michael@0 86 // commit
michael@0 87 synthesizeText(
michael@0 88 { composition:
michael@0 89 { string: "\u732B",
michael@0 90 clauses: [
michael@0 91 { length: 0, attr: 0 }
michael@0 92 ]
michael@0 93 },
michael@0 94 caret: { start: 1, length: 0 }
michael@0 95 });
michael@0 96
michael@0 97 // end composition
michael@0 98 synthesizeComposition({ type: "compositionend", data: "\u732B" });
michael@0 99
michael@0 100 document.body.clientWidth;
michael@0 101
michael@0 102 // undo
michael@0 103 synthesizeKey("Z", {accelKey: true});
michael@0 104 });
michael@0 105 </script>
michael@0 106 </body>
michael@0 107 </html>

mercurial