dom/events/test/test_bug563329.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial