|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=563329 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 563329</title> |
|
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
|
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
11 </head> |
|
12 <body> |
|
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=563329">Mozilla Bug 563329</a> |
|
14 <p id="display"></p> |
|
15 <div id="content" style="display: none"> |
|
16 |
|
17 </div> |
|
18 <pre id="test"> |
|
19 <script type="application/javascript;version=1.7"> |
|
20 |
|
21 /** Test for Bug 563329 **/ |
|
22 /* ui.click_hold_context_menus preference */ |
|
23 |
|
24 var target = null; |
|
25 var tests = getTests(); |
|
26 var currentTest = null; |
|
27 |
|
28 function getTests() { |
|
29 let tests = [ |
|
30 { "func": function() { setTimeout(doCheckContextMenu, 100)}, "message": "Context menu should has fired"}, |
|
31 { "func": function() { setTimeout(doCheckDuration, 100)}, "message": "Context menu should has fired with delay"}, |
|
32 { "func": function() { setTimeout(finishTest, 100)}, "message": "" } |
|
33 ]; |
|
34 |
|
35 let i = 0; |
|
36 while (i < tests.length) |
|
37 yield tests[i++]; |
|
38 } |
|
39 |
|
40 function doTest() { |
|
41 // Enable context menus |
|
42 SpecialPowers.setBoolPref("ui.click_hold_context_menus", true); |
|
43 |
|
44 target = document.getElementById("testTarget"); |
|
45 |
|
46 document.documentElement.addEventListener("contextmenu", function() { |
|
47 SimpleTest.ok(true, currentTest.message); |
|
48 synthesizeMouse(target, 0, 0, {type: "mouseup"}); |
|
49 SimpleTest.executeSoon(function() { |
|
50 currentTest = tests.next(); |
|
51 currentTest.func(); |
|
52 }); |
|
53 }, false); |
|
54 |
|
55 SimpleTest.executeSoon(function() { |
|
56 currentTest = tests.next(); |
|
57 currentTest.func(); |
|
58 }); |
|
59 } |
|
60 |
|
61 function doCheckContextMenu() { |
|
62 synthesizeMouse(target, 0, 0, {type: "mousedown"}); |
|
63 } |
|
64 |
|
65 function doCheckDuration() { |
|
66 var duration = 50; |
|
67 |
|
68 // Change click hold delay |
|
69 SpecialPowers.setIntPref("ui.click_hold_context_menus.delay", duration); |
|
70 |
|
71 synthesizeMouse(target, 0, 0, {type: "mousedown"}); |
|
72 } |
|
73 |
|
74 function finishTest() { |
|
75 synthesizeKey("VK_ESCAPE", {}, window); |
|
76 try { |
|
77 SpecialPowers.clearUserPref("ui.click_hold_context_menus"); |
|
78 } |
|
79 catch(e) {} |
|
80 |
|
81 try { |
|
82 SpecialPowers.clearUserPref("ui.click_hold_context_menus.delay"); |
|
83 } |
|
84 catch(e) {} |
|
85 |
|
86 SimpleTest.finish(); |
|
87 } |
|
88 |
|
89 SimpleTest.waitForExplicitFinish(); |
|
90 addLoadEvent(doTest); |
|
91 |
|
92 </script> |
|
93 </pre> |
|
94 <span id="testTarget" style="border: 1px solid black;">testTarget</span> |
|
95 </body> |
|
96 </html> |