accessible/tests/mochitest/events/test_textattrchange.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>Text attribute changed event for misspelled text</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="../role.js"></script>
    18   <script type="application/javascript"
    19           src="../states.js"></script>
    20   <script type="application/javascript"
    21           src="../events.js"></script>
    22   <script type="application/javascript"
    23           src="../attributes.js"></script>
    25   <script type="application/javascript">
    27     const nsIDOMNSEditableElement =
    28       Components.interfaces.nsIDOMNSEditableElement;
    30     Components.utils.import("resource://gre/modules/InlineSpellChecker.jsm");
    32     function spelledTextInvoker(aID)
    33     {
    34       this.DOMNode = getNode(aID);
    36       this.eventSeq = [
    37         new invokerChecker(EVENT_TEXT_ATTRIBUTE_CHANGED, this.DOMNode)
    38       ];
    40       this.invoke = function spelledTextInvoker_invoke()
    41       {
    42         var editor = this.DOMNode.QueryInterface(nsIDOMNSEditableElement).editor;
    43         var spellChecker = new InlineSpellChecker(editor);
    44         spellChecker.enabled = true;
    46         //var spellchecker = editor.getInlineSpellChecker(true);
    47         //spellchecker.enableRealTimeSpell = true;
    49         this.DOMNode.value = "valid text inalid tixt";
    50       }
    52       this.finalCheck = function spelledTextInvoker_finalCheck()
    53       {
    54         var defAttrs = buildDefaultTextAttrs(this.DOMNode, kInputFontSize,
    55                                              kNormalFontWeight,
    56                                              kInputFontFamily);
    57         testDefaultTextAttrs(aID, defAttrs);
    59         var attrs = { };
    60         var misspelledAttrs = {
    61           "invalid": "spelling"
    62         };
    64         testTextAttrs(aID, 0, attrs, defAttrs, 0, 11);
    65         testTextAttrs(aID, 11, misspelledAttrs, defAttrs, 11, 17);
    66         testTextAttrs(aID, 17, attrs, defAttrs, 17, 18);
    67         testTextAttrs(aID, 18, misspelledAttrs, defAttrs, 18, 22);
    68       }
    70       this.getID = function spelledTextInvoker_getID()
    71       {
    72         return "text attribute change for misspelled text";
    73       }
    74     }
    76     /**
    77      * Do tests.
    78      */
    79     //gA11yEventDumpID = "eventdump"; // debug stuff
    80     //gA11yEventDumpToConsole = true;
    82     var gQueue = null;
    83     function doTests()
    84     {
    85       // Synth focus before spellchecking turning on to make sure editor
    86       // gets a time for initialization.
    88       gQueue = new eventQueue();
    89       gQueue.push(new synthFocus("input"));
    90       gQueue.push(new spelledTextInvoker("input"));
    91       gQueue.invoke(); // Will call SimpleTest.finish();
    92     }
    94     SimpleTest.waitForExplicitFinish();
    95     addA11yLoadEvent(doTests);
    96   </script>
    97 </head>
    99 <body>
   101   <a target="_blank"
   102      href="https://bugzilla.mozilla.org/show_bug.cgi?id=345759"
   103      title="Implement text attributes">
   104     Mozilla Bug 345759
   105   </a>
   106   <p id="display"></p>
   107   <div id="content" style="display: none"></div>
   108   <pre id="test">
   109   </pre>
   111   <input id="input"/>
   113   <div id="eventdump"></div>
   114 </body>
   115 </html>

mercurial