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

Side by Side Diff: LayoutTests/http/tests/fetch/resources/fetch-access-control-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
(Empty)
1 importScripts('fetch-test-options.js');
2 importScripts('fetch-access-control-util.js');
3
4 var port = undefined;
5 var isTestTargetFetch = false;
6
7 self.onmessage = function(e) {
8 var message = e.data;
9 if ('port' in message) {
10 port = message.port;
11 } else if (message.msg === 'START TEST CASE') {
12 isTestTargetFetch = true;
13 port.postMessage({msg: 'READY'});
14 }
15 };
16
17 self.addEventListener('fetch', function(event) {
18 if (!isTestTargetFetch) {
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.
21 return;
22 }
23 isTestTargetFetch = false;
24
25 event.respondWith(
26 doFetch(event.request)
27 .then(function(message) {
28 var response = message.response;
29 message.response = undefined;
30 // Send the result to fetch-access-control-util.js.
31 port.postMessage(message);
32 return response;
33 })
34 .catch(function(message) {
35 port.postMessage(message);
36 return Promise.reject();
37 })
38 );
39 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698