accessible/tests/mochitest/treeupdate/test_recreation.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/tests/mochitest/treeupdate/test_recreation.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,164 @@
     1.4 +<!DOCTYPE html>
     1.5 +<html>
     1.6 +
     1.7 +<head>
     1.8 +  <title>Test accessible recreation</title>
     1.9 +
    1.10 +  <link rel="stylesheet" type="text/css"
    1.11 +        href="chrome://mochikit/content/tests/SimpleTest/test.css" />
    1.12 +
    1.13 +  <script type="application/javascript"
    1.14 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.15 +
    1.16 +  <script type="application/javascript"
    1.17 +          src="../common.js"></script>
    1.18 +  <script type="application/javascript"
    1.19 +          src="../role.js"></script>
    1.20 +  <script type="application/javascript"
    1.21 +          src="../events.js"></script>
    1.22 +
    1.23 +  <script type="application/javascript">
    1.24 +
    1.25 +    ////////////////////////////////////////////////////////////////////////////
    1.26 +    // Invokers
    1.27 +
    1.28 +    function recreateAccessible(aID, aWontBeAccessible)
    1.29 +    {
    1.30 +      this.node = getNode(aID);
    1.31 +      this.accessible =
    1.32 +        isAccessible(this.node) ? getAccessible(this.node) : null;
    1.33 +
    1.34 +      this.eventSeq = [ ];
    1.35 +
    1.36 +      if (this.accessible)
    1.37 +        this.eventSeq.push(new invokerChecker(EVENT_HIDE,
    1.38 +                                              this.accessible));
    1.39 +
    1.40 +      if (!aWontBeAccessible)
    1.41 +        this.eventSeq.push(new invokerChecker(EVENT_SHOW, getAccessible,
    1.42 +                                              this.node));
    1.43 +
    1.44 +      this.eventSeq.push(new invokerChecker(EVENT_REORDER,
    1.45 +                                            getContainerAccessible(this.node)));
    1.46 +
    1.47 +      if (this.accessible) {
    1.48 +        this.unexpectedEventSeq = [
    1.49 +          new invokerChecker(EVENT_SHOW, this.accessible)
    1.50 +        ];
    1.51 +      }
    1.52 +    }
    1.53 +
    1.54 +    function changeAttr(aID, aAttr, aValue)
    1.55 +    {
    1.56 +      this.__proto__ = new recreateAccessible(aID);
    1.57 +
    1.58 +      this.invoke = function changeAttr_invoke()
    1.59 +      {
    1.60 +        this.node.setAttribute(aAttr, aValue);
    1.61 +      }
    1.62 +
    1.63 +      this.getID = function changeAttr_getID()
    1.64 +      {
    1.65 +        return "change " + aAttr + "attribute for " + aID;
    1.66 +      }
    1.67 +    }
    1.68 +
    1.69 +    function removeAttr(aID, aAttr)
    1.70 +    {
    1.71 +      this.__proto__ = new recreateAccessible(aID, true);
    1.72 +
    1.73 +      this.invoke = function remvoeAttr_invoke()
    1.74 +      {
    1.75 +        this.node.removeAttribute(aAttr);
    1.76 +      }
    1.77 +
    1.78 +      this.getID = function remvoeAttr_getID()
    1.79 +      {
    1.80 +        return "remove " + aAttr + "attribute for " + aID;
    1.81 +      }
    1.82 +    }
    1.83 +
    1.84 +    function changeRole(aID, aHasAccessible)
    1.85 +    {
    1.86 +      this.__proto__ = new changeAttr(aID, "role", "button");
    1.87 +    }
    1.88 +
    1.89 +    function removeRole(aID)
    1.90 +    {
    1.91 +      this.__proto__ = new removeAttr(aID, "role");
    1.92 +    }
    1.93 +
    1.94 +    function changeOnclick(aID)
    1.95 +    {
    1.96 +      this.__proto__ = new changeAttr(aID, "onclick", "alert(3);");
    1.97 +    }
    1.98 +
    1.99 +    function changeHref(aID)
   1.100 +    {
   1.101 +      this.__proto__ = new changeAttr(aID, "href", "www");
   1.102 +    }
   1.103 +
   1.104 +    function changeMultiselectable(aID)
   1.105 +    {
   1.106 +      this.__proto__ = new changeAttr(aID, "aria-multiselectable", "true");
   1.107 +    }
   1.108 +
   1.109 +    ////////////////////////////////////////////////////////////////////////////
   1.110 +    // Test
   1.111 +
   1.112 +    //gA11yEventDumpID = "eventdump"; // debug stuff
   1.113 +    //gA11yEventDumpToConsole = true;
   1.114 +
   1.115 +    var gQueue = null;
   1.116 +
   1.117 +    function doTest()
   1.118 +    {
   1.119 +      gQueue = new eventQueue();
   1.120 +
   1.121 +      // make the accessible an inaccessible
   1.122 +      gQueue.push(new changeRole("span"));
   1.123 +
   1.124 +      // make the inaccessible an accessible
   1.125 +      gQueue.push(new removeRole("span"));
   1.126 +
   1.127 +      // recreate an accessible by role change
   1.128 +      gQueue.push(new changeRole("div1"));
   1.129 +
   1.130 +      // recreate an accessible by onclick change
   1.131 +      gQueue.push(new changeOnclick("div2"));
   1.132 +
   1.133 +      // recreate an accessible by href change
   1.134 +      gQueue.push(new changeHref("anchor"));
   1.135 +
   1.136 +      // recreate an accessible by aria-multiselectable change
   1.137 +      gQueue.push(new changeMultiselectable("div3"));
   1.138 +
   1.139 +      gQueue.invoke(); // SimpleTest.finish() will be called in the end
   1.140 +    }
   1.141 +
   1.142 +    SimpleTest.waitForExplicitFinish();
   1.143 +    addA11yLoadEvent(doTest);
   1.144 +  </script>
   1.145 +</head>
   1.146 +<body>
   1.147 +
   1.148 +  <a target="_blank"
   1.149 +     title="Rework accessible tree update code"
   1.150 +     href="https://bugzilla.mozilla.org/show_bug.cgi?id=570275">
   1.151 +    Mozilla Bug 570275
   1.152 +  </a>
   1.153 +
   1.154 +  <p id="display"></p>
   1.155 +  <div id="content" style="display: none"></div>
   1.156 +  <pre id="test">
   1.157 +  </pre>
   1.158 +
   1.159 +  <span id="span">span</span>
   1.160 +  <div id="div1">div</div>
   1.161 +  <div id="div2">div</div>
   1.162 +  <a id="anchor">anchor</a>
   1.163 +  <div id="div3" role="listbox">list</div>
   1.164 +
   1.165 +  <div id="eventdump"></div>
   1.166 +</body>
   1.167 +</html>

mercurial