extra: import at 3.0.1 beta 1
[mozilla-extra.git] / extensions / xmlextras / tests / 404post.html
blob4912ff9c4db9154faf97ccfc98b7a08cf1a6476f
1 <html>
2 <head><title>POST test</title>
3 <style type="text/css">
4 .box {
5 display: box;
6 border: 1px solid black;
7 margin-bottom: 0.5em;
9 .boxheader {
10 font-weight: bold;
11 color: maroon;
13 pre {
14 margin-left: 2em;
16 </style>
17 <script type="text/javascript">
18 const WSTRING_CONTRACTID = "@mozilla.org/supports-string;1";
20 // You can only create the text string if you can bybass security, like in chrome
21 var sendPlainTextData = false;
23 var x;
24 if (!sendPlainTextData) {
25 x = document.implementation.createDocument("", "test", null);
26 x.documentElement.appendChild(document.createElement("Foo"));
27 x.documentElement.appendChild(document.createElement("Bar"));
28 x.documentElement.firstChild.appendChild(document.createTextNode("My Stuff\nYeah"));
31 var p = new XMLHttpRequest();
33 function myfunc(e)
35 document.getElementById("id1").firstChild.nodeValue = p.responseText;
36 if (p.responseXML) {
37 var s = new XMLSerializer();
38 var d = p.responseXML;
39 var str = s.serializeToString(d);
40 document.getElementById("id2").firstChild.nodeValue = str;
42 document.getElementById("id3").firstChild.nodeValue = p.getAllResponseHeaders();
43 document.getElementById("id4").firstChild.nodeValue = p.status;
44 document.getElementById("id5").firstChild.nodeValue = p.statusText;
45 document.getElementById("id6").firstChild.nodeValue = p.readyState;
46 var eventProperties = "";
47 for (prop in e) {
48 eventProperties += prop + " : '" + e[prop] + "'\n";
50 document.getElementById("id7").firstChild.nodeValue =
51 "Event object: " + e + "\n" +
52 "Event properties:\n" + eventProperties;
55 p.onload = myfunc;
56 netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
57 p.open("POST", "http://green/cgi-bin/this.handler.does.not.exist.xgfrsjfrsgdfr.cgi");
59 if (!sendPlainTextData) {
60 p.send(x);
61 } else {
62 var mystr = Components.classes[WSTRING_CONTRACTID].createInstance(Components.interfaces.nsISupportsString);
63 mystr.data = "Heikki's data";
64 p.send(mystr);
66 </script>
67 </head>
68 <body>
69 <h1>POST test</h1>
71 <div class="box"><span class="boxheader">responseText</span>
72 <pre id="id1">@@No result@@</pre>
73 </div>
74 <div class="box"><span class="boxheader">responseXML serialized</span>
75 <pre id="id2">@@No result@@</pre>
76 </div>
77 <div class="box"><span class="boxheader">getAllResponseHeaders()</span>
78 <pre id="id3">@@No result@@</pre>
79 </div>
80 <div class="box"><span class="boxheader">status</span>
81 <pre id="id4">@@No result@@</pre>
82 </div>
83 <div class="box"><span class="boxheader">statusText</span>
84 <pre id="id5">@@No result@@</pre>
85 </div>
86 <div class="box"><span class="boxheader">readyState</span>
87 <pre id="id6">@@No result@@</pre>
88 </div>
89 <div class="box"><span class="boxheader">Event information</span>
90 <pre id="id7">@@No result@@</pre>
91 </div>
93 </body>
94 </html>