accessible/tests/mochitest/test_bug429285.html
author Jason Evans <jasone@canonware.com>
Fri, 20 Jun 2008 10:29:43 -0700
changeset 15456 38972d94e6312cca26dc09bb1d8ac4a9bec84b1c
parent 15374 583509de7d02de30a1cab2b5ae335bd7afa8fe16
child 21256 ed2e583d9edfdc6844869bb96f3bd0d636f3f3b2
permissions -rw-r--r--
Bug 431743: Upstream jemalloc fixes, r=benjamin Incorporate upstream jemalloc fixes from FreeBSD: * Detect overflow for huge allocations via sbrk(2). * Fix deadlock for base (internal) allocations in OOM case. * Fix bitmap vector initialization for small allocation runs.

<!DOCTYPE html>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=429285
-->
<head>
  <title>Propagate aria-disabled state to descendants chrome tests</title>
  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />

  <script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>

  <script type="application/javascript">
    // Mapping needed state flags for easier handling.
    const state_disabled = 
          Components.interfaces.nsIAccessibleStates.STATE_UNAVAILABLE;
    const state_focusable = 
          Components.interfaces.nsIAccessibleStates.STATE_FOCUSABLE;

    const nsIAccessibleRetrieval = Components.interfaces.nsIAccessibleRetrieval;
    const nsIAccessible = Components.interfaces.nsIAccessible;

    var gAccRetrieval = null;

    function testChildren(aID, aAcc)
    {
      // Check state of aAcc first.
      var state = {}, extraState = {};
      aAcc.getFinalState(state, extraState);
      if (state.value & state_focusable) {
        is(state.value & state_disabled, state_disabled,
           "Wrong disabled state bit for " + aID + "!");
      }

      // Iterate over its children to see if they are disabled, too.
      var children = null;
      try {
        children = aAcc.children;
      } catch(e) {}
      ok(children, "Could not get children for " + aID +"!");

      if (children) {
        for (var i=0; i<children.length; i++) {
          var childAcc = children.queryElementAt(i, nsIAccessible);
          // Test and recurse over its children as well.
          testChildren(childAcc.name, childAcc);
        }
      }
    }

    function doTest()
    {
      gAccRetrieval = Components.classes["@mozilla.org/accessibleRetrieval;1"].
                      getService(nsIAccessibleRetrieval);

      var groupItem = document.getElementById("group");
      var groupAcc = null;
      try {
        groupAcc = gAccRetrieval.getAccessibleFor(groupItem);
      } catch (e) {}
      ok (groupAcc,
          "No accessible for group element!");

      if (groupAcc) {
        var state = {}, extraState = {};
        groupAcc.getFinalState(state, extraState);
        is(state.value & state_disabled, state_disabled,
          "Wrong disabled state bit for Group element!");
        testChildren("group", groupAcc);
      }
      SimpleTest.finish();
    }

    SimpleTest.waitForExplicitFinish();
    addLoadEvent(doTest);
  </script>
</head>
<body>

  <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=429285"
     title="Propagate aria-disabled to descendants">
    Mozilla Bug 429285
  </a>
  <p id="display"></p>
  <div id="content" style="display: none"></div>
  <pre id="test">
  </pre>

  <div id="group" role="group" aria-disabled="true">
    <button>hi</button>
    <div tabindex="0" role="listbox" aria-activedescendant="item1">
      <div role="option" id="item1">Item 1</div>
      <div role="option" id="item2">Item 2</div>
      <div role="option" id="item3">Item 3</div>
      <div role="option" id="item4">Item 4</div>
    </div>
    <div role="slider" tabindex="0">A slider</div>
  </div>
</body>
</html>