OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <meta charset="utf-8"> | 2 <meta charset="utf-8"> |
3 <title>Tests for PaymentRequest interface</title> | 3 <title>Tests for PaymentRequest interface</title> |
4 <script src="../resources/testharness.js"></script> | 4 <script src="../resources/testharness.js"></script> |
5 <script src="../resources/testharnessreport.js"></script> | 5 <script src="../resources/testharnessreport.js"></script> |
6 <script> | 6 <script> |
7 function substitute(originalObject, substituteKeyValuePairs) { | 7 function substitute(originalObject, substituteKeyValuePairs) { |
8 for (var key in originalObject) { | 8 for (var key in originalObject) { |
9 if (originalObject.hasOwnProperty(key) && substituteKeyValuePairs.hasOwn
Property(key)) { | 9 if (originalObject.hasOwnProperty(key) && substituteKeyValuePairs.hasOwn
Property(key)) { |
10 originalObject[key] = substituteKeyValuePairs[key]; | 10 originalObject[key] = substituteKeyValuePairs[key]; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 test(function() { | 174 test(function() { |
175 new PaymentRequest(['foo'], buildDetails('displayItems', {'value': '-0.01'})
); | 175 new PaymentRequest(['foo'], buildDetails('displayItems', {'value': '-0.01'})
); |
176 }, 'Negative line item value should not throw.'); | 176 }, 'Negative line item value should not throw.'); |
177 | 177 |
178 test(function() { | 178 test(function() { |
179 assert_throws(new TypeError(), function() { | 179 assert_throws(new TypeError(), function() { |
180 new PaymentRequest(['foo'], {'displayItems': [buildItem()]}); | 180 new PaymentRequest(['foo'], {'displayItems': [buildItem()]}); |
181 }); | 181 }); |
182 }, 'Absence of total should throw TypeError.'); | 182 }, 'Absence of total should throw TypeError.'); |
183 | 183 |
| 184 promise_test(function(t) { |
| 185 return promise_rejects(t, null, new PaymentRequest(['foo'], buildDetails()).
abort()); |
| 186 }, 'abort() without show() should reject with error'); |
| 187 |
184 generate_tests(assert_throws, [ | 188 generate_tests(assert_throws, [ |
185 ['PaymentRequest constructor should throw for incorrect parameter types.', n
ull, function() { | 189 ['PaymentRequest constructor should throw for incorrect parameter types.', n
ull, function() { |
186 new PaymentRequest('', '', '', '') | 190 new PaymentRequest('', '', '', '') |
187 }], | 191 }], |
188 ['PaymentRequest constructor should throw for undefined required parameters.
', null, function() { | 192 ['PaymentRequest constructor should throw for undefined required parameters.
', null, function() { |
189 new PaymentRequest(undefined, undefined) | 193 new PaymentRequest(undefined, undefined) |
190 }], | 194 }], |
191 ['PaymentRequest constructor should throw for null required parameter.', nul
l, function() { | 195 ['PaymentRequest constructor should throw for null required parameter.', nul
l, function() { |
192 new PaymentRequest(null, null) | 196 new PaymentRequest(null, null) |
193 }], | 197 }], |
194 ['Empty list of supported payment method identifiers should throw TypeError.
', new TypeError(), function() { | 198 ['Empty list of supported payment method identifiers should throw TypeError.
', new TypeError(), function() { |
195 new PaymentRequest([], buildDetails()) | 199 new PaymentRequest([], buildDetails()) |
196 }], | 200 }], |
197 ['Keys in payment method specific data object should match accepted method i
dentifiers.', null, function() { | 201 ['Keys in payment method specific data object should match accepted method i
dentifiers.', null, function() { |
198 new PaymentRequest(['foo'], buildDetails(), {}, {'bar': {'gateway': 'baz
'}}) | 202 new PaymentRequest(['foo'], buildDetails(), {}, {'bar': {'gateway': 'baz
'}}) |
199 }], | 203 }], |
200 ['Empty details should throw', null, function() { | 204 ['Empty details should throw', null, function() { |
201 new PaymentRequest(['foo'], {}) | 205 new PaymentRequest(['foo'], {}) |
202 }], | 206 }], |
203 ['Null items should throw', new TypeError(), function() { | 207 ['Null items should throw', new TypeError(), function() { |
204 new PaymentRequest(['foo'], {'total': buildItem(), 'displayItems': null}
); | 208 new PaymentRequest(['foo'], {'total': buildItem(), 'displayItems': null}
); |
205 }], | 209 }], |
206 ['Null shipping options should throw', new TypeError(), function() { | 210 ['Null shipping options should throw', new TypeError(), function() { |
207 new PaymentRequest(['foo'], {'total': buildItem(), 'displayItems': [buil
dItem()], 'shippingOptions': null}); | 211 new PaymentRequest(['foo'], {'total': buildItem(), 'displayItems': [buil
dItem()], 'shippingOptions': null}); |
208 }], | 212 }], |
209 ['Aborting before showing should throw.', null, function() { | |
210 new PaymentRequest(['foo'], buildDetails()).abort() | |
211 }], | |
212 | 213 |
213 // Payment method specific data should be a JSON-serializable object. | 214 // Payment method specific data should be a JSON-serializable object. |
214 ['Array value for payment method specific data parameter should throw', null
, function() { | 215 ['Array value for payment method specific data parameter should throw', null
, function() { |
215 new PaymentRequest(['foo'], buildDetails(), {}, []) | 216 new PaymentRequest(['foo'], buildDetails(), {}, []) |
216 }], | 217 }], |
217 ['String value for payment method specific data parameter should throw', nul
l, function() { | 218 ['String value for payment method specific data parameter should throw', nul
l, function() { |
218 new PaymentRequest(['foo'], buildDetails(), {}, 'foo') | 219 new PaymentRequest(['foo'], buildDetails(), {}, 'foo') |
219 }], | 220 }], |
220 ['Numeric value for payment method specific data parameter should throw', nu
ll, function() { | 221 ['Numeric value for payment method specific data parameter should throw', nu
ll, function() { |
221 new PaymentRequest(['foo'], buildDetails(), {}, 42) | 222 new PaymentRequest(['foo'], buildDetails(), {}, 42) |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 }], | 304 }], |
304 ['Null amount should throw', null, function() { | 305 ['Null amount should throw', null, function() { |
305 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': n
ull})) | 306 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': n
ull})) |
306 }], | 307 }], |
307 ['Undefined amount should throw', null, function() { | 308 ['Undefined amount should throw', null, function() { |
308 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': u
ndefined})) | 309 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': u
ndefined})) |
309 }], | 310 }], |
310 ]); | 311 ]); |
311 } | 312 } |
312 </script> | 313 </script> |
OLD | NEW |