OLD | NEW |
(Empty) | |
| 1 if (this.document === undefined) { |
| 2 importScripts("/resources/testharness.js"); |
| 3 importScripts("../resources/utils.js"); |
| 4 } |
| 5 |
| 6 function corsMultipleOrigins(desc, originList, shouldPass) { |
| 7 var urlParameters = "?origin=" + encodeURIComponent(originList.join(", ")); |
| 8 var url = "http://{{host}}:{{ports[http][1]}}" + dirname(location.pathname) +
RESOURCES_DIR + "preflight.py"; |
| 9 |
| 10 if (shouldPass) { |
| 11 promise_test(function(test) { |
| 12 return fetch(url + urlParameters).then(function(resp) { |
| 13 assert_equals(resp.status, 200, "Response's status is 200"); |
| 14 }); |
| 15 }, desc); |
| 16 } else { |
| 17 promise_test(function(test) { |
| 18 return promise_rejects(test, new TypeError(), fetch(url + urlParameters)); |
| 19 }, desc); |
| 20 } |
| 21 } |
| 22 /* Actual origin */ |
| 23 var origin = "http://{{host}}:{{ports[http][0]}}"; |
| 24 |
| 25 corsMultipleOrigins("3 origins allowed, match the 3rd (" + origin + ")", ["\"\""
, "http://example.com", origin], true); |
| 26 corsMultipleOrigins("3 origins allowed, match the 3rd (\"*\")", ["\"\"", "http:/
/example.com", "*"], true); |
| 27 corsMultipleOrigins("3 origins allowed, match twice (" + origin + ")", ["\"\"",
origin, origin], true); |
| 28 corsMultipleOrigins("3 origins allowed, match twice (\"*\")", ["*", "http://exam
ple.com", "*"], true); |
| 29 corsMultipleOrigins("3 origins allowed, match twice (\"*\" and " + origin + ")",
["*", "http://example.com", origin], true); |
| 30 corsMultipleOrigins("3 origins allowed, no match", ["", "http://example.com", "h
ttps://example2.com"], false); |
| 31 |
| 32 done(); |
OLD | NEW |