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

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

Issue 1279163005: Initial Fetch integration for Subresource Integrity (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Simplified asserts 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
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 var URL = 'https://www.example.com/test.html'; 5 var URL = 'https://www.example.com/test.html';
6 6
7 test(function() { 7 test(function() {
8 var headers = new Headers; 8 var headers = new Headers;
9 headers.set('User-Agent', 'Mozilla/5.0'); 9 headers.set('User-Agent', 'Mozilla/5.0');
10 headers.set('Accept', 'text/html'); 10 headers.set('Accept', 'text/html');
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } 215 }
216 request2 = new Request(request1, init2); 216 request2 = new Request(request1, init2);
217 assert_equals(request2.credentials, 217 assert_equals(request2.credentials,
218 credentials2 ? credentials2 : request1.credentials, 218 credentials2 ? credentials2 : request1.credentials,
219 'Request.credentials should be overridden'); 219 'Request.credentials should be overridden');
220 }); 220 });
221 }); 221 });
222 }, 'Request credentials test'); 222 }, 'Request credentials test');
223 223
224 test(function() { 224 test(function() {
225 var request1 = {};
226 var request2 = {};
227 var init = {};
228 request1 = new Request(URL, init);
229 assert_equals(request1.integrity, '',
230 'Request.integrity should be empty on init');
231 init['integrity'] = 'sha256-deadbeef';
232 request1 = new Request(URL, init);
233 assert_equals(request1.integrity, 'sha256-deadbeef',
234 'Request.integrity match the integrity of init');
235 request2 = new Request(request1);
236 assert_equals(request2.integrity, 'sha256-deadbeef',
237 'Request.integrity should match');
238 init['mode'] = 'no-cors';
239 assert_throws(
240 {name: 'TypeError'},
241 function() {
242 var request = new Request(URL, init);
243 },
244 'new Request with a non-empty integrity and mode of \'no-cors\' should t hrow');
245 }, 'Request integrity test');
246
247 test(function() {
225 ['same-origin', 'cors', 'no-cors'].forEach(function(mode) { 248 ['same-origin', 'cors', 'no-cors'].forEach(function(mode) {
226 FORBIDDEN_METHODS.forEach(function(method) { 249 FORBIDDEN_METHODS.forEach(function(method) {
227 assert_throws( 250 assert_throws(
228 {name: 'TypeError'}, 251 {name: 'TypeError'},
229 function() { 252 function() {
230 var request = new Request(URL, {mode: mode, method: method}); 253 var request = new Request(URL, {mode: mode, method: method});
231 }, 254 },
232 'new Request with a forbidden method (' + method + ') should ' + 255 'new Request with a forbidden method (' + method + ') should ' +
233 'throw'); 256 'throw');
234 }); 257 });
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 634
612 // Tests for requests context. 635 // Tests for requests context.
613 test(function() { 636 test(function() {
614 var request = new Request('http://localhost/', {method: 'POST', body: ''}); 637 var request = new Request('http://localhost/', {method: 'POST', body: ''});
615 assert_equals(request.context, '', 638 assert_equals(request.context, '',
616 'Request.context should be empty string ' + 639 'Request.context should be empty string ' +
617 'for synthetic Request object'); 640 'for synthetic Request object');
618 }, 'RequestContext of a synthetic Request object'); 641 }, 'RequestContext of a synthetic Request object');
619 642
620 done(); 643 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698