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

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

Issue 2255383002: Allow a foreign fetch event handler to not handle an event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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/get-host-info.js"></script> 4 <script src="../resources/get-host-info.js"></script>
5 <script src="resources/test-helpers.js"></script> 5 <script src="resources/test-helpers.js"></script>
6 <script src="resources/foreign-fetch-helpers.js"></script> 6 <script src="resources/foreign-fetch-helpers.js"></script>
7 <body> 7 <body>
8 <script> 8 <script>
9 var host_info = get_host_info(); 9 var host_info = get_host_info();
10 10
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 var channel = new MessageChannel(); 96 var channel = new MessageChannel();
97 frame.contentWindow.postMessage('ping', '*', [channel.port1]); 97 frame.contentWindow.postMessage('ping', '*', [channel.port1]);
98 channel.port2.onmessage = reply => resolve(reply.data); 98 channel.port2.onmessage = reply => resolve(reply.data);
99 })) 99 }))
100 .then(reply => { 100 .then(reply => {
101 assert_equals(reply, 'ping'); 101 assert_equals(reply, 'ping');
102 }); 102 });
103 }, 'Service Worker does not intercept navigations.'); 103 }, 'Service Worker does not intercept navigations.');
104 104
105 promise_test(t => { 105 promise_test(t => {
106 var scope = 'fetch-access-control.php?fallback&ACAOrigin=*';
107 var remote_url =
108 host_info.HTTPS_REMOTE_ORIGIN + '/serviceworker/resources/' + scope;
109 return install_cross_origin_worker(t, worker_for_scopes(['']), scope)
110 .then(() => fetch(remote_url))
111 .then(response => response.text())
112 .then(response_text => assert_true(response_text.startsWith('report(')));
113 }, 'Service Worker that fallback to network should fallback to network.');
114
115 promise_test(t => {
106 var scope = 'simple.txt?fallback'; 116 var scope = 'simple.txt?fallback';
107 var remote_url = 117 var remote_url =
108 host_info.HTTPS_REMOTE_ORIGIN + '/serviceworker/resources/' + scope; 118 host_info.HTTPS_REMOTE_ORIGIN + '/serviceworker/resources/' + scope;
109 return install_cross_origin_worker(t, worker_for_scopes(['']), scope) 119 return install_cross_origin_worker(t, worker_for_scopes(['']), scope)
110 .then(() => fetch(remote_url)) 120 .then(() => fetch(remote_url, {mode: 'no-cors'}))
111 .then(response => {}); 121 .then(response => assert_equals(response.type, 'opaque'))
112 }, 'Service Worker that fallback to network should not crash.'); 122 .then(() => promise_rejects(t, new TypeError(), fetch(remote_url)));
123 }, 'Falling back to network should still respect CORS.');
113 124
114 promise_test(t => { 125 promise_test(t => {
115 var ff_scope = 'foreign-fetch/scope/controlled?basic'; 126 var ff_scope = 'foreign-fetch/scope/controlled?basic';
116 var remote_url = 127 var remote_url =
117 host_info.HTTPS_REMOTE_ORIGIN + '/serviceworker/resources/' + ff_scope; 128 host_info.HTTPS_REMOTE_ORIGIN + '/serviceworker/resources/' + ff_scope;
118 var scope = 'resources/simple.html?fetch'; 129 var scope = 'resources/simple.html?fetch';
119 var worker = 'resources/empty-worker.js'; 130 var worker = 'resources/empty-worker.js';
120 return install_cross_origin_worker(t, worker_for_scopes(['']), ff_scope) 131 return install_cross_origin_worker(t, worker_for_scopes(['']), ff_scope)
121 .then(() => service_worker_unregister_and_register(t, worker, scope)) 132 .then(() => service_worker_unregister_and_register(t, worker, scope))
122 .then(r => { 133 .then(r => {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 var remote_url = 224 var remote_url =
214 host_info.HTTPS_REMOTE_ORIGIN + '/serviceworker/resources/' + scope; 225 host_info.HTTPS_REMOTE_ORIGIN + '/serviceworker/resources/' + scope;
215 return install_cross_origin_worker(t, worker_for_scopes(['']), scope) 226 return install_cross_origin_worker(t, worker_for_scopes(['']), scope)
216 .then(() => fetch(remote_url, {method: 'SPECIAL'})) 227 .then(() => fetch(remote_url, {method: 'SPECIAL'}))
217 .then(response => response.text()) 228 .then(response => response.text())
218 .then(response_text => assert_true(response_text.startsWith('report('))); 229 .then(response_text => assert_true(response_text.startsWith('report(')));
219 }, 'Service Worker does not intercept fetches with CORS preflight'); 230 }, 'Service Worker does not intercept fetches with CORS preflight');
220 231
221 </script> 232 </script>
222 </body> 233 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698