Fri, 16 Jan 2015 18:13:44 +0100
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 select options 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 addOptions(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 addOptions_invoke() |
michael@0 | 26 | { |
michael@0 | 27 | for (i = 0; i < 2; i++) { |
michael@0 | 28 | var opt = document.createElement("option"); |
michael@0 | 29 | opt.value = i; |
michael@0 | 30 | opt.text = "Option: Value " + i; |
michael@0 | 31 | |
michael@0 | 32 | this.selectNode.add(opt, null); |
michael@0 | 33 | } |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | this.eventSeq = [ |
michael@0 | 37 | new invokerChecker(EVENT_REORDER, this.select) |
michael@0 | 38 | ]; |
michael@0 | 39 | |
michael@0 | 40 | this.finalCheck = function addOptions_finalCheck() |
michael@0 | 41 | { |
michael@0 | 42 | var tree = |
michael@0 | 43 | { COMBOBOX: [ |
michael@0 | 44 | { COMBOBOX_LIST: [ |
michael@0 | 45 | { COMBOBOX_OPTION: [ |
michael@0 | 46 | { TEXT_LEAF: [] } |
michael@0 | 47 | ] }, |
michael@0 | 48 | { COMBOBOX_OPTION: [ |
michael@0 | 49 | { TEXT_LEAF: [] } |
michael@0 | 50 | ] } |
michael@0 | 51 | ] } |
michael@0 | 52 | ] }; |
michael@0 | 53 | testAccessibleTree(this.select, tree); |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | this.getID = function addOptions_getID() |
michael@0 | 57 | { |
michael@0 | 58 | return "test elements insertion into a select"; |
michael@0 | 59 | } |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | function removeOptions(aID) |
michael@0 | 63 | { |
michael@0 | 64 | this.selectNode = getNode(aID); |
michael@0 | 65 | this.select = getAccessible(this.selectNode); |
michael@0 | 66 | |
michael@0 | 67 | this.invoke = function removeOptions_invoke() |
michael@0 | 68 | { |
michael@0 | 69 | while (this.selectNode.length) |
michael@0 | 70 | this.selectNode.remove(0); |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | this.eventSeq = [ |
michael@0 | 74 | new invokerChecker(EVENT_REORDER, this.select) |
michael@0 | 75 | ]; |
michael@0 | 76 | |
michael@0 | 77 | this.finalCheck = function removeOptions_finalCheck() |
michael@0 | 78 | { |
michael@0 | 79 | var tree = |
michael@0 | 80 | { COMBOBOX: [ |
michael@0 | 81 | { COMBOBOX_LIST: [] } |
michael@0 | 82 | ] }; |
michael@0 | 83 | testAccessibleTree(this.select, tree); |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | this.getID = function removeptions_getID() |
michael@0 | 87 | { |
michael@0 | 88 | return "test elements removal from a select"; |
michael@0 | 89 | } |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | //gA11yEventDumpID = "debug"; |
michael@0 | 93 | |
michael@0 | 94 | function doTest() |
michael@0 | 95 | { |
michael@0 | 96 | gQueue = new eventQueue(); |
michael@0 | 97 | |
michael@0 | 98 | gQueue.push(new addOptions("select")); |
michael@0 | 99 | gQueue.push(new removeOptions("select")); |
michael@0 | 100 | |
michael@0 | 101 | gQueue.invoke(); // Will call SimpleTest.finish(); |
michael@0 | 102 | |
michael@0 | 103 | } |
michael@0 | 104 | |
michael@0 | 105 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 106 | addA11yLoadEvent(doTest); |
michael@0 | 107 | </script> |
michael@0 | 108 | </head> |
michael@0 | 109 | <body> |
michael@0 | 110 | |
michael@0 | 111 | <a target="_blank" |
michael@0 | 112 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=616452" |
michael@0 | 113 | title="Bug 616452 - Dynamically inserted select options aren't reflected in accessible tree"> |
michael@0 | 114 | Mozilla Bug 616452</a> |
michael@0 | 115 | <a target="_blank" |
michael@0 | 116 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=616940" |
michael@0 | 117 | title="Removed select option accessibles aren't removed until hide event is fired"> |
michael@0 | 118 | Mozilla Bug 616940</a> |
michael@0 | 119 | <p id="display"></p> |
michael@0 | 120 | <div id="content" style="display: none"></div> |
michael@0 | 121 | <pre id="test"> |
michael@0 | 122 | </pre> |
michael@0 | 123 | |
michael@0 | 124 | <select id="select"></select> |
michael@0 | 125 | |
michael@0 | 126 | <div id="debug"/> |
michael@0 | 127 | </body> |
michael@0 | 128 | </html> |