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

Side by Side Diff: test/codegen_expected/lib/html/xhr_test.js

Issue 2211293002: Reify type params on map literals (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Suppress empty arg with dynamic params 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 dart_library.library('lib/html/xhr_test', null, /* Imports */[ 1 dart_library.library('lib/html/xhr_test', null, /* Imports */[
2 'dart_sdk', 2 'dart_sdk',
3 'unittest' 3 'unittest'
4 ], function load__xhr_test(exports, dart_sdk, unittest) { 4 ], function load__xhr_test(exports, dart_sdk, unittest) {
5 'use strict'; 5 'use strict';
6 const core = dart_sdk.core; 6 const core = dart_sdk.core;
7 const convert = dart_sdk.convert; 7 const convert = dart_sdk.convert;
8 const html = dart_sdk.html; 8 const html = dart_sdk.html;
9 const async = dart_sdk.async; 9 const async = dart_sdk.async;
10 const typed_data = dart_sdk.typed_data; 10 const typed_data = dart_sdk.typed_data;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 }, VoidTodynamic())); 138 }, VoidTodynamic()));
139 unittest$.test('XHR.getString No file', dart.fn(() => { 139 unittest$.test('XHR.getString No file', dart.fn(() => {
140 html.HttpRequest.getString('NonExistingFile').then(dart.dynamic)(dart.fn (_ => { 140 html.HttpRequest.getString('NonExistingFile').then(dart.dynamic)(dart.fn (_ => {
141 src__matcher__expect.fail('Succeeded for non-existing file.'); 141 src__matcher__expect.fail('Succeeded for non-existing file.');
142 }, StringTodynamic$()), {onError: unittest$.expectAsync(dart.fn(error => { 142 }, StringTodynamic$()), {onError: unittest$.expectAsync(dart.fn(error => {
143 validate404(dart.dload(error, 'target')); 143 validate404(dart.dload(error, 'target'));
144 }, dynamicTodynamic()))}); 144 }, dynamicTodynamic()))});
145 }, VoidTodynamic())); 145 }, VoidTodynamic()));
146 unittest$.test('XHR.request responseType arraybuffer', dart.fn(() => { 146 unittest$.test('XHR.request responseType arraybuffer', dart.fn(() => {
147 if (dart.test(html.Platform.supportsTypedData)) { 147 if (dart.test(html.Platform.supportsTypedData)) {
148 html.HttpRequest.request(url, {responseType: 'arraybuffer', requestHea ders: dart.map({'Content-Type': 'text/xml'})}).then(dart.dynamic)(HttpRequestTod ynamic()._check(unittest$.expectAsync(dart.fn(xhr => { 148 html.HttpRequest.request(url, {responseType: 'arraybuffer', requestHea ders: dart.map({'Content-Type': 'text/xml'}, core.String, core.String)}).then(da rt.dynamic)(HttpRequestTodynamic()._check(unittest$.expectAsync(dart.fn(xhr => {
149 src__matcher__expect.expect(dart.dload(xhr, 'status'), src__matcher_ _core_matchers.equals(200)); 149 src__matcher__expect.expect(dart.dload(xhr, 'status'), src__matcher_ _core_matchers.equals(200));
150 let byteBuffer = dart.dload(xhr, 'response'); 150 let byteBuffer = dart.dload(xhr, 'response');
151 src__matcher__expect.expect(byteBuffer, new (isInstanceOfOfByteBuffe r())()); 151 src__matcher__expect.expect(byteBuffer, new (isInstanceOfOfByteBuffe r())());
152 src__matcher__expect.expect(byteBuffer, src__matcher__core_matchers. isNotNull); 152 src__matcher__expect.expect(byteBuffer, src__matcher__core_matchers. isNotNull);
153 }, dynamicTodynamic())))); 153 }, dynamicTodynamic()))));
154 } 154 }
155 }, VoidTodynamic())); 155 }, VoidTodynamic()));
156 unittest$.test('overrideMimeType', dart.fn(() => { 156 unittest$.test('overrideMimeType', dart.fn(() => {
157 let expectation = dart.test(html.HttpRequest[dartx.supportsOverrideMimeT ype]) ? src__matcher__core_matchers.returnsNormally : src__matcher__throws_match er.throws; 157 let expectation = dart.test(html.HttpRequest[dartx.supportsOverrideMimeT ype]) ? src__matcher__core_matchers.returnsNormally : src__matcher__throws_match er.throws;
158 src__matcher__expect.expect(dart.fn(() => { 158 src__matcher__expect.expect(dart.fn(() => {
(...skipping 12 matching lines...) Expand all
171 for (let i = 0; i < dart.notNull(data[dartx.length]); ++i) { 171 for (let i = 0; i < dart.notNull(data[dartx.length]); ++i) {
172 data[dartx.set](i, i & 255); 172 data[dartx.set](i, i & 255);
173 } 173 }
174 xhr[dartx.send](typed_data.Uint8List.view(data[dartx.buffer])); 174 xhr[dartx.send](typed_data.Uint8List.view(data[dartx.buffer]));
175 return xhr[dartx.onLoad].first.then(dart.dynamic)(dart.fn(_ => { 175 return xhr[dartx.onLoad].first.then(dart.dynamic)(dart.fn(_ => {
176 src__matcher__expect.expect(progressCalled, src__matcher__core_match ers.isTrue, {reason: 'onProgress should be fired'}); 176 src__matcher__expect.expect(progressCalled, src__matcher__core_match ers.isTrue, {reason: 'onProgress should be fired'});
177 }, ProgressEventTodynamic())); 177 }, ProgressEventTodynamic()));
178 }, VoidToFuture())); 178 }, VoidToFuture()));
179 } 179 }
180 unittest$.test('xhr postFormData', dart.fn(() => { 180 unittest$.test('xhr postFormData', dart.fn(() => {
181 let data = dart.map({name: 'John', time: '2 pm'}); 181 let data = dart.map({name: 'John', time: '2 pm'}, core.String, core.Stri ng);
182 let parts = []; 182 let parts = [];
183 for (let key of data[dartx.keys]) { 183 for (let key of data[dartx.keys]) {
184 parts[dartx.add](dart.str`${core.Uri.encodeQueryComponent(key)}=` + da rt.str`${core.Uri.encodeQueryComponent(data[dartx.get](key))}`); 184 parts[dartx.add](dart.str`${core.Uri.encodeQueryComponent(key)}=` + da rt.str`${core.Uri.encodeQueryComponent(data[dartx.get](key))}`);
185 } 185 }
186 let encodedData = parts[dartx.join]('&'); 186 let encodedData = parts[dartx.join]('&');
187 return html.HttpRequest.postFormData(dart.str`${html.window[dartx.locati on][dartx.protocol]}//${html.window[dartx.location][dartx.host]}/echo`, data).th en(dart.dynamic)(dart.fn(xhr => { 187 return html.HttpRequest.postFormData(dart.str`${html.window[dartx.locati on][dartx.protocol]}//${html.window[dartx.location][dartx.host]}/echo`, data).th en(dart.dynamic)(dart.fn(xhr => {
188 src__matcher__expect.expect(xhr[dartx.responseText], encodedData); 188 src__matcher__expect.expect(xhr[dartx.responseText], encodedData);
189 }, HttpRequestTodynamic$())); 189 }, HttpRequestTodynamic$()));
190 }, VoidToFuture())); 190 }, VoidToFuture()));
191 }, VoidTovoid$())); 191 }, VoidTovoid$()));
192 unittest$.group('xhr_requestBlob', dart.fn(() => { 192 unittest$.group('xhr_requestBlob', dart.fn(() => {
193 unittest$.test('XHR.request responseType blob', dart.fn(() => { 193 unittest$.test('XHR.request responseType blob', dart.fn(() => {
194 if (dart.test(html.Platform.supportsTypedData)) { 194 if (dart.test(html.Platform.supportsTypedData)) {
195 return html.HttpRequest.request(url, {responseType: 'blob'}).then(dart .dynamic)(dart.fn(xhr => { 195 return html.HttpRequest.request(url, {responseType: 'blob'}).then(dart .dynamic)(dart.fn(xhr => {
196 src__matcher__expect.expect(xhr[dartx.status], src__matcher__core_ma tchers.equals(200)); 196 src__matcher__expect.expect(xhr[dartx.status], src__matcher__core_ma tchers.equals(200));
197 let blob = xhr[dartx.response]; 197 let blob = xhr[dartx.response];
198 src__matcher__expect.expect(html.Blob.is(blob), src__matcher__core_m atchers.isTrue); 198 src__matcher__expect.expect(html.Blob.is(blob), src__matcher__core_m atchers.isTrue);
199 src__matcher__expect.expect(blob, src__matcher__core_matchers.isNotN ull); 199 src__matcher__expect.expect(blob, src__matcher__core_matchers.isNotN ull);
200 }, HttpRequestTodynamic$())); 200 }, HttpRequestTodynamic$()));
201 } 201 }
202 }, VoidToFuture())); 202 }, VoidToFuture()));
203 }, VoidTovoid$())); 203 }, VoidTovoid$()));
204 unittest$.group('json', dart.fn(() => { 204 unittest$.group('json', dart.fn(() => {
205 unittest$.test('xhr responseType json', dart.fn(() => { 205 unittest$.test('xhr responseType json', dart.fn(() => {
206 let url = dart.str`${html.window[dartx.location][dartx.protocol]}//${htm l.window[dartx.location][dartx.host]}/echo`; 206 let url = dart.str`${html.window[dartx.location][dartx.protocol]}//${htm l.window[dartx.location][dartx.host]}/echo`;
207 let data = dart.map({key: 'value', a: 'b', one: 2}); 207 let data = dart.map({key: 'value', a: 'b', one: 2}, core.String, core.Ob ject);
208 html.HttpRequest.request(url, {method: 'POST', sendData: convert.JSON.en code(data), responseType: 'json'}).then(dart.dynamic)(HttpRequestTodynamic()._ch eck(unittest$.expectAsync(dart.fn(xhr => { 208 html.HttpRequest.request(url, {method: 'POST', sendData: convert.JSON.en code(data), responseType: 'json'}).then(dart.dynamic)(HttpRequestTodynamic()._ch eck(unittest$.expectAsync(dart.fn(xhr => {
209 src__matcher__expect.expect(dart.dload(xhr, 'status'), src__matcher__c ore_matchers.equals(200)); 209 src__matcher__expect.expect(dart.dload(xhr, 'status'), src__matcher__c ore_matchers.equals(200));
210 let json = dart.dload(xhr, 'response'); 210 let json = dart.dload(xhr, 'response');
211 src__matcher__expect.expect(json, src__matcher__core_matchers.equals(d ata)); 211 src__matcher__expect.expect(json, src__matcher__core_matchers.equals(d ata));
212 }, dynamicTodynamic())))); 212 }, dynamicTodynamic()))));
213 }, VoidTodynamic())); 213 }, VoidTodynamic()));
214 }, VoidTovoid$())); 214 }, VoidTovoid$()));
215 unittest$.group('headers', dart.fn(() => { 215 unittest$.group('headers', dart.fn(() => {
216 unittest$.test('xhr responseHeaders', dart.fn(() => html.HttpRequest.reque st(url).then(dart.dynamic)(dart.fn(xhr => { 216 unittest$.test('xhr responseHeaders', dart.fn(() => html.HttpRequest.reque st(url).then(dart.dynamic)(dart.fn(xhr => {
217 let contentTypeHeader = xhr[dartx.responseHeaders][dartx.get]('content-t ype'); 217 let contentTypeHeader = xhr[dartx.responseHeaders][dartx.get]('content-t ype');
218 src__matcher__expect.expect(contentTypeHeader, src__matcher__core_matche rs.isNotNull); 218 src__matcher__expect.expect(contentTypeHeader, src__matcher__core_matche rs.isNotNull);
219 src__matcher__expect.expect(contentTypeHeader[dartx.contains]('text/plai n'), src__matcher__core_matchers.isTrue); 219 src__matcher__expect.expect(contentTypeHeader[dartx.contains]('text/plai n'), src__matcher__core_matchers.isTrue);
220 src__matcher__expect.expect(contentTypeHeader[dartx.contains]('charset=u tf-8'), src__matcher__core_matchers.isTrue); 220 src__matcher__expect.expect(contentTypeHeader[dartx.contains]('charset=u tf-8'), src__matcher__core_matchers.isTrue);
221 }, HttpRequestTodynamic$())), VoidToFuture())); 221 }, HttpRequestTodynamic$())), VoidToFuture()));
222 }, VoidTovoid$())); 222 }, VoidTovoid$()));
223 }; 223 };
224 dart.fn(xhr_test.main, VoidTodynamic()); 224 dart.fn(xhr_test.main, VoidTodynamic());
225 // Exports: 225 // Exports:
226 exports.xhr_test = xhr_test; 226 exports.xhr_test = xhr_test;
227 }); 227 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698