Opera CORS: Added MANIFEST file and a not outdated status-basic
authorOdin Hørthe Omdal <odinho@opera.com>
Thu, 15 Dec 2011 19:46:57 +0100
changeset 16 8c4f146655aa
parent 15 8a0775f6d0eb
child 17 46cba6fd558c
Opera CORS: Added MANIFEST file and a not outdated status-basic
tests/cors/submitted/opera/js/MANIFEST
tests/cors/submitted/opera/js/status-basic.htm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/cors/submitted/opera/js/MANIFEST	Thu Dec 15 19:46:57 2011 +0100
@@ -0,0 +1,15 @@
+basic.htm
+credentials-flag.htm
+errors-async.htm
+errors-sync.htm
+https.htm
+origin.htm
+preflight-cache.htm
+redirect-preflight.htm
+redirect.htm
+request.htm
+response.htm
+simple-requests.htm
+status-async.htm
+status-basic.htm
+status-preflight.htm
--- a/tests/cors/submitted/opera/js/status-basic.htm	Thu Dec 15 18:49:07 2011 +0100
+++ b/tests/cors/submitted/opera/js/status-basic.htm	Thu Dec 15 19:46:57 2011 +0100
@@ -12,21 +12,32 @@
       var crossdomain = "http://crosssite." + location.hostname + location.pathname.replace(/\/[^\/]*$/, '/')
 
       function statusRequest(method, code, text, content, type) {
-        test(function() {
+        var test = async_test(document.title + " (" + method + " " + code + ")")
+        test.step(function() {
           var client = new XMLHttpRequest()
-          client.open(method, crossdomain + "resources/status.php?code=" + code + "&text=" + text + "&content=" + content + "&type=" + type, false)
+          client.open(method, crossdomain + "resources/status.php?code=" + code + "&text=" + text + "&content=" + content + "&type=" + type, true)
           client.setRequestHeader('Content-Type', 'text/plain')
+
+          client.onload = test.step_func(function() {
+            assert_equals(client.status, code, "status")
+            assert_equals(client.statusText, text, "statusText")
+            assert_equals(client.getResponseHeader("X-Request-Method"), method, "X-Request-Method")
+            if(method != "HEAD") {
+              if(type == "text/xml") {
+                assert_equals(client.responseXML.documentElement.localName, "x")
+              }
+              assert_equals(client.responseText, content)
+            }
+
+            test.done()
+          })
+
+          client.onerror = test.step_func(function(e) {
+              assert_unreached("Got error event.")
+          })
+
           client.send(null)
-          assert_equals(client.status, code)
-          assert_equals(client.statusText, text)
-          assert_equals(client.getResponseHeader("X-Request-Method"), method)
-          if(method != "HEAD") {
-            if(type == "text/xml") {
-              assert_equals(client.responseXML.documentElement.localName, "x")
-            }
-            assert_equals(client.responseText, content)
-          }
-        }, document.title + " (" + method + " " + code + ")")
+        })
       }
 
       statusRequest("GET", 200, 'OK', 'Not today.', '')
@@ -36,28 +47,20 @@
       statusRequest("CHICKEN", 200, 'OK', 'bah', '')
 
 
-      function statusRequestFail(method, code, text) {
-        test(function() {
-          var client = new XMLHttpRequest()
-          client.open(method, crossdomain + "resources/status.php?code="
-            + code + "&text=" + text, false)
-          assert_throws('NETWORK_ERR', function() { client.send(null) })
-        }, document.title + " (" + method + " " + code + ") throws NETWORK_ERR")
-      }
       function status(code, text) {
-        statusRequestFail("GET", code, text)
-        statusRequestFail("HEAD", code, text)
-        statusRequestFail("POST", code, text)
-        statusRequestFail("PUT", code, text)
-        statusRequestFail("CHICKEN", code, text)
+        statusRequest("GET", code, text, text, 'text/plain')
+        statusRequest("HEAD", code, text, text, 'text/plain')
+        statusRequest("POST", code, text, text, 'text/plain')
+        statusRequest("PUT", code, text, text, 'text/plain')
+        statusRequest("CHICKEN", code, text, text, 'text/plain')
       }
 
       status(201, "UNICORNSWAM")
-      status(204, "UNICORNSWIN")
-      status(401, "OH HELLO")
+      status(203, "UNICORNSWIN")
+      status(400, "OH HELLO")
       status(402, "FIVE BUCKS")
-      status(402, "FREE")
       status(404, "404 NOT FOUND")
+      status(412, "FREE")
       status(502, "lowercase")
       status(503, "HOUSTON WE HAVE A")
       status(699, "WAY OUTTA RANGE")