1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/devtools/webconsole/test/network_requests_iframe.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,61 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 + <head> 1.7 + <meta charset="utf-8"> 1.8 + <title>Console HTTP test page</title> 1.9 + <!-- Any copyright is dedicated to the Public Domain. 1.10 + - http://creativecommons.org/publicdomain/zero/1.0/ --> 1.11 + <script type="text/javascript"><!-- 1.12 + var setAllowAllCookies = false; 1.13 + 1.14 + function makeXhr(aMethod, aUrl, aRequestBody, aCallback) { 1.15 + // On the first call, allow all cookies and set cookies, then resume the actual test 1.16 + if(!setAllowAllCookies) 1.17 + SpecialPowers.pushPrefEnv({"set": [["network.cookie.cookieBehavior", 0]]}, function () { 1.18 + setAllowAllCookies = true; 1.19 + setCookies(); 1.20 + makeXhrCallback(aMethod, aUrl, aRequestBody, aCallback); 1.21 + }); 1.22 + else 1.23 + makeXhrCallback(aMethod, aUrl, aRequestBody, aCallback); 1.24 + } 1.25 + 1.26 + function makeXhrCallback(aMethod, aUrl, aRequestBody, aCallback) { 1.27 + var xmlhttp = new XMLHttpRequest(); 1.28 + xmlhttp.open(aMethod, aUrl, true); 1.29 + if (aCallback) { 1.30 + xmlhttp.onreadystatechange = function() { 1.31 + if (xmlhttp.readyState == 4) { 1.32 + aCallback(); 1.33 + } 1.34 + }; 1.35 + } 1.36 + xmlhttp.send(aRequestBody); 1.37 + } 1.38 + 1.39 + function testXhrGet(aCallback) { 1.40 + makeXhr('get', 'data.json', null, aCallback); 1.41 + } 1.42 + 1.43 + function testXhrPost(aCallback) { 1.44 + var body = "Hello world! " + (new Array(50)).join("foobaz barr"); 1.45 + makeXhr('post', 'data.json', body, aCallback); 1.46 + } 1.47 + 1.48 + function setCookies() { 1.49 + document.cookie = "foobar=fooval"; 1.50 + document.cookie = "omgfoo=bug768096"; 1.51 + document.cookie = "badcookie=bug826798=st3fan"; 1.52 + } 1.53 + // --></script> 1.54 + </head> 1.55 + <body> 1.56 + <h1>Web Console HTTP Logging Testpage</h1> 1.57 + <h2>This page is used to test the HTTP logging.</h2> 1.58 + 1.59 + <form action="?" method="post"> 1.60 + <input name="name" type="text" value="foo bar"><br> 1.61 + <input name="age" type="text" value="144"><br> 1.62 + </form> 1.63 + </body> 1.64 +</html>