gecko/editor/libeditor/base/tests/test_bug646194.xul

61 lines
1.9 KiB
XML

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin"
type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=646194
-->
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="Mozilla Bug 646194" onload="runTest();">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<body xmlns="http://www.w3.org/1999/xhtml">
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=646194"
target="_blank">Mozilla Bug 646194</a>
<p/>
<iframe id="i" src="data:text/html,&lt;div contenteditable=true id=t&gt;test me now&lt;/div&gt;"/>
<p/>
<pre id="test">
</pre>
</body>
<script class="testbody" type="application/javascript">
<![CDATA[
function runTest() {
function doCommand(aCmd) {
var controller = top.document.commandDispatcher
.getControllerForCommand(aCmd);
ok((controller && controller.isCommandEnabled(aCmd)), "command available");
controller.doCommand(aCmd);
}
var i = document.getElementById("i");
i.focus();
var doc = i.contentDocument;
var t = doc.getElementById("t");
t.focus();
// put the caret at the end
getSelection().collapse(t.firstChild, 11);
// Simulate pression Option+Delete on Mac
// We do things this way because not every platform can invoke this
// command using the available key bindings.
doCommand("cmd_wordPrevious");
doCommand("cmd_wordPrevious");
doCommand("cmd_deleteWordBackward");
doCommand("cmd_deleteWordBackward");
// If we reach here, we haven't crashed. Phew!
// But let's check the value too, now that we're here.
is(t.textContent, "me now", "The command has worked correctly");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
]]>
</script>
</window>