|
1 | 1 | if (self.importScripts) {
|
2 | 2 | importScripts('/resources/testharness.js');
|
| 3 | + importScripts('/common/get-host-info.sub.js'); |
3 | 4 | importScripts('../resources/test-helpers.js');
|
4 | 5 | }
|
5 | 6 |
|
6 | 7 | var test_url = 'https://example.com/foo';
|
7 | 8 | var test_body = 'Hello world!';
|
| 9 | +const { REMOTE_HOST } = get_host_info(); |
8 | 10 |
|
9 | 11 | cache_test(function(cache) {
|
10 | 12 | var request = new Request(test_url);
|
@@ -129,6 +131,23 @@ cache_test(function(cache, test) {
|
129 | 131 | });
|
130 | 132 | }, 'Cache.put with HTTP 206 response');
|
131 | 133 |
|
| 134 | +cache_test(function(cache, test) { |
| 135 | + var test_url = new URL('../resources/fetch-status.py?status=206', location.href); |
| 136 | + test_url.hostname = REMOTE_HOST; |
| 137 | + var request = new Request(test_url.href, { mode: 'no-cors' }); |
| 138 | + var response; |
| 139 | + return fetch(request) |
| 140 | + .then(function(fetch_result) { |
| 141 | + assert_equals(fetch_result.type, 'opaque', |
| 142 | + 'Test framework error: The response type should be opaque.'); |
| 143 | + assert_equals(fetch_result.status, 0, |
| 144 | + 'Test framework error: The status code should be 0 for an ' + |
| 145 | + ' opaque-filtered response. This is actually HTTP 206.'); |
| 146 | + response = fetch_result.clone(); |
| 147 | + return promise_rejects_js(test, TypeError, cache.put(request, fetch_result)); |
| 148 | + }); |
| 149 | + }, 'Cache.put with opaque-filtered HTTP 206 response'); |
| 150 | + |
132 | 151 | cache_test(function(cache) {
|
133 | 152 | var test_url = new URL('../resources/fetch-status.py?status=500', location.href).href;
|
134 | 153 | var request = new Request(test_url);
|
|
0 commit comments