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

Side by Side Diff: LayoutTests/http/tests/fetch/script-tests/fetch.js

Issue 1304183006: Fail preflight request when redirect is received (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated expectation Created 5 years, 3 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 if (self.importScripts) { 1 if (self.importScripts) {
2 importScripts('../resources/fetch-test-helpers.js'); 2 importScripts('../resources/fetch-test-helpers.js');
3 } 3 }
4 4
5 promise_test(function(t) { 5 promise_test(function(t) {
6 return fetch('http://') 6 return fetch('http://')
7 .then( 7 .then(
8 t.unreached_func('fetch of invalid URL must fail'), 8 t.unreached_func('fetch of invalid URL must fail'),
9 function() {}); 9 function() {});
10 }, 'Fetch invalid URL'); 10 }, 'Fetch invalid URL');
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 return fetch(request) 107 return fetch(request)
108 .then(function(response) { 108 .then(function(response) {
109 assert_equals(response.status, 0); 109 assert_equals(response.status, 0);
110 assert_equals(response.type, 'opaqueredirect'); 110 assert_equals(response.type, 'opaqueredirect');
111 assert_equals(response.url, ''); 111 assert_equals(response.url, '');
112 }); 112 });
113 }, 'Manual redirect fetch returns opaque redirect response'); 113 }, 'Manual redirect fetch returns opaque redirect response');
114 114
115 promise_test(function(t) { 115 promise_test(function(t) {
116 var redirect_target_url = 116 var redirect_target_url =
117 OTHER_ORIGIN + '/fetch/resources/fetch-status.php?status=200';
118 var redirect_original_url =
119 OTHER_ORIGIN + '/serviceworker/resources/redirect.php?Redirect=' +
120 redirect_target_url;
121
122 var request = new Request(redirect_original_url,
123 {headers: [['X-Fetch-Test', 'A']],
124 redirect: 'manual'});
125
126 // Cross-origin request with non-simple header initiates CORS preflight
127 // request.
128 return fetch(request)
129 .then(
130 t.unreached_func('Even in manual redirect mode, fetch with preflight' +
131 ' must fail when redirect response is received'),
132 function() {});
133 }, 'Even in manual redirect mode, fetch with preflight must fail when' +
134 ' redirect response is received');
135
136 promise_test(function(t) {
137 var redirect_target_url =
117 BASE_ORIGIN + '/fetch/resources/fetch-status.php?status=200'; 138 BASE_ORIGIN + '/fetch/resources/fetch-status.php?status=200';
118 var redirect_original_url = 139 var redirect_original_url =
119 BASE_ORIGIN + '/serviceworker/resources/redirect.php?Redirect=' + 140 BASE_ORIGIN + '/serviceworker/resources/redirect.php?Redirect=' +
120 redirect_target_url; 141 redirect_target_url;
121 142
122 var request = new Request(redirect_original_url, {redirect: 'error'}); 143 var request = new Request(redirect_original_url, {redirect: 'error'});
123 assert_equals(request.url, redirect_original_url, 144 assert_equals(request.url, redirect_original_url,
124 'Request\'s url is the original URL'); 145 'Request\'s url is the original URL');
125 assert_equals(request.redirect, 'error'); 146 assert_equals(request.redirect, 'error');
126 147
127 return fetch(request) 148 return fetch(request)
128 .then( 149 .then(
129 t.unreached_func('Redirect response must cause an error when redirct' + 150 t.unreached_func('Redirect response must cause an error when redirect' +
130 ' mode is error.'), 151 ' mode is error.'),
131 function() {}); 152 function() {});
132 }, 'Redirect response must cause an error when redirct mode is error.'); 153 }, 'Redirect response must cause an error when redirect mode is error.');
133 154
134 promise_test(function(test) { 155 promise_test(function(test) {
135 var url = BASE_ORIGIN + '/fetch/resources/doctype.html'; 156 var url = BASE_ORIGIN + '/fetch/resources/doctype.html';
136 return fetch(new Request(url, {redirect: 'manual'})) 157 return fetch(new Request(url, {redirect: 'manual'}))
137 .then(function(response) { 158 .then(function(response) {
138 assert_equals(response.status, 200); 159 assert_equals(response.status, 200);
139 assert_equals(response.statusText, 'OK'); 160 assert_equals(response.statusText, 'OK');
140 assert_equals(response.url, url); 161 assert_equals(response.url, url);
141 return response.text(); 162 return response.text();
142 }) 163 })
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 function runInfiniteFetchLoop() { 287 function runInfiniteFetchLoop() {
267 fetch('dummy.html') 288 fetch('dummy.html')
268 .then(function() { runInfiniteFetchLoop(); }); 289 .then(function() { runInfiniteFetchLoop(); });
269 } 290 }
270 runInfiniteFetchLoop(); 291 runInfiniteFetchLoop();
271 }, 292 },
272 'Destroying the execution context while fetch is happening should not ' + 293 'Destroying the execution context while fetch is happening should not ' +
273 'cause a crash.'); 294 'cause a crash.');
274 295
275 done(); 296 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698