tor-browser

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

test_bug1315862.html (2440B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=1315862
      5 -->
      6 <head>
      7  <meta charset="utf-8">
      8  <title>Test for Bug 1315862</title>
      9  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     10  <script src="/tests/SimpleTest/EventUtils.js"></script>
     11  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     12 </head>
     13 <body>
     14 <p id="content">
     15  This is a test to check if pointer events are dispatched in the system group
     16 </p>
     17 <script type="text/javascript">
     18 
     19 /** Test for Bug 1315862 */
     20 SimpleTest.waitForExplicitFinish();
     21 
     22 function runTests() {
     23  let allPointerEvents = ["pointerdown", "pointerup", "pointercancel",
     24                          "pointermove", "pointerover", "pointerout",
     25                          "pointerenter", "pointerleave", "gotpointercapture",
     26                          "lostpointercapture"
     27                         ];
     28  let content = document.getElementById('content');
     29  let iframe = document.createElement('iframe');
     30  let receivePointerEvents = false;
     31  iframe.width = 50;
     32  iframe.height = 50;
     33  content.appendChild(iframe);
     34  iframe.contentDocument.body.innerHTML =
     35    "<div style='width: 100%; height: 100%; border: 1px solid black;'></div>";
     36 
     37  let target = iframe.contentDocument.body.firstChild;
     38  allPointerEvents.forEach((event, idx, arr) => {
     39    SpecialPowers.wrap(target).addEventListener(event, () => {
     40      ok(false, "Shouldn't dispatch " + event + " in the system group");
     41      receivePointerEvents = true;
     42    }, { mozSystemGroup: true });
     43  });
     44  target.addEventListener("pointerdown", (e) => {
     45    target.setPointerCapture(e.pointerId);
     46  });
     47  target.addEventListener("pointerup", () => {
     48    is(receivePointerEvents, false, "Shouldn't dispatch pointer events in the system group");
     49    SimpleTest.finish();
     50  });
     51  let source = MouseEvent.MOZ_SOURCE_MOUSE;
     52  synthesizeMouse(target, 5, 5, { type: "mousemove", inputSource: source },
     53                  iframe.contentWindow);
     54  synthesizeMouse(target, 5, 5, { type: "mousedown", inputSource: source },
     55                  iframe.contentWindow);
     56  synthesizeMouse(target, 5, 5, { type: "mousemove", inputSource: source },
     57                  iframe.contentWindow);
     58  synthesizeMouse(target, 5, 5, { type: "mouseup", inputSource: source },
     59                  iframe.contentWindow);
     60 }
     61 
     62 SimpleTest.waitForFocus(runTests);
     63 
     64 </script>
     65 </body>
     66 </html>