OLD | NEW |
---|---|
(Empty) | |
1 importScripts('worker-test-helpers.js'); | |
2 | |
3 test(function() { | |
4 var headerMap = { | |
jsbell
2014/05/23 20:59:49
Rename?
kinuko
2014/05/26 05:45:13
Done.
| |
5 'Content-Language': 'ja', | |
6 'Content-Type': 'text/html; charset=UTF-8', | |
7 'X-ServiceWorker-Test': 'response test field' | |
8 }; | |
9 | |
10 var headers = new HeaderMap; | |
11 Object.keys(headerMap).forEach(function(key) { | |
12 headers.set(key, headerMap[key]); | |
13 }); | |
14 | |
15 var response = new Response({ | |
16 status: 303, | |
17 statusText: 'See Other', | |
18 headers: headers | |
19 }); | |
20 | |
21 assert_equals(response.status, 303, 'Response.status should match'); | |
22 assert_equals(response.statusText, 'See Other', 'Response.statusText should match'); | |
23 assert_true(response.headers instanceof HeaderMap, 'Response.headers should be HeaderMap'); | |
24 assert_equals(response.headers.size, 3, 'Response.headers.size should match' ); | |
25 | |
26 Object.keys(headerMap).forEach(function(key) { | |
falken
2014/05/24 14:32:36
Response.h implements namedPropertyEnumerator, but
kinuko
2014/05/26 05:45:13
Actually the spec got updated and we no longer see
| |
27 assert_true(key in response); | |
28 assert_equals(response[key], headerMap[key]); | |
29 }); | |
30 | |
31 var newKey = 'Cache-Control'; | |
32 var newValue = 'max-age=3600'; | |
33 response[newKey] = newValue; | |
34 assert_true(newKey in response); | |
35 assert_equals(response[newKey], newValue); | |
36 }, 'Response in ServiceWorkerGlobalScope'); | |
OLD | NEW |