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

Side by Side Diff: LayoutTests/http/tests/serviceworker/fetch-request-resources.html

Issue 1060033002: Implement Request.context for Fetch API (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 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 <title>Service Worker: FetchEvent for resources</title> 2 <title>Service Worker: FetchEvent for resources</title>
3 <script src="../resources/testharness.js"></script> 3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script> 4 <script src="../resources/testharnessreport.js"></script>
5 <script src="resources/test-helpers.js?pipe=sub"></script> 5 <script src="resources/test-helpers.js?pipe=sub"></script>
6 <script> 6 <script>
7 var url_count = 0; 7 var url_count = 0;
8 var expected_results = {}; 8 var expected_results = {};
9 9
10 function image_test(frame, url, cross_origin, 10 function image_test(frame, url, cross_origin, expected_context,
11 expexted_mode, expected_credentials) { 11 expexted_mode, expected_credentials) {
12 var actual_url = url + (++url_count); 12 var actual_url = url + (++url_count);
13 expected_results[actual_url] = { 13 expected_results[actual_url] = {
14 cross_origin: cross_origin, 14 cross_origin: cross_origin,
15 context: expected_context,
15 mode: expexted_mode, 16 mode: expexted_mode,
16 credentials: expected_credentials, 17 credentials: expected_credentials,
17 message: 'Image load (url:' + 18 message: 'Image load (url:' +
18 actual_url + ' cross_origin:' + cross_origin + ')' 19 actual_url + ' cross_origin:' + cross_origin + ')'
19 }; 20 };
20 return frame.contentWindow.load_image(actual_url, cross_origin); 21 return frame.contentWindow.load_image(actual_url, cross_origin);
21 } 22 }
22 23
23 function script_test(frame, url, cross_origin, 24 function script_test(frame, url, cross_origin, expected_context,
24 expexted_mode, expected_credentials) { 25 expexted_mode, expected_credentials) {
25 var actual_url = url + (++url_count); 26 var actual_url = url + (++url_count);
26 expected_results[actual_url] = { 27 expected_results[actual_url] = {
27 cross_origin: cross_origin, 28 cross_origin: cross_origin,
29 context: expected_context,
28 mode: expexted_mode, 30 mode: expexted_mode,
29 credentials: expected_credentials, 31 credentials: expected_credentials,
30 message: 'Script load (url:' + 32 message: 'Script load (url:' +
31 actual_url + ' cross_origin:' + cross_origin + ')' 33 actual_url + ' cross_origin:' + cross_origin + ')'
32 }; 34 };
33 return frame.contentWindow.load_script(actual_url, cross_origin); 35 return frame.contentWindow.load_script(actual_url, cross_origin);
34 } 36 }
35 37
36 function css_test(frame, url, cross_origin, 38 function css_test(frame, url, cross_origin, expected_context,
37 expexted_mode, expected_credentials) { 39 expexted_mode, expected_credentials) {
38 var actual_url = url + (++url_count); 40 var actual_url = url + (++url_count);
39 expected_results[actual_url] = { 41 expected_results[actual_url] = {
40 cross_origin: cross_origin, 42 cross_origin: cross_origin,
43 context: expected_context,
41 mode: expexted_mode, 44 mode: expexted_mode,
42 credentials: expected_credentials, 45 credentials: expected_credentials,
43 message: 'CSS load (url:' + 46 message: 'CSS load (url:' +
44 actual_url + ' cross_origin:' + cross_origin + ')' 47 actual_url + ' cross_origin:' + cross_origin + ')'
45 }; 48 };
46 return frame.contentWindow.load_css(actual_url, cross_origin); 49 return frame.contentWindow.load_css(actual_url, cross_origin);
47 } 50 }
48 51
49 function font_face_test(frame, url, expexted_mode, expected_credentials) { 52 function font_face_test(frame, url, expected_context, expexted_mode,
53 expected_credentials) {
50 var actual_url = url + (++url_count); 54 var actual_url = url + (++url_count);
51 expected_results[actual_url] = { 55 expected_results[actual_url] = {
52 url: actual_url, 56 url: actual_url,
57 context: expected_context,
53 mode: expexted_mode, 58 mode: expexted_mode,
54 credentials: expected_credentials, 59 credentials: expected_credentials,
55 message: 'FontFace load (url:' + actual_url + ')' 60 message: 'FontFace load (url:' + actual_url + ')'
56 }; 61 };
57 return frame.contentWindow.load_font(actual_url); 62 return frame.contentWindow.load_font(actual_url);
58 } 63 }
59 64
60 function css_image_test(frame, url, type, expexted_mode, expected_credentials) { 65 function css_image_test(frame, url, type, expected_context,
66 expexted_mode, expected_credentials) {
61 var actual_url = url + (++url_count); 67 var actual_url = url + (++url_count);
62 expected_results[actual_url] = { 68 expected_results[actual_url] = {
63 url: actual_url, 69 url: actual_url,
70 context: expected_context,
64 mode: expexted_mode, 71 mode: expexted_mode,
65 credentials: expected_credentials, 72 credentials: expected_credentials,
66 message: 'CSSImage load (url:' + actual_url + ' type:' + type + ')' 73 message: 'CSSImage load (url:' + actual_url + ' type:' + type + ')'
67 }; 74 };
68 return frame.contentWindow.load_css_image(actual_url, type); 75 return frame.contentWindow.load_css_image(actual_url, type);
69 } 76 }
70 77
71 function css_image_set_test(frame, url, type, 78 function css_image_set_test(frame, url, type, expected_context,
72 expexted_mode, expected_credentials) { 79 expexted_mode, expected_credentials) {
73 var actual_url = url + (++url_count); 80 var actual_url = url + (++url_count);
74 expected_results[actual_url] = { 81 expected_results[actual_url] = {
75 url: actual_url, 82 url: actual_url,
83 context: expected_context,
76 mode: expexted_mode, 84 mode: expexted_mode,
77 credentials: expected_credentials, 85 credentials: expected_credentials,
78 message: 'CSSImageSet load (url:' + actual_url + ' type:' + type + ')' 86 message: 'CSSImageSet load (url:' + actual_url + ' type:' + type + ')'
79 }; 87 };
80 return frame.contentWindow.load_css_image_set(actual_url, type); 88 return frame.contentWindow.load_css_image_set(actual_url, type);
81 } 89 }
82 90
83 async_test(function(t) { 91 async_test(function(t) {
84 var SCOPE = 'resources/fetch-request-resources-iframe.html'; 92 var SCOPE = 'resources/fetch-request-resources-iframe.html';
85 var SCRIPT = 'resources/fetch-request-resources-worker.js'; 93 var SCRIPT = 'resources/fetch-request-resources-worker.js';
(...skipping 16 matching lines...) Expand all
102 if (msg.data.ready) { 110 if (msg.data.ready) {
103 resolve(); 111 resolve();
104 return; 112 return;
105 } 113 }
106 var result = msg.data; 114 var result = msg.data;
107 var expected = expected_results[result.url]; 115 var expected = expected_results[result.url];
108 if (!expected) { 116 if (!expected) {
109 return; 117 return;
110 } 118 }
111 assert_equals( 119 assert_equals(
120 result.context, expected.context,
121 'context of ' + expected.message + ' must be ' +
122 expected.context + '.');
123 assert_equals(
124 result.context_clone, expected.context,
125 'context of clone() of' + expected.message +
126 ' must be ' + expected.context + '.');
127 assert_equals(
128 result.context_new, '',
129 'context of new Request() must be the empty string');
130 assert_equals(
112 result.mode, expected.mode, 131 result.mode, expected.mode,
113 'mode of ' + expected.message + ' must be ' + 132 'mode of ' + expected.message + ' must be ' +
114 expected.mode + '.'); 133 expected.mode + '.');
115 assert_equals( 134 assert_equals(
116 result.credentials, expected.credentials, 135 result.credentials, expected.credentials,
117 'credentials of ' + expected.message + ' must be ' + 136 'credentials of ' + expected.message + ' must be ' +
118 expected.credentials + '.'); 137 expected.credentials + '.');
119 --url_count; 138 --url_count;
120 delete expected_results[result.url]; 139 delete expected_results[result.url];
121 if (url_count == 0) { 140 if (url_count == 0) {
122 frame.remove(); 141 frame.remove();
123 service_worker_unregister_and_done(t, SCOPE); 142 service_worker_unregister_and_done(t, SCOPE);
124 } 143 }
125 }); 144 });
126 worker.postMessage( 145 worker.postMessage(
127 {port: channel.port2}, [channel.port2]); 146 {port: channel.port2}, [channel.port2]);
128 }); 147 });
129 }) 148 })
130 .then(function() { return with_iframe(SCOPE); }) 149 .then(function() { return with_iframe(SCOPE); })
131 .then(function(f) { 150 .then(function(f) {
132 frame = f; 151 frame = f;
133 image_test(f, LOCAL_URL, '', 'no-cors', 'same-origin'); 152 image_test(f, LOCAL_URL, '', 'image', 'no-cors', 'same-origin');
134 image_test(f, LOCAL_URL, 'anonymous', 'cors', 'omit'); 153 image_test(f, LOCAL_URL, 'anonymous', 'image', 'cors', 'omit');
135 image_test(f, LOCAL_URL, 'use-credentials', 'cors', 'include'); 154 image_test(f, LOCAL_URL, 'use-credentials', 'image', 'cors',
136 image_test(f, REMOTE_URL, '', 'no-cors', 'same-origin'); 155 'include');
137 image_test(f, REMOTE_URL, 'anonymous', 'cors', 'omit'); 156 image_test(f, REMOTE_URL, '', 'image', 'no-cors', 'same-origin');
138 image_test(f, REMOTE_URL, 'use-credentials', 'cors', 'include'); 157 image_test(f, REMOTE_URL, 'anonymous', 'image', 'cors', 'omit');
158 image_test(f, REMOTE_URL, 'use-credentials', 'image', 'cors',
159 'include');
139 160
140 script_test(f, LOCAL_URL, '', 'no-cors', 'same-origin'); 161 script_test(f, LOCAL_URL, '', 'script', 'no-cors', 'same-origin');
141 script_test(f, LOCAL_URL, 'anonymous', 'cors', 'omit'); 162 script_test(f, LOCAL_URL, 'anonymous', 'script', 'cors', 'omit');
142 script_test(f, LOCAL_URL, 'use-credentials', 'cors', 'include'); 163 script_test(f, LOCAL_URL, 'use-credentials', 'script', 'cors',
143 script_test(f, REMOTE_URL, '', 'no-cors', 'same-origin'); 164 'include');
144 script_test(f, REMOTE_URL, 'anonymous', 'cors', 'omit'); 165 script_test(f, REMOTE_URL, '', 'script', 'no-cors', 'same-origin');
145 script_test(f, REMOTE_URL, 'use-credentials', 'cors', 'include'); 166 script_test(f, REMOTE_URL, 'anonymous', 'script', 'cors', 'omit');
167 script_test(f, REMOTE_URL, 'use-credentials', 'script', 'cors',
168 'include');
146 169
147 css_test(f, LOCAL_URL, '', 'no-cors', 'same-origin'); 170 css_test(f, LOCAL_URL, '', 'style', 'no-cors', 'same-origin');
148 css_test(f, LOCAL_URL, 'anonymous', 'cors', 'omit'); 171 css_test(f, LOCAL_URL, 'anonymous', 'style', 'cors', 'omit');
149 css_test(f, LOCAL_URL, 'use-credentials', 'cors', 'include'); 172 css_test(f, LOCAL_URL, 'use-credentials', 'style', 'cors',
150 css_test(f, REMOTE_URL, '', 'no-cors', 'same-origin'); 173 'include');
151 css_test(f, REMOTE_URL, 'anonymous', 'cors', 'omit'); 174 css_test(f, REMOTE_URL, '', 'style', 'no-cors', 'same-origin');
152 css_test(f, REMOTE_URL, 'use-credentials', 'cors', 'include'); 175 css_test(f, REMOTE_URL, 'anonymous', 'style', 'cors', 'omit');
176 css_test(f, REMOTE_URL, 'use-credentials', 'style', 'cors',
177 'include');
153 178
154 font_face_test(f, LOCAL_URL, 'no-cors', 'same-origin'); 179 font_face_test(f, LOCAL_URL, 'font', 'no-cors', 'same-origin');
155 font_face_test(f, REMOTE_URL, 'cors', 'omit'); 180 font_face_test(f, REMOTE_URL, 'font', 'cors', 'omit');
156 181
157 css_image_test(f, LOCAL_URL, 'backgroundImage', 182 css_image_test(f, LOCAL_URL, 'backgroundImage', 'image',
158 'no-cors', 'same-origin'); 183 'no-cors', 'same-origin');
159 css_image_test(f, REMOTE_URL, 'backgroundImage', 184 css_image_test(f, REMOTE_URL, 'backgroundImage', 'image',
160 'no-cors', 'same-origin'); 185 'no-cors', 'same-origin');
161 css_image_test(f, LOCAL_URL, 'shapeOutside', 'cors', 'omit'); 186 css_image_test(f, LOCAL_URL, 'shapeOutside', 'image', 'cors',
162 css_image_test(f, REMOTE_URL, 'shapeOutside', 'cors', 'omit'); 187 'omit');
188 css_image_test(f, REMOTE_URL, 'shapeOutside', 'image', 'cors',
189 'omit');
163 190
164 css_image_set_test(f, LOCAL_URL, 'backgroundImage', 191 css_image_set_test(f, LOCAL_URL, 'backgroundImage', 'image',
165 'no-cors', 'same-origin'); 192 'no-cors', 'same-origin');
166 css_image_set_test(f, REMOTE_URL, 'backgroundImage', 193 css_image_set_test(f, REMOTE_URL, 'backgroundImage', 'image',
167 'no-cors', 'same-origin'); 194 'no-cors', 'same-origin');
168 css_image_set_test(f, LOCAL_URL, 'shapeOutside', 'cors', 'omit'); 195 css_image_set_test(f, LOCAL_URL, 'shapeOutside', 'image', 'cors',
169 css_image_set_test(f, REMOTE_URL, 'shapeOutside', 'cors', 'omit'); 196 'omit');
197 css_image_set_test(f, REMOTE_URL, 'shapeOutside', 'image', 'cors',
198 'omit');
170 199
171 }) 200 })
172 .catch(unreached_rejection(t)); 201 .catch(unreached_rejection(t));
173 }, 'Verify FetchEvent for resources.'); 202 }, 'Verify FetchEvent for resources.');
174 </script> 203 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698