|
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"?> |
|
4 |
|
5 <window title="Popup Prevent Default Tests" |
|
6 onload="setTimeout(runTest, 0);" |
|
7 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
|
8 |
|
9 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
10 |
|
11 <!-- |
|
12 This tests checks that preventDefault can be called on a popupshowing |
|
13 event and that preventDefault has no effect for the popuphiding event. |
|
14 --> |
|
15 |
|
16 <script> |
|
17 SimpleTest.waitForExplicitFinish(); |
|
18 |
|
19 var gBlockShowing = true; |
|
20 var gShownNotAllowed = true; |
|
21 |
|
22 function runTest() |
|
23 { |
|
24 document.getElementById("menu").open = true; |
|
25 } |
|
26 |
|
27 function popupShowing(event) |
|
28 { |
|
29 if (gBlockShowing) { |
|
30 event.preventDefault(); |
|
31 gBlockShowing = false; |
|
32 setTimeout(function() { |
|
33 gShownNotAllowed = false; |
|
34 document.getElementById("menu").open = true; |
|
35 }, 3000, true); |
|
36 } |
|
37 } |
|
38 |
|
39 function popupShown() |
|
40 { |
|
41 ok(!gShownNotAllowed, "popupshowing preventDefault"); |
|
42 document.getElementById("menu").open = false; |
|
43 } |
|
44 |
|
45 function popupHiding(event) |
|
46 { |
|
47 // since this is a content test, preventDefault should have no effect |
|
48 event.preventDefault(); |
|
49 } |
|
50 |
|
51 function popupHidden() |
|
52 { |
|
53 ok(true, "popuphiding preventDefault not allowed"); |
|
54 SimpleTest.finish(); |
|
55 } |
|
56 </script> |
|
57 |
|
58 <button id="menu" type="menu" label="Menu"> |
|
59 <menupopup onpopupshowing="popupShowing(event);" |
|
60 onpopupshown="popupShown();" |
|
61 onpopuphiding="popupHiding(event);" |
|
62 onpopuphidden="popupHidden();"> |
|
63 <menuitem label="Item"/> |
|
64 </menupopup> |
|
65 </button> |
|
66 |
|
67 <body xmlns="http://www.w3.org/1999/xhtml"> |
|
68 <p id="display"> |
|
69 </p> |
|
70 <div id="content" style="display: none"> |
|
71 </div> |
|
72 <pre id="test"> |
|
73 </pre> |
|
74 </body> |
|
75 |
|
76 </window> |