Not part of build. Test more stuff.

This commit is contained in:
heikki%netscape.com 2001-09-07 22:09:06 +00:00
Родитель 4df8637d13
Коммит a65f5e152d
7 изменённых файлов: 256 добавлений и 35 удалений

Просмотреть файл

@ -1,16 +1,57 @@
<html>
<body>
<h1>document.load() test</h1>
<script>
<head>
<title>Synchronized document.load() test</title>
<style type="text/css">
.box {
display: box;
border: 1px solid black;
margin-bottom: 0.5em;
}
.boxheader {
font-weight: bold;
color: maroon;
}
pre {
margin-left: 2em;
}
</style>
<script type="text/javascript">
var xmlDoc = document.implementation.createDocument("", "test", null);
function documentLoaded(e) {
alert(xmlDoc.getElementById("id1").firstChild.nodeValue);
var s = new XMLSerializer();
var str = s.serializeToString(xmlDoc);
document.getElementById("id1").firstChild.nodeValue = str;
var eventProperties;
for (prop in e) {
eventProperties += prop + " : '" + e[prop] + "'\n";
}
document.getElementById("id2").firstChild.nodeValue =
"Event object: " + e + "\n" +
"Event properties:\n" +
eventProperties;
}
xmlDoc.addEventListener("load", documentLoaded, false);
function execute()
{
xmlDoc.load("test.xml");
}
setTimeout(execute,0);
</script>
</head>
<body>
<h1>Synchronized document.load() test</h1>
<div class="box"><span class="boxheader">XML document serialized</span>
<pre id="id1">@@No result@@</pre>
</div>
<div class="box"><span class="boxheader">Event information</span>
<pre id="id2">@@No result@@</pre>
</div>
</body>
</body>
</html>

Просмотреть файл

@ -0,0 +1,94 @@
<html>
<head><title>POST test</title>
<style type="text/css">
.box {
display: box;
border: 1px solid black;
margin-bottom: 0.5em;
}
.boxheader {
font-weight: bold;
color: maroon;
}
pre {
margin-left: 2em;
}
</style>
<script type="text/javascript">
const WSTRING_CONTRACTID = "@mozilla.org/supports-wstring;1";
// You can only create the text string if you can bybass security, like in chrome
var sendPlainTextData = false;
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(e)
{
document.getElementById("id1").firstChild.nodeValue = p.responseText;
if (p.responseXML) {
var s = new XMLSerializer();
var d = p.responseXML;
var str = s.serializeToString(d);
document.getElementById("id2").firstChild.nodeValue = str;
}
document.getElementById("id3").firstChild.nodeValue = p.getAllResponseHeaders();
document.getElementById("id4").firstChild.nodeValue = p.status;
document.getElementById("id5").firstChild.nodeValue = p.statusText;
document.getElementById("id6").firstChild.nodeValue = p.readyState;
var eventProperties;
for (prop in e) {
eventProperties += prop + " : '" + e[prop] + "'\n";
}
document.getElementById("id7").firstChild.nodeValue =
"Event object: " + e + "\n" +
"Event properties:\n" + eventProperties;
}
p.onload = myfunc;
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
p.open("POST", "http://green/cgi-bin/this.handler.does.not.exist.xgfrsjfrsgdfr.cgi");
if (!sendPlainTextData) {
p.send(x);
} else {
var mystr = Components.classes[WSTRING_CONTRACTID].createInstance(Components.interfaces.nsISupportsWString);
mystr.data = "Heikki's data";
p.send(mystr);
}
</script>
</head>
<body>
<h1>POST test</h1>
<div class="box"><span class="boxheader">responseText</span>
<pre id="id1">@@No result@@</pre>
</div>
<div class="box"><span class="boxheader">responseXML serialized</span>
<pre id="id2">@@No result@@</pre>
</div>
<div class="box"><span class="boxheader">getAllResponseHeaders()</span>
<pre id="id3">@@No result@@</pre>
</div>
<div class="box"><span class="boxheader">status</span>
<pre id="id4">@@No result@@</pre>
</div>
<div class="box"><span class="boxheader">statusText</span>
<pre id="id5">@@No result@@</pre>
</div>
<div class="box"><span class="boxheader">readyState</span>
<pre id="id6">@@No result@@</pre>
</div>
<div class="box"><span class="boxheader">Event information</span>
<pre id="id7">@@No result@@</pre>
</div>
</body>
</html>

Просмотреть файл

