Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
michael@0 | 3 | <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> |
michael@0 | 4 | |
michael@0 | 5 | <window title="Panel Focus Tests" |
michael@0 | 6 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 7 | |
michael@0 | 8 | <script type="application/javascript" |
michael@0 | 9 | src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> |
michael@0 | 10 | |
michael@0 | 11 | <checkbox id="b1" label="Item 1"/> |
michael@0 | 12 | |
michael@0 | 13 | <!-- Focus should be in this order: 2 6 3 8 1 4 5 7 9 --> |
michael@0 | 14 | <panel id="panel" norestorefocus="true" onpopupshown="panelShown()" onpopuphidden="panelHidden()"> |
michael@0 | 15 | <button id="t1" label="Button One"/> |
michael@0 | 16 | <button id="t2" tabindex="1" label="Button Two" onblur="gButtonBlur++;"/> |
michael@0 | 17 | <button id="t3" tabindex="2" label="Button Three"/> |
michael@0 | 18 | <button id="t4" tabindex="0" label="Button Four"/> |
michael@0 | 19 | <button id="t5" label="Button Five"/> |
michael@0 | 20 | <button id="t6" tabindex="1" label="Button Six"/> |
michael@0 | 21 | <button id="t7" label="Button Seven"/> |
michael@0 | 22 | <button id="t8" tabindex="4" label="Button Eight"/> |
michael@0 | 23 | <button id="t9" label="Button Nine"/> |
michael@0 | 24 | </panel> |
michael@0 | 25 | |
michael@0 | 26 | <panel id="noautofocusPanel" noautofocus="true" |
michael@0 | 27 | onpopupshown="noautofocusPanelShown()" onpopuphidden="noautofocusPanelHidden()"> |
michael@0 | 28 | <textbox id="tb3"/> |
michael@0 | 29 | </panel> |
michael@0 | 30 | |
michael@0 | 31 | <checkbox id="b2" label="Item 2" popup="panel" onblur="gButtonBlur++;"/> |
michael@0 | 32 | |
michael@0 | 33 | <script class="testbody" type="application/javascript"> |
michael@0 | 34 | <![CDATA[ |
michael@0 | 35 | |
michael@0 | 36 | var gButtonBlur = 0; |
michael@0 | 37 | |
michael@0 | 38 | function showPanel() |
michael@0 | 39 | { |
michael@0 | 40 | // click on the document so that the window has focus |
michael@0 | 41 | synthesizeMouse(document.documentElement, 1, 1, { }); |
michael@0 | 42 | |
michael@0 | 43 | // focus the button |
michael@0 | 44 | synthesizeKeyExpectEvent("VK_TAB", { }, $("b1"), "focus", "button focus"); |
michael@0 | 45 | // tabbing again should skip the popup |
michael@0 | 46 | synthesizeKeyExpectEvent("VK_TAB", { }, $("b2"), "focus", "popup skipped in focus navigation"); |
michael@0 | 47 | |
michael@0 | 48 | $("panel").openPopup(null, "", 10, 10, false, false); |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | function panelShown() |
michael@0 | 52 | { |
michael@0 | 53 | // the focus on the button should have been removed when the popup was opened |
michael@0 | 54 | is(gButtonBlur, 1, "focus removed when popup opened"); |
michael@0 | 55 | |
michael@0 | 56 | // press tab numerous times to cycle through the buttons. The t2 button will |
michael@0 | 57 | // be blurred twice, so gButtonBlur will be 3 afterwards. |
michael@0 | 58 | synthesizeKeyExpectEvent("VK_TAB", { }, $("t2"), "focus", "tabindex 1"); |
michael@0 | 59 | synthesizeKeyExpectEvent("VK_TAB", { }, $("t6"), "focus", "tabindex 2"); |
michael@0 | 60 | synthesizeKeyExpectEvent("VK_TAB", { }, $("t3"), "focus", "tabindex 3"); |
michael@0 | 61 | synthesizeKeyExpectEvent("VK_TAB", { }, $("t8"), "focus", "tabindex 4"); |
michael@0 | 62 | synthesizeKeyExpectEvent("VK_TAB", { }, $("t1"), "focus", "tabindex 5"); |
michael@0 | 63 | synthesizeKeyExpectEvent("VK_TAB", { }, $("t4"), "focus", "tabindex 6"); |
michael@0 | 64 | synthesizeKeyExpectEvent("VK_TAB", { }, $("t5"), "focus", "tabindex 7"); |
michael@0 | 65 | synthesizeKeyExpectEvent("VK_TAB", { }, $("t7"), "focus", "tabindex 8"); |
michael@0 | 66 | synthesizeKeyExpectEvent("VK_TAB", { }, $("t9"), "focus", "tabindex 9"); |
michael@0 | 67 | synthesizeKeyExpectEvent("VK_TAB", { }, $("t2"), "focus", "tabindex 10"); |
michael@0 | 68 | |
michael@0 | 69 | synthesizeKeyExpectEvent("VK_TAB", { shiftKey: true }, $("t9"), "focus", "back tabindex 1"); |
michael@0 | 70 | synthesizeKeyExpectEvent("VK_TAB", { shiftKey: true }, $("t7"), "focus", "back tabindex 2"); |
michael@0 | 71 | synthesizeKeyExpectEvent("VK_TAB", { shiftKey: true }, $("t5"), "focus", "back tabindex 3"); |
michael@0 | 72 | synthesizeKeyExpectEvent("VK_TAB", { shiftKey: true }, $("t4"), "focus", "back tabindex 4"); |
michael@0 | 73 | synthesizeKeyExpectEvent("VK_TAB", { shiftKey: true }, $("t1"), "focus", "back tabindex 5"); |
michael@0 | 74 | synthesizeKeyExpectEvent("VK_TAB", { shiftKey: true }, $("t8"), "focus", "back tabindex 6"); |
michael@0 | 75 | synthesizeKeyExpectEvent("VK_TAB", { shiftKey: true }, $("t3"), "focus", "back tabindex 7"); |
michael@0 | 76 | synthesizeKeyExpectEvent("VK_TAB", { shiftKey: true }, $("t6"), "focus", "back tabindex 8"); |
michael@0 | 77 | synthesizeKeyExpectEvent("VK_TAB", { shiftKey: true }, $("t2"), "focus", "back tabindex 9"); |
michael@0 | 78 | |
michael@0 | 79 | is(gButtonBlur, 3, "blur events fired within popup"); |
michael@0 | 80 | |
michael@0 | 81 | synthesizeKey("VK_ESCAPE", { }); |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | function ok(condition, message) { |
michael@0 | 85 | window.opener.wrappedJSObject.SimpleTest.ok(condition, message); |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | function is(left, right, message) { |
michael@0 | 89 | window.opener.wrappedJSObject.SimpleTest.is(left, right, message); |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | function panelHidden() |
michael@0 | 93 | { |
michael@0 | 94 | // closing the popup should have blurred the focused element |
michael@0 | 95 | is(gButtonBlur, 4, "focus removed when popup closed"); |
michael@0 | 96 | |
michael@0 | 97 | // now that the panel is hidden, pressing tab should focus the elements in |
michael@0 | 98 | // the main window again |
michael@0 | 99 | synthesizeKeyExpectEvent("VK_TAB", { }, $("b1"), "focus", "focus after popup closed"); |
michael@0 | 100 | |
michael@0 | 101 | $("noautofocusPanel").openPopup(null, "", 10, 10, false, false); |
michael@0 | 102 | } |
michael@0 | 103 | |
michael@0 | 104 | function noautofocusPanelShown() |
michael@0 | 105 | { |
michael@0 | 106 | // with noautofocus="true", the focus should not be removed when the panel is |
michael@0 | 107 | // opened, so key events should still be fired at the checkbox. |
michael@0 | 108 | synthesizeKeyExpectEvent("VK_SPACE", { }, $("b1"), "command", "noautofocus"); |
michael@0 | 109 | $("noautofocusPanel").hidePopup(); |
michael@0 | 110 | } |
michael@0 | 111 | |
michael@0 | 112 | function noautofocusPanelHidden() |
michael@0 | 113 | { |
michael@0 | 114 | window.close(); |
michael@0 | 115 | window.opener.wrappedJSObject.SimpleTest.finish(); |
michael@0 | 116 | } |
michael@0 | 117 | |
michael@0 | 118 | window.opener.wrappedJSObject.SimpleTest.waitForFocus(showPanel, window); |
michael@0 | 119 | |
michael@0 | 120 | ]]> |
michael@0 | 121 | </script> |
michael@0 | 122 | |
michael@0 | 123 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 124 | <p id="display"> |
michael@0 | 125 | </p> |
michael@0 | 126 | <div id="content" style="display: none"> |
michael@0 | 127 | </div> |
michael@0 | 128 | <pre id="test"> |
michael@0 | 129 | </pre> |
michael@0 | 130 | </body> |
michael@0 | 131 | |
michael@0 | 132 | </window> |