toolkit/devtools/webconsole/test/network_requests_iframe.html
author Phil Ringnalda <philringnalda@gmail.com>
Sat, 13 Sep 2014 09:59:06 -0700
changeset 205205 d070787de8f7b56e32bf5800b30f143c4d02d474
parent 122662 8679f0f1c2153b06a31122670dcb7d7b2f9f2a42
child 260411 b2a5bd71898a3aebbc78c1425d6f39138584a173
permissions -rw-r--r--
Merge b-i to m-c

<!DOCTYPE HTML>
<html>
  <head>
    <meta charset="utf-8">
    <title>Console HTTP test page</title>
    <!-- Any copyright is dedicated to the Public Domain.
       - http://creativecommons.org/publicdomain/zero/1.0/ -->
    <script type="text/javascript"><!--
      var setAllowAllCookies = false;

      function makeXhr(aMethod, aUrl, aRequestBody, aCallback) {
        // On the first call, allow all cookies and set cookies, then resume the actual test
        if(!setAllowAllCookies)
          SpecialPowers.pushPrefEnv({"set": [["network.cookie.cookieBehavior", 0]]}, function () {
            setAllowAllCookies = true;
            setCookies();
            makeXhrCallback(aMethod, aUrl, aRequestBody, aCallback);
          });
        else
          makeXhrCallback(aMethod, aUrl, aRequestBody, aCallback);
      }

      function makeXhrCallback(aMethod, aUrl, aRequestBody, aCallback) {
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.open(aMethod, aUrl, true);
        if (aCallback) {
          xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4) {
              aCallback();
            }
          };
        }
        xmlhttp.send(aRequestBody);
      }

      function testXhrGet(aCallback) {
        makeXhr('get', 'data.json', null, aCallback);
      }

      function testXhrPost(aCallback) {
        var body = "Hello world! " + (new Array(50)).join("foobaz barr");
        makeXhr('post', 'data.json', body, aCallback);
      }
      
      function setCookies() {
        document.cookie = "foobar=fooval";
        document.cookie = "omgfoo=bug768096";
        document.cookie = "badcookie=bug826798=st3fan";
      }
    // --></script>
  </head>
  <body>
    <h1>Web Console HTTP Logging Testpage</h1>
    <h2>This page is used to test the HTTP logging.</h2>

    <form action="?" method="post">
      <input name="name" type="text" value="foo bar"><br>
      <input name="age" type="text" value="144"><br>
    </form>
  </body>
</html>