mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-01 14:45:29 +00:00
108 lines
2.7 KiB
HTML
108 lines
2.7 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
|
</head>
|
|
<body>
|
|
<textarea id="t" rows="4"></textarea>
|
|
<script>
|
|
if (typeof(addLoadEvent) == 'undefined') {
|
|
_newCallStack = function(path) {
|
|
var rval = function () {
|
|
var callStack = arguments.callee.callStack;
|
|
for (var i = 0; i < callStack.length; i++) {
|
|
if (callStack[i].apply(this, arguments) === false) {
|
|
break;
|
|
}
|
|
}
|
|
try {
|
|
this[path] = null;
|
|
} catch (e) {
|
|
// pass
|
|
}
|
|
};
|
|
rval.callStack = [];
|
|
return rval;
|
|
};
|
|
function addLoadEvent(func) {
|
|
var existing = window["onload"];
|
|
var regfunc = existing;
|
|
if (!(typeof(existing) == 'function'
|
|
&& typeof(existing.callStack) == "object"
|
|
&& existing.callStack !== null)) {
|
|
regfunc = _newCallStack("onload");
|
|
if (typeof(existing) == 'function') {
|
|
regfunc.callStack.push(existing);
|
|
}
|
|
window["onload"] = regfunc;
|
|
}
|
|
regfunc.callStack.push(func);
|
|
};
|
|
}
|
|
|
|
addLoadEvent(function() {
|
|
var area = document.getElementById('t');
|
|
area.focus();
|
|
|
|
var domWindowUtils = SpecialPowers.getDOMWindowUtils(window);
|
|
|
|
// start composition
|
|
synthesizeComposition({ type: "compositionstart" });
|
|
|
|
// input raw characters
|
|
synthesizeComposition({ type: "compositionupdate", data: "\u306D" });
|
|
synthesizeText(
|
|
{ composition:
|
|
{ string: "\u306D",
|
|
clauses: [
|
|
{ length: 1, attr: domWindowUtils.COMPOSITION_ATTR_RAWINPUT }
|
|
]
|
|
},
|
|
caret: { start: 1, length: 0 }
|
|
});
|
|
synthesizeComposition({ type: "compositionupdate", data: "\u306D\u3053" });
|
|
synthesizeText(
|
|
{ composition:
|
|
{ string: "\u306D\u3053",
|
|
clauses: [
|
|
{ length: 2, attr: domWindowUtils.COMPOSITION_ATTR_RAWINPUT }
|
|
]
|
|
},
|
|
caret: { start: 2, length: 0 }
|
|
});
|
|
|
|
// convert
|
|
synthesizeComposition({ type: "compositionupdate", data: "\u732B" });
|
|
synthesizeText(
|
|
{ composition:
|
|
{ string: "\u732B",
|
|
clauses: [
|
|
{ length: 1, attr: domWindowUtils.COMPOSITION_ATTR_SELECTEDCONVERTEDTEXT }
|
|
]
|
|
},
|
|
caret: { start: 1, length: 0 }
|
|
});
|
|
|
|
// commit
|
|
synthesizeText(
|
|
{ composition:
|
|
{ string: "\u732B",
|
|
clauses: [
|
|
{ length: 0, attr: 0 }
|
|
]
|
|
},
|
|
caret: { start: 1, length: 0 }
|
|
});
|
|
|
|
// end composition
|
|
synthesizeComposition({ type: "compositionend", data: "\u732B" });
|
|
|
|
document.body.clientWidth;
|
|
|
|
// undo
|
|
synthesizeKey("Z", {accelKey: true});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|