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

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

Issue 2591723003: [Fetch API] Remove Headers.prototype.getAll() (Closed)
Patch Set: Update get. Created 3 years, 7 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 var request = new Request(URL); 106 var request = new Request(URL);
107 request.headers.append('X-Fetch-Foo', 'foo1'); 107 request.headers.append('X-Fetch-Foo', 'foo1');
108 request.headers.append('X-Fetch-Foo', 'foo2'); 108 request.headers.append('X-Fetch-Foo', 'foo2');
109 request.headers.append('X-Fetch-Bar', 'bar'); 109 request.headers.append('X-Fetch-Bar', 'bar');
110 var request2 = new Request(request); 110 var request2 = new Request(request);
111 assert_equals(request2.url, URL, 'Request.url should match'); 111 assert_equals(request2.url, URL, 'Request.url should match');
112 assert_equals(request2.method, 'GET', 'Request.method should match'); 112 assert_equals(request2.method, 'GET', 'Request.method should match');
113 assert_equals(request2.mode, 'cors', 'Request.mode should match'); 113 assert_equals(request2.mode, 'cors', 'Request.mode should match');
114 assert_equals(request2.credentials, 'omit', 114 assert_equals(request2.credentials, 'omit',
115 'Request.credentials should match'); 115 'Request.credentials should match');
116 assert_equals(request2.headers.getAll('X-Fetch-Foo')[0], 'foo1', 116 assert_equals(request2.headers.get('X-Fetch-Foo').split(', ')[0], 'foo1',
117 'Request.headers should match'); 117 'Request.headers should match');
118 assert_equals(request2.headers.getAll('X-Fetch-Foo')[1], 'foo2', 118 assert_equals(request2.headers.get('X-Fetch-Foo').split(', ')[1], 'foo2',
119 'Request.headers should match'); 119 'Request.headers should match');
120 assert_equals(request2.headers.getAll('X-Fetch-Bar')[0], 'bar', 120 assert_equals(request2.headers.get('X-Fetch-Bar').split(', ')[0], 'bar',
121 'Request.headers should match'); 121 'Request.headers should match');
122 var request3 = new Request(URL, 122 var request3 = new Request(URL,
123 {headers: [['X-Fetch-Foo', 'foo1'], 123 {headers: [['X-Fetch-Foo', 'foo1'],
124 ['X-Fetch-Foo', 'foo2'], 124 ['X-Fetch-Foo', 'foo2'],
125 ['X-Fetch-Bar', 'bar']]}); 125 ['X-Fetch-Bar', 'bar']]});
126 assert_equals(request3.headers.getAll('X-Fetch-Foo')[0], 'foo1', 126 assert_equals(request3.headers.get('X-Fetch-Foo').split(', ')[0], 'foo1',
127 'Request.headers should match'); 127 'Request.headers should match');
128 assert_equals(request3.headers.getAll('X-Fetch-Foo')[1], 'foo2', 128 assert_equals(request3.headers.get('X-Fetch-Foo').split(', ')[1], 'foo2',
129 'Request.headers should match'); 129 'Request.headers should match');
130 assert_equals(request3.headers.getAll('X-Fetch-Bar')[0], 'bar', 130 assert_equals(request3.headers.get('X-Fetch-Bar').split(', ')[0], 'bar',
131 'Request.headers should match'); 131 'Request.headers should match');
132 var request4 = new Request(URL, 132 var request4 = new Request(URL,
133 {headers: {'X-Fetch-Foo': 'foo1', 133 {headers: {'X-Fetch-Foo': 'foo1',
134 'X-Fetch-Foo': 'foo2', 134 'X-Fetch-Foo': 'foo2',
135 'X-Fetch-Bar': 'bar'}}); 135 'X-Fetch-Bar': 'bar'}});
136 assert_equals(request4.headers.getAll('X-Fetch-Foo')[0], 'foo2', 136 assert_equals(request4.headers.get('X-Fetch-Foo').split(', ')[0], 'foo2',
137 'Request.headers should match'); 137 'Request.headers should match');
138 assert_equals(request4.headers.getAll('X-Fetch-Bar')[0], 'bar', 138 assert_equals(request4.headers.get('X-Fetch-Bar').split(', ')[0], 'bar',
139 'Request.headers should match'); 139 'Request.headers should match');
140 // https://github.com/whatwg/fetch/issues/479 140 // https://github.com/whatwg/fetch/issues/479
141 var request5 = new Request(request, {headers: undefined}); 141 var request5 = new Request(request, {headers: undefined});
142 assert_equals(request5.headers.getAll('X-Fetch-Foo')[0], 'foo1', 142 assert_equals(request5.headers.get('X-Fetch-Foo').split(', ')[0], 'foo1',
143 'Request.headers should match'); 143 'Request.headers should match');
144 assert_equals(request5.headers.getAll('X-Fetch-Foo')[1], 'foo2', 144 assert_equals(request5.headers.get('X-Fetch-Foo').split(', ')[1], 'foo2',
145 'Request.headers should match'); 145 'Request.headers should match');
146 assert_equals(request5.headers.getAll('X-Fetch-Bar')[0], 'bar', 146 assert_equals(request5.headers.get('X-Fetch-Bar').split(', ')[0], 'bar',
147 'Request.headers should match'); 147 'Request.headers should match');
148 var request6 = new Request(request, {}); 148 var request6 = new Request(request, {});
149 assert_equals(request6.headers.getAll('X-Fetch-Foo')[0], 'foo1', 149 assert_equals(request6.headers.get('X-Fetch-Foo').split(', ')[0], 'foo1',
150 'Request.headers should match'); 150 'Request.headers should match');
151 assert_equals(request6.headers.getAll('X-Fetch-Foo')[1], 'foo2', 151 assert_equals(request6.headers.get('X-Fetch-Foo').split(', ')[1], 'foo2',
152 'Request.headers should match'); 152 'Request.headers should match');
153 assert_equals(request6.headers.getAll('X-Fetch-Bar')[0], 'bar', 153 assert_equals(request6.headers.get('X-Fetch-Bar').split(', ')[0], 'bar',
154 'Request.headers should match'); 154 'Request.headers should match');
155 assert_throws(new TypeError(), 155 assert_throws(new TypeError(),
156 () => { new Request(request, {headers: null}) }, 156 () => { new Request(request, {headers: null}) },
157 'null cannot be converted to a HeaderInit'); 157 'null cannot be converted to a HeaderInit');
158 }, 'Request header test'); 158 }, 'Request header test');
159 159
160 test(function() { 160 test(function() {
161 var request1 = {}; 161 var request1 = {};
162 var request2 = {}; 162 var request2 = {};
163 var METHODS = ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'OPTIONS', 163 var METHODS = ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'OPTIONS',
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 credentials: 'include', 852 credentials: 'include',
853 body: 'this is a body'}); 853 body: 'this is a body'});
854 854
855 return req.text() 855 return req.text()
856 .then(t => { 856 .then(t => {
857 assert_equals(t, 'this is a body'); 857 assert_equals(t, 'this is a body');
858 }); 858 });
859 }, 'Credentials and body can both be set.'); 859 }, 'Credentials and body can both be set.');
860 860
861 done(); 861 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698