Bug 701787 - Part 2: Tests. r=smaug.
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Thu, 08 Dec 2011 15:55:20 +0200
changeset 83917 c175352a397b8a537d2c21a325b48b1bca5fc657
parent 83916 e21ee958e5fd01b0947e4c44e3d89b4cf8fa0732
child 83918 b0f8871174a5bc7f011ccf3585a8906430e668a9
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs701787
milestone11.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 701787 - Part 2: Tests. r=smaug.
content/base/test/test_XHR.html
content/base/test/test_XHRSendData.html
content/base/test/test_bug338583.html
content/base/test/test_bug466080.html
content/base/test/unit/test_xhr_standalone.js
content/base/test/unit/xpcshell.ini
--- a/content/base/test/test_XHR.html
+++ b/content/base/test/test_XHR.html
@@ -1,24 +1,29 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>Test for XMLHttpRequest</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
-<body>
+<body onload="gen.next();">
 <p id="display"></p>
 <div id="content" style="display: none">
   
 </div>
 <pre id="test">
-<script class="testbody" type="text/javascript">
+<script class="testbody" type="application/javascript;version=1.7">
 SimpleTest.waitForExplicitFinish();
 
+var gen = runTests();
+function continueTest() { gen.next(); }
+
+function runTests() {
+
 var path = "/tests/content/base/test/";
 
 var passFiles = [['file_XHR_pass1.xml', 'GET'],
                  ['file_XHR_pass2.txt', 'GET'],
                  ['file_XHR_pass3.txt', 'GET'],
                  ];
 
 var failFiles = [['//example.com' + path + 'file_XHR_pass1.xml', 'GET'],
@@ -58,17 +63,16 @@ for (i = 0; i < failFiles.length; ++i) {
     is(xhr.status, 301, "wrong status");
     is(xhr.responseText, "redirect file\n", "wrong response");
   }
   else {
     ok(1, "should have thrown or given incorrect result");
   }
 }
 
-// test response (responseType='document')
 function checkResponseTextAccessThrows(xhr) {
   var didthrow = false;
   try { xhr.responseText } catch (e) { didthrow = true; }
   ok(didthrow, "should have thrown when accessing responseText");
 }
 function checkResponseXMLAccessThrows(xhr) {
   var didthrow = false;
   try { xhr.responseXML } catch (e) { didthrow = true; }
@@ -79,118 +83,153 @@ function checkResponseAccessThrows(xhr) 
   try { xhr.response } catch (e) { didthrow = true; }
   ok(didthrow, "should have thrown when accessing response");
 }
 function checkSetResponseTypeThrows(xhr, type) {
   var didthrow = false;
   try { xhr.responseType = type; } catch (e) { didthrow = true; }
   ok(didthrow, "should have thrown when setting responseType");
 }
+function checkOpenThrows(xhr, method, url, async) {
+  var didthrow = false;
+  try { xhr.open(method, url, async); } catch (e) { didthrow = true; }
+  ok(didthrow, "should have thrown when open is called");
+}
 
+// test response (sync, responseType is not changeable)
 xhr = new XMLHttpRequest();
+xhr.open("GET", 'file_XHR_pass2.txt', false); 
+checkSetResponseTypeThrows(xhr, "");
+checkSetResponseTypeThrows(xhr, "text");
 checkSetResponseTypeThrows(xhr, "document");
-xhr.open("GET", 'file_XHR_pass1.xml', false); 
+checkSetResponseTypeThrows(xhr, "arraybuffer");
+checkSetResponseTypeThrows(xhr, "blob");
+checkSetResponseTypeThrows(xhr, "moz-json");
 checkSetResponseTypeThrows(xhr, "moz-chunked-text");
 checkSetResponseTypeThrows(xhr, "moz-chunked-arraybuffer");
+xhr.send(null);
+checkSetResponseTypeThrows(xhr, "document");
+is(xhr.status, 200, "wrong status");
+is(xhr.response, "hello pass\n", "wrong response");
+
+// test response (responseType='document')
+xhr = new XMLHttpRequest();
+xhr.open("GET", 'file_XHR_pass1.xml'); 
 xhr.responseType = 'document';
+xhr.onloadend = continueTest;
 xhr.send(null);
+yield;
 checkSetResponseTypeThrows(xhr, "document");
 is(xhr.status, 200, "wrong status");
 checkResponseTextAccessThrows(xhr);
 is((new XMLSerializer()).serializeToString(xhr.response.documentElement),
    "<res>hello</res>",
    "wrong response");
 
 // test response (responseType='text')
 xhr = new XMLHttpRequest();
-xhr.open("GET", 'file_XHR_pass2.txt', false); 
+xhr.open("GET", 'file_XHR_pass2.txt'); 
 xhr.responseType = 'text';
+xhr.onloadend = continueTest;
 xhr.send(null);
+yield;
 is(xhr.status, 200, "wrong status");
 checkResponseXMLAccessThrows(xhr);
 is(xhr.response, "hello pass\n", "wrong response");
 
 // test response (responseType='arraybuffer')
 function arraybuffer_equals_to(ab, s) {
   is(ab.byteLength, s.length, "wrong arraybuffer byteLength");
 
   u8v = new Uint8Array(ab);
   is(String.fromCharCode.apply(String, u8v), s, "wrong values");
 }
 
 // with a simple text file
 xhr = new XMLHttpRequest();
-xhr.open("GET", 'file_XHR_pass2.txt', false); 
+xhr.open("GET", 'file_XHR_pass2.txt'); 
 xhr.responseType = 'arraybuffer';
+xhr.onloadend = continueTest;
 xhr.send(null);
+yield;
 is(xhr.status, 200, "wrong status");
 checkResponseTextAccessThrows(xhr);
 checkResponseXMLAccessThrows(xhr);
 ab = xhr.response;
 ok(ab != null, "should have a non-null arraybuffer");
 arraybuffer_equals_to(ab, "hello pass\n");
 
 // test reusing the same XHR (Bug 680816)
-xhr.open("GET", 'file_XHR_binary1.bin', false);
+xhr.open("GET", 'file_XHR_binary1.bin');
 xhr.responseType = 'arraybuffer';
+xhr.onloadend = continueTest;
 xhr.send(null);
+yield;
 is(xhr.status, 200, "wrong status");
 ab2 = xhr.response;
 ok(ab2 != null, "should have a non-null arraybuffer");
 ok(ab2 != ab, "arraybuffer on XHR reuse should be distinct");
 arraybuffer_equals_to(ab, "hello pass\n");
 arraybuffer_equals_to(ab2, "\xaa\xee\0\x03\xff\xff\xff\xff\xbb\xbb\xbb\xbb");
 
 // with a binary file
 xhr = new XMLHttpRequest();
-xhr.open("GET", 'file_XHR_binary1.bin', false); 
+xhr.open("GET", 'file_XHR_binary1.bin'); 
 xhr.responseType = 'arraybuffer';
-xhr.send(null)
+xhr.onloadend = continueTest;
+xhr.send(null);
+yield;
 is(xhr.status, 200, "wrong status");
 checkResponseTextAccessThrows(xhr);
 checkResponseXMLAccessThrows(xhr);
 ab = xhr.response;
 ok(ab != null, "should have a non-null arraybuffer");
 arraybuffer_equals_to(ab, "\xaa\xee\0\x03\xff\xff\xff\xff\xbb\xbb\xbb\xbb");
 is(xhr.response, xhr.response, "returns the same ArrayBuffer");
 
 // test response (responseType='moz-json')
 var xhr = new XMLHttpRequest();
-xhr.open("POST", 'responseIdentical.sjs', false);
+xhr.open("POST", 'responseIdentical.sjs');
 xhr.responseType = 'moz-json';
 jsonObjStr = JSON.stringify({title: "aBook", author: "john"});
+xhr.onloadend = continueTest;
 xhr.send(jsonObjStr);
+yield;
 is(xhr.status, 200, "wrong status");
 checkResponseTextAccessThrows(xhr);
 checkResponseXMLAccessThrows(xhr);
 is(JSON.stringify(xhr.response), jsonObjStr, "correct result");
 is(xhr.response, xhr.response, "returning the same object on each access");
 
 // with invalid json
 var xhr = new XMLHttpRequest();
-xhr.open("POST", 'responseIdentical.sjs', false);
+xhr.open("POST", 'responseIdentical.sjs');
 xhr.responseType = 'moz-json';
+xhr.onloadend = continueTest;
 xhr.send("{");
+yield;
 is(xhr.status, 200, "wrong status");
 checkResponseTextAccessThrows(xhr);
 checkResponseXMLAccessThrows(xhr);
 checkResponseAccessThrows(xhr);
 checkResponseAccessThrows(xhr); // Check twice to ensure that we still throw
 
 // test response (responseType='blob')
 var onloadCount = 0;
 function checkOnloadCount() {
   if (++onloadCount >= 3) SimpleTest.finish();
 };
 
 // with a simple text file
 xhr = new XMLHttpRequest();
-xhr.open("GET", 'file_XHR_pass2.txt', false); 
+xhr.open("GET", 'file_XHR_pass2.txt'); 
 xhr.responseType = 'blob';
+xhr.onloadend = continueTest;
 xhr.send(null);
+yield;
 is(xhr.status, 200, "wrong status");
 checkResponseTextAccessThrows(xhr);
 checkResponseXMLAccessThrows(xhr);
 b = xhr.response;
 ok(b, "should have a non-null blob");
 ok(b instanceof Blob, "should be a Blob");
 ok(!(b instanceof File), "should not be a File");
 is(b.size, "hello pass\n".length, "wrong blob size");
@@ -276,12 +315,14 @@ client.onreadystatechange = function() {
         ok(false, "Shouldn't throw! [" + ex + "]");
       }
     }
   }
 client.open("GET", "file_XHR_pass1.xml", true);
 client.send();
 client.abort();
 
