Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(418)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/fetch-event.html

Issue 1588003005: Revert of Service Worker: Add FetchEvent.clientId (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script> 2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script> 3 <script src="../resources/testharnessreport.js"></script>
4 <script src="resources/test-helpers.js"></script> 4 <script src="resources/test-helpers.js"></script>
5 <body> 5 <body>
6 <script> 6 <script>
7 var worker = 'resources/fetch-event-test-worker.js'; 7 var worker = 'resources/fetch-event-test-worker.js';
8 8
9 async_test(function(t) { 9 async_test(function(t) {
10 var scope = 'resources/simple.html?string'; 10 var scope = 'resources/simple.html?string';
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 frame.contentDocument.body.textContent, 62 frame.contentDocument.body.textContent,
63 'Referrer: ' + document.location.href, 63 'Referrer: ' + document.location.href,
64 'Service Worker should respond to fetch with the referrer URL'); 64 'Service Worker should respond to fetch with the referrer URL');
65 frame.remove(); 65 frame.remove();
66 return service_worker_unregister_and_done(t, scope); 66 return service_worker_unregister_and_done(t, scope);
67 }) 67 })
68 .catch(unreached_rejection(t)); 68 .catch(unreached_rejection(t));
69 }, 'Service Worker responds to fetch event with the referrer URL'); 69 }, 'Service Worker responds to fetch event with the referrer URL');
70 70
71 async_test(function(t) { 71 async_test(function(t) {
72 var scope = 'resources/simple.html?clientId';
73 var frame;
74 var client_id1, client_id2;
75 service_worker_unregister_and_register(t, worker, scope)
76 .then(function(reg) {
77 return wait_for_state(t, reg.installing, 'activated');
78 })
79 .then(function() { return with_iframe(scope); })
80 .then(function(f) {
81 frame = f;
82 assert_equals(
83 frame.contentDocument.body.textContent.substr(0, 19),
84 'Client ID Not Found',
85 'Service Worker should respond to navigation fetch with no ' +
86 'client id');
87 return frame.contentWindow.fetch('resources/other.html?clientId');
88 })
89 .then(function(response) { return response.text(); })
90 .then(function(response_text) {
91 client_id1 = response_text.substr(17, 36);
92 assert_equals(
93 response_text.substr(0, 15),
94 'Client ID Found',
95 'Service Worker should respond to fetch with a client id');
96 return frame.contentWindow.fetch('resources/other.html?clientId');
97 })
98 .then(function(response) { return response.text(); })
99 .then(function(response_text) {
100 client_id2 = response_text.substr(17, 36);
101 assert_equals(
102 client_id1,
103 client_id2,
104 'Service Worker should respond to another fetch from the same ' +
105 'client with the same client id');
106 frame.remove();
107 return service_worker_unregister_and_done(t, scope);
108 })
109 .catch(unreached_rejection(t));
110 }, 'Service Worker responds to fetch event with a client id');
111
112 async_test(function(t) {
113 var scope = 'resources/simple.html?ignore'; 72 var scope = 'resources/simple.html?ignore';
114 service_worker_unregister_and_register(t, worker, scope) 73 service_worker_unregister_and_register(t, worker, scope)
115 .then(function(reg) { 74 .then(function(reg) {
116 return wait_for_state(t, reg.installing, 'activated'); 75 return wait_for_state(t, reg.installing, 'activated');
117 }) 76 })
118 .then(function() { return with_iframe(scope); }) 77 .then(function() { return with_iframe(scope); })
119 .then(function(frame) { 78 .then(function(frame) {
120 assert_equals(frame.contentDocument.body.textContent, 79 assert_equals(frame.contentDocument.body.textContent,
121 'Here\'s a simple html file.\n', 80 'Here\'s a simple html file.\n',
122 'Response should come from fallback to native fetch'); 81 'Response should come from fallback to native fetch');
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 document.body.appendChild(form); 148 document.body.appendChild(form);
190 frame.onload = function() { 149 frame.onload = function() {
191 document.body.removeChild(form); 150 document.body.removeChild(form);
192 resolve(frame); 151 resolve(frame);
193 }; 152 };
194 form.submit(); 153 form.submit();
195 }); 154 });
196 }) 155 })
197 .then(function(frame) { 156 .then(function(frame) {
198 assert_equals(frame.contentDocument.body.textContent, 157 assert_equals(frame.contentDocument.body.textContent,
199 'POST:application/x-www-form-urlencoded:' + 158 'POST:testName1=testValue1&testName2=testValue2');
200 'testName1=testValue1&testName2=testValue2'); 159 document.body.removeChild(frame);
201 frame.remove();
202 return service_worker_unregister_and_done(t, scope); 160 return service_worker_unregister_and_done(t, scope);
203 }) 161 })
204 .catch(unreached_rejection(t)); 162 .catch(unreached_rejection(t));
205 }, 'Service Worker responds to fetch event with POST form'); 163 }, 'Service Worker responds to fetch event with POST form');
206 164
207 async_test(function(t) { 165 async_test(function(t) {
208 var scope = 'resources/simple.html?multiple-respond-with'; 166 var scope = 'resources/simple.html?multiple-respond-with';
209 service_worker_unregister_and_register(t, worker, scope) 167 service_worker_unregister_and_register(t, worker, scope)
210 .then(function(reg) { 168 .then(function(reg) {
211 return wait_for_state(t, reg.installing, 'activated'); 169 return wait_for_state(t, reg.installing, 'activated');
212 }) 170 })
213 .then(function() { return with_iframe(scope); }) 171 .then(function() { return with_iframe(scope); })
214 .then(function(frame) { 172 .then(function(frame) {
215 assert_equals( 173 assert_equals(
216 frame.contentDocument.body.textContent, 174 frame.contentDocument.body.textContent,
217 '(0)(1)[InvalidStateError](2)[InvalidStateError]', 175 '(0)',
176 'Response should be the argument of the first respondWith() call.');
177 frame.remove();
178 return with_iframe(scope);
179 })
180 .then(function(frame) {
181 assert_equals(
182 frame.contentDocument.body.textContent,
183 '(0)(1)[InvalidStateError](2)[InvalidStateError](0)',
218 'Multiple calls of respondWith must throw InvalidStateErrors.'); 184 'Multiple calls of respondWith must throw InvalidStateErrors.');
219 frame.remove(); 185 frame.remove();
220 return service_worker_unregister_and_done(t, scope); 186 return service_worker_unregister_and_done(t, scope);
221 }) 187 })
222 .catch(unreached_rejection(t)); 188 .catch(unreached_rejection(t));
223 }, 'Multiple calls of respondWith must throw InvalidStateErrors'); 189 }, 'Multiple calls of respondWith must throw InvalidStateErrors');
224 190
225 async_test(function(t) { 191 async_test(function(t) {
226 var scope = 'resources/simple.html?used-check'; 192 var scope = 'resources/simple.html?used-check';
227 var first_frame;
228 service_worker_unregister_and_register(t, worker, scope) 193 service_worker_unregister_and_register(t, worker, scope)
229 .then(function(reg) { 194 .then(function(reg) {
230 return wait_for_state(t, reg.installing, 'activated'); 195 return wait_for_state(t, reg.installing, 'activated');
231 }) 196 })
232 .then(function() { return with_iframe(scope); }) 197 .then(function() { return with_iframe(scope); })
233 .then(function(frame) { 198 .then(function(frame) {
234 assert_equals(frame.contentDocument.body.textContent, 199 assert_equals(frame.contentDocument.body.textContent,
235 'Here\'s an other html file.\n', 200 'Here\'s an other html file.\n',
236 'Response should come from fetched other file'); 201 'Response should come from fetched other file');
237 first_frame = frame; 202 frame.remove();
238 return with_iframe(scope); 203 return with_iframe(scope);
239 }) 204 })
240 .then(function(frame) { 205 .then(function(frame) {
241 // When we access to the scope in the second time, the content of the 206 // When we access to the scope in the second time, the content of the
242 // response is generated inside the ServiceWorker. The body contains 207 // response is generated inside the ServiceWorker. The body contains
243 // the value of bodyUsed of the first response which is already 208 // the value of bodyUsed of the first response which is already
244 // consumed by FetchEvent.respondWith method. 209 // consumed by FetchEvent.respondWith method.
245 assert_equals( 210 assert_equals(
246 frame.contentDocument.body.textContent, 211 frame.contentDocument.body.textContent,
247 'bodyUsed: true', 212 'bodyUsed: true',
248 'event.respondWith must set the used flag.'); 213 'event.respondWith must set the used flag.');
249 first_frame.remove();
250 frame.remove(); 214 frame.remove();
251 return service_worker_unregister_and_done(t, scope); 215 return service_worker_unregister_and_done(t, scope);
252 }) 216 })
253 .catch(unreached_rejection(t)); 217 .catch(unreached_rejection(t));
254 }, 'Service Worker event.respondWith must set the used flag'); 218 }, 'Service Worker event.respondWith must set the used flag');
255 219
256 </script> 220 </script>
257 </body> 221 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698