accessible/tests/mochitest/events/test_aria_statechange.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/tests/mochitest/events/test_aria_statechange.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,190 @@
     1.4 +<html>
     1.5 +
     1.6 +<head>
     1.7 +  <title>ARIA state change event testing</title>
     1.8 +
     1.9 +  <link rel="stylesheet" type="text/css"
    1.10 +        href="chrome://mochikit/content/tests/SimpleTest/test.css" />
    1.11 +
    1.12 +  <script type="application/javascript"
    1.13 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.14 +
    1.15 +  <script type="application/javascript"
    1.16 +          src="../common.js"></script>
    1.17 +  <script type="application/javascript"
    1.18 +          src="../role.js"></script>
    1.19 +  <script type="application/javascript"
    1.20 +          src="../states.js"></script>
    1.21 +  <script type="application/javascript"
    1.22 +          src="../events.js"></script>
    1.23 +
    1.24 +  <script type="application/javascript">
    1.25 +
    1.26 +
    1.27 +    /**
    1.28 +     * Do tests.
    1.29 +     */
    1.30 +    var gQueue = null;
    1.31 +
    1.32 +    //gA11yEventDumpID = "eventdump"; // debugging
    1.33 +    //gA11yEventDumpToConsole = true; // debugging
    1.34 +
    1.35 +    function expandNode(aID, aIsExpanded)
    1.36 +    {
    1.37 +      this.DOMNode = getNode(aID);
    1.38 +
    1.39 +      this.eventSeq = [
    1.40 +        new expandedStateChecker(aIsExpanded, this.DOMNode)
    1.41 +      ];
    1.42 +
    1.43 +      this.invoke = function expandNode_invoke()
    1.44 +      {
    1.45 +        this.DOMNode.setAttribute("aria-expanded",
    1.46 +                                  (aIsExpanded ? "true" : "false"));
    1.47 +      };
    1.48 +
    1.49 +      this.getID = function expandNode_getID()
    1.50 +      {
    1.51 +        return prettyName(aID) + " aria-expanded changed to '" + aIsExpanded + "'";
    1.52 +      };
    1.53 +    }
    1.54 +
    1.55 +    function busyify(aID, aIsBusy)
    1.56 +    {
    1.57 +      this.DOMNode = getNode(aID);
    1.58 +
    1.59 +      this.eventSeq = [
    1.60 +        new stateChangeChecker(STATE_BUSY, kOrdinalState, aIsBusy, this.DOMNode)
    1.61 +      ];
    1.62 +
    1.63 +      this.invoke = function busyify_invoke()
    1.64 +      {
    1.65 +        this.DOMNode.setAttribute("aria-busy", (aIsBusy ? "true" : "false"));
    1.66 +      };
    1.67 +
    1.68 +      this.getID = function busyify_getID()
    1.69 +      {
    1.70 +        return prettyName(aID) + " aria-busy changed to '" + aIsBusy + "'";
    1.71 +      };
    1.72 +    }
    1.73 +
    1.74 +    function setAttrOfMixedType(aID, aAttr, aState, aValue)
    1.75 +    {
    1.76 +      this.DOMNode = getNode(aID);
    1.77 +
    1.78 +      this.eventSeq = [
    1.79 +        new stateChangeChecker(aState, kOrdinalState,
    1.80 +                               aValue == "true", this.DOMNode)
    1.81 +      ];
    1.82 +
    1.83 +      if (hasState(aID, STATE_MIXED) || aValue == "mixed") {
    1.84 +        this.eventSeq.push(
    1.85 +          new stateChangeChecker(STATE_MIXED, kOrdinalState,
    1.86 +                                 aValue == "mixed", this.DOMNode)
    1.87 +        );
    1.88 +      }
    1.89 +
    1.90 +      this.invoke = function setAttrOfMixedType_invoke()
    1.91 +      {
    1.92 +        this.DOMNode.setAttribute(aAttr, aValue);
    1.93 +      };
    1.94 +
    1.95 +      this.getID = function setAttrOfMixedType_getID()
    1.96 +      {
    1.97 +        return prettyName(aID) + " " + aAttr + " changed to '" + aValue + "'";
    1.98 +      };
    1.99 +    }
   1.100 +
   1.101 +    function setPressed(aID, aValue)
   1.102 +    {
   1.103 +      this.__proto__ =
   1.104 +        new setAttrOfMixedType(aID, "aria-pressed", STATE_PRESSED, aValue);
   1.105 +    }
   1.106 +
   1.107 +    function setChecked(aID, aValue)
   1.108 +    {
   1.109 +      this.__proto__ =
   1.110 +        new setAttrOfMixedType(aID, "aria-checked", STATE_CHECKED, aValue);
   1.111 +    }
   1.112 +
   1.113 +    function buildQueueForAttrOfMixedType(aQueue, aID, aInvokerFunc)
   1.114 +    {
   1.115 +      var list = [ "", "undefined", "false", "true", "mixed" ];
   1.116 +      for (var i = 0; i < list.length; i++) {
   1.117 +        for (var j = i + 1; j < list.length; j++) {
   1.118 +          // XXX: changes from/to "undefined"/"" shouldn't fire state change
   1.119 +          // events, bug 472142.
   1.120 +          aQueue.push(new aInvokerFunc(aID, list[i]));
   1.121 +          aQueue.push(new aInvokerFunc(aID, list[j]));
   1.122 +        }
   1.123 +      }
   1.124 +    }
   1.125 +
   1.126 +    function doTests()
   1.127 +    {
   1.128 +      gQueue = new eventQueue();
   1.129 +
   1.130 +      gQueue.push(new expandNode("section", true));
   1.131 +      gQueue.push(new expandNode("section", false));
   1.132 +      gQueue.push(new expandNode("div", true));
   1.133 +      gQueue.push(new expandNode("div", false));
   1.134 +
   1.135 +      gQueue.push(new busyify("aria_doc", true));
   1.136 +      gQueue.push(new busyify("aria_doc", false));
   1.137 +
   1.138 +      buildQueueForAttrOfMixedType(gQueue, "pressable", setPressed);
   1.139 +      buildQueueForAttrOfMixedType(gQueue, "pressable_native", setPressed);
   1.140 +      buildQueueForAttrOfMixedType(gQueue, "checkable", setChecked);
   1.141 +
   1.142 +      gQueue.invoke(); // Will call SimpleTest.finish();
   1.143 +    }
   1.144 +
   1.145 +    SimpleTest.waitForExplicitFinish();
   1.146 +    addA11yLoadEvent(doTests);
   1.147 +  </script>
   1.148 +</head>
   1.149 +
   1.150 +<body>
   1.151 +
   1.152 +  <a target="_blank"
   1.153 +     href="https://bugzilla.mozilla.org/show_bug.cgi?id=551684"
   1.154 +     title="No statechange event for aria-expanded on native HTML elements, is fired on ARIA widgets">
   1.155 +    Mozilla Bug 551684
   1.156 +  </a><br>
   1.157 +  <a target="_blank"
   1.158 +     href="https://bugzilla.mozilla.org/show_bug.cgi?id=648133"
   1.159 +     title="fire state change event for aria-busy"
   1.160 +    Mozilla Bug 648133
   1.161 +  </a><br>
   1.162 +  <a target="_blank"
   1.163 +     href="https://bugzilla.mozilla.org/show_bug.cgi?id=467143"
   1.164 +     title="mixed state change event is fired for focused accessible only"
   1.165 +    Mozilla Bug 467143
   1.166 +  </a>
   1.167 +  <a target="_blank"
   1.168 +     href="https://bugzilla.mozilla.org/show_bug.cgi?id=989958"
   1.169 +     title="Pressed state is not exposed on a button element with aria-pressed attribute"
   1.170 +    Mozilla Bug 989958
   1.171 +  </a>
   1.172 +
   1.173 +  <p id="display"></p>
   1.174 +  <div id="content" style="display: none"></div>
   1.175 +  <pre id="test">
   1.176 +  </pre>
   1.177 +  <div id="eventdump"></div>
   1.178 +
   1.179 +  <!-- aria-expanded -->
   1.180 +  <div id="section" role="section" aria-expanded="false">expandable section</div>
   1.181 +  <div id="div" aria-expanded="false">expandable native div</div>
   1.182 +
   1.183 +  <!-- aria-busy -->
   1.184 +  <div id="aria_doc" role="document" tabindex="0">A document</div>
   1.185 +
   1.186 +  <!-- aria-pressed -->
   1.187 +  <div id="pressable" role="button"></div>
   1.188 +  <button id="pressable_native"></button>
   1.189 +
   1.190 +  <!-- aria-checked -->
   1.191 +  <div id="checkable" role="checkbox"></div>
   1.192 +</body>
   1.193 +</html>

mercurial