accessible/tests/mochitest/treeupdate/test_optgroup.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.

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

mercurial