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

     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">
    17 </div>
    18 <pre id="test">
    19 <script type="application/javascript;version=1.7">
    21 /** Test for Bug 563329 **/
    22 /*  ui.click_hold_context_menus preference */
    24 var target = null;
    25 var tests = getTests();
    26 var currentTest = null;
    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   ];
    35   let i = 0;
    36   while (i < tests.length)
    37     yield tests[i++];
    38 }
    40 function doTest() {
    41   // Enable context menus
    42   SpecialPowers.setBoolPref("ui.click_hold_context_menus", true);
    44   target = document.getElementById("testTarget");
    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);
    55   SimpleTest.executeSoon(function() {
    56     currentTest = tests.next();
    57     currentTest.func();
    58   });
    59 }
    61 function doCheckContextMenu() {
    62   synthesizeMouse(target, 0, 0, {type: "mousedown"});
    63 }
    65 function doCheckDuration() {
    66   var duration = 50;
    68   // Change click hold delay
    69   SpecialPowers.setIntPref("ui.click_hold_context_menus.delay", duration);
    71   synthesizeMouse(target, 0, 0, {type: "mousedown"});
    72 }
    74 function finishTest() {
    75   synthesizeKey("VK_ESCAPE", {}, window);
    76   try {
    77     SpecialPowers.clearUserPref("ui.click_hold_context_menus");
    78   }
    79   catch(e) {}
    81   try {
    82     SpecialPowers.clearUserPref("ui.click_hold_context_menus.delay");
    83   }
    84   catch(e) {}
    86   SimpleTest.finish();
    87 }
    89 SimpleTest.waitForExplicitFinish();
    90 addLoadEvent(doTest);
    92 </script>
    93 </pre>
    94 <span id="testTarget" style="border: 1px solid black;">testTarget</span>
    95 </body>
    96 </html>

mercurial