editor/libeditor/base/tests/test_bug646194.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/editor/libeditor/base/tests/test_bug646194.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,63 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<?xml-stylesheet href="chrome://global/skin"
     1.6 +                 type="text/css"?>
     1.7 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
     1.8 +                 type="text/css"?>
     1.9 +<!--
    1.10 +https://bugzilla.mozilla.org/show_bug.cgi?id=646194
    1.11 +-->
    1.12 +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    1.13 +        title="Mozilla Bug 646194" onload="runTest();">
    1.14 +  <script type="application/javascript"
    1.15 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
    1.16 +
    1.17 +  <body xmlns="http://www.w3.org/1999/xhtml">
    1.18 +  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=646194"
    1.19 +     target="_blank">Mozilla Bug 646194</a>
    1.20 +  <p/>
    1.21 +  <iframe id="i" src="data:text/html,&lt;div contenteditable=true id=t&gt;test me now&lt;/div&gt;"/>
    1.22 +  <p/>
    1.23 +  <pre id="test">
    1.24 +  </pre>
    1.25 +  </body>
    1.26 +  <script class="testbody" type="application/javascript">
    1.27 +  <![CDATA[
    1.28 +
    1.29 +SimpleTest.expectAssertions(1);
    1.30 +
    1.31 +function runTest() {
    1.32 +  function doCommand(aCmd) {
    1.33 +    var controller = top.document.commandDispatcher
    1.34 +                     .getControllerForCommand(aCmd);
    1.35 +    ok((controller && controller.isCommandEnabled(aCmd)), "command available");
    1.36 +    controller.doCommand(aCmd);
    1.37 +  }
    1.38 +
    1.39 +  var i = document.getElementById("i");
    1.40 +  i.focus();
    1.41 +  var win = i.contentWindow;
    1.42 +  var doc = i.contentDocument;
    1.43 +  var t = doc.getElementById("t");
    1.44 +  t.focus();
    1.45 +  // put the caret at the end
    1.46 +  win.getSelection().collapse(t.firstChild, 11);
    1.47 +
    1.48 +  // Simulate pression Option+Delete on Mac
    1.49 +  // We do things this way because not every platform can invoke this
    1.50 +  // command using the available key bindings.
    1.51 +  doCommand("cmd_wordPrevious");
    1.52 +  doCommand("cmd_wordPrevious");
    1.53 +  doCommand("cmd_deleteWordBackward");
    1.54 +  doCommand("cmd_deleteWordBackward");
    1.55 +
    1.56 +  // If we reach here, we haven't crashed.  Phew!
    1.57 +  // But let's check the value too, now that we're here.
    1.58 +  is(t.textContent, "me now", "The command has worked correctly");
    1.59 +
    1.60 +  SimpleTest.finish();
    1.61 +}
    1.62 +
    1.63 +SimpleTest.waitForExplicitFinish();
    1.64 +]]>
    1.65 +</script>
    1.66 +</window>

mercurial