accessible/tests/mochitest/test_bug420863.html
author Jason Evans <jasone@canonware.com>
Fri, 20 Jun 2008 10:29:43 -0700
changeset 15456 38972d94e6312cca26dc09bb1d8ac4a9bec84b1c
parent 13129 c13429bf59cf446ad40aab2227d2e7052a1a8b68
child 19499 58a8c32dea84b240837b204f15083c5db0831315
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=420863
-->
<head>
  <title>Table indexes 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">
    var gAccService = null;

    var gTdClickAttr = false;
    var gTdClickEventHandler = false;
    var gClickHandler = null;

    var gID = "";
    var gNode = null;
    var gAcc = null;

    function doTest()
    {
      const nsIAccessibleRetrieval =
        Components.interfaces.nsIAccessibleRetrieval;

      gAccService = Components.classes["@mozilla.org/accessibleRetrieval;1"].
                    getService(nsIAccessibleRetrieval);

      // Actions should be exposed on any accessible having related DOM node
      // with registered 'click' event handler.

      //////////////////////////////////////////////////////////////////////////
      // generic td
      gID = "td1";
      gNode = document.getElementById(gID);
      gAcc = gAccService.getAccessibleFor(gNode);

      is(gAcc.numActions, 0, gID + ": shouldn't have actions");

      //////////////////////////////////////////////////////////////////////////
      // td with 'onclick' attribute
      gID = "td2";
      gNode = document.getElementById(gID);
      gAcc = gAccService.getAccessibleFor(gNode);

      is(gAcc.numActions, 1, gID + ": should have one action");
      is(gAcc.getActionName(0), "click", gID + ": should have 'click' action");
      gAcc.doAction(0);

      // actions are performed via timeout
      window.setTimeout(doTest2, 0);
    }

    function doTest2()
    {
      //////////////////////////////////////////////////////////////////////////
      // td with 'onclick' attribute (sequel, see doTest1())
      ok(gTdClickAttr, gID + ": 'click' action hasn't been performed");

      //////////////////////////////////////////////////////////////////////////
      // td with registered 'click' event handler
      gID = "td3";
      gNode = document.getElementById(gID);
      gAcc = gAccService.getAccessibleFor(gNode);

      // register 'click' event handler
      gClickHandler = {
        handleEvent: function handleEvent(aEvent)
        {
          gTdClickEventHandler = true;
        }
      };
      gNode.addEventListener("click", gClickHandler, false);

      // check actions
      is(gAcc.numActions, 1, gID + ": should have one action");
      is(gAcc.getActionName(0), "click", gID + ": should have 'click' action");
      gAcc.doAction(0);

      // actions are performed via timeout
      window.setTimeout(doTest3, 0);
    }

    function doTest3()
    {
      //////////////////////////////////////////////////////////////////////////
      // td with registered 'click' event handler (sequel, see doTest2())
      ok(gTdClickEventHandler, gID + ": 'click' action hasn't been performed");

      // unregister click event handler
      gNode.removeEventListener("click", gClickHandler, false);

      // check actions
      is(gAcc.numActions, 0, gID + ": shouldn't have actions");

      SimpleTest.finish();
    }

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

  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=420863"
     title="If an HTML element has an onClick attribute, expose its click action on the element rather than its child text leaf node."
     target="_blank">Mozilla Bug 420863</a>
  <p id="display"></p>
  <div id="content" style="display: none"></div>
  <pre id="test">
  </pre>

  <table>
    <tr>
      <td id="td1">Can't click this cell</td>
      <td onclick="gTdClickAttr = true;"
          id="td2">Cell with 'onclick' attribute</td>
      <td id="td3">Cell with registered 'click' event handler</td>
    </tr>
  </table>

</body>
</html>