tor-browser

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

test_check_timestamp_iframe.html (1861B)


      1 <!-- Any copyright is dedicated to the Public Domain.
      2   - http://creativecommons.org/publicdomain/zero/1.0/ -->
      3 <!DOCTYPE HTML>
      4 <html>
      5 <head>
      6  <title>Test Gamepad.timestamp</title>
      7  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      8 </head>
      9 <body>
     10 <script type="text/javascript" src="mock_gamepad.js"></script>
     11 <script class="testbody" type="text/javascript">
     12 
     13 let ok = window.parent.ok;
     14 let is = window.parent.is;
     15 let SimpleTest = window.parent.SimpleTest;
     16 let SpecialPowers = window.parent.SpecialPowers;
     17 
     18 window.addEventListener("gamepadbuttondown", buttonpresshandler);
     19 
     20 var index;
     21 var timea=0;
     22 var firstPress = true;
     23 var testOver = false;
     24 
     25 runGamepadTest(checkTimestamp);
     26 
     27 async function checkTimestamp(){
     28  const index = await GamepadService.addGamepad("test gamepad 1",
     29                            GamepadService.standardMapping,
     30                            GamepadService.noHand,
     31                            4,
     32                            2,
     33                            0,
     34                            0,
     35                            0);
     36 
     37  // Press a button to make the gamepad visible
     38  // to the page.
     39  await GamepadService.newButtonEvent(index, 0, true, true);
     40  await GamepadService.newButtonEvent(index, 0, true, true);
     41  ok(true, "test");
     42 }
     43 
     44 function cleanup(){
     45  SpecialPowers.executeSoon(async function() {
     46    await GamepadService.removeGamepad(index);
     47    SimpleTest.finish();
     48  });
     49 }
     50 
     51 async function buttonpresshandler(e) {
     52  if (testOver) {
     53    return;
     54  }
     55  if (timea == 0){
     56    timea = e.gamepad.timestamp;
     57  } else {
     58    ok(timea <= e.gamepad.timestamp, "Timestamp less than last timestamp");
     59  }
     60  await GamepadService.newButtonEvent(index, 0, false, false);
     61  if (!firstPress) {
     62    testOver = true;
     63    SpecialPowers.executeSoon(cleanup);
     64  } else {
     65    firstPress = false;
     66  }
     67 }
     68 
     69 </script>
     70 </body>
     71 </html>