accessible/tests/mochitest/events/test_aria_statechange.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>ARIA state change event testing</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>
    12   <script type="application/javascript"
    13           src="../common.js"></script>
    14   <script type="application/javascript"
    15           src="../role.js"></script>
    16   <script type="application/javascript"
    17           src="../states.js"></script>
    18   <script type="application/javascript"
    19           src="../events.js"></script>
    21   <script type="application/javascript">
    24     /**
    25      * Do tests.
    26      */
    27     var gQueue = null;
    29     //gA11yEventDumpID = "eventdump"; // debugging
    30     //gA11yEventDumpToConsole = true; // debugging
    32     function expandNode(aID, aIsExpanded)
    33     {
    34       this.DOMNode = getNode(aID);
    36       this.eventSeq = [
    37         new expandedStateChecker(aIsExpanded, this.DOMNode)
    38       ];
    40       this.invoke = function expandNode_invoke()
    41       {
    42         this.DOMNode.setAttribute("aria-expanded",
    43                                   (aIsExpanded ? "true" : "false"));
    44       };
    46       this.getID = function expandNode_getID()
    47       {
    48         return prettyName(aID) + " aria-expanded changed to '" + aIsExpanded + "'";
    49       };
    50     }
    52     function busyify(aID, aIsBusy)
    53     {
    54       this.DOMNode = getNode(aID);
    56       this.eventSeq = [
    57         new stateChangeChecker(STATE_BUSY, kOrdinalState, aIsBusy, this.DOMNode)
    58       ];
    60       this.invoke = function busyify_invoke()
    61       {
    62         this.DOMNode.setAttribute("aria-busy", (aIsBusy ? "true" : "false"));
    63       };
    65       this.getID = function busyify_getID()
    66       {
    67         return prettyName(aID) + " aria-busy changed to '" + aIsBusy + "'";
    68       };
    69     }
    71     function setAttrOfMixedType(aID, aAttr, aState, aValue)
    72     {
    73       this.DOMNode = getNode(aID);
    75       this.eventSeq = [
    76         new stateChangeChecker(aState, kOrdinalState,
    77                                aValue == "true", this.DOMNode)
    78       ];
    80       if (hasState(aID, STATE_MIXED) || aValue == "mixed") {
    81         this.eventSeq.push(
    82           new stateChangeChecker(STATE_MIXED, kOrdinalState,
    83                                  aValue == "mixed", this.DOMNode)
    84         );
    85       }
    87       this.invoke = function setAttrOfMixedType_invoke()
    88       {
    89         this.DOMNode.setAttribute(aAttr, aValue);
    90       };
    92       this.getID = function setAttrOfMixedType_getID()
    93       {
    94         return prettyName(aID) + " " + aAttr + " changed to '" + aValue + "'";
    95       };
    96     }
    98     function setPressed(aID, aValue)
    99     {
   100       this.__proto__ =
   101         new setAttrOfMixedType(aID, "aria-pressed", STATE_PRESSED, aValue);
   102     }
   104     function setChecked(aID, aValue)
   105     {
   106       this.__proto__ =
   107         new setAttrOfMixedType(aID, "aria-checked", STATE_CHECKED, aValue);
   108     }
   110     function buildQueueForAttrOfMixedType(aQueue, aID, aInvokerFunc)
   111     {
   112       var list = [ "", "undefined", "false", "true", "mixed" ];
   113       for (var i = 0; i < list.length; i++) {
   114         for (var j = i + 1; j < list.length; j++) {
   115           // XXX: changes from/to "undefined"/"" shouldn't fire state change
   116           // events, bug 472142.
   117           aQueue.push(new aInvokerFunc(aID, list[i]));
   118           aQueue.push(new aInvokerFunc(aID, list[j]));
   119         }
   120       }
   121     }
   123     function doTests()
   124     {
   125       gQueue = new eventQueue();
   127       gQueue.push(new expandNode("section", true));
   128       gQueue.push(new expandNode("section", false));
   129       gQueue.push(new expandNode("div", true));
   130       gQueue.push(new expandNode("div", false));
   132       gQueue.push(new busyify("aria_doc", true));
   133       gQueue.push(new busyify("aria_doc", false));
   135       buildQueueForAttrOfMixedType(gQueue, "pressable", setPressed);
   136       buildQueueForAttrOfMixedType(gQueue, "pressable_native", setPressed);
   137       buildQueueForAttrOfMixedType(gQueue, "checkable", setChecked);
   139       gQueue.invoke(); // Will call SimpleTest.finish();
   140     }
   142     SimpleTest.waitForExplicitFinish();
   143     addA11yLoadEvent(doTests);
   144   </script>
   145 </head>
   147 <body>
   149   <a target="_blank"
   150      href="https://bugzilla.mozilla.org/show_bug.cgi?id=551684"
   151      title="No statechange event for aria-expanded on native HTML elements, is fired on ARIA widgets">
   152     Mozilla Bug 551684
   153   </a><br>
   154   <a target="_blank"
   155      href="https://bugzilla.mozilla.org/show_bug.cgi?id=648133"
   156      title="fire state change event for aria-busy"
   157     Mozilla Bug 648133
   158   </a><br>
   159   <a target="_blank"
   160      href="https://bugzilla.mozilla.org/show_bug.cgi?id=467143"
   161      title="mixed state change event is fired for focused accessible only"
   162     Mozilla Bug 467143
   163   </a>
   164   <a target="_blank"
   165      href="https://bugzilla.mozilla.org/show_bug.cgi?id=989958"
   166      title="Pressed state is not exposed on a button element with aria-pressed attribute"
   167     Mozilla Bug 989958
   168   </a>
   170   <p id="display"></p>
   171   <div id="content" style="display: none"></div>
   172   <pre id="test">
   173   </pre>
   174   <div id="eventdump"></div>
   176   <!-- aria-expanded -->
   177   <div id="section" role="section" aria-expanded="false">expandable section</div>
   178   <div id="div" aria-expanded="false">expandable native div</div>
   180   <!-- aria-busy -->
   181   <div id="aria_doc" role="document" tabindex="0">A document</div>
   183   <!-- aria-pressed -->
   184   <div id="pressable" role="button"></div>
   185   <button id="pressable_native"></button>
   187   <!-- aria-checked -->
   188   <div id="checkable" role="checkbox"></div>
   189 </body>
   190 </html>

mercurial