RetroZilla/extensions/xmlextras/tests/post.xhtml
2015-10-20 23:03:22 -04:00

49 lines
1.2 KiB
HTML

<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<h1>Posting test</h1>
<script>
<![CDATA[
const WSTRING_CONTRACTID = "@mozilla.org/supports-string;1";
var sendPlainTextData = false; // you can only create the text string if you can bybass security
var x;
if (!sendPlainTextData) {
x = document.implementation.createDocument("", "test", null);
x.documentElement.appendChild(document.createElement("Foo"));
x.documentElement.appendChild(document.createElement("Bar"));
x.documentElement.firstChild.appendChild(document.createTextNode("My Stuff\nYeah"));
}
var p = new XMLHttpRequest();
function myfunc()
{
var s = new XMLSerializer();
var str;
if (!sendPlainTextData) {
var d = p.responseXML;
str = s.serializeToString(d);
} else {
str = p.responseText;
}
alert(str);
alert(p.getAllResponseHeaders());
}
p.onload = myfunc;
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
p.open("POST", "http://green/cgi-bin/echo_xml.cgi");
if (!sendPlainTextData) {
p.send(x);
} else {
var mystr = Components.classes[WSTRING_CONTRACTID].createInstance(Components.interfaces.nsISupportsString);
mystr.data = "Heikki's data";
p.send(mystr);
}
]]>
</script>
</body>
</html>