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="Menu ignorekeys Test" |
michael@0 | 6 | onkeydown="keyDown()" |
michael@0 | 7 | onload="setTimeout(runTests, 0);" |
michael@0 | 8 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 9 | |
michael@0 | 10 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 11 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 12 | |
michael@0 | 13 | <!-- |
michael@0 | 14 | This test checks that the ignorekeys attribute can be used on a menu to |
michael@0 | 15 | disable key navigation. The test is performed twice by opening the menu, |
michael@0 | 16 | simulating a cursor down key, and closing the popup. When keys are enabled, |
michael@0 | 17 | the first item on the menu should be highlighted, otherwise the first item |
michael@0 | 18 | should not be highlighted. |
michael@0 | 19 | --> |
michael@0 | 20 | |
michael@0 | 21 | <menupopup id="popup" onpopupshown="popupShown()" onpopuphidden="popupHidden()"> |
michael@0 | 22 | <menuitem id="i1" label="One" onDOMAttrModified="attrModified(event)"/> |
michael@0 | 23 | <menuitem id="i2" label="Two"/> |
michael@0 | 24 | <menuitem id="i3" label="Three"/> |
michael@0 | 25 | <menuitem id="i4" label="Four"/> |
michael@0 | 26 | </menupopup> |
michael@0 | 27 | |
michael@0 | 28 | <script class="testbody" type="application/javascript"> |
michael@0 | 29 | <![CDATA[ |
michael@0 | 30 | |
michael@0 | 31 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 32 | |
michael@0 | 33 | var gIgnoreKeys = false; |
michael@0 | 34 | var gIgnoreAttrChange = false; |
michael@0 | 35 | |
michael@0 | 36 | function runTests() |
michael@0 | 37 | { |
michael@0 | 38 | var popup = $("popup"); |
michael@0 | 39 | popup.enableKeyboardNavigator(false); |
michael@0 | 40 | is(popup.getAttribute("ignorekeys"), "true", "keys disabled"); |
michael@0 | 41 | popup.enableKeyboardNavigator(true); |
michael@0 | 42 | is(popup.hasAttribute("ignorekeys"), false, "keys enabled"); |
michael@0 | 43 | popup.openPopup(null, "after_start"); |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | function popupShown() |
michael@0 | 47 | { |
michael@0 | 48 | synthesizeKey("VK_DOWN", { }); |
michael@0 | 49 | if (gIgnoreKeys) { |
michael@0 | 50 | var popup = $("popup"); |
michael@0 | 51 | setTimeout(function() { popup.hidePopup() }, 1000); |
michael@0 | 52 | } |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | function popupHidden() |
michael@0 | 56 | { |
michael@0 | 57 | if (gIgnoreKeys) { |
michael@0 | 58 | SimpleTest.finish(); |
michael@0 | 59 | } |
michael@0 | 60 | else { |
michael@0 | 61 | // try the test again with ignorekeys set |
michael@0 | 62 | gIgnoreKeys = true; |
michael@0 | 63 | var popup = $("popup"); |
michael@0 | 64 | popup.setAttribute("ignorekeys", "true"); |
michael@0 | 65 | // clear this first to avoid confusion |
michael@0 | 66 | gIgnoreAttrChange = true; |
michael@0 | 67 | $("i1").removeAttribute("_moz-menuactive") |
michael@0 | 68 | gIgnoreAttrChange = false; |
michael@0 | 69 | popup.openPopup(null, "after_start"); |
michael@0 | 70 | } |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | function attrModified(event) |
michael@0 | 74 | { |
michael@0 | 75 | if (gIgnoreAttrChange || event.attrName != "_moz-menuactive") |
michael@0 | 76 | return; |
michael@0 | 77 | |
michael@0 | 78 | // the attribute should not be changed when ignorekeys is enabled |
michael@0 | 79 | if (gIgnoreKeys) { |
michael@0 | 80 | ok(false, "move key with keys disabled"); |
michael@0 | 81 | } |
michael@0 | 82 | else { |
michael@0 | 83 | is($("i1").getAttribute("_moz-menuactive"), "true", "move key with keys enabled"); |
michael@0 | 84 | $("popup").hidePopup(); |
michael@0 | 85 | } |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | function keyDown() |
michael@0 | 89 | { |
michael@0 | 90 | // when keys are enabled, the menu should have stopped propagation of the |
michael@0 | 91 | // event, so a bubbling listener for a keydown event should only occur |
michael@0 | 92 | // when keys are disabled. |
michael@0 | 93 | ok(gIgnoreKeys, "key listener fired with keys " + |
michael@0 | 94 | (gIgnoreKeys ? "disabled" : "enabled")); |
michael@0 | 95 | } |
michael@0 | 96 | |
michael@0 | 97 | ]]> |
michael@0 | 98 | </script> |
michael@0 | 99 | |
michael@0 | 100 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 101 | <p id="display"> |
michael@0 | 102 | </p> |
michael@0 | 103 | <div id="content" style="display: none"> |
michael@0 | 104 | </div> |
michael@0 | 105 | <pre id="test"> |
michael@0 | 106 | </pre> |
michael@0 | 107 | </body> |
michael@0 | 108 | |
michael@0 | 109 | </window> |