tor-browser

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

no-focus.tentative.html (1975B)


      1 <!DOCTYPE html>
      2 <meta charset=utf-8>
      3 <link rel="help" href="https://github.com/WICG/PEPC/blob/main/explainer.md#locking-the-pepc-style">
      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-actions.js"></script>
      8 <script src="/resources/testdriver-vendor.js"></script>
      9 <body>
     10 <!-- The usermedia element should not be focusable by script.
     11 -->
     12 <usermedia tabindex="0" id="valid_usermedia_element" type="camera"></usermedia>
     13 
     14 <span tabindex="0" id="focusable_span">This is some text</span>
     15 
     16 <!-- style needed to allow the invalid element to have a width -->
     17 <usermedia style="width: auto; padding-left: 10px" tabindex="0" id="invalid_usermedia_element" type="invalid"></usermedia>
     18 
     19 <script>
     20  promise_test(async() => {
     21    invalid_usermedia_element.focus();
     22    assert_equals(document.activeElement, invalid_usermedia_element,
     23      "Invalid usermedia element should be focusable");
     24 
     25    focusable_span.focus();
     26    valid_usermedia_element.focus();
     27    assert_equals(document.activeElement, focusable_span,
     28      "UserMedia element should not be focused.");
     29 
     30    focusable_span.focus();
     31    await test_driver.bless('Focus with user activation', () => {
     32      valid_usermedia_element.focus();
     33    });
     34    assert_equals(document.activeElement, valid_usermedia_element,
     35      "Focus is allowed with user activation");
     36 
     37    focusable_span.focus();
     38    actions = new test_driver.Actions()
     39       .pointerMove(1, 1, {origin: valid_usermedia_element})
     40       .pointerDown()
     41       .addTick();
     42    await actions.send();
     43    assert_equals(document.activeElement, valid_usermedia_element,
     44      "Users can focus the element");
     45 
     46    focusable_span.focus();
     47    assert_equals(document.activeElement, focusable_span,
     48        "Other element should be focused");
     49 }, "UserMedia element is not focusable by script without user activation");
     50 </script>
     51 </body>