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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/fetch/resources/fetch-test-helpers.js

Issue 1358203003: Normalize and update the header value checks to RFC 7230 for Fetch Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/headers.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 if (self.importScripts) { 1 if (self.importScripts) {
2 importScripts('/resources/testharness.js'); 2 importScripts('/resources/testharness.js');
3 importScripts('/resources/testharness-helpers.js'); 3 importScripts('/resources/testharness-helpers.js');
4 importScripts('/serviceworker/resources/test-helpers.js'); 4 importScripts('/serviceworker/resources/test-helpers.js');
5 importScripts('/fetch/resources/fetch-test-options.js'); 5 importScripts('/fetch/resources/fetch-test-options.js');
6 } 6 }
7 7
8 function getContentType(headers) { 8 function getContentType(headers) {
9 var content_type = ''; 9 var content_type = '';
10 for (var header of headers) { 10 for (var header of headers) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // - "Content-Type" (CONTENT_TYPE): This can be 72 // - "Content-Type" (CONTENT_TYPE): This can be
73 // a simple header if the header value is in SIMPLE_HEADER_CONTENT_TYPE_VALUES 73 // a simple header if the header value is in SIMPLE_HEADER_CONTENT_TYPE_VALUES
74 // or not if the header value is in NON_SIMPLE_HEADER_CONTENT_TYPE_VALUES. 74 // or not if the header value is in NON_SIMPLE_HEADER_CONTENT_TYPE_VALUES.
75 // - others (NON_SIMPLE_HEADER_NAMES) 75 // - others (NON_SIMPLE_HEADER_NAMES)
76 76
77 // A header name must match token in RFC 2616. 77 // A header name must match token in RFC 2616.
78 // Fetch API Spec: https://fetch.spec.whatwg.org/#concept-header-name 78 // Fetch API Spec: https://fetch.spec.whatwg.org/#concept-header-name
79 var INVALID_HEADER_NAMES = INVALID_TOKENS; 79 var INVALID_HEADER_NAMES = INVALID_TOKENS;
80 var INVALID_HEADER_VALUES = [ 80 var INVALID_HEADER_VALUES = [
81 'test \r data', 'test \n data', 'test \0 data', 81 'test \r data', 'test \n data', 'test \0 data',
82 'test\r\n data', 82 'test\r\n data', 'test\0', 't\bt', 't\vt',
83 'test\r', 'test\n', 'test\r\n', 'test\0', 83 '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x08',
84 '\0'.repeat(100000), '\r\n'.repeat(50000), 'x'.repeat(100000) + '\0']; 84 '\x0b', '\x0c', '\x0e', '\x0f',
85 '\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17',
86 '\x18', '\x19', '\x1a', '\x1b', '\x1c', '\x1d', '\x1e', '\x1f', '\x7f',
87 '\0'.repeat(100000), '\u3042', 'x'.repeat(100000) + '\0'];
85 88
86 var FORBIDDEN_HEADER_NAMES = 89 var FORBIDDEN_HEADER_NAMES =
87 ['Accept-Charset', 'Accept-Encoding', 'Access-Control-Request-Headers', 90 ['Accept-Charset', 'Accept-Encoding', 'Access-Control-Request-Headers',
88 'Access-Control-Request-Method', 'Connection', 'Content-Length', 91 'Access-Control-Request-Method', 'Connection', 'Content-Length',
89 'Cookie', 'Cookie2', 'Date', 'DNT', 'Expect', 'Host', 'Keep-Alive', 92 'Cookie', 'Cookie2', 'Date', 'DNT', 'Expect', 'Host', 'Keep-Alive',
90 'Origin', 'Referer', 'TE', 'Trailer', 'Transfer-Encoding', 'Upgrade', 93 'Origin', 'Referer', 'TE', 'Trailer', 'Transfer-Encoding', 'Upgrade',
91 'User-Agent', 'Via', 'Proxy-', 'Sec-', 'Proxy-FooBar', 'Sec-FooBar']; 94 'User-Agent', 'Via', 'Proxy-', 'Sec-', 'Proxy-FooBar', 'Sec-FooBar'];
92 var FORBIDDEN_RESPONSE_HEADER_NAMES = 95 var FORBIDDEN_RESPONSE_HEADER_NAMES =
93 ['Set-Cookie', 'Set-Cookie2', 96 ['Set-Cookie', 'Set-Cookie2',
94 'set-cookie', 'set-cookie2', 97 'set-cookie', 'set-cookie2',
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 var request = new Request(url, {referrer: referrer, mode: 'cors'}); 229 var request = new Request(url, {referrer: referrer, mode: 'cors'});
227 return fetch(new Request(url, request)).then(res => { 230 return fetch(new Request(url, request)).then(res => {
228 return res.json(); 231 return res.json();
229 }).then(json => { 232 }).then(json => {
230 assert_equals(json.referrer, expected, 'referrer'); 233 assert_equals(json.referrer, expected, 'referrer');
231 }); 234 });
232 }).bind(undefined, url, referrer, expected), 235 }).bind(undefined, url, referrer, expected),
233 'referrer test: url = ' + url + ', referrer = ' + referrer); 236 'referrer test: url = ' + url + ', referrer = ' + referrer);
234 } 237 }
235 } 238 }
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/headers.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698