network_requests_iframe.html 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. var setAllowAllCookies = false;
  10. function makeXhr(aMethod, aUrl, aRequestBody, aCallback) {
  11. // On the first call, allow all cookies and set cookies, then resume the actual test
  12. if (!setAllowAllCookies)
  13. SpecialPowers.pushPrefEnv({"set": [["network.cookie.cookieBehavior", 0]]}, function () {
  14. setAllowAllCookies = true;
  15. setCookies();
  16. makeXhrCallback(aMethod, aUrl, aRequestBody, aCallback);
  17. });
  18. else
  19. makeXhrCallback(aMethod, aUrl, aRequestBody, aCallback);
  20. }
  21. function makeXhrCallback(aMethod, aUrl, aRequestBody, aCallback) {
  22. var xmlhttp = new XMLHttpRequest();
  23. xmlhttp.open(aMethod, aUrl, true);
  24. if (aCallback) {
  25. xmlhttp.onreadystatechange = function() {
  26. if (xmlhttp.readyState == 4) {
  27. aCallback();
  28. }
  29. };
  30. }
  31. xmlhttp.send(aRequestBody);
  32. }
  33. function testXhrGet(aCallback) {
  34. makeXhr('get', 'data.json', null, aCallback);
  35. }
  36. function testXhrPost(aCallback) {
  37. var body = "Hello world! " + (new Array(50)).join("foobaz barr");
  38. makeXhr('post', 'data.json', body, aCallback);
  39. }
  40. function setCookies() {
  41. document.cookie = "foobar=fooval";
  42. document.cookie = "omgfoo=bug768096";
  43. document.cookie = "badcookie=bug826798=st3fan";
  44. }
  45. // --></script>
  46. </head>
  47. <body>
  48. <h1>Web Console HTTP Logging Testpage</h1>
  49. <h2>This page is used to test the HTTP logging.</h2>
  50. <form action="?" method="post">
  51. <input name="name" type="text" value="foo bar"><br>
  52. <input name="age" type="text" value="144"><br>
  53. </form>
  54. </body>
  55. </html>