+2006-02-24 Alexey Proskuryakov <ap@nypop.com>
+
+ Reviewed by Darin.
+
+ - http://bugzilla.opendarwin.org/show_bug.cgi?id=7435
+ Add Ian Hickson's XMLHttpRequest tests
+
+ * http/conf/httpd.conf: Enable send-as-is handler, required by the tests.
+
+ * http/tests/xmlhttprequest/web-apps: Added.
+ * http/tests/xmlhttprequest/web-apps/.htaccess: Added.
+ * http/tests/xmlhttprequest/web-apps/001-expected.txt: Added.
+ * http/tests/xmlhttprequest/web-apps/001-test.cgi: Added.
+ * http/tests/xmlhttprequest/web-apps/001.html: Added.
+ * http/tests/xmlhttprequest/web-apps/002-expected.txt: Added.
+ * http/tests/xmlhttprequest/web-apps/002-simple-a.txt: Added.
+ * http/tests/xmlhttprequest/web-apps/002-simple-b.txt: Added.
+ * http/tests/xmlhttprequest/web-apps/002-simple-expected.txt: Added.
+ * http/tests/xmlhttprequest/web-apps/002-simple.html: Added.
+ * http/tests/xmlhttprequest/web-apps/002.html: Added.
+ * http/tests/xmlhttprequest/web-apps/002a.txt: Added.
+ * http/tests/xmlhttprequest/web-apps/002b.txt: Added.
+ * http/tests/xmlhttprequest/web-apps/002c.txt: Added.
+ * http/tests/xmlhttprequest/web-apps/003-expected.txt: Added.
+ * http/tests/xmlhttprequest/web-apps/003-test.cgi: Added.
+ * http/tests/xmlhttprequest/web-apps/003.html: Added.
+ * http/tests/xmlhttprequest/web-apps/004-expected.txt: Added.
+ * http/tests/xmlhttprequest/web-apps/004-test.cgi: Added.
+ * http/tests/xmlhttprequest/web-apps/004.html: Added.
+ * http/tests/xmlhttprequest/web-apps/005-expected.txt: Added.
+ * http/tests/xmlhttprequest/web-apps/005-test.cgi: Added.
+ * http/tests/xmlhttprequest/web-apps/005.html: Added.
+ * http/tests/xmlhttprequest/web-apps/006-test.cgi: Added.
+ * http/tests/xmlhttprequest/web-apps/006.html-disabled: Added.
+ * http/tests/xmlhttprequest/web-apps/007-expected.txt: Added.
+ * http/tests/xmlhttprequest/web-apps/007-test.asis: Added.
+ * http/tests/xmlhttprequest/web-apps/007.html: Added.
+ * http/tests/xmlhttprequest/web-apps/008-expected.txt: Added.
+ * http/tests/xmlhttprequest/web-apps/008-test.asis: Added.
+ * http/tests/xmlhttprequest/web-apps/008.html: Added.
+ * http/tests/xmlhttprequest/web-apps/009-test.cgi: Added.
+ * http/tests/xmlhttprequest/web-apps/009.html-disabled: Added.
+ * http/tests/xmlhttprequest/web-apps/010-expected.txt: Added.
+ * http/tests/xmlhttprequest/web-apps/010-test.cgi: Added.
+ * http/tests/xmlhttprequest/web-apps/010.html: Added.
+ * http/tests/xmlhttprequest/web-apps/011-expected.txt: Added.
+ * http/tests/xmlhttprequest/web-apps/011-test200.asis: Added.
+ * http/tests/xmlhttprequest/web-apps/011.html: Added.
+ * http/tests/xmlhttprequest/web-apps/012-expected.txt: Added.
+ * http/tests/xmlhttprequest/web-apps/012-test200.asis: Added.
+ * http/tests/xmlhttprequest/web-apps/012.html: Added.
+ * http/tests/xmlhttprequest/web-apps/013-expected.txt: Added.
+ * http/tests/xmlhttprequest/web-apps/013-test.cgi: Added.
+ * http/tests/xmlhttprequest/web-apps/013.html: Added.
+ * http/tests/xmlhttprequest/web-apps/014-expected.txt: Added.
+ * http/tests/xmlhttprequest/web-apps/014-test404.asis: Added.
+ * http/tests/xmlhttprequest/web-apps/014.html: Added.
+ * http/tests/xmlhttprequest/web-apps/015-expected.txt: Added.
+ * http/tests/xmlhttprequest/web-apps/015-test.cgi: Added.
+ * http/tests/xmlhttprequest/web-apps/015.html: Added.
+ * http/tests/xmlhttprequest/web-apps/016-test.cgi: Added.
+ * http/tests/xmlhttprequest/web-apps/016.html-disabled: Added.
+ * http/tests/xmlhttprequest/web-apps/017.html-disabled: Added.
+ * http/tests/xmlhttprequest/web-apps/README: Added.
+ * http/tests/xmlhttprequest/web-apps/TODO: Added.
+ * http/tests/xmlhttprequest/web-apps/readme.txt: Added.
+ * http/tests/xmlhttprequest/web-apps/recursion: Added.
+ * http/tests/xmlhttprequest/web-apps/recursion/001.html-disabled: Added.
+ * http/tests/xmlhttprequest/web-apps/recursion/README: Added.
+
2006-02-22 Alexey Proskuryakov <ap@nypop.com>
Reviewed by Darin.
# Uncomment the following line to enable Apache's send-asis HTTP file
# feature
#
- #AddHandler send-as-is asis
+ AddHandler send-as-is asis
#
# If you wish to use server-parsed imagemap files, use
--- /dev/null
+<files 017.html>
+ SetHandler cgi-script
+</files>
--- /dev/null
+#!/usr/bin/perl -wT
+use strict;
+
+if ($ENV{'HTTP_X_TEST_HEADER'} eq 'Test') {
+ print "Content-Type: text/plain\nCache-Control: no-store\n\nPASS";
+} else {
+ print "Content-Type: text/plain\nCache-Control: no-store\n\nFAIL";
+}
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html lang="en">
+ <head>
+ <title>setRequestHeader</title>
+ </head>
+ <body>
+ <p>Script did not run.</p>
+ <script type="text/javascript">
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ var p = document.getElementsByTagName('p')[0];
+ p.firstChild.data = 'Test script started.';
+ window.onerror = function (error, file, line) { p.firstChild.data = 'ERROR: ' + error + ' (line ' + line + ')'; }
+ // window.XMLHttpRequest = function () { return new ActiveXObject("Microsoft.XMLHTTP"); }
+ var r = new XMLHttpRequest();
+ r.onreadystatechange = function () {
+ if (r.readyState == 4)
+ p.firstChild.data = r.responseText;
+ else
+ p.firstChild.data = 'Test in progress (' + r.readyState + '/4)';
+ };
+ r.open('GET', '001-test.cgi', true);
+ r.setRequestHeader('X-Test-Header', 'Test');
+ r.send(null);
+ p.firstChild.data = 'Request sent...';
+ </script>
+ </body>
+</html>
--- /dev/null
+A
\ No newline at end of file
--- /dev/null
+B
\ No newline at end of file
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html lang="en">
+ <head>
+ <title>multiple open()s (simple version)</title>
+ </head>
+ <body>
+ <p>FAIL: Script did not run.</p>
+ <script type="text/javascript">
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ var p = document.getElementsByTagName('p')[0];
+ p.firstChild.data = 'FAIL: Test did not complete.';
+ //if (window.ActiveXObject) // hack to let IE work
+ // window.XMLHttpRequest = function () { return new ActiveXObject("Microsoft.XMLHTTP"); }
+ var r = new XMLHttpRequest();
+ r.open('GET', '002-simple-a.txt', false); // "A"
+ r.send();
+ r.open('GET', '002-simple-b.txt', false); // "B"
+ r.send();
+ if (r.responseText == 'B') {
+ p.firstChild.data = 'PASS';
+ } else {
+ p.firstChild.data = 'FAIL: responseText contains "' + r.responseText + '".';
+ }
+ </script>
+ </body>
+</html>
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html lang="en">
+ <head>
+ <title>multiple open()s</title>
+ </head>
+ <body>
+ <p>Script did not run.</p>
+ <script type="text/javascript">
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ var p = document.getElementsByTagName('p')[0];
+ p.firstChild.data = 'FAIL: Test script failed and window.onerror not supported.';
+ window.onerror = function (error, file, line) { p.firstChild.data = 'FAIL: ' + error + ' (line ' + line + ')'; }
+ //window.XMLHttpRequest = function () { return new ActiveXObject("Microsoft.XMLHTTP"); }
+ var r = new XMLHttpRequest();
+ if (r.readyState != 0) { throw "readyState wrong after creation: should be 0, was " + r.readyState; }
+ r.open('GET', '002a.txt', false);
+ if (r.readyState != 1) { throw "readyState wrong after open(): should be 1, was " + r.readyState; }
+ r.open('GET', '002b.txt', false);
+ if (r.readyState != 1) { throw "readyState wrong after second open(): should be 1, was " + r.readyState; }
+ r.send();
+ if (r.readyState != 4) { throw "readyState wrong after sync send(): should be 4, was " + r.readyState; }
+ if (r.responseText != 'TWO') { throw "Wrong file downloaded: " + r.responseText; }
+ r.open('GET', '002c.txt', false);
+ if (r.readyState != 1) { throw "readyState wrong after third open(): should be 1, was " + r.readyState; }
+ r.send();
+ if (r.readyState != 4) { throw "readyState wrong after second sync send(): should be 4, was " + r.readyState; }
+ if (r.responseText == 'TWOTHREE') { throw "responseText not cleared by open()"; }
+ if (r.responseText != 'THREE') { throw "Wrong file downloaded: " + r.responseText; }
+ p.firstChild.data = 'PASS';
+ </script>
+ </body>
+</html>
--- /dev/null
+First open() used.
\ No newline at end of file
--- /dev/null
+TWO
\ No newline at end of file
--- /dev/null
+THREE
\ No newline at end of file
--- /dev/null
+#!/usr/bin/perl -wT
+use strict;
+
+print "Content-Type: text/plain\nCache-Control: no-store\n\nRESULT:[$ENV{'HTTP_X_TEST_HEADER'}]";
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html lang="en">
+ <head>
+ <title>setRequestHeader at odd times</title>
+ </head>
+ <body>
+ <p>FAIL: Script did not run.</p>
+ <script type="text/javascript">
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ var p = document.getElementsByTagName('p')[0];
+ p.firstChild.data = 'FAIL: Test script did not finish.';
+ window.onerror = function (error, file, line) { p.firstChild.data = 'ERROR: ' + error + ' (line ' + line + ')'; }
+ if (!window.XMLHttpRequest)
+ window.XMLHttpRequest = function () { return new ActiveXObject("Microsoft.XMLHTTP"); }
+ var r = new XMLHttpRequest;
+ r.open('GET', '003-test.cgi', false);
+ r.setRequestHeader('X-Test-Header', 'FAIL1');
+ r.send(null);
+ r.open('GET', '003-test.cgi', false);
+ r.setRequestHeader('X-Test-Header', 'FAIL2');
+ r.open('GET', '003-test.cgi', false);
+ r.setRequestHeader('X-Test-Header', 'TEST3');
+ r.send(null);
+ if (r.responseText == 'RESULT:[TEST3]') {
+ p.firstChild.data = 'PASS';
+ } else {
+ p.firstChild.data = 'FAIL (' + r.responseText + ')';
+ }
+ </script>
+ </body>
+</html>
--- /dev/null
+#!/usr/bin/perl -wT
+use strict;
+
+print "Content-Type: text/plain\nCache-Control: no-store\n\nRESULT:[$ENV{'HTTP_X_TEST_HEADER1'}][$ENV{'HTTP_X_TEST_HEADER2'}]";
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html lang="en">
+ <head>
+ <title>setRequestHeader at odd times</title>
+ </head>
+ <body>
+ <p>FAIL: Script did not run.</p>
+ <script type="text/javascript">
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ var p = document.getElementsByTagName('p')[0];
+ p.firstChild.data = 'FAIL: Test script did not finish.';
+ window.onerror = function (error, file, line) { p.firstChild.data = 'ERROR: ' + error + ' (line ' + line + ')'; }
+ if (!window.XMLHttpRequest)
+ window.XMLHttpRequest = function () { return new ActiveXObject("Microsoft.XMLHTTP"); }
+ var r = new XMLHttpRequest();
+ r.open('GET', '004-test.cgi', false);
+ r.setRequestHeader('X-Test-Header1', 'YES');
+ r.setRequestHeader('X-Test-Header2', 'NO');
+ r.send(null);
+ r.open('GET', '004-test.cgi', false);
+ r.setRequestHeader('X-Test-Header2', 'YES');
+ r.send(null);
+ if (r.responseText == 'RESULT:[][YES]') {
+ p.firstChild.data = 'PASS';
+ } else {
+ p.firstChild.data = 'FAIL (' + r.responseText + ')';
+ }
+ </script>
+ </body>
+</html>
--- /dev/null
+#!/usr/bin/perl -wT
+use strict;
+
+print "Content-Type: text/plain\nCache-Control: no-store\n\nRESULT:[$ENV{'HTTP_X_TEST_HEADER'}]";
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html lang="en">
+ <head>
+ <title>setRequestHeader twice for the same header</title>
+ </head>
+ <body>
+ <p>FAIL: Script did not run.</p>
+ <script type="text/javascript">
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ var p = document.getElementsByTagName('p')[0];
+ p.firstChild.data = 'FAIL: Test script did not finish.';
+ window.onerror = function (error, file, line) { p.firstChild.data = 'ERROR: ' + error + ' (line ' + line + ')'; }
+ if (!window.XMLHttpRequest)
+ window.XMLHttpRequest = function () { return new ActiveXObject("Microsoft.XMLHTTP"); }
+ var r = new XMLHttpRequest();
+ r.open('GET', '005-test.cgi', false);
+ r.setRequestHeader('X-Test-Header', 'ONE');
+ r.setRequestHeader('X-Test-Header', 'TWO');
+ r.send(null);
+ if (r.responseText == 'RESULT:[ONE, TWO]') {
+ p.firstChild.data = 'PASS';
+ } else {
+ p.firstChild.data = 'FAIL (' + r.responseText + ')';
+ }
+ </script>
+ </body>
+</html>
--- /dev/null
+#!/usr/bin/perl -wT
+use strict;
+
+$| = 1;
+print "Content-Type: text/plain\nCache-Control: no-store\n\nTOP (wait 60 seconds for the next line)\n";
+sleep 10;
+print "BOTTOM\n";
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html lang="en">
+ <head>
+ <title>setTimeout and sync XMLHttpRequests</title>
+ </head>
+ <body>
+ <p>FAIL: Script did not run.</p>
+ <script type="text/javascript">
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ var p = document.getElementsByTagName('p')[0];
+ p.firstChild.data = 'FAIL: Test script did not finish.';
+ if (!window.XMLHttpRequest)
+ window.XMLHttpRequest = function () { return new ActiveXObject("Microsoft.XMLHTTP"); }
+ var r = new XMLHttpRequest();
+ r.open('GET', '006-test.cgi', false);
+ var x = 0;
+ window.setTimeout(function() { r.abort(); x += 1; }, 20);
+ p.firstChild.data = 'Please wait 10 seconds...';
+ r.send(null);
+ p.firstChild.data = x ? 'FAIL' : 'PASS (unless your browser UI locked up for 10 seconds)';
+ </script>
+ </body>
+</html>
--- /dev/null
+Test: PASS
+
+BODY
\ No newline at end of file
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html lang="en">
+ <head>
+ <title>getAllResponseHeaders</title>
+ <style type="text/css">
+ pre { color: silver; }
+ </style>
+ </head>
+ <body>
+ <p>FAIL: Script did not run.</p>
+ <pre></pre>
+ <script type="text/javascript">
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ var p = document.getElementsByTagName('p')[0];
+ var pre = document.getElementsByTagName('pre')[0];
+ p.firstChild.data = 'FAIL: Test script did not finish.';
+ if (!window.XMLHttpRequest)
+ window.XMLHttpRequest = function () { return new ActiveXObject("Microsoft.XMLHTTP"); }
+ var r = new XMLHttpRequest();
+ r.open('GET', '007-test.asis', false);
+ r.send(null);
+ var s = r.getAllResponseHeaders();
+ p.firstChild.data = (s.length > 100) ? 'PASS' : 'FAIL';
+ s = s.replace(/Date: .+[\r\n]+/, 'Date: (censored)\n');
+// pre.appendChild(document.createTextNode(s));
+ </script>
+ </body>
+</html>
--- /dev/null
+FAIL ("test1", "a, b", "undefined")
+
+
--- /dev/null
+Test1: test1
+test2: a
+test2: b
+
+BODY
\ No newline at end of file
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html lang="en">
+ <head>
+ <title>getResponseHeader</title>
+ </head>
+ <body>
+ <p>FAIL: Script did not run.</p>
+ <script type="text/javascript">
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ var p = document.getElementsByTagName('p')[0];
+ p.firstChild.data = 'FAIL: Test script did not finish.';
+ if (!window.XMLHttpRequest)
+ window.XMLHttpRequest = function () { return new ActiveXObject("Microsoft.XMLHTTP"); }
+ var r = new XMLHttpRequest();
+ r.open('GET', '008-test.asis', false);
+ r.send(null);
+ var s1 = r.getResponseHeader('test1');
+ var s2 = r.getResponseHeader('test2');
+ var s3 = r.getResponseHeader('test3');
+ p.firstChild.data = (s1 == 'test1' && s2 == 'a, b' && s3 == '') ? 'PASS' : 'FAIL ("' + s1 + '", "' + s2 + '", "' + s3 + '")';
+ </script>
+ </body>
+</html>
--- /dev/null
+#!/usr/bin/perl -wT
+use strict;
+
+$| = 1;
+print "Content-Type: text/xml\nCache-Control: no-store\n\n<test>";
+sleep 60;
+print "</test>\n";
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html lang="en">
+ <head>
+ <title>responseXML and slow loads</title>
+ </head>
+ <body>
+ <p>FAIL: Script did not run.</p>
+ <script type="text/javascript">
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ var p = document.getElementsByTagName('p')[0];
+ p.firstChild.data = 'FAIL: Test script did not finish.';
+ if (!window.XMLHttpRequest)
+ window.XMLHttpRequest = function () { return new ActiveXObject("Microsoft.XMLHTTP"); }
+ var r = new XMLHttpRequest();
+ r.open('GET', '009-test.cgi', true);
+ window.setTimeout(function() {
+ p.firstChild.data = r.responseXML ?
+ r.responseXML.documentElement ?
+ r.responseXML.documentElement.tagName == 'test' ? 'FAIL: Incomplete document was parsed'
+ : 'FAIL: documentElement had wrong tagName (and shouldn\'t exist anyway)'
+ : 'FAIL: responseXML had documentElement (responseXML should be null)'
+ : 'PASS';
+ }, 2000);
+ p.firstChild.data = 'FAIL: setTimeout did not trigger.';
+ r.send(null);
+ </script>
+ </body>
+</html>
--- /dev/null
+#!/usr/bin/perl -wT
+use strict;
+
+$| = 1;
+print "Content-Type: text/xml\nCache-Control: no-store\n\n<test></test>";
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html lang="en">
+ <head>
+ <title>responseXML</title>
+ </head>
+ <body>
+ <p>FAIL: Script did not run.</p>
+ <script type="text/javascript">
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ var p = document.getElementsByTagName('p')[0];
+ p.firstChild.data = 'FAIL: Test script did not finish.';
+ if (!window.XMLHttpRequest)
+ window.XMLHttpRequest = function () { return new ActiveXObject("Microsoft.XMLHTTP"); }
+ var r = new XMLHttpRequest();
+ r.open('GET', '010-test.cgi', false);
+ r.send(null);
+ p.firstChild.data = r.responseXML ?
+ r.responseXML.documentElement ?
+ r.responseXML.documentElement.tagName == 'test' ? 'PASS'
+ : 'FAIL: wrong tagName: ' + r.responseXML.documentElement.tagName
+ : 'FAIL: no documentElement in ' + r.responseXML
+ : 'FAIL: no document in ' + r;
+ </script>
+ </body>
+</html>
--- /dev/null
+Status: 200 Foo widdle waddle!
+
+BODY
\ No newline at end of file
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html lang="en">
+ <head>
+ <title>status</title>
+ </head>
+ <body>
+ <p>FAIL: Script did not run.</p>
+ <script type="text/javascript">
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ var p = document.getElementsByTagName('p')[0];
+ p.firstChild.data = 'FAIL: Test script did not finish.';
+ if (!window.XMLHttpRequest)
+ window.XMLHttpRequest = function () { return new ActiveXObject("Microsoft.XMLHTTP"); }
+ var r = new XMLHttpRequest();
+ r.open('GET', '011-test200.asis', false);
+ r.send(null);
+ var c = r.status;
+ p.firstChild.data = c == 200 ? 'PASS' : 'FAIL:' + c3;
+ </script>
+ </body>
+</html>
--- /dev/null
+FAIL: "OK"
+
+
--- /dev/null
+Status: 200 Foo widdle waddle!
+
+BODY
\ No newline at end of file
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html lang="en-Hixie">
+ <head>
+ <title>statusText</title>
+ </head>
+ <body>
+ <p>FAIL: Script did not run.</p>
+ <script type="text/javascript">
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ var p = document.getElementsByTagName('p')[0];
+ p.firstChild.data = 'FAIL: Test script did not finish.';
+ if (!window.XMLHttpRequest)
+ window.XMLHttpRequest = function () { return new ActiveXObject("Microsoft.XMLHTTP"); }
+ var r = new XMLHttpRequest();
+ r.open('GET', '012-test200.asis', false);
+ r.send(null);
+ var c = r.statusText;
+ p.firstChild.data = c == 'Foo widdle waddle!' ? 'PASS' : 'FAIL: "' + c + '"';
+ </script>
+ </body>
+</html>
--- /dev/null
+FAIL: Status at readyState 3 was: 400, "OK"
+
+
--- /dev/null
+#!/usr/bin/perl -wT
+use strict;
+
+sleep 3;
+
+$| = 1;
+print "Status: 400 Good work\nContent-Type: text/plain\nCache-Control: no-store\n\nBODY";
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html lang="en-Hixie">
+ <head>
+ <title>statusText</title>
+ </head>
+ <body>
+ <p>FAIL: Script did not run.</p>
+ <script type="text/javascript">
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+ }
+
+ var p = document.getElementsByTagName('p')[0];
+ p.firstChild.data = 'FAIL: Test script did not finish.';
+ if (!window.XMLHttpRequest)
+ window.XMLHttpRequest = function () { return new ActiveXObject("Microsoft.XMLHTTP"); }
+ var r = new XMLHttpRequest();
+ r.open('GET', '013-test.cgi', true);
+ p.firstChild.data = 'FAIL: Test script blocked on async request.';
+ r.send(null);
+ p.firstChild.data = 'FAIL: readyState did not change to 3 (Receiving). (Wait a few seconds, just in case it does.)';
+ setTimeout(function () {
+ r.onreadystatechange = function() {
+ if (r.readyState == 3) {
+ p.firstChild.data = 'FAIL: Exceptions were probably raised while accessing status or statusText.';
+ setTimeout(function() {
+ var c1 = r.status;
+ var c2 = r.statusText;
+ p.firstChild.data = c1 == 400 && c2 == 'Good work' ? 'PASS' : 'FAIL: Status at readyState 3 was: ' + c1 + ', "' + c2 + '"';
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }, 500);
+ }
+ }
+ }, 1000);
+ </script>
+ </body>
+</html>
--- /dev/null
+Status: 404 The cat and the fiddle!
+
+BODY
\ No newline at end of file
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html lang="en">
+ <head>
+ <title>status</title>
+ </head>
+ <body>
+ <p>FAIL: Script did not run.</p>
+ <script type="text/javascript">
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ var p = document.getElementsByTagName('p')[0];
+ p.firstChild.data = 'FAIL: Test script did not finish.';
+ if (!window.XMLHttpRequest)
+ window.XMLHttpRequest = function () { return new ActiveXObject("Microsoft.XMLHTTP"); }
+ var r = new XMLHttpRequest();
+ r.open('GET', '014-test404.asis', false);
+ r.send(null);
+ var c = r.status;
+ p.firstChild.data = c == 404 ? 'PASS' : 'FAIL:' + c;
+ </script>
+ </body>
+</html>
--- /dev/null
+#!/usr/bin/perl -wT
+use strict;
+
+print "Content-Type: text/plain\nCache-Control: no-store\n\nRESULT:[$ENV{'HTTP_X_TEST_HEADER1'}][$ENV{'HTTP_X_TEST_HEADER2'}][$ENV{'HTTP_X_TEST_HEADER3'}]";
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html lang="en">
+ <head>
+ <title>Multiple setRequestHeader()s</title>
+ </head>
+ <body>
+ <p>FAIL: Script did not run.</p>
+ <script type="text/javascript">
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ var p = document.getElementsByTagName('p')[0];
+ p.firstChild.data = 'FAIL: Test script did not finish.';
+ window.onerror = function (error, file, line) { p.firstChild.data = 'ERROR: ' + error + ' (line ' + line + ')'; }
+ if (!window.XMLHttpRequest)
+ window.XMLHttpRequest = function () { return new ActiveXObject("Microsoft.XMLHTTP"); }
+ var r = new XMLHttpRequest();
+ r.open('GET', '015-test.cgi', false);
+ r.setRequestHeader('X-Test-Header1', 'A');
+ r.setRequestHeader('X-Test-Header2', 'B');
+ r.setRequestHeader('X-Test-Header3', 'C');
+ r.send(null);
+ if (r.responseText == 'RESULT:[A][B][C]') {
+ p.firstChild.data = 'PASS';
+ } else {
+ p.firstChild.data = 'FAIL (' + r.responseText + ')';
+ }
+ </script>
+ </body>
+</html>
--- /dev/null
+#!/usr/bin/perl -wT
+use strict;
+sleep 600; # ten minutes
+close STDOUT;
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html lang="en">
+ <head>
+ <title>XMLHttpRequest and timeouts</title>
+ </head>
+ <body>
+ <p>FAIL: Script did not run.</p>
+ <script type="text/javascript">
+ var p = document.getElementsByTagName('p')[0];
+ p.firstChild.data = 'FAIL: Test script did not finish.';
+ window.onerror = function (error, file, line) { p.firstChild.data += ' (ERROR: ' + error + ' (line ' + line + '))'; }
+ if (!window.XMLHttpRequest)
+ window.XMLHttpRequest = function () { return new ActiveXObject("Microsoft.XMLHTTP"); }
+ var r = new XMLHttpRequest();
+ r.open('GET', '016-test.cgi', true);
+ r.onreadystatechange = function () {
+ p.firstChild.data += r.readyState + ' ';
+ p.firstChild.data += '(status: ' + r.status + ') ';
+ }
+ r.send(null);
+ p.firstChild.data = 'Wait at least 10 minutes. Response: ';
+ </script>
+ </body>
+</html>
--- /dev/null
+#!/usr/bin/perl -wT
+use strict;
+use IO::Socket;
+use IO::Select;
+
+my $port = 10080;
+my $server = undef;
+while (!$server and $port < 10180) {
+ $server = IO::Socket::INET->new(LocalAddr => '127.0.0.1', LocalPort => $port, Proto => 'tcp', Listen => 2, ReuseAddr => 1);
+ $port += 1 unless $server;
+}
+die "Could not connect: $! $@\n" unless $server;
+
+my $sockets = IO::Select->new($server);
+my $clients = {};
+
+print "Status: 303 See Other\r\nLocation: http://127.0.0.1:$port/test1\r\nContent-Type: text/plain\r\n\r\nTest server started on port $port\r\n";
+close STDOUT;
+
+my @pendingData = $sockets->can_read(5);
+foreach my $socket (@pendingData) {
+ if ($socket == $server) {
+ $socket = $server->accept;
+ if ($socket) {
+ $socket->syswrite(<<ENDTEST);
+HTTP/1.1 200 OK
+Content-Type: text/html
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html lang="en">
+ <head>
+ <title>XMLHttpRequest and connection refused</title>
+ </head>
+ <body>
+ <p>FAIL: Script did not run.</p>
+ <script type="text/javascript">
+ var p = document.getElementsByTagName('p')[0];
+ p.firstChild.data = 'FAIL: Test script did not finish.';
+ window.onerror = function (error, file, line) { p.firstChild.data += ' (ERROR: ' + error + ' (line ' + line + '))'; }
+ if (!window.XMLHttpRequest)
+ window.XMLHttpRequest = function () { return new ActiveXObject("Microsoft.XMLHTTP"); }
+ var r = new XMLHttpRequest();
+ r.open('GET', 'test2', true);
+ r.onreadystatechange = function () {
+ p.firstChild.data += r.readyState + ' ';
+ p.firstChild.data += '(status: ' + r.status + ') ';
+ }
+ r.send(null);
+ p.firstChild.data = 'Response: ';
+ </script>
+ </body>
+</html>
+ENDTEST
+ $socket->shutdown(2);
+ last;
+ }
+ }
+}
+
+$server->shutdown(2);
--- /dev/null
+There is a potential problem with some of these tests: Apache
+sometimes returns 304s (correctly, I guess) instead of always running
+the CGI script. I've tried to avoid this problem using 'no-store'
+headers but I don't know if that's the right way to do this.
+
+Note: 016 and 017 do not yet have pass criteria.
--- /dev/null
+Check that a document with type "text/x-pseudo-xml" is not parsed as XML.
+Do XML documents fetched using XMLHttpRequest have script run? Have XML Stylesheet PIs loaded?
+Do responseXML and responseText return null or raise exceptions when not ready?
+Does .abort() send readyState to 0 and leave the event listeners?
+Do headers with U+000A, U+000D, U+0020, U+003A characters cause it to be dropped?
--- /dev/null
+Tests submitted by Ian 'Hixie' Hickson, the current version is available at <http://www.hixie.ch/tests/adhoc/dom/web-apps/XMLHttpRequest/>.
\ No newline at end of file
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html lang="en">
+ <head>
+ <title>XMLHttpRequest recursion</title>
+ </head>
+ <body>
+ <pre>FAIL: Script did not run.</pre>
+ <script type="text/javascript">
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ document.title = 'XMLHttpRequest recursion.'; // adds '.'
+ var p = document.getElementsByTagName('pre')[0];
+ p.firstChild.data = 'FAIL: Test script did not finish.';
+ window.onerror = function (error, file, line) { p.firstChild.data = 'ERROR: ' + error + ' (line ' + line + ')'; }
+ if (!window.XMLHttpRequest)
+ window.XMLHttpRequest = function () { return new ActiveXObject("Microsoft.XMLHTTP"); }
+ var r = new XMLHttpRequest();
+ r.open('GET', '001.html', false);
+ r.send(null);
+ if (r.responseXML) {
+ if (r.responseXML.title == 'XMLHttpRequest recursion.') {
+ p.firstChild.data = 'PASS';
+ } else {
+ p.firstChild.data = 'FAIL (fetched but not run) ' + r.responseXML.title;
+ }
+ } else {
+ p.firstChild.data = 'FAIL (no responseXML)';
+ }
+ </script>
+ </body>
+</html>
--- /dev/null
+WARNING! These tests could easily crash your browser.
\ No newline at end of file