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

Side by Side Diff: third_party/WebKit/LayoutTests/payments/payment-request-interface.html

Issue 2451873003: Allow duplicate payment method identifiers. (Closed)
Patch Set: Make modifier total optional Created 4 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
OLDNEW
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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 }, 'Negative line item value should not throw.'); 238 }, 'Negative line item value should not throw.');
239 239
240 test(function() { 240 test(function() {
241 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), ' modifiers': undefined}); 241 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), ' modifiers': undefined});
242 }, 'Undefined modifiers should not throw.'); 242 }, 'Undefined modifiers should not throw.');
243 243
244 test(function() { 244 test(function() {
245 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), ' modifiers': [{'supportedMethods': ['foo'], 'total': buildItem({'value': '0.0'})} ]}); 245 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), ' modifiers': [{'supportedMethods': ['foo'], 'total': buildItem({'value': '0.0'})} ]});
246 }, 'Non-negative total value in PaymentDetailsModifier should not throw.'); 246 }, 'Non-negative total value in PaymentDetailsModifier should not throw.');
247 247
248 test(function() {
249 new PaymentRequest([{'supportedMethods': ['foo', 'foo']}], buildDetails(), { });
250 }, 'Duplicate supported payment method identifiers should not throw.');
251
252 test(function() {
253 new PaymentRequest([{'supportedMethods': ['foo']}, {'supportedMethods': ['fo o']}], buildDetails(), {});
254 }, 'Duplicate supported payment method identifiers should not throw.');
255
256 test(function() {
257 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), ' modifiers': [{'supportedMethods': ['foo', 'foo']}]});
258 }, 'Duplicate supported payment method identifiers in modifiers should not throw .');
259
260 test(function() {
261 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), ' modifiers': [{'supportedMethods': ['foo']}, {'supportedMethods': ['foo']}]});
262 }, 'Duplicate supported payment method identifiers in modifiers should not throw .');
263
248 promise_test(function(t) { 264 promise_test(function(t) {
249 return promise_rejects(t, null, new PaymentRequest([{'supportedMethods': ['f oo']}], buildDetails()).abort()); 265 return promise_rejects(t, null, new PaymentRequest([{'supportedMethods': ['f oo']}], buildDetails()).abort());
250 }, 'abort() without show() should reject with error'); 266 }, 'abort() without show() should reject with error');
251 267
252 generate_tests(assert_throws, [ 268 generate_tests(assert_throws, [
253 ['PaymentRequest constructor should throw for incorrect parameter types.', n ull, function() { 269 ['PaymentRequest constructor should throw for incorrect parameter types.', n ull, function() {
254 new PaymentRequest('', '', '') 270 new PaymentRequest('', '', '')
255 }], 271 }],
256 ['PaymentRequest constructor should throw for undefined required parameters. ', null, function() { 272 ['PaymentRequest constructor should throw for undefined required parameters. ', null, function() {
257 new PaymentRequest(undefined, undefined) 273 new PaymentRequest(undefined, undefined)
258 }], 274 }],
259 ['PaymentRequest constructor should throw for null required parameter.', nul l, function() { 275 ['PaymentRequest constructor should throw for null required parameter.', nul l, function() {
260 new PaymentRequest(null, null) 276 new PaymentRequest(null, null)
261 }], 277 }],
262 ['Empty list of supported payment method identifiers should throw TypeError. ', new TypeError(), function() { 278 ['Empty list of supported payment method identifiers should throw TypeError. ', new TypeError(), function() {
263 new PaymentRequest([], buildDetails()) 279 new PaymentRequest([], buildDetails())
264 }], 280 }],
265 ['Empty supported payment method identifiers should throw TypeError.', null, function() { 281 ['Empty supported payment method identifiers should throw TypeError.', null, function() {
266 new PaymentRequest([{'supportedMethods': []}], buildDetails()) 282 new PaymentRequest([{'supportedMethods': []}], buildDetails())
267 }], 283 }],
268 ['Duplicate supported payment method identifiers should throw TypeError.', n ull, function() {
269 new PaymentRequest([{'supportedMethods': ['foo', 'foo']}], buildDetails( ), {})
270 }],
271 ['Duplicate supported payment method identifiers should throw TypeError.', n ull, function() {
272 new PaymentRequest([{'supportedMethods': ['foo']}, {'supportedMethods': ['foo']}], buildDetails(), {})
273 }],
274 ['Absence of total should throw TypeError.', null, function() { 284 ['Absence of total should throw TypeError.', null, function() {
275 new PaymentRequest([{'supportedMethods': ['foo']}], {'displayItems': [bu ildItem()]}) 285 new PaymentRequest([{'supportedMethods': ['foo']}], {'displayItems': [bu ildItem()]})
276 }], 286 }],
277 ['Negative total value should throw a TypeError.', null, function() { 287 ['Negative total value should throw a TypeError.', null, function() {
278 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails('total' , {'value': '-0.01'})) 288 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails('total' , {'value': '-0.01'}))
279 }], 289 }],
280 ['Duplicate supported payment method identifiers in modifiers should throw T ypeError.', null, function() {
281 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': ['foo', 'foo']}]})
282 }],
283 ['Duplicate supported payment method identifiers in modifiers should throw T ypeError.', null, function() {
284 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': ['foo']}, {'supportedMethods': ['foo']}]})
285 }],
286 ['Negative total value in PaymentDetailsModifier should throw a TypeError.', null, function() { 290 ['Negative total value in PaymentDetailsModifier should throw a TypeError.', null, function() {
287 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': ['foo'], 'total': buildItem({'value': '-0. 01'})}]}) 291 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': ['foo'], 'total': buildItem({'value': '-0. 01'})}]})
288 }], 292 }],
289 ['Null supportedMethods in modifiers should throw TypeError.', null, functio n() { 293 ['Null supportedMethods in modifiers should throw TypeError.', null, functio n() {
290 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': null}]}) 294 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': null}]})
291 }], 295 }],
292 ['Undefined supportedMethods in modifiers should throw TypeError.', null, fu nction() { 296 ['Undefined supportedMethods in modifiers should throw TypeError.', null, fu nction() {
293 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': undefined}]}) 297 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': undefined}]})
294 }], 298 }],
295 ['Empty supportedMethods in modifiers should throw TypeError.', null, functi on() { 299 ['Empty supportedMethods in modifiers should throw TypeError.', null, functi on() {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 }], 385 }],
382 ['Null amount should throw', null, function() { 386 ['Null amount should throw', null, function() {
383 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': null})) 387 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': null}))
384 }], 388 }],
385 ['Undefined amount should throw', null, function() { 389 ['Undefined amount should throw', null, function() {
386 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': undefined})) 390 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': undefined}))
387 }], 391 }],
388 ]); 392 ]);
389 } 393 }
390 </script> 394 </script>
OLDNEW
« no previous file with comments | « components/payments/payment_request.mojom ('k') | third_party/WebKit/Source/modules/payments/PaymentRequest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698