Reviewed by Darin.
authorap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Feb 2006 09:10:54 +0000 (09:10 +0000)
committerap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Feb 2006 09:10:54 +0000 (09:10 +0000)
        - 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 (recursively).

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@12964 268f45cc-cd09-0410-ab3c-d52691b4dbfc

60 files changed:
LayoutTests/ChangeLog
LayoutTests/http/conf/httpd.conf
LayoutTests/http/tests/xmlhttprequest/web-apps/.htaccess [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/001-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/001-test.cgi [new file with mode: 0755]
LayoutTests/http/tests/xmlhttprequest/web-apps/001.html [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/002-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/002-simple-a.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/002-simple-b.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/002-simple-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/002-simple.html [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/002.html [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/002a.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/002b.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/002c.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/003-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/003-test.cgi [new file with mode: 0755]
LayoutTests/http/tests/xmlhttprequest/web-apps/003.html [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/004-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/004-test.cgi [new file with mode: 0755]
LayoutTests/http/tests/xmlhttprequest/web-apps/004.html [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/005-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/005-test.cgi [new file with mode: 0755]
LayoutTests/http/tests/xmlhttprequest/web-apps/005.html [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/006-test.cgi [new file with mode: 0755]
LayoutTests/http/tests/xmlhttprequest/web-apps/006.html-disabled [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/007-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/007-test.asis [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/007.html [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/008-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/008-test.asis [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/008.html [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/009-test.cgi [new file with mode: 0755]
LayoutTests/http/tests/xmlhttprequest/web-apps/009.html-disabled [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/010-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/010-test.cgi [new file with mode: 0755]
LayoutTests/http/tests/xmlhttprequest/web-apps/010.html [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/011-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/011-test200.asis [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/011.html [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/012-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/012-test200.asis [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/012.html [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/013-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/013-test.cgi [new file with mode: 0755]
LayoutTests/http/tests/xmlhttprequest/web-apps/013.html [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/014-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/014-test404.asis [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/014.html [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/015-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/015-test.cgi [new file with mode: 0755]
LayoutTests/http/tests/xmlhttprequest/web-apps/015.html [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/016-test.cgi [new file with mode: 0755]
LayoutTests/http/tests/xmlhttprequest/web-apps/016.html-disabled [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/017.html-disabled [new file with mode: 0755]
LayoutTests/http/tests/xmlhttprequest/web-apps/README [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/TODO [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/readme.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/recursion/001.html-disabled [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/web-apps/recursion/README [new file with mode: 0644]

index 40188bc..b4a0120 100644 (file)
@@ -1,3 +1,73 @@
+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.
index b754047..be39fc9 100644 (file)
@@ -621,7 +621,7 @@ ServerSignature On
     # 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
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/.htaccess b/LayoutTests/http/tests/xmlhttprequest/web-apps/.htaccess
new file mode 100644 (file)
index 0000000..b748713
--- /dev/null
@@ -0,0 +1,3 @@
+<files 017.html>
+  SetHandler cgi-script
+</files>
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/001-expected.txt b/LayoutTests/http/tests/xmlhttprequest/web-apps/001-expected.txt
new file mode 100644 (file)
index 0000000..9976b12
--- /dev/null
@@ -0,0 +1,3 @@
+PASS
+
+
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/001-test.cgi b/LayoutTests/http/tests/xmlhttprequest/web-apps/001-test.cgi
new file mode 100755 (executable)
index 0000000..074959f
--- /dev/null
@@ -0,0 +1,8 @@
+#!/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";
+}
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/001.html b/LayoutTests/http/tests/xmlhttprequest/web-apps/001.html
new file mode 100644 (file)
index 0000000..1fbb1e3
--- /dev/null
@@ -0,0 +1,29 @@
+<!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>
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/002-expected.txt b/LayoutTests/http/tests/xmlhttprequest/web-apps/002-expected.txt
new file mode 100644 (file)
index 0000000..9976b12
--- /dev/null
@@ -0,0 +1,3 @@
+PASS
+
+
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/002-simple-a.txt b/LayoutTests/http/tests/xmlhttprequest/web-apps/002-simple-a.txt
new file mode 100644 (file)
index 0000000..8c7e5a6
--- /dev/null
@@ -0,0 +1 @@
+A
\ No newline at end of file
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/002-simple-b.txt b/LayoutTests/http/tests/xmlhttprequest/web-apps/002-simple-b.txt
new file mode 100644 (file)
index 0000000..7371f47
--- /dev/null
@@ -0,0 +1 @@
+B
\ No newline at end of file
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/002-simple-expected.txt b/LayoutTests/http/tests/xmlhttprequest/web-apps/002-simple-expected.txt
new file mode 100644 (file)
index 0000000..9976b12
--- /dev/null
@@ -0,0 +1,3 @@
+PASS
+
+
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/002-simple.html b/LayoutTests/http/tests/xmlhttprequest/web-apps/002-simple.html
new file mode 100644 (file)
index 0000000..e228cc2
--- /dev/null
@@ -0,0 +1,28 @@
+<!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>
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/002.html b/LayoutTests/http/tests/xmlhttprequest/web-apps/002.html
new file mode 100644 (file)
index 0000000..a74dd93
--- /dev/null
@@ -0,0 +1,34 @@
+<!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>
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/002a.txt b/LayoutTests/http/tests/xmlhttprequest/web-apps/002a.txt
new file mode 100644 (file)
index 0000000..7faa7a9
--- /dev/null
@@ -0,0 +1 @@
+First open() used.
\ No newline at end of file
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/002b.txt b/LayoutTests/http/tests/xmlhttprequest/web-apps/002b.txt
new file mode 100644 (file)
index 0000000..17f548e
--- /dev/null
@@ -0,0 +1 @@
+TWO
\ No newline at end of file
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/002c.txt b/LayoutTests/http/tests/xmlhttprequest/web-apps/002c.txt
new file mode 100644 (file)
index 0000000..08d2444
--- /dev/null
@@ -0,0 +1 @@
+THREE
\ No newline at end of file
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/003-expected.txt b/LayoutTests/http/tests/xmlhttprequest/web-apps/003-expected.txt
new file mode 100644 (file)
index 0000000..9976b12
--- /dev/null
@@ -0,0 +1,3 @@
+PASS
+
+
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/003-test.cgi b/LayoutTests/http/tests/xmlhttprequest/web-apps/003-test.cgi
new file mode 100755 (executable)
index 0000000..f330bb0
--- /dev/null
@@ -0,0 +1,4 @@
+#!/usr/bin/perl -wT
+use strict;
+
+print "Content-Type: text/plain\nCache-Control: no-store\n\nRESULT:[$ENV{'HTTP_X_TEST_HEADER'}]";
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/003.html b/LayoutTests/http/tests/xmlhttprequest/web-apps/003.html
new file mode 100644 (file)
index 0000000..9a3c8ef
--- /dev/null
@@ -0,0 +1,33 @@
+<!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>
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/004-expected.txt b/LayoutTests/http/tests/xmlhttprequest/web-apps/004-expected.txt
new file mode 100644 (file)
index 0000000..9976b12
--- /dev/null
@@ -0,0 +1,3 @@
+PASS
+
+
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/004-test.cgi b/LayoutTests/http/tests/xmlhttprequest/web-apps/004-test.cgi
new file mode 100755 (executable)
index 0000000..4db9ca1
--- /dev/null
@@ -0,0 +1,4 @@
+#!/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'}]";
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/004.html b/LayoutTests/http/tests/xmlhttprequest/web-apps/004.html
new file mode 100644 (file)
index 0000000..98c2f0b
--- /dev/null
@@ -0,0 +1,32 @@
+<!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>
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/005-expected.txt b/LayoutTests/http/tests/xmlhttprequest/web-apps/005-expected.txt
new file mode 100644 (file)
index 0000000..9976b12
--- /dev/null
@@ -0,0 +1,3 @@
+PASS
+
+
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/005-test.cgi b/LayoutTests/http/tests/xmlhttprequest/web-apps/005-test.cgi
new file mode 100755 (executable)
index 0000000..f330bb0
--- /dev/null
@@ -0,0 +1,4 @@
+#!/usr/bin/perl -wT
+use strict;
+
+print "Content-Type: text/plain\nCache-Control: no-store\n\nRESULT:[$ENV{'HTTP_X_TEST_HEADER'}]";
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/005.html b/LayoutTests/http/tests/xmlhttprequest/web-apps/005.html
new file mode 100644 (file)
index 0000000..f98b28d
--- /dev/null
@@ -0,0 +1,29 @@
+<!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>
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/006-test.cgi b/LayoutTests/http/tests/xmlhttprequest/web-apps/006-test.cgi
new file mode 100755 (executable)
index 0000000..28b5a1a
--- /dev/null
@@ -0,0 +1,7 @@
+#!/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";
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/006.html-disabled b/LayoutTests/http/tests/xmlhttprequest/web-apps/006.html-disabled
new file mode 100644 (file)
index 0000000..4f6de00
--- /dev/null
@@ -0,0 +1,25 @@
+<!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>
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/007-expected.txt b/LayoutTests/http/tests/xmlhttprequest/web-apps/007-expected.txt
new file mode 100644 (file)
index 0000000..9976b12
--- /dev/null
@@ -0,0 +1,3 @@
+PASS
+
+
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/007-test.asis b/LayoutTests/http/tests/xmlhttprequest/web-apps/007-test.asis
new file mode 100644 (file)
index 0000000..ca313fb
--- /dev/null
@@ -0,0 +1,3 @@
+Test: PASS
+
+BODY
\ No newline at end of file
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/007.html b/LayoutTests/http/tests/xmlhttprequest/web-apps/007.html
new file mode 100644 (file)
index 0000000..929bdac
--- /dev/null
@@ -0,0 +1,30 @@
+<!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>
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/008-expected.txt b/LayoutTests/http/tests/xmlhttprequest/web-apps/008-expected.txt
new file mode 100644 (file)
index 0000000..896fa42
--- /dev/null
@@ -0,0 +1,3 @@
+FAIL ("test1", "a, b", "undefined")
+
+
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/008-test.asis b/LayoutTests/http/tests/xmlhttprequest/web-apps/008-test.asis
new file mode 100644 (file)
index 0000000..946c81b
--- /dev/null
@@ -0,0 +1,5 @@
+Test1: test1
+test2: a
+test2: b
+
+BODY
\ No newline at end of file
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/008.html b/LayoutTests/http/tests/xmlhttprequest/web-apps/008.html
new file mode 100644 (file)
index 0000000..d29d82d
--- /dev/null
@@ -0,0 +1,25 @@
+<!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>
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/009-test.cgi b/LayoutTests/http/tests/xmlhttprequest/web-apps/009-test.cgi
new file mode 100755 (executable)
index 0000000..56d3a8b
--- /dev/null
@@ -0,0 +1,7 @@
+#!/usr/bin/perl -wT
+use strict;
+
+$| = 1;
+print "Content-Type: text/xml\nCache-Control: no-store\n\n<test>";
+sleep 60;
+print "</test>\n";
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/009.html-disabled b/LayoutTests/http/tests/xmlhttprequest/web-apps/009.html-disabled
new file mode 100644 (file)
index 0000000..b478a4a
--- /dev/null
@@ -0,0 +1,30 @@
+<!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>
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/010-expected.txt b/LayoutTests/http/tests/xmlhttprequest/web-apps/010-expected.txt
new file mode 100644 (file)
index 0000000..9976b12
--- /dev/null
@@ -0,0 +1,3 @@
+PASS
+
+
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/010-test.cgi b/LayoutTests/http/tests/xmlhttprequest/web-apps/010-test.cgi
new file mode 100755 (executable)
index 0000000..dce5eea
--- /dev/null
@@ -0,0 +1,5 @@
+#!/usr/bin/perl -wT
+use strict;
+
+$| = 1;
+print "Content-Type: text/xml\nCache-Control: no-store\n\n<test></test>";
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/010.html b/LayoutTests/http/tests/xmlhttprequest/web-apps/010.html
new file mode 100644 (file)
index 0000000..7af0346
--- /dev/null
@@ -0,0 +1,27 @@
+<!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>
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/011-expected.txt b/LayoutTests/http/tests/xmlhttprequest/web-apps/011-expected.txt
new file mode 100644 (file)
index 0000000..9976b12
--- /dev/null
@@ -0,0 +1,3 @@
+PASS
+
+
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/011-test200.asis b/LayoutTests/http/tests/xmlhttprequest/web-apps/011-test200.asis
new file mode 100644 (file)
index 0000000..2257dc1
--- /dev/null
@@ -0,0 +1,3 @@
+Status: 200 Foo widdle waddle!
+
+BODY
\ No newline at end of file
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/011.html b/LayoutTests/http/tests/xmlhttprequest/web-apps/011.html
new file mode 100644 (file)
index 0000000..ef1671e
--- /dev/null
@@ -0,0 +1,23 @@
+<!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>
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/012-expected.txt b/LayoutTests/http/tests/xmlhttprequest/web-apps/012-expected.txt
new file mode 100644 (file)
index 0000000..f17e926
--- /dev/null
@@ -0,0 +1,3 @@
+FAIL: "OK"
+
+
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/012-test200.asis b/LayoutTests/http/tests/xmlhttprequest/web-apps/012-test200.asis
new file mode 100644 (file)
index 0000000..2257dc1
--- /dev/null
@@ -0,0 +1,3 @@
+Status: 200 Foo widdle waddle!
+
+BODY
\ No newline at end of file
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/012.html b/LayoutTests/http/tests/xmlhttprequest/web-apps/012.html
new file mode 100644 (file)
index 0000000..6101c0a
--- /dev/null
@@ -0,0 +1,23 @@
+<!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>
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/013-expected.txt b/LayoutTests/http/tests/xmlhttprequest/web-apps/013-expected.txt
new file mode 100644 (file)
index 0000000..0faabe1
--- /dev/null
@@ -0,0 +1,3 @@
+FAIL: Status at readyState 3 was: 400, "OK"
+
+
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/013-test.cgi b/LayoutTests/http/tests/xmlhttprequest/web-apps/013-test.cgi
new file mode 100755 (executable)
index 0000000..36d6d5a
--- /dev/null
@@ -0,0 +1,7 @@
+#!/usr/bin/perl -wT
+use strict;
+
+sleep 3;
+
+$| = 1;
+print "Status: 400 Good work\nContent-Type: text/plain\nCache-Control: no-store\n\nBODY";
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/013.html b/LayoutTests/http/tests/xmlhttprequest/web-apps/013.html
new file mode 100644 (file)
index 0000000..f1ed0e1
--- /dev/null
@@ -0,0 +1,40 @@
+<!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>
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/014-expected.txt b/LayoutTests/http/tests/xmlhttprequest/web-apps/014-expected.txt
new file mode 100644 (file)
index 0000000..9976b12
--- /dev/null
@@ -0,0 +1,3 @@
+PASS
+
+
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/014-test404.asis b/LayoutTests/http/tests/xmlhttprequest/web-apps/014-test404.asis
new file mode 100644 (file)
index 0000000..211332b
--- /dev/null
@@ -0,0 +1,3 @@
+Status: 404 The cat and the fiddle!
+
+BODY
\ No newline at end of file
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/014.html b/LayoutTests/http/tests/xmlhttprequest/web-apps/014.html
new file mode 100644 (file)
index 0000000..0fb1b34
--- /dev/null
@@ -0,0 +1,23 @@
+<!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>
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/015-expected.txt b/LayoutTests/http/tests/xmlhttprequest/web-apps/015-expected.txt
new file mode 100644 (file)
index 0000000..9976b12
--- /dev/null
@@ -0,0 +1,3 @@
+PASS
+
+
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/015-test.cgi b/LayoutTests/http/tests/xmlhttprequest/web-apps/015-test.cgi
new file mode 100755 (executable)
index 0000000..477a1eb
--- /dev/null
@@ -0,0 +1,4 @@
+#!/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'}]";
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/015.html b/LayoutTests/http/tests/xmlhttprequest/web-apps/015.html
new file mode 100644 (file)
index 0000000..f202db3
--- /dev/null
@@ -0,0 +1,30 @@
+<!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>
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/016-test.cgi b/LayoutTests/http/tests/xmlhttprequest/web-apps/016-test.cgi
new file mode 100755 (executable)
index 0000000..afae951
--- /dev/null
@@ -0,0 +1,4 @@
+#!/usr/bin/perl -wT
+use strict;
+sleep 600; # ten minutes
+close STDOUT;
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/016.html-disabled b/LayoutTests/http/tests/xmlhttprequest/web-apps/016.html-disabled
new file mode 100644 (file)
index 0000000..a7b9aa9
--- /dev/null
@@ -0,0 +1,24 @@
+<!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>
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/017.html-disabled b/LayoutTests/http/tests/xmlhttprequest/web-apps/017.html-disabled
new file mode 100755 (executable)
index 0000000..e9ed616
--- /dev/null
@@ -0,0 +1,60 @@
+#!/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);
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/README b/LayoutTests/http/tests/xmlhttprequest/web-apps/README
new file mode 100644 (file)
index 0000000..04f385d
--- /dev/null
@@ -0,0 +1,6 @@
+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.
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/TODO b/LayoutTests/http/tests/xmlhttprequest/web-apps/TODO
new file mode 100644 (file)
index 0000000..92bb665
--- /dev/null
@@ -0,0 +1,5 @@
+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?
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/readme.txt b/LayoutTests/http/tests/xmlhttprequest/web-apps/readme.txt
new file mode 100644 (file)
index 0000000..6783246
--- /dev/null
@@ -0,0 +1 @@
+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
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/recursion/001.html-disabled b/LayoutTests/http/tests/xmlhttprequest/web-apps/recursion/001.html-disabled
new file mode 100644 (file)
index 0000000..7ceb026
--- /dev/null
@@ -0,0 +1,32 @@
+<!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>
diff --git a/LayoutTests/http/tests/xmlhttprequest/web-apps/recursion/README b/LayoutTests/http/tests/xmlhttprequest/web-apps/recursion/README
new file mode 100644 (file)
index 0000000..896f0f3
--- /dev/null
@@ -0,0 +1 @@
+WARNING! These tests could easily crash your browser.
\ No newline at end of file