@ -18,17 +18,26 @@ pre {
<script type="text/javascript">
var p = new XMLHttpRequest();
function myfunc()
function myfunc(e)
{
document.getElementById("id1").firstChild.nodeValue = p.responseText;
if (p.responseXML) {
var s = new XMLSerializer();
var d = p.responseXML;
var str = s.serializeToString(d);
document.getElementById("id1").firstChild.nodeValue = p.responseText;
document.getElementById("id2").firstChild.nodeValue = str;
}
document.getElementById("id3").firstChild.nodeValue = p.getAllResponseHeaders();
document.getElementById("id4").firstChild.nodeValue = p.status;
document.getElementById("id5").firstChild.nodeValue = p.statusText;
document.getElementById("id6").firstChild.nodeValue = p.readyState;
var eventProperties;
for (prop in e) {
eventProperties += prop + " : '" + e[prop] + "'\n";
}
document.getElementById("id7").firstChild.nodeValue =
"Event object: " + e + "\n" +
"Event properties:\n" + eventProperties;
}
p.onload = myfunc;
@ -58,6 +67,9 @@ p.send(null);
<div class="box"><span class="boxheader">readyState</span>
<pre id="id6">@@No result@@</pre>
</div>
<div class="box"><span class="boxheader">Event information</span>
<pre id="id7">@@No result@@</pre>
</div>
</body>
</html>

Просмотреть файл

@ -30,22 +30,26 @@ if (!sendPlainTextData) {
var p = new XMLHttpRequest();
function myfunc()
function myfunc(e)
{
var s = new XMLSerializer();
var str;
if (!sendPlainTextData) {
var d = p.responseXML;
str = s.serializeToString(d);
} else {
str = p.responseText;
}
document.getElementById("id1").firstChild.nodeValue = p.responseText;
if (p.responseXML) {
var s = new XMLSerializer();
var d = p.responseXML;
var str = s.serializeToString(d);
document.getElementById("id2").firstChild.nodeValue = str;
}
document.getElementById("id3").firstChild.nodeValue = p.getAllResponseHeaders();
document.getElementById("id4").firstChild.nodeValue = p.status;
document.getElementById("id5").firstChild.nodeValue = p.statusText;
document.getElementById("id6").firstChild.nodeValue = p.readyState;
var eventProperties;
for (prop in e) {
eventProperties += prop + " : '" + e[prop] + "'\n";
}
document.getElementById("id7").firstChild.nodeValue =
"Event object: " + e + "\n" +
"Event properties:\n" + eventProperties;
}
p.onload = myfunc;
@ -82,6 +86,9 @@ if (!sendPlainTextData) {
<div class="box"><span class="boxheader">readyState</span>
<pre id="id6">@@No result@@</pre>
</div>
<div class="box"><span class="boxheader">Event information</span>
<pre id="id7">@@No result@@</pre>
</div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,48 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<h1>Posting test</h1>
<script>
<![CDATA[
const WSTRING_CONTRACTID = "@mozilla.org/supports-wstring;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.nsISupportsWString);
mystr.data = "Heikki's data";
p.send(mystr);
}
]]>
</script>
</body>
</html>

Просмотреть файл

@ -28,11 +28,13 @@ function execute()
p.open("POST", "http://green/cgi-bin/echo_xml.cgi", false);
p.send(x);
var d = p.responseXML;
var s = new XMLSerializer()
str = s.serializeToString(d);
document.getElementById("id1").firstChild.nodeValue = p.responseText;
if (p.responseXML) {
var s = new XMLSerializer();
var d = p.responseXML;
var str = s.serializeToString(d);
document.getElementById("id2").firstChild.nodeValue = str;
}
document.getElementById("id3").firstChild.nodeValue = p.getAllResponseHeaders();
document.getElementById("id4").firstChild.nodeValue = p.status;
document.getElementById("id5").firstChild.nodeValue = p.statusText;

Просмотреть файл

@ -25,21 +25,37 @@ try {
// In Mozilla, you can only create the text string if you can bybass security, like in chrome
var sendPlainTextData = false;
var docsize = 400; // the document has docsize*2+1 elements
var x;
if (!sendPlainTextData) {
try {
x = document.implementation.createDocument("", "test", null);
x.documentElement.appendChild(document.createElement("Foo"));
var i;
for (i = 0; i < docsize; i++) {
var fooElement = document.createElement("Foo");
fooElement.appendChild(document.createTextNode("My Stuff\nYeah"));
x.documentElement.appendChild(fooElement);
x.documentElement.appendChild(document.createElement("Bar"));
x.documentElement.firstChild.appendChild(document.createTextNode("My Stuff\nYeah"));
}
} catch (e) {
x = new ActiveXObject("Msxml2.DOMDocument");
x.loadXML("<?xml version='1.0'?>\n<test><foo>My Stuff\nYeah</foo><bar/></test>");
var str = "<?xml version='1.0'?>\n<test>";
var i;
for (i = 0; i < docsize; i++) {
str += "<Foo>My Stuff\nYeah</Foo><Bar/>";
}
str += "</test>";
x.loadXML(str);
}
}
var interactiveCount = 0;
function myfunc()
{
if (p.readyState == 3) {
interactiveCount++;
}
//alert("myfunc readyState=" + p.readyState);
//if (p.readyState == 2) {
// alert(p.getAllResponseHeaders());
@ -48,9 +64,9 @@ function myfunc()
if (p.readyState != 4)
return;
document.getElementById("id1").firstChild.nodeValue = p.responseText;
if (p.responseXML) {
var str;
if (!sendPlainTextData) {
try {
var s = new XMLSerializer();
var d = p.responseXML;
@ -58,15 +74,13 @@ function myfunc()
} catch (e) {
str = "@@TODO@@";
}
} else {
str = p.responseText;
}
document.getElementById("id1").firstChild.nodeValue = p.responseText;
document.getElementById("id2").firstChild.nodeValue = str;
}
document.getElementById("id3").firstChild.nodeValue = p.getAllResponseHeaders();
document.getElementById("id4").firstChild.nodeValue = p.status;
document.getElementById("id5").firstChild.nodeValue = p.statusText;
document.getElementById("id6").firstChild.nodeValue = p.readyState;
document.getElementById("id7").firstChild.nodeValue = interactiveCount;
}
// p.onload would also work in Mozilla
@ -122,6 +136,9 @@ if (!sendPlainTextData) {
<div class="box"><span class="boxheader">readyState</span>
<pre id="id6">@@No result@@</pre>
</div>
<div class="box"><span class="boxheader"># of times onreadystatechanged handler called with INTERACTIVE status</span>
<pre id="id7">@@No result@@</pre>
</div>
</body>
</html>