accessible/tests/mochitest/events/test_focus_dialog.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 <html>
michael@0 2
michael@0 3 <head>
michael@0 4 <title>Accessible focus testing</title>
michael@0 5
michael@0 6 <link rel="stylesheet" type="text/css"
michael@0 7 href="chrome://mochikit/content/tests/SimpleTest/test.css" />
michael@0 8
michael@0 9 <script type="application/javascript"
michael@0 10 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 11 <script type="application/javascript"
michael@0 12 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
michael@0 13
michael@0 14 <script type="application/javascript"
michael@0 15 src="../common.js"></script>
michael@0 16 <script type="application/javascript"
michael@0 17 src="../events.js"></script>
michael@0 18 <script type="application/javascript"
michael@0 19 src="../role.js"></script>
michael@0 20 <script type="application/javascript"
michael@0 21 src="../states.js"></script>
michael@0 22
michael@0 23 <script type="application/javascript">
michael@0 24 function openCloseDialog(aID)
michael@0 25 {
michael@0 26 this.eventSeq = [
michael@0 27 new focusChecker(getNode(aID))
michael@0 28 ];
michael@0 29
michael@0 30 this.invoke = function openCloseDialog_invoke()
michael@0 31 {
michael@0 32 var wnd = window.open("focus.html");
michael@0 33 wnd.close();
michael@0 34 }
michael@0 35
michael@0 36 this.getID = function openCloseDialog_getID()
michael@0 37 {
michael@0 38 return "Open close dialog while focus on " + prettyName(aID);
michael@0 39 }
michael@0 40 }
michael@0 41
michael@0 42 var gDialogWnd = null;
michael@0 43 function getDialogDocument()
michael@0 44 {
michael@0 45 return gDialogWnd.document;
michael@0 46 }
michael@0 47
michael@0 48 function openDialog(aID)
michael@0 49 {
michael@0 50 this.eventSeq = [
michael@0 51 new focusChecker(getDialogDocument)
michael@0 52 ];
michael@0 53
michael@0 54 this.invoke = function openDialog_invoke()
michael@0 55 {
michael@0 56 gDialogWnd = window.open("focus.html");
michael@0 57 }
michael@0 58
michael@0 59 this.getID = function openDialog_getID()
michael@0 60 {
michael@0 61 return "Open dialog while focus on " + prettyName(aID);
michael@0 62 }
michael@0 63 }
michael@0 64
michael@0 65 function closeDialog(aID)
michael@0 66 {
michael@0 67 this.eventSeq = [
michael@0 68 new focusChecker(aID)
michael@0 69 ];
michael@0 70
michael@0 71 this.invoke = function closeDialog_invoke()
michael@0 72 {
michael@0 73 gDialogWnd.close();
michael@0 74 }
michael@0 75
michael@0 76 this.getID = function closeDialog_getID()
michael@0 77 {
michael@0 78 return "Close dialog while focus on " + prettyName(aID);
michael@0 79 }
michael@0 80 }
michael@0 81
michael@0 82 function showNFocusAlertDialog()
michael@0 83 {
michael@0 84 this.ID = "alertdialog";
michael@0 85 this.DOMNode = getNode(this.ID);
michael@0 86
michael@0 87 this.invoke = function showNFocusAlertDialog_invoke()
michael@0 88 {
michael@0 89 document.getElementById(this.ID).style.display = 'block';
michael@0 90 document.getElementById(this.ID).focus();
michael@0 91 }
michael@0 92
michael@0 93 this.eventSeq = [
michael@0 94 new invokerChecker(EVENT_SHOW, this.DOMNode),
michael@0 95 new focusChecker(this.DOMNode)
michael@0 96 ];
michael@0 97
michael@0 98 this.getID = function showNFocusAlertDialog_getID()
michael@0 99 {
michael@0 100 return "Show and focus alert dialog " + prettyName(this.ID);
michael@0 101 }
michael@0 102 }
michael@0 103
michael@0 104 /**
michael@0 105 * Do tests.
michael@0 106 */
michael@0 107
michael@0 108 //gA11yEventDumpID = "eventdump"; // debug stuff
michael@0 109 //gA11yEventDumpToConsole = true;
michael@0 110
michael@0 111 var gQueue = null;
michael@0 112
michael@0 113 function doTests()
michael@0 114 {
michael@0 115 gQueue = new eventQueue(EVENT_FOCUS);
michael@0 116
michael@0 117 gQueue.push(new synthFocus("button"));
michael@0 118 gQueue.push(new openDialog("button"));
michael@0 119 gQueue.push(new closeDialog("button"));
michael@0 120
michael@0 121 var frameNode = getNode("editabledoc");
michael@0 122 gQueue.push(new synthFocusOnFrame(frameNode));
michael@0 123 gQueue.push(new openCloseDialog(frameNode.contentDocument));
michael@0 124
michael@0 125 gQueue.push(new showNFocusAlertDialog());
michael@0 126
michael@0 127 gQueue.invoke(); // Will call SimpleTest.finish();
michael@0 128 }
michael@0 129
michael@0 130 SimpleTest.waitForExplicitFinish();
michael@0 131 addA11yLoadEvent(doTests);
michael@0 132 </script>
michael@0 133 </head>
michael@0 134
michael@0 135 <body>
michael@0 136
michael@0 137 <a target="_blank"
michael@0 138 href="https://bugzilla.mozilla.org/show_bug.cgi?id=551679"
michael@0 139 title="focus is not fired for focused document when switching between windows">
michael@0 140 Mozilla Bug 551679
michael@0 141 </a>
michael@0 142 <a target="_blank"
michael@0 143 href="https://bugzilla.mozilla.org/show_bug.cgi?id=580464"
michael@0 144 title="Accessible focus incorrect after JS focus() but correct after switching apps or using menu bar">
michael@0 145 Mozilla Bug 580464
michael@0 146 </a>
michael@0 147 <p id="display"></p>
michael@0 148 <div id="content" style="display: none"></div>
michael@0 149 <pre id="test">
michael@0 150 </pre>
michael@0 151
michael@0 152 <button id="button">button</button>
michael@0 153 <iframe id="editabledoc" src="focus.html"></iframe>
michael@0 154
michael@0 155 <div id="alertdialog" style="display: none" tabindex="-1" role="alertdialog" aria-labelledby="title2" aria-describedby="desc2">
michael@0 156 <div id="title2">Blah blah</div>
michael@0 157 <div id="desc2">Woof woof woof.</div>
michael@0 158 <button>Close</button>
michael@0 159 </div>
michael@0 160
michael@0 161
michael@0 162 <div id="eventdump"></div>
michael@0 163 </body>
michael@0 164 </html>

mercurial