accessible/tests/mochitest/actions/test_link.html
author Mark Banner <standard8@mozilla.com>
Mon, 11 Dec 2017 13:36:16 +0000
changeset 711860 326c098b0054fa2e12d536945268f8175da3b95a
parent 680764 167e5e6fd9308fa6557f2010ac5c3821558e8015
permissions -rw-r--r--
Bug 1425244 - Enable ESLint rule no-cond-assign for accessible/tests/mochitest/. r?surkov MozReview-Commit-ID: 59yovY1BQ0p

<html>

<head>
  <title>nsIAccessible actions testing on HTML links (HTML:a)</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="../common.js"></script>
  <script type="application/javascript"
          src="../events.js"></script>
  <script type="application/javascript"
          src="../actions.js"></script>

  <script type="application/javascript">
    function getAnchorTargetDocumentAcc() {
      var thisTabDocAcc = getTabDocAccessible();
      var thisDocTabPanelAcc = thisTabDocAcc.parent.parent;
      var tabPanelsAcc = thisDocTabPanelAcc.parent;
      var newDocTabPanelAcc = tabPanelsAcc.firstChild;
      var nextAcc = newDocTabPanelAcc;

      while ((nextAcc = nextAcc.nextSibling)) {
        // Find the last accessible for a browser with about:mozilla loaded.
        if (nextAcc.firstChild.DOMNode.currentURI.spec == "about:mozilla") {
          newDocTabPanelAcc = nextAcc;
        }
      }

      return newDocTabPanelAcc.firstChild.firstChild;
    }

    function linkChecker(aID) {
      this.type = EVENT_DOCUMENT_LOAD_COMPLETE;
      this.__defineGetter__("target", getAnchorTargetDocumentAcc);

      this.check = function linkChecker_check() {
        var anchorTargetWindow =
          getAccessible(getAnchorTargetDocumentAcc(), [nsIAccessibleDocument]).
          window;
        anchorTargetWindow.close();
      };

      this.getID = function linkChecker_getID() {
        return "link '" + aID + "' states check ";
      };
    }

    // gA11yEventDumpToConsole = true;
    // enableLogging("tree,eventTree,verbose");

    function doTest() {
      var actionsArray = [
        {
          ID: "link1",
          actionName: "jump",
          events: CLICK_EVENTS,
          eventSeq: [
            new linkChecker("link1")
          ]
        },
        {
          ID: "img1",
          targetID: "link1",
          actionName: "jump",
          events: CLICK_EVENTS,
          eventSeq: [
            new linkChecker("link1")
          ]
        },
        {
          ID: "link2",
          actionName: "click",
          events: CLICK_EVENTS
        },
        {
          ID: "img2",
          targetID: "link2",
          actionName: "jump",
          events: CLICK_EVENTS
        },
        {
          ID: "link3",
          actionName: "click",
          events: CLICK_EVENTS
        },
        {
          ID: "img3",
          targetID: "link3",
          actionName: "jump",
          events: CLICK_EVENTS
        },
        {
          ID: "link4",
          actionName: "click",
          events: CLICK_EVENTS
        },
        {
          ID: "img4",
          targetID: "link4",
          actionName: "jump",
          events: CLICK_EVENTS
        }
      ];
      testActions(actionsArray);
    }

    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>
  <p id="display"></p>
  <div id="content" style="display: none"></div>
  <pre id="test">
  </pre>

  <a href="about:mozilla" id="link1" target="_blank">
    <img src="../moz.png" id="img1">
  </a>
  <a id="link2" onmousedown="">
    <img src="../moz.png" id="img2">
  </a>
  <a id="link3" onclick="">
    <img src="../moz.png" id="img3">
  </a>
  <a id="link4" onmouseup="">
    <img src="../moz.png" id="img4">
  </a>
</body>
</html>