accessible/tests/mochitest/states/test_link.html
author Alexander Surkov <surkov.alexander@gmail.com>
Mon, 24 Sep 2012 20:07:35 +0900
changeset 108009 e950ed8dc21fffa3198948b30732f9f94a12120f
parent 107913 a713d74f4cd2b475c1561a488da96a4a2c2ac3c0
child 109939 73ca717cde7260cd982f2249cd8fa9bfa69ede78
permissions -rw-r--r--
Bug 782991 - enable more logging of states/test_link.html

<html>

<head>
  <title>HTML link states testing</title>

  <link rel="stylesheet" type="text/css"
        href="chrome://mochikit/content/tests/SimpleTest/test.css" />

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

  <script type="application/javascript"
          src="../common.js"></script>
  <script type="application/javascript"
          src="../role.js"></script>
  <script type="application/javascript"
          src="../states.js"></script>
  <script type="application/javascript"
          src="../events.js"></script>

  <script type="application/javascript">
    gA11yEventDumpToConsole = true; // debug stuff

    function doTest()
    {
      // a@href and its text node
      testStates("link_href", STATE_LINKED);
      testStates(getAccessible("link_href").firstChild, STATE_LINKED);

      // a@onclick
      testStates("link_click", STATE_LINKED);

      // a@onmousedown
      testStates("link_mousedown", STATE_LINKED);

      // a@onmouseup
      testStates("link_mouseup", STATE_LINKED);

      // a@role="link"
      testStates("link_arialink", STATE_LINKED);

      // a@role="button"
      testStates("link_ariabutton", 0, 0, STATE_LINKED);

      // a (no @href, no click event listener)
      testStates("link_notlink", 0, 0, STATE_LINKED);

      // a: traversal state
      testStates("link_traversed", 0, 0, STATE_TRAVERSED);

      enableLogging("docload");
      registerA11yEventListener(EVENT_DOCUMENT_LOAD_COMPLETE,
                                traversedLinkTester);

      synthesizeMouse(getNode("link_traversed"), 1, 1, { shiftKey: true });
    }

    var traversedLinkTester = {
      handleEvent: function traversedLinkTester_handleEvent(aEvent) {
        unregisterA11yEventListener(EVENT_DOCUMENT_LOAD_COMPLETE,
                                    traversedLinkTester);
        aEvent.accessible.rootDocument.window.close();

        testStates("link_traversed", STATE_TRAVERSED);
        disableLogging();
        SimpleTest.finish();
      }
    };

    SimpleTest.waitForExplicitFinish();
    addA11yLoadEvent(doTest);
  </script>

</head>

<body>

  <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=423409"
     title="Expose click action if mouseup and mousedown are registered">
    Mozilla Bug 423409
  </a>
  <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=754830"
     title="Calculate link states separately">
    Mozilla Bug 754830
  </a>
  <p id="display"></p>
  <div id="content" style="display: none"></div>
  <pre id="test">
  </pre>

  <a id="link_href" href="http://mozilla.org">link</a>
  <a id="link_click" onclick="">link</a>
  <a id="link_mousedown" onmousedown="">link</a>
  <a id="link_mouseup" onmouseup="">link</a>
  <a id="link_arialink" role="link">aria link</a>
  <a id="link_ariabutton" role="button">aria button</a>
  <a id="link_notlink">not link</a>

  <a id="link_traversed" href="http://www.example.com" target="_top">example.com</a>

</body>
</html>