editor/libeditor/base/tests/test_bug646194.xul

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <?xml version="1.0"?>
michael@0 2 <?xml-stylesheet href="chrome://global/skin"
michael@0 3 type="text/css"?>
michael@0 4 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
michael@0 5 type="text/css"?>
michael@0 6 <!--
michael@0 7 https://bugzilla.mozilla.org/show_bug.cgi?id=646194
michael@0 8 -->
michael@0 9 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
michael@0 10 title="Mozilla Bug 646194" onload="runTest();">
michael@0 11 <script type="application/javascript"
michael@0 12 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
michael@0 13
michael@0 14 <body xmlns="http://www.w3.org/1999/xhtml">
michael@0 15 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=646194"
michael@0 16 target="_blank">Mozilla Bug 646194</a>
michael@0 17 <p/>
michael@0 18 <iframe id="i" src="data:text/html,&lt;div contenteditable=true id=t&gt;test me now&lt;/div&gt;"/>
michael@0 19 <p/>
michael@0 20 <pre id="test">
michael@0 21 </pre>
michael@0 22 </body>
michael@0 23 <script class="testbody" type="application/javascript">
michael@0 24 <![CDATA[
michael@0 25
michael@0 26 SimpleTest.expectAssertions(1);
michael@0 27
michael@0 28 function runTest() {
michael@0 29 function doCommand(aCmd) {
michael@0 30 var controller = top.document.commandDispatcher
michael@0 31 .getControllerForCommand(aCmd);
michael@0 32 ok((controller && controller.isCommandEnabled(aCmd)), "command available");
michael@0 33 controller.doCommand(aCmd);
michael@0 34 }
michael@0 35
michael@0 36 var i = document.getElementById("i");
michael@0 37 i.focus();
michael@0 38 var win = i.contentWindow;
michael@0 39 var doc = i.contentDocument;
michael@0 40 var t = doc.getElementById("t");
michael@0 41 t.focus();
michael@0 42 // put the caret at the end
michael@0 43 win.getSelection().collapse(t.firstChild, 11);
michael@0 44
michael@0 45 // Simulate pression Option+Delete on Mac
michael@0 46 // We do things this way because not every platform can invoke this
michael@0 47 // command using the available key bindings.
michael@0 48 doCommand("cmd_wordPrevious");
michael@0 49 doCommand("cmd_wordPrevious");
michael@0 50 doCommand("cmd_deleteWordBackward");
michael@0 51 doCommand("cmd_deleteWordBackward");
michael@0 52
michael@0 53 // If we reach here, we haven't crashed. Phew!
michael@0 54 // But let's check the value too, now that we're here.
michael@0 55 is(t.textContent, "me now", "The command has worked correctly");
michael@0 56
michael@0 57 SimpleTest.finish();
michael@0 58 }
michael@0 59
michael@0 60 SimpleTest.waitForExplicitFinish();
michael@0 61 ]]>
michael@0 62 </script>
michael@0 63 </window>

mercurial