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

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

Issue 1908263002: Don't expose URL.createObjectURL and revokeObjectURL to Service Workers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test cleanup Created 4 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
« 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. 61 // Only [Exposed=(Window,DedicatedWorker,SharedWorker)].
62 promise_test(function(t) { 62 if ('createObjectURL' in URL) {
63 var url = URL.createObjectURL(new Blob(['fox'], {type: 'text/fox'})); 63 // Tests for blob: scheme.
64 return fetch(url) 64 promise_test(function(t) {
65 .then(function(response) { 65 var url = URL.createObjectURL(new Blob(['fox'], {type: 'text/fox'}));
66 assert_equals(response.status, 200); 66 return fetch(url)
67 assert_equals(response.statusText, 'OK'); 67 .then(function(response) {
68 assert_equals(response.headers.get('Content-Type'), 'text/fox'); 68 assert_equals(response.status, 200);
69 assert_equals(response.headers.get('Content-Length'), '3'); 69 assert_equals(response.statusText, 'OK');
70 assert_equals(size(response.headers), 2); 70 assert_equals(response.headers.get('Content-Type'), 'text/fox');
71 return response.text(); 71 assert_equals(response.headers.get('Content-Length'), '3');
72 }) 72 assert_equals(size(response.headers), 2);
73 .then(function(text) { 73 return response.text();
74 assert_equals(text, 'fox'); 74 })
75 }); 75 .then(function(text) {
76 }, 'fetch blob: URL'); 76 assert_equals(text, 'fox');
77 });
78 }, 'fetch blob: URL');
77 79
78 promise_test(function(t) { 80 promise_test(function(t) {
79 var url = URL.createObjectURL(new Blob(['fox'], {type: 'text/fox'})); 81 var url = URL.createObjectURL(new Blob(['fox'], {type: 'text/fox'}));
80 return fetch(url + 'invalid') 82 return fetch(url + 'invalid')
81 .then( 83 .then(
82 t.unreached_func('fetching non-existent blob: URL must fail'), 84 t.unreached_func('fetching non-existent blob: URL must fail'),
83 function() {}); 85 function() {});
84 }, 'fetch non-existent blob: URL'); 86 }, 'fetch non-existent blob: URL');
87 }
85 88
86 // https://fetch.spec.whatwg.org/#concept-basic-fetch 89 // https://fetch.spec.whatwg.org/#concept-basic-fetch
87 // The last statement: 90 // The last statement:
88 // Otherwise 91 // Otherwise
89 // Return a network error. 92 // Return a network error.
90 promise_test(function(t) { 93 promise_test(function(t) {
91 return fetch('foobar://localhost/', {mode: 'no-cors'}) 94 return fetch('foobar://localhost/', {mode: 'no-cors'})
92 .then( 95 .then(
93 t.unreached_func('scheme not listed in basic fetch spec must fail'), 96 t.unreached_func('scheme not listed in basic fetch spec must fail'),
94 function() {}); 97 function() {});
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 assert_true(req.bodyUsed); 365 assert_true(req.bodyUsed);
363 }, 'Calling fetch() disturbs body if not null'); 366 }, 'Calling fetch() disturbs body if not null');
364 367
365 test(t => { 368 test(t => {
366 var req = new Request('/', {method: 'POST'}); 369 var req = new Request('/', {method: 'POST'});
367 fetch(req); 370 fetch(req);
368 assert_false(req.bodyUsed); 371 assert_false(req.bodyUsed);
369 }, 'Calling fetch() doesn\'t disturb body if null'); 372 }, 'Calling fetch() doesn\'t disturb body if null');
370 373
371 done(); 374 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