test_bug563329.html 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. </div>
  17. <pre id="test">
  18. <script type="application/javascript;version=1.7">
  19. /** Test for Bug 563329 **/
  20. /* ui.click_hold_context_menus preference */
  21. var target = null;
  22. var tests = getTests();
  23. var currentTest = null;
  24. function getTests() {
  25. let tests = [
  26. { "func": function() { setTimeout(doCheckContextMenu, 100)}, "message": "Context menu should has fired"},
  27. { "func": function() { setTimeout(doCheckDuration, 100)}, "message": "Context menu should has fired with delay"},
  28. { "func": function() { setTimeout(finishTest, 100)}, "message": "" }
  29. ];
  30. let i = 0;
  31. while (i < tests.length)
  32. yield tests[i++];
  33. }
  34. function doTest() {
  35. target = document.getElementById("testTarget");
  36. document.documentElement.addEventListener("contextmenu", function() {
  37. SimpleTest.ok(true, currentTest.message);
  38. synthesizeMouse(target, 0, 0, {type: "mouseup"});
  39. SimpleTest.executeSoon(function() {
  40. currentTest = tests.next();
  41. currentTest.func();
  42. });
  43. }, false);
  44. SimpleTest.executeSoon(function() {
  45. currentTest = tests.next();
  46. currentTest.func();
  47. });
  48. }
  49. function doCheckContextMenu() {
  50. synthesizeMouse(target, 0, 0, {type: "mousedown"});
  51. }
  52. function doCheckDuration() {
  53. var duration = 50;
  54. // Change click hold delay
  55. SpecialPowers.pushPrefEnv({"set":[["ui.click_hold_context_menus.delay", duration]]}, function() { synthesizeMouse(target, 0, 0, {type: "mousedown"}); });
  56. }
  57. function finishTest() {
  58. synthesizeKey("VK_ESCAPE", {}, window);
  59. SimpleTest.finish();
  60. }
  61. SimpleTest.waitForExplicitFinish();
  62. addLoadEvent(function() {
  63. SpecialPowers.pushPrefEnv({"set":[["ui.click_hold_context_menus", true]]}, doTest);
  64. });
  65. </script>
  66. </pre>
  67. <span id="testTarget" style="border: 1px solid black;">testTarget</span>
  68. </body>
  69. </html>