1 if (self
.importScripts
) {
2 importScripts('../resources/fetch-test-helpers.js');
5 promise_test(function() {
8 var url
= '../resources/doctype.html';
9 var expectedText
= '<!DOCTYPE html>\n';
12 lastModified
= res
.headers
.get('last-modified');
13 eTag
= res
.headers
.get('etag');
14 assert_not_equals(lastModified
, '', 'last-modified must be set.');
15 assert_not_equals(eTag
, '', 'eTag must be set.');
20 assert_equals(res
.status
, 200,
21 'Automatically cached response status must be 200.');
24 .then(function(text
) {
27 'Automatically cached response body must be correct.');
30 { headers
: [['If-Modified-Since', lastModified
]] });
35 'When If-Modified-Since is overridden, the response status must ' +
39 .then(function(text
) {
42 'When If-Modified-Since is overridden, the response body must be' +
46 { headers
: [['If-Modified-Since',
47 'Tue, 01 Jan 1980 01:00:00 GMT']] });
52 'When If-Modified-Since is overridden, the modified response ' +
53 'status must be 200.');
56 .then(function(text
) {
59 'When If-Modified-Since is overridden, the modified response body' +
63 { headers
: [['If-Unmodified-Since', lastModified
]] });
68 'When If-Unmodified-Since is overridden, the modified response ' +
69 'status must be 200.');
72 .then(function(text
) {
75 'When If-Unmodified-Since is overridden, the modified response ' +
76 'body must be correct.');
79 { headers
: [['If-Unmodified-Since',
80 'Tue, 01 Jan 1980 01:00:00 GMT']] });
85 'When If-Unmodified is overridden, the modified response status ' +
89 .then(function(text
) {
92 'When If-Unmodified is overridden, the modified response body ' +
96 { headers
: [['If-Match', eTag
]] });
101 'When If-Match is overridden, the response status must be 200.');
104 .then(function(text
) {
107 'When If-Match is overridden, the response body must be correct.');
109 // FIXME: We used to have a test of If-Match overridden with an
110 // invalid etag, but removed due to broken If-Match handling of
111 // Apache 2.4. See crbug.com/423070
114 { headers
: [['If-None-Match', eTag
]] });
116 .then(function(res
) {
119 'When If-None-Match is overridden, the response status must be ' +
123 .then(function(text
) {
126 'When If-None-Match is overridden, the response body must be ' +
130 { headers
: [['If-None-Match', 'xyzzy']] });
132 .then(function(res
) {
135 'When If-None-Match is overridden to the invalid tag, the ' +
136 'response status must be 200.');
139 .then(function(text
) {
142 'When If-None-Match is overridden to the invalid tag, the ' +
143 'response body must be correct.');
146 { headers
: [['If-Range', eTag
],
147 ['Range', 'bytes=10-30']] });
149 .then(function(res
) {
152 'When If-Range is overridden, the response status must be 206.');
155 .then(function(text
) {
157 text
, expectedText
.substring(10, 31),
158 'When If-Range is overridden, the response body must be correct.');
161 { headers
: [['If-Range', 'xyzzy'],
162 ['Range', 'bytes=10-30']] });
164 .then(function(res
) {
167 'When If-Range is overridden to the invalid tag, the response ' +
168 'status must be 200.');
171 .then(function(text
) {
174 'When If-Range is overridden to the invalid tag, the response ' +
175 'body must be correct.');
177 return fetch('../resources/fetch-status.php?status=304');
179 .then(function(res
) {
182 'When the server returns 304 and there\'s a cache miss, the ' +
183 'response status must be 304.');
185 }, '304 handling for fetch().');