OLD | NEW |
1 importScripts('worker-testharness.js'); | 1 importScripts('worker-testharness.js'); |
2 importScripts('test-helpers.js'); | 2 importScripts('test-helpers.js'); |
3 | 3 |
4 async_test(function(t) { | 4 async_test(function(t) { |
5 fetch('http://') | 5 fetch('http://') |
6 .then( | 6 .then( |
7 unreached_rejection(t, 'fetch of invalid URL must fail'), | 7 unreached_rejection(t, 'fetch of invalid URL must fail'), |
8 function(e) { | 8 function(e) { |
9 assert_equals(e.message, 'Invalid URL'); | 9 assert_equals(e.message, 'Invalid URL'); |
10 t.done(); | 10 t.done(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 .then(evalJsonp) | 66 .then(evalJsonp) |
67 .then(function(result) { | 67 .then(function(result) { |
68 assert_equals(result.method, 'POST'); | 68 assert_equals(result.method, 'POST'); |
69 assert_equals(result.body, 'Test String'); | 69 assert_equals(result.body, 'Test String'); |
70 t.done(); | 70 t.done(); |
71 }) | 71 }) |
72 .catch(unreached_rejection(t)); | 72 .catch(unreached_rejection(t)); |
73 }, 'Fetch with string body test in ServiceWorkerGlobalScope'); | 73 }, 'Fetch with string body test in ServiceWorkerGlobalScope'); |
74 | 74 |
75 async_test(function(t) { | 75 async_test(function(t) { |
76 var text = "Test ArrayBuffer"; | 76 var text = 'Test ArrayBuffer'; |
77 var array = new Uint8Array(text.length); | 77 var array = new Uint8Array(text.length); |
78 for (var i = 0; i < text.length; ++i) | 78 for (var i = 0; i < text.length; ++i) |
79 array[i] = text.charCodeAt(i); | 79 array[i] = text.charCodeAt(i); |
80 var request = new Request('fetch-access-control.php', | 80 var request = new Request('fetch-access-control.php', |
81 {method: 'POST', body: array.buffer}); | 81 {method: 'POST', body: array.buffer}); |
82 fetch(request) | 82 fetch(request) |
83 .then(function(response) { return response.text(); }) | 83 .then(function(response) { return response.text(); }) |
84 .then(evalJsonp) | 84 .then(evalJsonp) |
85 .then(function(result) { | 85 .then(function(result) { |
86 assert_equals(result.method, 'POST'); | 86 assert_equals(result.method, 'POST'); |
87 assert_equals(result.body, 'Test ArrayBuffer'); | 87 assert_equals(result.body, 'Test ArrayBuffer'); |
88 t.done(); | 88 t.done(); |
89 }) | 89 }) |
90 .catch(unreached_rejection(t)); | 90 .catch(unreached_rejection(t)); |
91 }, 'Fetch with ArrayBuffer body test in ServiceWorkerGlobalScope'); | 91 }, 'Fetch with ArrayBuffer body test in ServiceWorkerGlobalScope'); |
92 | 92 |
93 async_test(function(t) { | 93 async_test(function(t) { |
94 var text = "Test ArrayBufferView"; | 94 var text = 'Test ArrayBufferView'; |
95 var array = new Uint8Array(text.length); | 95 var array = new Uint8Array(text.length); |
96 for (var i = 0; i < text.length; ++i) | 96 for (var i = 0; i < text.length; ++i) |
97 array[i] = text.charCodeAt(i); | 97 array[i] = text.charCodeAt(i); |
98 var request = new Request('fetch-access-control.php', | 98 var request = new Request('fetch-access-control.php', |
99 {method: 'POST', body: array}); | 99 {method: 'POST', body: array}); |
100 fetch(request) | 100 fetch(request) |
101 .then(function(response) { return response.text(); }) | 101 .then(function(response) { return response.text(); }) |
102 .then(evalJsonp) | 102 .then(evalJsonp) |
103 .then(function(result) { | 103 .then(function(result) { |
104 assert_equals(result.method, 'POST'); | 104 assert_equals(result.method, 'POST'); |
105 assert_equals(result.body, 'Test ArrayBufferView'); | 105 assert_equals(result.body, 'Test ArrayBufferView'); |
106 t.done(); | 106 t.done(); |
107 }) | 107 }) |
108 .catch(unreached_rejection(t)); | 108 .catch(unreached_rejection(t)); |
109 }, 'Fetch with ArrayBufferView body test in ServiceWorkerGlobalScope'); | 109 }, 'Fetch with ArrayBufferView body test in ServiceWorkerGlobalScope'); |
110 | 110 |
111 async_test(function(t) { | 111 async_test(function(t) { |
112 var formData = new FormData(); | 112 var formData = new FormData(); |
113 formData.append('StringKey1', '1234567890'); | 113 formData.append('StringKey1', '1234567890'); |
114 formData.append('StringKey2', 'ABCDEFGHIJ'); | 114 formData.append('StringKey2', 'ABCDEFGHIJ'); |
115 formData.append('BlobKey', new Blob(['blob content'])); | 115 formData.append('BlobKey', new Blob(['blob content'])); |
116 formData.append('FileKey', | 116 formData.append('FileKey', |
117 new File(['file content'], 'file.dat')); | 117 new File(['file content'], 'file.dat')); |
118 var request = new Request('fetch-access-control.php', | 118 var request = new Request('fetch-access-control.php', |
119 {method: 'POST', body: formData}); | 119 {method: 'POST', body: formData}); |
120 fetch(request) | 120 fetch(request) |
121 .then(function(response) { return response.text(); }) | 121 .then(function(response) { return response.text(); }) |
122 .then(evalJsonp) | 122 .then(evalJsonp) |
123 .then(function(result) { | 123 .then(function(result) { |
124 assert_equals(result.method, 'POST'); | 124 assert_equals(result.method, 'POST'); |
125 assert_equals(result.post['StringKey1'], '1234567890'); | 125 assert_equals(result.post['StringKey1'], '1234567890'); |
126 assert_equals(result.post['StringKey2'], 'ABCDEFGHIJ'); | 126 assert_equals(result.post['StringKey2'], 'ABCDEFGHIJ'); |
127 var files = []; | 127 var files = []; |
128 for (var i = 0; i < result.files.length; ++i) { | 128 for (var i = 0; i < result.files.length; ++i) { |
129 files[result.files[i].key] = result.files[i]; | 129 files[result.files[i].key] = result.files[i]; |
(...skipping 10 matching lines...) Expand all Loading... |
140 }, 'Fetch with FormData body test in ServiceWorkerGlobalScope'); | 140 }, 'Fetch with FormData body test in ServiceWorkerGlobalScope'); |
141 | 141 |
142 test(function(t) { | 142 test(function(t) { |
143 function runInfiniteFetchLoop() { | 143 function runInfiniteFetchLoop() { |
144 fetch('dummy.html') | 144 fetch('dummy.html') |
145 .then(function() { runInfiniteFetchLoop(); }); | 145 .then(function() { runInfiniteFetchLoop(); }); |
146 } | 146 } |
147 runInfiniteFetchLoop(); | 147 runInfiniteFetchLoop(); |
148 }, | 148 }, |
149 'Destroying the execution context while fetch is happening should not ' + | 149 'Destroying the execution context while fetch is happening should not ' + |
150 'cause a crash.'); | 150 'cause a crash.'); |
OLD | NEW |