Bug 1884032 [wpt PR 44942] - [css-color] add missing colorscheme-aware tests, a=testonly
[gecko.git] / widget / tests / test_key_event_counts.xhtml
blobe50164ddfddbb60663ac5ea1c4a22d38ae0358c4
1 <?xml version="1.0"?>
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
5 <!-- We've had issues on Mac OS X where native key events either don't get processed
6 or they get processed twice. This test tests some of those scenarios. -->
8 <window id="window1" title="Test Key Event Counts" onload="runTest()"
9 xmlns:html="http://www.w3.org/1999/xhtml"
10 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
12 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
13 <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
14 <script src="chrome://mochikit/content/tests/SimpleTest/NativeKeyCodes.js"/>
16 <!-- test results are displayed in the html:body -->
17 <body xmlns="http://www.w3.org/1999/xhtml">
18 <p id="display"></p>
19 <div id="content" style="display: none"></div>
20 <pre id="test"></pre>
21 </body>
23 <script type="application/javascript"><![CDATA[
24 var gKeyPressEventCount = 0;
25 var gKeyDownEventCount = 0;
27 function onKeyDown()
29 gKeyDownEventCount++;
32 function onKeyPress(e)
34 gKeyPressEventCount++;
35 e.preventDefault();
38 function* testBody()
40 window.addEventListener("keydown", onKeyDown);
41 window.addEventListener("keypress", onKeyPress);
43 // Test ctrl-tab
44 gKeyDownEventCount = 0;
45 gKeyPressEventCount = 0;
46 yield synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, MAC_VK_Tab, {ctrlKey:1}, "\t", "\t", continueTest);
47 is(gKeyDownEventCount, 1);
48 is(gKeyPressEventCount, 0, "ctrl-tab should be consumed by tabbox of tabbrowser at keydown");
50 // Test cmd+shift+a
51 gKeyDownEventCount = 0;
52 gKeyPressEventCount = 0;
53 yield synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_A, {metaKey:1, shiftKey:1}, "a", "A", continueTest);
54 is(gKeyDownEventCount, 1);
55 is(gKeyPressEventCount, 1);
57 // Test cmd-;
58 gKeyDownEventCount = 0;
59 gKeyPressEventCount = 0;
60 yield synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_Semicolon, {metaKey:1}, ";", ";", continueTest);
61 is(gKeyDownEventCount, 1);
62 is(gKeyPressEventCount, 1);
64 window.removeEventListener("keydown", onKeyDown);
65 window.removeEventListener("keypress", onKeyPress);
68 var gTestContinuation = null;
70 function continueTest()
72 if (!gTestContinuation) {
73 gTestContinuation = testBody();
75 var ret = gTestContinuation.next();
76 if (ret.done) {
77 SimpleTest.finish();
78 } else {
79 is(ret.value, true, "Key synthesized successfully");
83 function runTest()
85 SimpleTest.waitForExplicitFinish();
86 continueTest();
88 ]]></script>
90 </window>