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

Side by Side Diff: LayoutTests/http/tests/fetch/resources/thorough-worker.js

Issue 1267263003: Rename fetch layout tests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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 | Annotate | Revision Log
OLDNEW
1 importScripts('fetch-test-options.js'); 1 importScripts('fetch-test-options.js');
2 importScripts('fetch-access-control-util.js'); 2 importScripts('thorough-util.js');
3 3
4 var port = undefined; 4 var port = undefined;
5 var isTestTargetFetch = false; 5 var isTestTargetFetch = false;
6 6
7 self.onmessage = function(e) { 7 self.onmessage = function(e) {
8 var message = e.data; 8 var message = e.data;
9 if ('port' in message) { 9 if ('port' in message) {
10 port = message.port; 10 port = message.port;
11 } else if (message.msg === 'START TEST CASE') { 11 } else if (message.msg === 'START TEST CASE') {
12 isTestTargetFetch = true; 12 isTestTargetFetch = true;
13 port.postMessage({msg: 'READY'}); 13 port.postMessage({msg: 'READY'});
14 } 14 }
15 }; 15 };
16 16
17 self.addEventListener('fetch', function(event) { 17 self.addEventListener('fetch', function(event) {
18 if (!isTestTargetFetch) { 18 if (!isTestTargetFetch) {
19 // Don't handle the event when it is not the test target fetch such as a 19 // Don't handle the event when it is not the test target fetch such as a
20 // redirected fetch or for the iframe html. 20 // redirected fetch or for the iframe html.
21 return; 21 return;
22 } 22 }
23 isTestTargetFetch = false; 23 isTestTargetFetch = false;
24 24
25 event.respondWith( 25 event.respondWith(
26 doFetch(event.request) 26 doFetch(event.request)
27 .then(function(message) { 27 .then(function(message) {
28 var response = message.response; 28 var response = message.response;
29 message.response = undefined; 29 message.response = undefined;
30 // Send the result to fetch-access-control-util.js. 30 // Send the result to thorough-control-util.js.
31 port.postMessage(message); 31 port.postMessage(message);
32 return response; 32 return response;
33 }) 33 })
34 .catch(function(message) { 34 .catch(function(message) {
35 port.postMessage(message); 35 port.postMessage(message);
36 return Promise.reject(); 36 return Promise.reject();
37 }) 37 })
38 ); 38 );
39 }); 39 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698