tor-browser

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

show-picker-user-gesture.html (1502B)


      1 <!DOCTYPE html>
      2 <title>Test showPicker() user gesture requirement</title>
      3 <meta name="timeout" content="long">
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script src="/resources/testdriver.js"></script>
      7 <script src="/resources/testdriver-vendor.js"></script>
      8 
      9 <body>
     10 <script type=module>
     11 import inputTypes from "./input-types.js";
     12 
     13 // File pickers can't be closed.
     14 const types = inputTypes.filter((t) => t != 'file');
     15 
     16 function createElement(t,type) {
     17  const input = document.createElement("input");
     18  input.setAttribute("type", type);
     19  document.body.appendChild(input);
     20  t.add_cleanup(() => input.remove());
     21  return input;
     22 }
     23 for (const inputType of types) {
     24  promise_test(async (t) => {
     25    const input = createElement(t,inputType);
     26    assert_throws_dom('NotAllowedError', () => { input.showPicker(); });
     27  }, `input[type=${inputType}] showPicker() requires a user gesture`);
     28 
     29  promise_test(async (t) => {
     30    const input = createElement(t,inputType);
     31    await test_driver.bless('show picker');
     32    input.showPicker();
     33    input.blur();
     34  }, `input[type=${inputType}] showPicker() does not throw when user activation is active`);
     35 
     36  promise_test(async (t) => {
     37    const input = createElement(t,inputType);
     38    await test_driver.bless('show picker');
     39    input.showPicker();
     40    input.blur();
     41    assert_false(navigator.userActivation.isActive);
     42  }, `input[type=${inputType}] showPicker() consumes user activation`);
     43 }
     44 </script>