layout/base/tests/bug585922.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/base/tests/bug585922.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,35 @@
     1.4 +<!DOCTYPE html>
     1.5 +<html class="reftest-wait">
     1.6 +  <head>
     1.7 +    <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
     1.8 +  </head>
     1.9 +  <body onload="doTest()">
    1.10 +    <input type=text style="-moz-appearance: none">
    1.11 +    <script>
    1.12 +      function doTest() {
    1.13 +        function enableCaret(aEnable) {
    1.14 +          var selCon = editor.selectionController;
    1.15 +          selCon.setCaretEnabled(aEnable);
    1.16 +        }
    1.17 +
    1.18 +        var d = document.querySelector("input");
    1.19 +        d.value = "a";
    1.20 +        d.focus();
    1.21 +        var editor = SpecialPowers.wrap(d).QueryInterface(SpecialPowers.Ci.nsIDOMNSEditableElement).editor;
    1.22 +        var sel = editor.selection;
    1.23 +        var t = editor.rootElement.firstChild;
    1.24 +        sel.collapse(t, 1); // put the caret at the end of the div
    1.25 +        setTimeout(function() {
    1.26 +          enableCaret(false);enableCaret(true);// force a caret display
    1.27 +          enableCaret(false); // hide the caret
    1.28 +          t.replaceData(0, 1, "b"); // replace the text node data
    1.29 +          // at this point, the selection is collapsed to offset 0
    1.30 +          synthesizeQuerySelectedText(); // call nsCaret::GetGeometry
    1.31 +          sel.collapse(t, 1); // put the caret at the end again
    1.32 +          enableCaret(true); // show the caret again
    1.33 +          document.documentElement.removeAttribute("class");
    1.34 +        }, 0);
    1.35 +      }
    1.36 +    </script>
    1.37 +  </body>
    1.38 +</html>

mercurial