+yield;
+} /* runTests */
 </script>
 </pre>
 </body>
 </html>
--- a/content/base/test/test_XHRSendData.html
+++ b/content/base/test/test_XHRSendData.html
@@ -3,27 +3,33 @@
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=464848
 -->
 <head>
   <title>XMLHttpRequest send data and headers</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
-<body>
+<body onload="gen.next();">
 <a target="_blank"
    href="https://bugzilla.mozilla.org/show_bug.cgi?id=464848">Mozilla Bug 464848</a>
 <p id="display">
   <input id="fileList" type="file"></input>
 </p>
 <div id="content" style="display: none">
   
 </div>
 <pre id="test">
 <script class="testbody" type="application/javascript;version=1.8">
+SimpleTest.waitForExplicitFinish();
+
+var gen = runTests();
+function continueTest() { gen.next(); }
+
+function runTests() {
 
 xhr = new XMLHttpRequest();
 xhr.open("GET", "file_XHRSendData_doc.xml", false);
 xhr.send();
 testDoc1 = xhr.responseXML;
 is(testDoc1.inputEncoding, "ISO-8859-1", "wrong encoding");
 
 testDoc2 = document.implementation.createDocument("", "", null);
@@ -171,22 +177,26 @@ for (var i = 0; i < testDOMFiles.length;
                resContentType: fileTypes[i],
                resContentLength: testData.length,
               });
 }
 
 try {
   for each(test in tests) {
     xhr = new XMLHttpRequest;
-    xhr.open("POST", "file_XHRSendData.sjs", false);
+    xhr.open("POST", "file_XHRSendData.sjs", !!test.resType);
     if (test.contentType)
       xhr.setRequestHeader("Content-Type", test.contentType);
-    if (test.resType)
+    if (test.resType) {
       xhr.responseType = test.resType;
+      xhr.onloadend = continueTest;
+    }
     xhr.send(test.body);
+    if (test.resType)
+      yield;
 
     if (test.resContentType) {
       is(xhr.getResponseHeader("Result-Content-Type"), test.resContentType,
          "Wrong Content-Type sent");
     }
     else {
       is(xhr.getResponseHeader("Result-Content-Type"), null);
     }
@@ -229,12 +239,16 @@ function cleanUpData() {
 function is_identical_arraybuffer(ab1, ab2) {
   is(ab1.byteLength, ab2.byteLength, "arraybuffer byteLengths not equal");
   u8v1 = new Uint8Array(ab1);
   u8v2 = new Uint8Array(ab2);
   is(String.fromCharCode.apply(String, u8v1),
      String.fromCharCode.apply(String, u8v2), "arraybuffer values not equal");
 }
 
+SimpleTest.finish();
+yield;
+} /* runTests */
+
 </script>
 </pre>
 </body>
 </html>
--- a/content/base/test/test_bug338583.html
+++ b/content/base/test/test_bug338583.html
@@ -419,114 +419,122 @@ https://bugzilla.mozilla.org/show_bug.cg
   }
 
   function doTest5_c(test_id)
   {
     // credentials using the auth cache and cookies
     var xhr = SpecialPowers.createSystemXHR();
     xhr.withCredentials = true;
     // also, test mixed mode UI
-    xhr.open("GET", "https://example.com/tests/content/base/test/file_restrictedEventSource.sjs?test=user1_xhr", false, "user 1", "password 1");
+    xhr.open("GET", "https://example.com/tests/content/base/test/file_restrictedEventSource.sjs?test=user1_xhr", true, "user 1", "password 1");
     xhr.send();
-    ok(xhr.status == 200, "Failed to set credentials in test 5.c");
+    xhr.onloadend = function() {
+      ok(xhr.status == 200, "Failed to set credentials in test 5.c");
 
-    gEventSourceObj5_c = new EventSource("https://example.com/tests/content/base/test/file_restrictedEventSource.sjs?test=user1_evtsrc",
-                                         { withCredentials: true } );
-    ok(gEventSourceObj5_c.withCredentials, "Wrong withCredentials in test 5.c");
+      gEventSourceObj5_c = new EventSource("https://example.com/tests/content/base/test/file_restrictedEventSource.sjs?test=user1_evtsrc",
+                                           { withCredentials: true } );
+      ok(gEventSourceObj5_c.withCredentials, "Wrong withCredentials in test 5.c");
 
-    gEventSourceObj5_c.onmessage = function(e) {
-      ok(e.origin == "https://example.com", "Wrong Origin in test 5.c");
-      fn_onmessage(e);
+      gEventSourceObj5_c.onmessage = function(e) {
+        ok(e.origin == "https://example.com", "Wrong Origin in test 5.c");
+        fn_onmessage(e);
+      };
+      gEventSourceObj5_c.hits = [];
+      gEventSourceObj5_c.hits['fn_onmessage'] = 0;
+
+      setTimeout(function() {
+        ok(gEventSourceObj5_c.hits['fn_onmessage'] > 0, "Test 5.c failed");
+        gEventSourceObj5_c.close();
+        doTest5_d(test_id);
+      }, parseInt(3000*stress_factor));
     };
-    gEventSourceObj5_c.hits = [];
-    gEventSourceObj5_c.hits['fn_onmessage'] = 0;
-
-    setTimeout(function() {
-      ok(gEventSourceObj5_c.hits['fn_onmessage'] > 0, "Test 5.c failed");
-      gEventSourceObj5_c.close();
-      doTest5_d(test_id);
-    }, parseInt(3000*stress_factor));
   }
 
   function doTest5_d(test_id)
   {
     var xhr = SpecialPowers.createSystemXHR();
     xhr.withCredentials = true;
-    xhr.open("GET", "https://example.com/tests/content/base/test/file_restrictedEventSource.sjs?test=user2_xhr", false, "user 2", "password 2");
+    xhr.open("GET", "https://example.com/tests/content/base/test/file_restrictedEventSource.sjs?test=user2_xhr", true, "user 2", "password 2");
     xhr.send();
-    ok(xhr.status == 200, "Failed to set credentials in test 5.d");
-
-    gEventSourceObj5_d = new EventSource("https://example.com/tests/content/base/test/file_restrictedEventSource.sjs?test=user2_evtsrc");
-    ok(!gEventSourceObj5_d.withCredentials, "Wrong withCredentials in test 5.d");
-
-    gEventSourceObj5_d.onmessage = function(e) {
-      ok(e.origin == "https://example.com", "Wrong Origin in test 5.d");
-      fn_onmessage(e);
+    xhr.onloadend = function() {
+      ok(xhr.status == 200, "Failed to set credentials in test 5.d");
+  
+      gEventSourceObj5_d = new EventSource("https://example.com/tests/content/base/test/file_restrictedEventSource.sjs?test=user2_evtsrc");
+      ok(!gEventSourceObj5_d.withCredentials, "Wrong withCredentials in test 5.d");
+  
+      gEventSourceObj5_d.onmessage = function(e) {
+        ok(e.origin == "https://example.com", "Wrong Origin in test 5.d");
+        fn_onmessage(e);
+      };
+      gEventSourceObj5_d.hits = [];
+      gEventSourceObj5_d.hits['fn_onmessage'] = 0;
+  
+      setTimeout(function() {
+        ok(gEventSourceObj5_d.hits['fn_onmessage'] == 0, "Test 5.d failed");
+        gEventSourceObj5_d.close();
+        setTestHasFinished(test_id);
+      }, parseInt(3000*stress_factor));
     };
-    gEventSourceObj5_d.hits = [];
-    gEventSourceObj5_d.hits['fn_onmessage'] = 0;
-
-    setTimeout(function() {
-      ok(gEventSourceObj5_d.hits['fn_onmessage'] == 0, "Test 5.d failed");
-      gEventSourceObj5_d.close();
-      setTestHasFinished(test_id);
-    }, parseInt(3000*stress_factor));
   }
 
   function doTest5_e(test_id)
   {
     // credentials using the auth cache and cookies
     var xhr = SpecialPowers.createSystemXHR();
     xhr.withCredentials = true;
-    xhr.open("GET", "http://example.org/tests/content/base/test/file_restrictedEventSource.sjs?test=user1_xhr", false, "user 1", "password 1");
+    xhr.open("GET", "http://example.org/tests/content/base/test/file_restrictedEventSource.sjs?test=user1_xhr", true, "user 1", "password 1");
     xhr.send();
-    ok(xhr.status == 200, "Failed to set credentials in test 5.e");
+    xhr.onloadend = function() {
+      ok(xhr.status == 200, "Failed to set credentials in test 5.e");
 
-    gEventSourceObj5_e = new EventSource("http://example.org/tests/content/base/test/file_restrictedEventSource.sjs?test=user1_evtsrc",
-                                         { get withCredentials() { return true; } } );
-    ok(gEventSourceObj5_e.withCredentials, "Wrong withCredentials in test 5.e");
+      gEventSourceObj5_e = new EventSource("http://example.org/tests/content/base/test/file_restrictedEventSource.sjs?test=user1_evtsrc",
+                                           { get withCredentials() { return true; } } );
+      ok(gEventSourceObj5_e.withCredentials, "Wrong withCredentials in test 5.e");
 
-    gEventSourceObj5_e.onmessage = function(e) {
-      ok(e.origin == "http://example.org", "Wrong Origin in test 5.e");
-      fn_onmessage(e);
+      gEventSourceObj5_e.onmessage = function(e) {
+        ok(e.origin == "http://example.org", "Wrong Origin in test 5.e");
+        fn_onmessage(e);
+      };
+      gEventSourceObj5_e.hits = [];
+      gEventSourceObj5_e.hits['fn_onmessage'] = 0;
+
+      setTimeout(function() {
+        ok(gEventSourceObj5_e.hits['fn_onmessage'] > 0, "Test 5.e failed");
+        gEventSourceObj5_e.close();
+        doTest5_f(test_id);
+      }, parseInt(5000*stress_factor));
     };
-    gEventSourceObj5_e.hits = [];
-    gEventSourceObj5_e.hits['fn_onmessage'] = 0;
-
-    setTimeout(function() {
-      ok(gEventSourceObj5_e.hits['fn_onmessage'] > 0, "Test 5.e failed");
-      gEventSourceObj5_e.close();
-      doTest5_f(test_id);
-    }, parseInt(5000*stress_factor));
   }
 
   function doTest5_f(test_id)
   {
     var xhr = SpecialPowers.createSystemXHR();
     xhr.withCredentials = true;
-    xhr.open("GET", "http://example.org/tests/content/base/test/file_restrictedEventSource.sjs?test=user2_xhr", false, "user 2", "password 2");
+    xhr.open("GET", "http://example.org/tests/content/base/test/file_restrictedEventSource.sjs?test=user2_xhr", true, "user 2", "password 2");
     xhr.send();
-    ok(xhr.status == 200, "Failed to set credentials in test 5.f");
+    xhr.onloadend = function() {
+      ok(xhr.status == 200, "Failed to set credentials in test 5.f");
 
-    gEventSourceObj5_f = new EventSource("http://example.org/tests/content/base/test/file_restrictedEventSource.sjs?test=user2_evtsrc",
-                                         { });
-    ok(!gEventSourceObj5_f.withCredentials, "Wrong withCredentials in test 5.f");
+      gEventSourceObj5_f = new EventSource("http://example.org/tests/content/base/test/file_restrictedEventSource.sjs?test=user2_evtsrc",
+                                           { });
+      ok(!gEventSourceObj5_f.withCredentials, "Wrong withCredentials in test 5.f");
 
-    gEventSourceObj5_f.onmessage = function(e) {
-      ok(e.origin == "http://example.org", "Wrong Origin in test 5.f");
-      fn_onmessage(e);
+      gEventSourceObj5_f.onmessage = function(e) {
+        ok(e.origin == "http://example.org", "Wrong Origin in test 5.f");
+        fn_onmessage(e);
+      };
+      gEventSourceObj5_f.hits = [];
+      gEventSourceObj5_f.hits['fn_onmessage'] = 0;
+
+      setTimeout(function() {
+        ok(gEventSourceObj5_f.hits['fn_onmessage'] == 0, "Test 5.f failed");
+        gEventSourceObj5_f.close();
+        setTestHasFinished(test_id);
+      }, parseInt(3000*stress_factor));
     };
-    gEventSourceObj5_f.hits = [];
-    gEventSourceObj5_f.hits['fn_onmessage'] = 0;
-
-    setTimeout(function() {
-      ok(gEventSourceObj5_f.hits['fn_onmessage'] == 0, "Test 5.f failed");
-      gEventSourceObj5_f.close();
-      setTestHasFinished(test_id);
-    }, parseInt(3000*stress_factor));
   }
 
   function doTest6(test_id)
   {
     gEventSourceObj6 = new EventSource("somedatas.resource");
     var fn_somedata = function(e) {
       if (fn_somedata.expected == 0) {
         ok(e.data == "123456789\n123456789123456789\n123456789123456789123456789123456789\n 123456789123456789123456789123456789123456789123456789123456789123456789\nçãá\"\'@`~Ý Ḿyyyy",
--- a/content/base/test/test_bug466080.html
+++ b/content/base/test/test_bug466080.html
@@ -81,38 +81,47 @@ var alltests = [
 ];
 
 function onWindowLoad() {
     // First, check that resource was loaded into the iframe
     // This check in fact depends on bug #444165... :)
     ok(document.iframeWasLoaded, "Loading resource via src-attribute");
 
 
-    for each (test in alltests) {
+    function runTest(test) {
 
         var xhr =  new XMLHttpRequest();
-        
+
         var method = "GET";
         if (test.method != null) { method = test.method; }
-        xhr.open(method, test.url, false);
-        
+        xhr.open(method, test.url);
+
         xhr.withCredentials = test.withCredentials;
 
         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
         xhr.setRequestHeader("Connection", "Keep-Alive", false);
         netscape.security.PrivilegeManager.disablePrivilege("UniversalXPConnect");
 
         try {
             xhr.send();
         } catch(e) {
         }
-        var success = eval(xhr.status + test.status_check);
-        ok(success, test.error);
+
+        xhr.onloadend = function() {
+            var success = eval(xhr.status + test.status_check);
+            ok(success, test.error);
+
+            if (alltests.length == 0) {
+                SimpleTest.finish();
+            } else {
+                runTest(alltests.shift());
+            }
+        };
     }
-    
-    SimpleTest.finish();
+
+    runTest(alltests.shift());
 }
 
 SimpleTest.waitForExplicitFinish();
 
 </script>
 </body>
 </html>
new file mode 100644
--- /dev/null
+++ b/content/base/test/unit/test_xhr_standalone.js
@@ -0,0 +1,21 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+// Test setting .responseType and .withCredentials is allowed
+// in non-window non-Worker context
+
+function run_test()
+{
+    var xhr = Components.classes['@mozilla.org/xmlextras/xmlhttprequest;1'].
+          createInstance(Components.interfaces.nsIXMLHttpRequest);
+    xhr.open('GET', 'data:,', false);
+    var exceptionThrown = false;
+    try {
+        xhr.responseType = '';
+        xhr.withCredentials = false;
+    } catch (e) {
+        exceptionThrown = true;
+    }
+    do_check_eq(false, exceptionThrown);
+}
--- a/content/base/test/unit/xpcshell.ini
+++ b/content/base/test/unit/xpcshell.ini
@@ -2,9 +2,10 @@
 head = head_utilities.js
 tail = 
 
 [test_bug553888.js]
 [test_bug558431.js]
 [test_csputils.js]
 [test_error_codes.js]
 [test_thirdpartyutil.js]
+[test_xhr_standalone.js]
 [test_xmlserializer.js]