CORS: Make a few small fixes to Opera testsuite
authorOdin Hørthe Omdal <odinho@opera.com>
Wed, 21 Nov 2012 17:14:07 +0100
changeset 83 4ef672190e0a
parent 82 4a52799fb77d
child 84 9471bbe93db1
CORS: Make a few small fixes to Opera testsuite
tests/cors/submitted/opera/staging/MANIFEST
tests/cors/submitted/opera/staging/basic.htm
tests/cors/submitted/opera/staging/origin.htm
tests/cors/submitted/opera/staging/remote-origin.htm
tests/cors/submitted/opera/staging/resources/remote-xhrer.html
tests/cors/submitted/opera/staging/support.js
--- a/tests/cors/submitted/opera/staging/MANIFEST	Tue Nov 20 13:41:59 2012 -0500
+++ b/tests/cors/submitted/opera/staging/MANIFEST	Wed Nov 21 17:14:07 2012 +0100
@@ -4,7 +4,7 @@
 preflight-cache.htm
 redirect-origin.htm
 redirect-preflight.htm
-remote_origin.htm
+remote-origin.htm
 request-headers.htm
 response-headers.htm
 simple-requests.htm
--- a/tests/cors/submitted/opera/staging/basic.htm	Tue Nov 20 13:41:59 2012 -0500
+++ b/tests/cors/submitted/opera/staging/basic.htm	Wed Nov 21 17:14:07 2012 +0100
@@ -59,11 +59,14 @@
 cors("Cross domain different protocol",
         CROSSDOMAIN.replace("http:", "https:"));
 
+/* W3C has no "alternative" port for HTTPS. So turn these tests off.
+
 cors("Same domain different protocol different port",
         "https://" + location.hostname + ":" + PORTS + dirname(location.pathname));
 
 cors("Cross domain different protocol different port",
         "https://" + SUBDOMAIN + "." + location.hostname + ":"
         + PORTS + dirname(location.pathname));
+*/
 
 </script>
--- a/tests/cors/submitted/opera/staging/origin.htm	Tue Nov 20 13:41:59 2012 -0500
+++ b/tests/cors/submitted/opera/staging/origin.htm	Wed Nov 21 17:14:07 2012 +0100
@@ -48,7 +48,7 @@
                             + encodeURIComponent(origin),
                     false)
         assert_throws(null, function() { client.send() }, 'send')
-    }, 'Disallow origin: ' + origin);
+    }, 'Disallow origin: ' + origin.replace(/\0/g, "\\0"));
 }
 
 shouldFail(location.protocol + "//" + SUBDOMAIN + "." + location.host)
--- a/tests/cors/submitted/opera/staging/remote-origin.htm	Tue Nov 20 13:41:59 2012 -0500
+++ b/tests/cors/submitted/opera/staging/remote-origin.htm	Wed Nov 21 17:14:07 2012 +0100
@@ -13,7 +13,7 @@
 
 var remote_tests = [];
 var iframe = document.createElement("iframe")
-iframe.src = CROSSDOMAIN + 'remote_xhrer.htm';
+iframe.src = CROSSDOMAIN + 'resources/remote-xhrer.html';
 document.body.appendChild(iframe);
 
 function reverseOrigin(expect_pass, origin)
@@ -27,6 +27,7 @@
                         .replace("<PROTOCOL>", REMOTE_PROTOCOL.toUpperCase());
 
     var t = async_test((expect_pass ? 'Allow origin: ' : 'Disallow origin: ') + real_origin
+                            .replace(/\0/g, "\\0")
                             .replace(/\t/g, "[tab]")
                             .replace(/ /g, '_'));
     t.step(function() {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/cors/submitted/opera/staging/resources/remote-xhrer.html	Wed Nov 21 17:14:07 2012 +0100
@@ -0,0 +1,28 @@
+<!doctype html>
+<title>Child helper</title>
+
+<script>
+window.addEventListener("message", function(e) {
+//    e.source.postMessage(e.data, e.origin);
+
+    var client = new XMLHttpRequest();
+    var localurl = decodeURIComponent(e.data.url)
+                    .replace("<host>", location.host)
+                    .replace("<protocol>", location.protocol);
+
+    client.open('GET', localurl, true);
+    client.onload = function() {
+        e.data.state = "load";
+        e.data.response = client.response;
+        e.source.postMessage(e.data, e.origin);
+    }
+    client.onerror = function() {
+        e.data.state = "error";
+        e.data.response = client.response;
+        e.source.postMessage(e.data, e.origin);
+    }
+    client.send();
+});
+</script>
+
+The remote window
--- a/tests/cors/submitted/opera/staging/support.js	Tue Nov 20 13:41:59 2012 -0500
+++ b/tests/cors/submitted/opera/staging/support.js	Wed Nov 21 17:14:07 2012 +0100
@@ -19,7 +19,7 @@
 var SUBDOMAIN = 'www1'
 var SUBDOMAIN2 = 'www2'
 var PORT = "81"
-var PORTS = "83"
+var PORTS = "83" // w3c actually has no "alternate" https port
 
 /* Changes http://example.com/abc/def/cool.htm to http://www1.example.com/abc/def/ */
 var CROSSDOMAIN     = dirname(location.href)