Index: LayoutTests/http/tests/fetch/script-tests/fetch.js |
diff --git a/LayoutTests/http/tests/fetch/script-tests/fetch.js b/LayoutTests/http/tests/fetch/script-tests/fetch.js |
index 60974662b01e9fcf195a5b93bcbff316afe1fe4c..cdec19146dc44063899c728552d1abf48b77fa79 100644 |
--- a/LayoutTests/http/tests/fetch/script-tests/fetch.js |
+++ b/LayoutTests/http/tests/fetch/script-tests/fetch.js |
@@ -20,6 +20,77 @@ promise_test(function(t) { |
function() {}); |
}, 'fetch non-HTTP(S) CORS'); |
+// Tests for non-HTTP(S) schemes. |
+promise_test(function(t) { |
+ var url = URL.createObjectURL(new Blob(['fox'], {type: 'text/fox'})); |
+ return fetch(url) |
+ .then(function(response) { |
+ assert_equals(response.status, 200); |
+ assert_equals(response.statusText, 'OK'); |
+ assert_equals(response.headers.get('Content-Type'), 'text/fox'); |
+ assert_equals(response.headers.get('Content-Length'), '3'); |
+ assert_equals(size(response.headers), 2); |
+ return response.text(); |
+ }) |
+ .then(function(text) { |
+ assert_equals(text, 'fox'); |
+ }); |
+ }, 'fetch blob: URL'); |
+ |
+promise_test(function(t) { |
+ var url = URL.createObjectURL(new Blob(['fox'], {type: 'text/fox'})); |
+ return fetch(url + 'invalid') |
+ .then( |
+ t.unreached_func('fetching non-existent blob: URL must fail'), |
+ function() {}); |
+ }, 'fetch non-existent blob: URL'); |
+ |
+promise_test(function(t) { |
+ return fetch('data:,Foobar') |
+ .then(function(response) { |
+ assert_equals(response.status, 200); |
+ assert_equals(response.statusText, 'OK'); |
+ assert_equals(response.headers.get('Content-Type'), |
+ 'text/plain;charset=US-ASCII'); |
+ assert_equals(size(response.headers), 1); |
+ return response.text(); |
+ }) |
+ .then(function(text) { |
+ assert_equals(text, 'Foobar'); |
+ }); |
+ }, 'fetch data: URL'); |
+ |
+promise_test(function(t) { |
+ return fetch('data:text/html;charset=utf-8;base64,5paH5a2X') |
+ .then(function(response) { |
+ assert_equals(response.status, 200); |
+ assert_equals(response.statusText, 'OK'); |
+ assert_equals(response.headers.get('Content-Type'), |
+ 'text/html;charset=utf-8'); |
+ assert_equals(size(response.headers), 1); |
+ return response.text(); |
+ }) |
+ .then(function(text) { |
+ assert_equals(text, '\u6587\u5b57'); |
+ }); |
+ }, 'fetch data: URL with non-ASCII characters'); |
+ |
+promise_test(function(t) { |
+ return fetch('data:text/html;base64,***') |
+ .then( |
+ t.unreached_func('fetching invalid data: URL must fail'), |
+ function() {}); |
+ }, 'fetch invalid data: URL'); |
+ |
+// +disable all cors route |
+// +allow first data: and all about: |
+// data: all OK |
+// Redirect -> data: same-origin: NG / no-cors: OK / cors: NG |
+// about: all OK |
+// Redirect -> about: all OK |
+// blob: same-origin: check / no-cors: check-OK / cors: check-NG |
+// Redirect -> blob: same-origin: NG / no-cors: OK / cors: NG |
+ |
// https://fetch.spec.whatwg.org/#concept-basic-fetch |
// The last statement: |
// Otherwise |