1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/widget/tests/test_key_event_counts.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,55 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> 1.7 + 1.8 +<!-- We've had issues on Mac OS X where native key events either don't get processed 1.9 + or they get processed twice. This test tests some of those scenarios. --> 1.10 + 1.11 +<window id="window1" title="Test Key Event Counts" onload="runTest()" 1.12 + xmlns:html="http://www.w3.org/1999/xhtml" 1.13 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.14 + 1.15 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> 1.16 + <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> 1.17 + <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/NativeKeyCodes.js"/> 1.18 + 1.19 + <!-- test results are displayed in the html:body --> 1.20 + <body xmlns="http://www.w3.org/1999/xhtml"> 1.21 + <p id="display"></p> 1.22 + <div id="content" style="display: none"></div> 1.23 + <pre id="test"></pre> 1.24 + </body> 1.25 + 1.26 + <script type="application/javascript"><![CDATA[ 1.27 + var gKeyPressEventCount = 0; 1.28 + 1.29 + function onKeyPress(e) 1.30 + { 1.31 + gKeyPressEventCount++; 1.32 + e.preventDefault(); 1.33 + } 1.34 + 1.35 + function runTest() 1.36 + { 1.37 + window.addEventListener("keypress", onKeyPress, false); 1.38 + 1.39 + // Test ctrl-tab 1.40 + gKeyPressEventCount = 0; 1.41 + synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, MAC_VK_Tab, {ctrlKey:1}, "\t", "\t"); 1.42 + is(gKeyPressEventCount, 1); 1.43 + 1.44 + // Test cmd+shift+a 1.45 + gKeyPressEventCount = 0; 1.46 + synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_A, {metaKey:1, shiftKey:1}, "a", "A"); 1.47 + is(gKeyPressEventCount, 1); 1.48 + 1.49 + // Test cmd-; 1.50 + gKeyPressEventCount = 0; 1.51 + synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_Semicolon, {metaKey:1}, ";", ";"); 1.52 + is(gKeyPressEventCount, 1); 1.53 + 1.54 + window.removeEventListener("keypress", onKeyPress, false); 1.55 + } 1.56 + ]]></script> 1.57 + 1.58 +</window>