toolkit/content/tests/chrome/window_cursorsnap_dialog.xul

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:282ee33a4d92
1 <?xml version="1.0"?>
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
3 <dialog title="Cursor snapping test" id="dialog"
4 width="600" height="600"
5 onload="onload();"
6 onunload="onunload();"
7 buttons="accept,cancel"
8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
9
10 <script class="testbody" type="application/javascript">
11 <![CDATA[
12
13 function ok(aCondition, aMessage)
14 {
15 window.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage);
16 }
17
18 function is(aLeft, aRight, aMessage)
19 {
20 window.opener.wrappedJSObject.SimpleTest.is(aLeft, aRight, aMessage);
21 }
22
23 function isnot(aLeft, aRight, aMessage)
24 {
25 window.opener.wrappedJSObject.SimpleTest.isnot(aLeft, aRight, aMessage);
26 }
27
28 function canRetryTest()
29 {
30 return window.opener.wrappedJSObject.canRetryTest();
31 }
32
33 function getTimeoutTime()
34 {
35 return window.opener.wrappedJSObject.getTimeoutTime();
36 }
37
38 var gTimer;
39 var gRetry;
40
41 function finishByTimeout()
42 {
43 var button = document.getElementById("dialog").getButton("accept");
44 if (button.disabled)
45 ok(true, "cursor is NOT snapped to the disabled button (dialog)");
46 else if (button.hidden)
47 ok(true, "cursor is NOT snapped to the hidden button (dialog)");
48 else {
49 if (!canRetryTest()) {
50 ok(false, "cursor is NOT snapped to the default button (dialog)");
51 } else {
52 // otherwise, this may be unexpected timeout, we should retry the test.
53 gRetry = true;
54 }
55 }
56 finish();
57 }
58
59 function finish()
60 {
61 window.close();
62 }
63
64 function onMouseMove(aEvent)
65 {
66 var button = document.getElementById("dialog").getButton("accept");
67 if (button.disabled)
68 ok(false, "cursor IS snapped to the disabled button (dialog)");
69 else if (button.hidden)
70 ok(false, "cursor IS snapped to the hidden button (dialog)");
71 else
72 ok(true, "cursor IS snapped to the default button (dialog)");
73 clearTimeout(gTimer);
74 finish();
75 }
76
77 function onload()
78 {
79 var button = document.getElementById("dialog").getButton("accept");
80 button.addEventListener("mousemove", onMouseMove, false);
81
82 if (window.opener.wrappedJSObject.gDisable) {
83 button.disabled = true;
84 }
85 if (window.opener.wrappedJSObject.gHidden) {
86 button.hidden = true;
87 }
88 gRetry = false;
89 gTimer = setTimeout(finishByTimeout, getTimeoutTime());
90 }
91
92 function onunload()
93 {
94 if (gRetry) {
95 window.opener.wrappedJSObject.retryCurrentTest();
96 } else {
97 window.opener.wrappedJSObject.runNextTest();
98 }
99 }
100
101 ]]>
102 </script>
103
104 </dialog>

mercurial