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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 ['Infinite JSON value for one of the payment method specific data pieces sho
uld throw', null, function() { | 354 ['Infinite JSON value for one of the payment method specific data pieces sho
uld throw', null, function() { |
355 var infiniteData = {'foo': {}}; | 355 var infiniteData = {'foo': {}}; |
356 infiniteData.foo = infiniteData; | 356 infiniteData.foo = infiniteData; |
357 new PaymentRequest([{'supportedMethods': ['foo'], 'data': infiniteData}]
, buildDetails()) | 357 new PaymentRequest([{'supportedMethods': ['foo'], 'data': infiniteData}]
, buildDetails()) |
358 }], | 358 }], |
359 ['Null for payment method specific data parameter should throw', null, funct
ion() { | 359 ['Null for payment method specific data parameter should throw', null, funct
ion() { |
360 new PaymentRequest([{'supportedMethods': ['foo'], 'data': null}], buildD
etails()) | 360 new PaymentRequest([{'supportedMethods': ['foo'], 'data': null}], buildD
etails()) |
361 }], | 361 }], |
362 ['Empty string for payment method specific data parameter should throw', nul
l, function() { | 362 ['Empty string for payment method specific data parameter should throw', nul
l, function() { |
363 new PaymentRequest([{'supportedMethods': ['foo'], 'data': ''}], buildDet
ails()) | 363 new PaymentRequest([{'supportedMethods': ['foo'], 'data': ''}], buildDet
ails()) |
| 364 }], |
| 365 ['If details contains a null value for error, then throw a TypeError', new T
ypeError(), function() { |
| 366 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(
), 'error': null}) |
| 367 }], |
| 368 ['If details contains an empty string value for error, then throw a TypeErro
r', new TypeError(), function() { |
| 369 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(
), 'error': ''}) |
| 370 }], |
| 371 ['If details contains a non-empty string value for error, then throw a TypeE
rror', new TypeError(), function() { |
| 372 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(
), 'error': 'Message'}) |
364 }] | 373 }] |
365 ]); | 374 ]); |
366 | 375 |
367 var detailNames = ['total', 'displayItems.0', 'shippingOptions.0', 'modifiers.0.
total', 'modifiers.0.additionalDisplayItems.0']; | 376 var detailNames = ['total', 'displayItems.0', 'shippingOptions.0', 'modifiers.0.
total', 'modifiers.0.additionalDisplayItems.0']; |
368 for (var i in detailNames) { | 377 for (var i in detailNames) { |
369 generate_tests(assert_throws, [ | 378 generate_tests(assert_throws, [ |
370 // Invalid currency code formats. | 379 // Invalid currency code formats. |
371 ['Undefined currency code should throw', null, function() { | 380 ['Undefined currency code should throw', null, function() { |
372 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'currency': undefined}), {requestShipping: true}) | 381 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'currency': undefined}), {requestShipping: true}) |
373 }], | 382 }], |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 }], | 420 }], |
412 ['Null amount should throw', null, function() { | 421 ['Null amount should throw', null, function() { |
413 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': null}), {requestShipping: true}) | 422 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': null}), {requestShipping: true}) |
414 }], | 423 }], |
415 ['Undefined amount should throw', null, function() { | 424 ['Undefined amount should throw', null, function() { |
416 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': undefined}), {requestShipping: true}) | 425 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': undefined}), {requestShipping: true}) |
417 }], | 426 }], |
418 ]); | 427 ]); |
419 } | 428 } |
420 </script> | 429 </script> |
OLD | NEW |