tor-browser

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

navigator-vibrate.https.html (2182B)


      1 <!DOCTYPE html>
      2 <title>Test that navigator.vibrate is disabled in fenced frames.</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script src="/resources/testdriver.js"></script>
      6 <script src="/resources/testdriver-actions.js"></script>
      7 <script src="/resources/testdriver-vendor.js"></script>
      8 <script src="/common/utils.js"></script>
      9 <script src="/common/dispatcher/dispatcher.js"></script>
     10 <script src="resources/utils.js"></script>
     11 
     12 <body>
     13 <script>
     14 // Simulate a click in frame context `frame`.
     15 async function click(frame) {
     16  var actions = new test_driver.Actions();
     17  await actions.pointerMove(0, 0, {origin: frame})
     18               .pointerDown()
     19               .pointerUp()
     20               .send();
     21 }
     22 
     23 promise_test(async () => {
     24  // This test ensures that vibration is disabled in fenced frames.
     25  // It uses a top-level frame A and a fenced frame B.
     26  // The structure of the test is as follows:
     27  // - Check that B can't vibrate before user activation.
     28  // - Check that B can't vibrate after user activation.
     29  // - Check that A can't vibrate before user activation.
     30  // - Check that A CAN vibrate after user activation.
     31 
     32  const B = attachFencedFrameContext();
     33  await B.execute(() => {
     34    assert_false(navigator.userActivation.hasBeenActive);
     35    var success = navigator.vibrate(100);
     36    assert_false(success,
     37        "Vibration failed in fenced frame before user activation");
     38  });
     39 
     40  await click(B.element);
     41  await B.execute(() => {
     42    assert_true(navigator.userActivation.hasBeenActive);
     43    var success = navigator.vibrate(100);
     44    assert_false(success,
     45        "Vibration failed in fenced frame, even after user activation");
     46  });
     47 
     48  var success = navigator.vibrate(100);
     49  assert_false(navigator.userActivation.hasBeenActive);
     50  assert_false(success,
     51      "Vibration failed in top-level frame before user activation");
     52 
     53  await click(document.documentElement);
     54  assert_true(navigator.userActivation.hasBeenActive);
     55  var success = navigator.vibrate(100);
     56  assert_true(success,
     57      "Vibration succeeded in top-level frame after user activation");
     58 }, 'navigator.vibrate');
     59 </script>
     60 </body>