tor-browser

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

network_requests_iframe.html (2097B)


      1 <!DOCTYPE HTML>
      2 <html>
      3  <head>
      4    <meta charset="utf-8">
      5    <title>Console HTTP test page</title>
      6    <!-- Any copyright is dedicated to the Public Domain.
      7       - http://creativecommons.org/publicdomain/zero/1.0/ -->
      8    <script type="text/javascript"><!--
      9      "use strict";
     10      let setAllowAllCookies = false;
     11 
     12      function makeXhr(method, url, requestBody, callback) {
     13        // On the first call, allow all cookies and set cookies, then resume the actual test
     14        if (!setAllowAllCookies) {
     15          SpecialPowers.pushPrefEnv({"set": [["network.cookie.cookieBehavior", 0]]},
     16          function() {
     17            setAllowAllCookies = true;
     18            setCookies();
     19            makeXhrCallback(method, url, requestBody, callback);
     20          });
     21        } else {
     22          makeXhrCallback(method, url, requestBody, callback);
     23        }
     24      }
     25 
     26      function makeXhrCallback(method, url, requestBody, callback) {
     27        const xmlhttp = new XMLHttpRequest();
     28        xmlhttp.open(method, url, true);
     29        if (callback) {
     30          xmlhttp.onreadystatechange = function() {
     31            if (xmlhttp.readyState == 4) {
     32              callback();
     33            }
     34          };
     35        }
     36        xmlhttp.send(requestBody);
     37      }
     38 
     39      /* exported testXhrGet */
     40      function testXhrGet(callback, url = "data.json") {
     41        makeXhr("get", url, null, callback);
     42      }
     43 
     44      /* exported testXhrPost */
     45      function testXhrPost(callback) {
     46        const body = "Hello world! " + (new Array(50)).join("foobaz barr");
     47        makeXhr("post", "data.json", body, callback);
     48      }
     49 
     50      function setCookies() {
     51        document.cookie = "foobar=fooval";
     52        document.cookie = "omgfoo=bug768096";
     53        document.cookie = "badcookie=bug826798=st3fan";
     54      }
     55      </script>
     56  </head>
     57  <body>
     58    <h1>Web Console HTTP Logging Testpage</h1>
     59    <h2>This page is used to test the HTTP logging.</h2>
     60 
     61    <form action="?" method="post">
     62      <input name="name" type="text" value="foo bar"><br>
     63      <input name="age" type="text" value="144"><br>
     64    </form>
     65  </body>
     66 </html>