OLD | NEW |
(Empty) | |
| 1 if (this.document === undefined) { |
| 2 importScripts("/resources/testharness.js"); |
| 3 importScripts("../resources/utils.js"); |
| 4 } |
| 5 |
| 6 function fetchNoCors(url, isOpaqueFiltered) { |
| 7 var urlQuery = "?pipe=header(x-is-filtered,value)" |
| 8 promise_test(function(test) { |
| 9 if (isOpaqueFiltered) |
| 10 return fetch(url + urlQuery, {"mode": "no-cors"}).then(function(resp) { |
| 11 assert_equals(resp.status, 0, "Opaque filter: status is 0"); |
| 12 assert_equals(resp.statusText, "", "Opaque filter: statusText is \"\""); |
| 13 assert_equals(resp.type , "opaque", "Opaque filter: response's type is o
paque"); |
| 14 assert_equals(resp.headers.get("x-is-filtered"), null, "Header x-is-filt
ered is filtered"); |
| 15 }); |
| 16 else |
| 17 return fetch(url + urlQuery, {"mode": "no-cors"}).then(function(resp) { |
| 18 assert_equals(resp.status, 200, "HTTP status is 200"); |
| 19 assert_equals(resp.type , "basic", "Response's type is basic"); |
| 20 assert_equals(resp.headers.get("x-is-filtered"), "value", "Header x-is-f
iltered is not filtered"); |
| 21 }); |
| 22 }, "Fetch "+ url + " with no-cors mode"); |
| 23 } |
| 24 |
| 25 fetchNoCors(RESOURCES_DIR + "top.txt", false); |
| 26 fetchNoCors("http://{{host}}:{{ports[http][0]}}/fetch/api/resources/top.txt", fa
lse); |
| 27 fetchNoCors("https://{{host}}:{{ports[https][0]}}/fetch/api/resources/top.txt",
true); |
| 28 fetchNoCors("http://{{host}}:{{ports[http][1]}}/fetch/api/resources/top.txt", tr
ue); |
| 29 |
| 30 done(); |
| 31 |
OLD | NEW |