--- 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")