tor-browser

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

test_sync_xhr_timer.xhtml (1103B)


      1 <?xml version="1.0"?>
      2 <html xmlns="http://www.w3.org/1999/xhtml">
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=
      5 -->
      6 <head>
      7  <title>Test for Bug </title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     10 </head>
     11 <body>
     12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
     13 <p id="display"></p>
     14 <div id="content" style="display: none">
     15 
     16 </div>
     17 <pre id="test">
     18 <script type="application/javascript">
     19 <![CDATA[
     20 
     21 var counter = 0;
     22 var xhr;
     23 
     24 function syncXHR() {
     25  xhr = new XMLHttpRequest();
     26  xhr.open("GET", window.location, false);
     27  xhr.send(null);
     28 }
     29 
     30 function increaseCounter() {
     31  ++counter;
     32  ok(counter <= 2, "Too many increaseCounter() calls!");
     33  if (counter == 2) {
     34    ok(true, "increaseCounter() should be called twice!");
     35    SimpleTest.finish();
     36  }
     37 }
     38 
     39 function runTest() {
     40  setTimeout(syncXHR, 0);
     41  setTimeout(increaseCounter, 0);
     42  setTimeout(increaseCounter, 0);
     43 }
     44 
     45 SimpleTest.waitForExplicitFinish();
     46 addLoadEvent(runTest);
     47 
     48 ]]>
     49 </script>
     50 </pre>
     51 </body>
     52 </html>