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

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

Issue 1371393003: [Fetch] Support blob: scheme (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 1 month 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/thorough/scheme-blob.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/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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 }); 51 });
52 }, 'fetch data: URL with non-ASCII characters'); 52 }, 'fetch data: URL with non-ASCII characters');
53 53
54 promise_test(function(t) { 54 promise_test(function(t) {
55 return fetch('data:text/html;base64,***') 55 return fetch('data:text/html;base64,***')
56 .then( 56 .then(
57 t.unreached_func('fetching invalid data: URL must fail'), 57 t.unreached_func('fetching invalid data: URL must fail'),
58 function() {}); 58 function() {});
59 }, 'fetch invalid data: URL'); 59 }, 'fetch invalid data: URL');
60 60
61 // Tests for blob: scheme.
62 promise_test(function(t) {
63 var url = URL.createObjectURL(new Blob(['fox'], {type: 'text/fox'}));
64 return fetch(url)
65 .then(function(response) {
66 assert_equals(response.status, 200);
67 assert_equals(response.statusText, 'OK');
68 assert_equals(response.headers.get('Content-Type'), 'text/fox');
69 assert_equals(response.headers.get('Content-Length'), '3');
70 assert_equals(size(response.headers), 2);
71 return response.text();
72 })
73 .then(function(text) {
74 assert_equals(text, 'fox');
75 });
76 }, 'fetch blob: URL');
77
78 promise_test(function(t) {
79 var url = URL.createObjectURL(new Blob(['fox'], {type: 'text/fox'}));
80 return fetch(url + 'invalid')
81 .then(
82 t.unreached_func('fetching non-existent blob: URL must fail'),
83 function() {});
84 }, 'fetch non-existent blob: URL');
85
61 // https://fetch.spec.whatwg.org/#concept-basic-fetch 86 // https://fetch.spec.whatwg.org/#concept-basic-fetch
62 // The last statement: 87 // The last statement:
63 // Otherwise 88 // Otherwise
64 // Return a network error. 89 // Return a network error.
65 promise_test(function(t) { 90 promise_test(function(t) {
66 return fetch('foobar://localhost/', {mode: 'no-cors'}) 91 return fetch('foobar://localhost/', {mode: 'no-cors'})
67 .then( 92 .then(
68 t.unreached_func('scheme not listed in basic fetch spec must fail'), 93 t.unreached_func('scheme not listed in basic fetch spec must fail'),
69 function() {}); 94 function() {});
70 }, 'fetch of scheme not listed in basic fetch spec'); 95 }, 'fetch of scheme not listed in basic fetch spec');
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 function runInfiniteFetchLoop() { 350 function runInfiniteFetchLoop() {
326 fetch('dummy.html') 351 fetch('dummy.html')
327 .then(function() { runInfiniteFetchLoop(); }); 352 .then(function() { runInfiniteFetchLoop(); });
328 } 353 }
329 runInfiniteFetchLoop(); 354 runInfiniteFetchLoop();
330 }, 355 },
331 'Destroying the execution context while fetch is happening should not ' + 356 'Destroying the execution context while fetch is happening should not ' +
332 'cause a crash.'); 357 'cause a crash.');
333 358
334 done(); 359 done();
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/thorough/scheme-blob.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698