tor-browser

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

test_resume.html (1268B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Media test: Test resume of server-dropped connections</title>
      5  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      7 </head>
      8 <body>
      9 <audio preload="auto" id="a"></audio>
     10 <iframe id="f"></iframe>
     11 <pre id="test">
     12 <script class="testbody" type="text/javascript">
     13 var key = Math.round(Math.random()*1000000000);
     14 var a = document.getElementById("a");
     15 var f = document.getElementById("f");
     16 
     17 function didEnd() {
     18  ok(a.currentTime > 2.26, "Reached correct end time (got " + a.currentTime + ", expected > 2.26");
     19  SimpleTest.finish();
     20 }
     21 
     22 function didSendCancel() {
     23  a.addEventListener("ended", didEnd);
     24  a.play();
     25 }
     26 
     27 function didSuspend() {
     28  a.removeEventListener("suspend", didSuspend);
     29 
     30  // Cache must have filled up, or something. Tell the Web server to drop
     31  // our connection.
     32  f.addEventListener("load", didSendCancel);
     33  f.src = "cancellable_request.sjs?cancelkey=" + key;
     34 }
     35 
     36 if (!a.canPlayType("audio/wave")) {
     37  todo(false, "Test requires support for audio/wave");
     38 } else {
     39  a.addEventListener("suspend", didSuspend);
     40  a.src = "cancellable_request.sjs?key=" + key;
     41  SimpleTest.waitForExplicitFinish();
     42 }
     43 </script>
     44 </pre>
     45 </body>
     46 </html>