accessible/tests/mochitest/treeupdate/test_optgroup.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4   <title>Add and remove optgroup test</title>
     5   <link rel="stylesheet" type="text/css"
     6         href="chrome://mochikit/content/tests/SimpleTest/test.css" />
     8   <script type="application/javascript"
     9           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    11   <script type="application/javascript"
    12           src="../common.js"></script>
    13   <script type="application/javascript"
    14           src="../role.js"></script>
    15   <script type="application/javascript"
    16           src="../events.js"></script>
    18   <script type="application/javascript">
    20     function addOptGroup(aID)
    21     {
    22       this.selectNode = getNode(aID);
    23       this.select = getAccessible(this.selectNode);
    25       this.invoke = function addOptGroup_invoke()
    26       {
    27         var optGroup = document.createElement("optgroup");
    28         for (i = 0; i < 2; i++) {
    29           var opt = document.createElement("option");
    30           opt.value = i;
    31           opt.text = "Option: Value " + i;
    33           optGroup.appendChild(opt);
    34         }
    36         this.selectNode.add(optGroup, null);
    37         var option = document.createElement("option");
    38         this.selectNode.add(option, null);
    39       }
    41       this.eventSeq = [
    42         new invokerChecker(EVENT_REORDER, this.select)
    43       ];
    45       this.finalCheck = function addOptGroup_finalCheck()
    46       {
    47         var tree =
    48           { COMBOBOX: [
    49             { COMBOBOX_LIST: [
    50               { GROUPING: [
    51                 { COMBOBOX_OPTION: [
    52                   { TEXT_LEAF: [] }
    53                 ] },
    54               { COMBOBOX_OPTION: [
    55                   { TEXT_LEAF: [] }
    56                 ] },
    57               ]},
    58               { COMBOBOX_OPTION: [] }
    59             ] }
    60           ] };
    61         testAccessibleTree(this.select, tree);
    62       }
    64       this.getID = function addOptGroup_getID()
    65       {
    66         return "test optgroup's insertion into a select";
    67       }
    68     }
    70     function removeOptGroup(aID)
    71     {
    72       this.selectNode = getNode(aID);
    73       this.select = getAccessible(this.selectNode);
    75       this.invoke = function removeOptGroup_invoke()
    76       {
    77         this.option1Node = this.selectNode.firstChild.firstChild;
    78         this.selectNode.removeChild(this.selectNode.firstChild);
    79       }
    81       this.eventSeq = [
    82         new invokerChecker(EVENT_REORDER, this.select)
    83       ];
    85       this.finalCheck = function removeOptGroup_finalCheck()
    86       {
    87         var tree =
    88           { COMBOBOX: [
    89             { COMBOBOX_LIST: [
    90               { COMBOBOX_OPTION: [] }
    91             ] }
    92           ] };
    93         testAccessibleTree(this.select, tree);
    94         is(isAccessible(this.option1Node), false, "removed option shouldn't be accessible anymore!");
    95       }
    97       this.getID = function removeOptGroup_getID()
    98       {
    99         return "test optgroup's removal from a select";
   100       }
   101     }
   103 //    gA11yEventDumpToConsole = true;
   105     function doTest()
   106     {
   107       gQueue = new eventQueue();
   109       gQueue.push(new addOptGroup("select"));
   110       gQueue.push(new removeOptGroup("select"));
   112       gQueue.invoke(); // Will call SimpleTest.finish();
   114     }
   116     SimpleTest.waitForExplicitFinish();
   117     addA11yLoadEvent(doTest);
   118   </script>
   119 </head>
   120 <body>
   122   <a target="_blank"
   123      href="https://bugzilla.mozilla.org/show_bug.cgi?id=616452"
   124      title="Bug 616452 - Dynamically inserted select options aren't reflected in accessible tree">
   125     Bug 616452</a>
   126   <p id="display"></p>
   127   <div id="content" style="display: none"></div>
   128   <pre id="test">
   129   </pre>
   131   <select id="select"></select>
   133   <div id="debug"/>
   134 </body>
   135 </html>

mercurial