tor-browser

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

test_input_file_cancel_event.html (1256B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Test for the input type=file cancel event</title>
      5  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6  <script src="/tests/SimpleTest/EventUtils.js"></script>
      7  <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
      8 </head>
      9 <body>
     10 
     11 <input type=file></input>
     12 
     13 <script>
     14 SimpleTest.waitForExplicitFinish();
     15 
     16 var MockFilePicker = SpecialPowers.MockFilePicker;
     17 MockFilePicker.init(SpecialPowers.wrap(window).browsingContext);
     18 MockFilePicker.useBlobFile();
     19 MockFilePicker.returnValue = MockFilePicker.returnCancel;
     20 
     21 let input = document.querySelector('input[type=file]');
     22 input.addEventListener('cancel', event => {
     23  ok(true, "cancel event correctly sent");
     24 
     25  is(event.target, input, "Has correct event target");
     26  is(event.isTrusted, true, "Event is trusted");
     27  is(event.bubbles, true, "Event bubbles");
     28  is(event.cancelable, false, "Event is not cancelable");
     29  is(event.composed, false, "Event is not composed");
     30 
     31  SimpleTest.executeSoon(function() {
     32    MockFilePicker.cleanup();
     33    SimpleTest.finish();
     34  });
     35 });
     36 input.addEventListener('change' , () => {
     37  ok(false, "unexpected change event");
     38 })
     39 
     40 SpecialPowers.wrap(document).notifyUserGestureActivation();
     41 input.click();
     42 </script>
     43 </body>
     44 </html>