accessible/tests/mochitest/events/test_fromUserInput.html

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.

     1 <html>
     3 <head>
     4   <title>Testing of isFromUserInput in text events</title>
     6   <link rel="stylesheet" type="text/css"
     7         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
     9   <script type="application/javascript"
    10           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    11   <script type="application/javascript"
    12           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
    14   <script type="application/javascript"
    15           src="../common.js"></script>
    16   <script type="application/javascript"
    17           src="../events.js"></script>
    19   <script type="application/javascript">
    21     /**
    22      * Remove text data from HTML input.
    23      */
    24     function removeTextFromInput(aID, aStart, aEnd, aText, aFromUser)
    25     {
    26       this.DOMNode = getNode(aID);
    28       this.eventSeq = [
    29         new textChangeChecker(aID, aStart, aEnd, aText, false, aFromUser)
    30       ];
    32       this.invoke = function removeTextFromInput_invoke()
    33       {
    34         const nsIDOMNSEditableElement =
    35           Components.interfaces.nsIDOMNSEditableElement;
    37         this.DOMNode.focus();
    38         this.DOMNode.setSelectionRange(aStart, aEnd);
    40         synthesizeKey("VK_DELETE", {});
    41       }
    43       this.getID = function removeTextFromInput_getID()
    44       {
    45         return "Remove text from " + aStart + " to " + aEnd + " for " +
    46           prettyName(aID);
    47       }
    48     }
    50     /**
    51      * Remove text data from text node.
    52      */
    53     function removeTextFromContentEditable(aID, aStart, aEnd, aText, aFromUser)
    54     {
    55       this.DOMNode = getNode(aID);
    57       this.eventSeq = [
    58         new textChangeChecker(aID, aStart, aEnd, aText, false, aFromUser)
    59       ];
    61       this.invoke = function removeTextFromContentEditable_invoke()
    62       {
    63         const nsIDOMNSEditableElement =
    64           Components.interfaces.nsIDOMNSEditableElement;
    66         this.DOMNode.focus();
    67         this.textNode = getNode(aID).firstChild;
    68         var selection = window.getSelection();
    69         var range = document.createRange();
    70         range.setStart(this.textNode, aStart);
    71         range.setEnd(this.textNode, aEnd);
    72         selection.addRange(range);
    74         synthesizeKey("VK_DELETE", {});
    75       }
    77       this.getID = function removeTextFromContentEditable_getID()
    78       {
    79         return "Remove text from " + aStart + " to " + aEnd + " for " +
    80           prettyName(aID);
    81       }
    82     }
    84     ////////////////////////////////////////////////////////////////////////////
    85     // Do tests
    86     // gA11yEventDumpID = "eventdump"; // debug stuff
    88     var gQueue = null;
    90     function doTests()
    91     {
    92       gQueue = new eventQueue();
    94       // Focused editable text node
    95       gQueue.push(new removeTextFromContentEditable("div", 0, 3, "hel", true));
    97       // Focused editable HTML input
    98       gQueue.push(new removeTextFromInput("input", 1, 2, "n", true));
   100       gQueue.invoke(); // Will call SimpleTest.finish()
   101     }
   103     SimpleTest.waitForExplicitFinish();
   104     addA11yLoadEvent(doTests);
   106   </script>
   107 </head>
   110 <body>
   111   <a target="_blank"
   112      href="https://bugzilla.mozilla.org/show_bug.cgi?id=686909"
   113      title="isFromUserInput flag on accessible text change events not correct">
   114     Mozilla Bug 686909
   115   </a>
   117   <p id="display"></p>
   118   <div id="content" style="display: none"></div>
   119   <pre id="test"></pre>
   120   <div id="eventdump"></div>
   122   <div id="div" contentEditable="true">hello</div>
   123   <input id="input" value="input">
   125 </body>
   127 </html>

mercurial