accessible/tests/mochitest/treeupdate/test_listbox.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/tests/mochitest/treeupdate/test_listbox.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,180 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
     1.7 +                 type="text/css"?>
     1.8 +
     1.9 +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    1.10 +        title="Accessible XUL listbox hierarchy tests">
    1.11 +
    1.12 +  <script type="application/javascript"
    1.13 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
    1.14 +
    1.15 +  <script type="application/javascript"
    1.16 +          src="../common.js" />
    1.17 +  <script type="application/javascript"
    1.18 +          src="../role.js" />
    1.19 +  <script type="application/javascript"
    1.20 +          src="../events.js" />
    1.21 +
    1.22 +  <script type="application/javascript">
    1.23 +  <![CDATA[
    1.24 +    ////////////////////////////////////////////////////////////////////////////
    1.25 +    // Test
    1.26 +
    1.27 +    function insertListitem(aListboxID)
    1.28 +    {
    1.29 +      this.listboxNode = getNode(aListboxID);
    1.30 +
    1.31 +      this.listitemNode = document.createElement("listitem");
    1.32 +      this.listitemNode.setAttribute("label", "item1");
    1.33 +
    1.34 +      this.eventSeq = [
    1.35 +        new invokerChecker(EVENT_SHOW, this.listitemNode),
    1.36 +        new invokerChecker(EVENT_REORDER, this.listboxNode)
    1.37 +      ];
    1.38 +
    1.39 +      this.invoke = function insertListitem_invoke()
    1.40 +      {
    1.41 +        this.listboxNode.insertBefore(this.listitemNode,
    1.42 +                                      this.listboxNode.firstChild);
    1.43 +      }
    1.44 +
    1.45 +      this.finalCheck = function insertListitem_finalCheck()
    1.46 +      {
    1.47 +        var tree =
    1.48 +          { LISTBOX: [
    1.49 +            {
    1.50 +              role: ROLE_RICH_OPTION,
    1.51 +              name: "item1"
    1.52 +            },
    1.53 +            {
    1.54 +              role: ROLE_RICH_OPTION,
    1.55 +              name: "item2"
    1.56 +            },
    1.57 +            {
    1.58 +              role: ROLE_RICH_OPTION,
    1.59 +              name: "item3"
    1.60 +            },
    1.61 +            {
    1.62 +              role: ROLE_RICH_OPTION,
    1.63 +              name: "item4"
    1.64 +            }
    1.65 +          ] };
    1.66 +        testAccessibleTree(this.listboxNode, tree);
    1.67 +      }
    1.68 +
    1.69 +      this.getID = function insertListitem_getID()
    1.70 +      {
    1.71 +        return "insert listitem ";
    1.72 +      }
    1.73 +    }
    1.74 +
    1.75 +    function removeListitem(aListboxID)
    1.76 +    {
    1.77 +      this.listboxNode = getNode(aListboxID);
    1.78 +      this.listitemNode = null;
    1.79 +      this.listitem;
    1.80 +
    1.81 +      function getListitem(aThisObj)
    1.82 +      {
    1.83 +        return aThisObj.listitem;
    1.84 +      }
    1.85 +
    1.86 +      this.eventSeq = [
    1.87 +        new invokerChecker(EVENT_HIDE, getListitem, this),
    1.88 +        new invokerChecker(EVENT_REORDER, this.listboxNode)
    1.89 +      ];
    1.90 +
    1.91 +      this.invoke = function removeListitem_invoke()
    1.92 +      {
    1.93 +        this.listitemNode = this.listboxNode.firstChild;
    1.94 +        this.listitem = getAccessible(this.listitemNode);
    1.95 +
    1.96 +        this.listboxNode.removeChild(this.listitemNode);
    1.97 +      }
    1.98 +
    1.99 +      this.finalCheck = function removeListitem_finalCheck()
   1.100 +      {
   1.101 +        var tree =
   1.102 +          { LISTBOX: [
   1.103 +            {
   1.104 +              role: ROLE_RICH_OPTION,
   1.105 +              name: "item2"
   1.106 +            },
   1.107 +            {
   1.108 +              role: ROLE_RICH_OPTION,
   1.109 +              name: "item3"
   1.110 +            },
   1.111 +            {
   1.112 +              role: ROLE_RICH_OPTION,
   1.113 +              name: "item4"
   1.114 +            }
   1.115 +          ] };
   1.116 +        testAccessibleTree(this.listboxNode, tree);
   1.117 +      }
   1.118 +
   1.119 +      this.getID = function removeListitem_getID()
   1.120 +      {
   1.121 +        return "remove listitem ";
   1.122 +      }
   1.123 +    }
   1.124 +
   1.125 +    //gA11yEventDumpToConsole = true; // debug stuff
   1.126 +
   1.127 +    var gQueue = null;
   1.128 +    function doTest()
   1.129 +    {
   1.130 +      var tree =
   1.131 +        { LISTBOX: [
   1.132 +          {
   1.133 +            role: ROLE_RICH_OPTION,
   1.134 +            name: "item2"
   1.135 +          },
   1.136 +          {
   1.137 +            role: ROLE_RICH_OPTION,
   1.138 +            name: "item3"
   1.139 +          },
   1.140 +          {
   1.141 +            role: ROLE_RICH_OPTION,
   1.142 +            name: "item4"
   1.143 +          }
   1.144 +        ] };
   1.145 +      testAccessibleTree("listbox", tree);
   1.146 +
   1.147 +      gQueue = new eventQueue();
   1.148 +      gQueue.push(new insertListitem("listbox"));
   1.149 +      gQueue.push(new removeListitem("listbox"));
   1.150 +      gQueue.invoke(); // Will call SimpleTest.finish()
   1.151 +    }
   1.152 +
   1.153 +    SimpleTest.waitForExplicitFinish();
   1.154 +    addA11yLoadEvent(doTest);
   1.155 +  ]]>
   1.156 +  </script>
   1.157 +
   1.158 +  <hbox flex="1" style="overflow: auto;">
   1.159 +    <body xmlns="http://www.w3.org/1999/xhtml">
   1.160 +      <a target="_blank"
   1.161 +         href="https://bugzilla.mozilla.org/show_bug.cgi?id=656225"
   1.162 +         title="XUL listbox accessible tree doesn't get updated">
   1.163 +        Mozilla Bug 656225
   1.164 +      </a>
   1.165 +      <br/>
   1.166 +      <p id="display"></p>
   1.167 +      <div id="content" style="display: none">
   1.168 +      </div>
   1.169 +      <pre id="test">
   1.170 +      </pre>
   1.171 +    </body>
   1.172 +
   1.173 +    <vbox flex="1">
   1.174 +      <listbox id="listbox" rows="2">
   1.175 +        <listitem label="item2"/>
   1.176 +        <listitem label="item3"/>
   1.177 +        <listitem label="item4"/>
   1.178 +      </listbox>
   1.179 +    </vbox>
   1.180 +  </hbox>
   1.181 +
   1.182 +</window>
   1.183 +

mercurial