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 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=429547 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>aria-activedescendant focus tests</title> |
michael@0 | 8 | <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" /> |
michael@0 | 9 | |
michael@0 | 10 | <script type="application/javascript" |
michael@0 | 11 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 12 | |
michael@0 | 13 | <script type="application/javascript" |
michael@0 | 14 | src="../common.js"></script> |
michael@0 | 15 | <script type="application/javascript" |
michael@0 | 16 | src="../role.js"></script> |
michael@0 | 17 | <script type="application/javascript" |
michael@0 | 18 | src="../states.js"></script> |
michael@0 | 19 | <script type="application/javascript" |
michael@0 | 20 | src="../events.js"></script> |
michael@0 | 21 | |
michael@0 | 22 | <script type="application/javascript"> |
michael@0 | 23 | //gA11yEventDumpToConsole = true; // debugging |
michael@0 | 24 | |
michael@0 | 25 | function changeARIAActiveDescendant(aID, aItemID) |
michael@0 | 26 | { |
michael@0 | 27 | this.eventSeq = [ |
michael@0 | 28 | new focusChecker(aItemID) |
michael@0 | 29 | ]; |
michael@0 | 30 | |
michael@0 | 31 | this.invoke = function changeARIAActiveDescendant_invoke() |
michael@0 | 32 | { |
michael@0 | 33 | getNode(aID).setAttribute("aria-activedescendant", aItemID); |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | this.getID = function changeARIAActiveDescendant_getID() |
michael@0 | 37 | { |
michael@0 | 38 | return "change aria-activedescendant on " + aItemID; |
michael@0 | 39 | } |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | function insertItemNFocus(aID, aNewItemID) |
michael@0 | 43 | { |
michael@0 | 44 | this.eventSeq = [ |
michael@0 | 45 | new invokerChecker(EVENT_SHOW, aNewItemID), |
michael@0 | 46 | new focusChecker(aNewItemID) |
michael@0 | 47 | ]; |
michael@0 | 48 | |
michael@0 | 49 | this.invoke = function insertItemNFocus_invoke() |
michael@0 | 50 | { |
michael@0 | 51 | var container = getNode(aID); |
michael@0 | 52 | var itemNode = document.createElement("div"); |
michael@0 | 53 | itemNode.setAttribute("id", aNewItemID); |
michael@0 | 54 | itemNode.textContent = "item3"; |
michael@0 | 55 | container.appendChild(itemNode); |
michael@0 | 56 | |
michael@0 | 57 | container.setAttribute("aria-activedescendant", aNewItemID); |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | this.getID = function insertItemNFocus_getID() |
michael@0 | 61 | { |
michael@0 | 62 | return "insert new node and focus it with ID: " + aNewItemID; |
michael@0 | 63 | } |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | var gQueue = null; |
michael@0 | 67 | function doTest() |
michael@0 | 68 | { |
michael@0 | 69 | gQueue = new eventQueue(); |
michael@0 | 70 | |
michael@0 | 71 | gQueue.push(new synthFocus("container", new focusChecker("item1"))); |
michael@0 | 72 | gQueue.push(new changeARIAActiveDescendant("container", "item2")); |
michael@0 | 73 | |
michael@0 | 74 | gQueue.push(new synthFocus("combobox_entry", new focusChecker("combobox_entry"))); |
michael@0 | 75 | gQueue.push(new changeARIAActiveDescendant("combobox", "combobox_option2")); |
michael@0 | 76 | |
michael@0 | 77 | todo(false, "No focus for inserted element, bug 687011"); |
michael@0 | 78 | //gQueue.push(new insertItemNFocus("container", "item3")); |
michael@0 | 79 | |
michael@0 | 80 | gQueue.invoke(); // Will call SimpleTest.finish(); |
michael@0 | 81 | } |
michael@0 | 82 | |
michael@0 | 83 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 84 | addA11yLoadEvent(doTest); |
michael@0 | 85 | </script> |
michael@0 | 86 | </head> |
michael@0 | 87 | <body> |
michael@0 | 88 | |
michael@0 | 89 | <a target="_blank" |
michael@0 | 90 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=429547" |
michael@0 | 91 | title="Support aria-activedescendant usage in nsIAccesible::TakeFocus()"> |
michael@0 | 92 | Mozilla Bug 429547 |
michael@0 | 93 | </a> |
michael@0 | 94 | <a target="_blank" |
michael@0 | 95 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=761102" |
michael@0 | 96 | title="Focus may be missed when ARIA active-descendant is changed on active composite widget"> |
michael@0 | 97 | Mozilla Bug 761102 |
michael@0 | 98 | </a> |
michael@0 | 99 | <p id="display"></p> |
michael@0 | 100 | <div id="content" style="display: none"></div> |
michael@0 | 101 | <pre id="test"> |
michael@0 | 102 | </pre> |
michael@0 | 103 | |
michael@0 | 104 | <div role="listbox" aria-activedescendant="item1" id="container" tabindex="1"> |
michael@0 | 105 | <div role="listitem" id="item1">item1</div> |
michael@0 | 106 | <div role="listitem" id="item2">item2</div> |
michael@0 | 107 | </div> |
michael@0 | 108 | |
michael@0 | 109 | <div role="combobox" id="combobox"> |
michael@0 | 110 | <input id="combobox_entry"> |
michael@0 | 111 | <ul> |
michael@0 | 112 | <li role="option" id="combobox_option1">option1</li> |
michael@0 | 113 | <li role="option" id="combobox_option2">option2</li> |
michael@0 | 114 | </ul> |
michael@0 | 115 | </div> |
michael@0 | 116 | </body> |
michael@0 | 117 | </html> |