tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug563329.html (2261B)


      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 src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <script 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">
     20 
     21 /** Test for Bug 563329 */
     22 /*  ui.click_hold_context_menus preference */
     23 
     24 var target = null;
     25 var testGen = 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  target = document.getElementById("testTarget");
     42 
     43  document.documentElement.addEventListener("contextmenu", function() {
     44    SimpleTest.ok(true, currentTest.message);
     45    synthesizeMouse(target, 0, 0, {type: "mouseup"});
     46    SimpleTest.executeSoon(function() {
     47      currentTest = testGen.next();
     48      currentTest.func();
     49    });
     50  });
     51 
     52  SimpleTest.executeSoon(function() {
     53    currentTest = testGen.next();
     54    currentTest.func();
     55  });
     56 }
     57 
     58 function doCheckContextMenu() {
     59  synthesizeMouse(target, 0, 0, {type: "mousedown"});
     60 }
     61 
     62 function doCheckDuration() {
     63  var duration = 50;
     64 
     65  // Change click hold delay
     66  SpecialPowers.pushPrefEnv({"set":[["ui.click_hold_context_menus.delay", duration]]}, function() { synthesizeMouse(target, 0, 0, {type: "mousedown"}); });
     67 }
     68 
     69 function finishTest() {
     70  synthesizeKey("VK_ESCAPE", {}, window);
     71  SimpleTest.finish();
     72 }
     73 
     74 SimpleTest.waitForExplicitFinish();
     75 addLoadEvent(function() {
     76  SpecialPowers.pushPrefEnv({"set":[["ui.click_hold_context_menus", true]]}, doTest);
     77 });
     78 </script>
     79 </pre>
     80 <span id="testTarget" style="border: 1px solid black;">testTarget</span>
     81 </body>
     82 </html>