|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <head> |
|
4 <title>Test for mochitest harness sanity</title> |
|
5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
6 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
|
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
8 </head> |
|
9 <body> |
|
10 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a> |
|
11 <p id="display"> |
|
12 <input id="testKeyEvent1" onkeypress="press1 = true"> |
|
13 <input id="testKeyEvent2" onkeydown="return false;" onkeypress="press2 = true"> |
|
14 <input id="testKeyEvent3" onkeypress="press3 = true"> |
|
15 <input id="testKeyEvent4" onkeydown="return false;" onkeypress="press4 = true"> |
|
16 </p |
|
17 <div id="content" style="display: none"> |
|
18 |
|
19 </div> |
|
20 <pre id="test"> |
|
21 <script class="testbody" type="text/javascript"> |
|
22 |
|
23 /** Test for sanity **/ |
|
24 ok(true, "true must be ok"); |
|
25 is(1, true, "1 must be true"); |
|
26 isnot(1, false, "1 must not be false"); |
|
27 is(0, false, "0 must be false"); |
|
28 isnot(0, true, "0 must not be true"); |
|
29 is("", 0, "Empty string must be 0"); |
|
30 is("1", 1, "Numeric string must be equal the number"); |
|
31 isnot("", null, "Empty string must not be null"); |
|
32 |
|
33 var press1 = false; |
|
34 $("testKeyEvent1").focus(); |
|
35 synthesizeKey("x", {}); |
|
36 is($("testKeyEvent1").value, "x", "synthesizeKey should work"); |
|
37 is(press1, true, "synthesizeKey should dispatch keyPress"); |
|
38 |
|
39 var press2 = false; |
|
40 $("testKeyEvent2").focus(); |
|
41 synthesizeKey("x", {}); |
|
42 is($("testKeyEvent2").value, "", "synthesizeKey should respect keydown preventDefault"); |
|
43 is(press2, false, "synthesizeKey should not dispatch keyPress with default prevented"); |
|
44 |
|
45 var press3 = false; |
|
46 $("testKeyEvent3").focus(); |
|
47 sendChar("x") |
|
48 is($("testKeyEvent3").value, "x", "sendChar should work"); |
|
49 is(press3, true, "sendChar should dispatch keyPress"); |
|
50 |
|
51 var press4 = false; |
|
52 $("testKeyEvent4").focus(); |
|
53 sendChar("x") |
|
54 is($("testKeyEvent4").value, "", "sendChar should respect keydown preventDefault"); |
|
55 is(press4, false, "sendChar should not dispatch keyPress with default prevented"); |
|
56 |
|
57 |
|
58 </script> |
|
59 </pre> |
|
60 </body> |
|
61 </html> |
|
62 |