accessible/tests/mochitest/treeupdate/test_recreation.html

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

     1 <!DOCTYPE html>
     2 <html>
     4 <head>
     5   <title>Test accessible recreation</title>
     7   <link rel="stylesheet" type="text/css"
     8         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
    10   <script type="application/javascript"
    11           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    13   <script type="application/javascript"
    14           src="../common.js"></script>
    15   <script type="application/javascript"
    16           src="../role.js"></script>
    17   <script type="application/javascript"
    18           src="../events.js"></script>
    20   <script type="application/javascript">
    22     ////////////////////////////////////////////////////////////////////////////
    23     // Invokers
    25     function recreateAccessible(aID, aWontBeAccessible)
    26     {
    27       this.node = getNode(aID);
    28       this.accessible =
    29         isAccessible(this.node) ? getAccessible(this.node) : null;
    31       this.eventSeq = [ ];
    33       if (this.accessible)
    34         this.eventSeq.push(new invokerChecker(EVENT_HIDE,
    35                                               this.accessible));
    37       if (!aWontBeAccessible)
    38         this.eventSeq.push(new invokerChecker(EVENT_SHOW, getAccessible,
    39                                               this.node));
    41       this.eventSeq.push(new invokerChecker(EVENT_REORDER,
    42                                             getContainerAccessible(this.node)));
    44       if (this.accessible) {
    45         this.unexpectedEventSeq = [
    46           new invokerChecker(EVENT_SHOW, this.accessible)
    47         ];
    48       }
    49     }
    51     function changeAttr(aID, aAttr, aValue)
    52     {
    53       this.__proto__ = new recreateAccessible(aID);
    55       this.invoke = function changeAttr_invoke()
    56       {
    57         this.node.setAttribute(aAttr, aValue);
    58       }
    60       this.getID = function changeAttr_getID()
    61       {
    62         return "change " + aAttr + "attribute for " + aID;
    63       }
    64     }
    66     function removeAttr(aID, aAttr)
    67     {
    68       this.__proto__ = new recreateAccessible(aID, true);
    70       this.invoke = function remvoeAttr_invoke()
    71       {
    72         this.node.removeAttribute(aAttr);
    73       }
    75       this.getID = function remvoeAttr_getID()
    76       {
    77         return "remove " + aAttr + "attribute for " + aID;
    78       }
    79     }
    81     function changeRole(aID, aHasAccessible)
    82     {
    83       this.__proto__ = new changeAttr(aID, "role", "button");
    84     }
    86     function removeRole(aID)
    87     {
    88       this.__proto__ = new removeAttr(aID, "role");
    89     }
    91     function changeOnclick(aID)
    92     {
    93       this.__proto__ = new changeAttr(aID, "onclick", "alert(3);");
    94     }
    96     function changeHref(aID)
    97     {
    98       this.__proto__ = new changeAttr(aID, "href", "www");
    99     }
   101     function changeMultiselectable(aID)
   102     {
   103       this.__proto__ = new changeAttr(aID, "aria-multiselectable", "true");
   104     }
   106     ////////////////////////////////////////////////////////////////////////////
   107     // Test
   109     //gA11yEventDumpID = "eventdump"; // debug stuff
   110     //gA11yEventDumpToConsole = true;
   112     var gQueue = null;
   114     function doTest()
   115     {
   116       gQueue = new eventQueue();
   118       // make the accessible an inaccessible
   119       gQueue.push(new changeRole("span"));
   121       // make the inaccessible an accessible
   122       gQueue.push(new removeRole("span"));
   124       // recreate an accessible by role change
   125       gQueue.push(new changeRole("div1"));
   127       // recreate an accessible by onclick change
   128       gQueue.push(new changeOnclick("div2"));
   130       // recreate an accessible by href change
   131       gQueue.push(new changeHref("anchor"));
   133       // recreate an accessible by aria-multiselectable change
   134       gQueue.push(new changeMultiselectable("div3"));
   136       gQueue.invoke(); // SimpleTest.finish() will be called in the end
   137     }
   139     SimpleTest.waitForExplicitFinish();
   140     addA11yLoadEvent(doTest);
   141   </script>
   142 </head>
   143 <body>
   145   <a target="_blank"
   146      title="Rework accessible tree update code"
   147      href="https://bugzilla.mozilla.org/show_bug.cgi?id=570275">
   148     Mozilla Bug 570275
   149   </a>
   151   <p id="display"></p>
   152   <div id="content" style="display: none"></div>
   153   <pre id="test">
   154   </pre>
   156   <span id="span">span</span>
   157   <div id="div1">div</div>
   158   <div id="div2">div</div>
   159   <a id="anchor">anchor</a>
   160   <div id="div3" role="listbox">list</div>
   162   <div id="eventdump"></div>
   163 </body>
   164 </html>

mercurial