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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 test(function() { | 219 test(function() { |
220 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), '
modifiers': [{'supportedMethods': ['foo'], 'total': buildItem({'value': '0.0'})}
]}); | 220 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), '
modifiers': [{'supportedMethods': ['foo'], 'total': buildItem({'value': '0.0'})}
]}); |
221 }, 'Non-negative total value in PaymentDetailsModifier should not throw.'); | 221 }, 'Non-negative total value in PaymentDetailsModifier should not throw.'); |
222 | 222 |
223 test(function() { | 223 test(function() { |
224 new PaymentRequest([{'supportedMethods': ['foo', 'foo']}], buildDetails(), {
}); | 224 new PaymentRequest([{'supportedMethods': ['foo', 'foo']}], buildDetails(), {
}); |
225 }, 'Duplicate supported payment method identifiers should not throw.'); | 225 }, 'Duplicate supported payment method identifiers should not throw.'); |
226 | 226 |
227 test(function() { | 227 test(function() { |
228 new PaymentRequest([{'supportedMethods': ['foo']}, {'supportedMethods': ['fo
o']}], buildDetails(), {}); | 228 new PaymentRequest([{'supportedMethods': ['foo']}, {'supportedMethods': ['fo
o']}], buildDetails(), {}); |
229 }, 'Duplicate supported payment method identifiers should not throw.'); | 229 }, 'Duplicate supported payment method identifiers in separate methodData object
s should not throw.'); |
230 | 230 |
231 test(function() { | 231 test(function() { |
232 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), '
modifiers': [{'supportedMethods': ['foo', 'foo']}]}); | 232 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), '
modifiers': [{'supportedMethods': ['foo', 'foo']}]}); |
233 }, 'Duplicate supported payment method identifiers in modifiers should not throw
.'); | 233 }, 'Duplicate supported payment method identifiers in modifiers should not throw
.'); |
234 | 234 |
235 test(function() { | 235 test(function() { |
236 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), '
modifiers': [{'supportedMethods': ['foo']}, {'supportedMethods': ['foo']}]}); | 236 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), '
modifiers': [{'supportedMethods': ['foo']}, {'supportedMethods': ['foo']}]}); |
237 }, 'Duplicate supported payment method identifiers in modifiers should not throw
.'); | 237 }, 'Duplicate supported payment method identifiers in separate methoData objects
of modifiers should not throw.'); |
238 | 238 |
239 test(function() { | 239 test(function() { |
240 new PaymentRequest([{'supportedMethods': ['https://android.com/pay'], 'data'
: {'environment': 'TEST', 'merchantName': 'Merchant Inc', 'merchantId': '123', '
allowedCardNetworks': ['AMEX', 'DISCOVER', 'MASTERCARD', 'VISA'], 'paymentMethod
TokenizationParameters': {'tokenizationType': 'GATEWAY_TOKEN', 'parameters': {'k
ey': 'value'}}}}], buildDetails()); | 240 new PaymentRequest([{'supportedMethods': ['https://android.com/pay'], 'data'
: {'environment': 'TEST', 'merchantName': 'Merchant Inc', 'merchantId': '123', '
allowedCardNetworks': ['AMEX', 'DISCOVER', 'MASTERCARD', 'VISA'], 'paymentMethod
TokenizationParameters': {'tokenizationType': 'GATEWAY_TOKEN', 'parameters': {'k
ey': 'value'}}}}], buildDetails()); |
241 }, 'Android Pay parameters for test environment with gateway token should not th
row.'); | 241 }, 'Android Pay parameters for test environment with gateway token should not th
row.'); |
242 | 242 |
243 test(function() { | 243 test(function() { |
244 new PaymentRequest([{'supportedMethods': ['https://android.com/pay'], 'data'
: {'environment': 'PRODUCTION', 'merchantName': 'Merchant Inc', 'merchantId': '1
23', 'allowedCardNetworks': ['AMEX', 'DISCOVER', 'MASTERCARD', 'VISA'], 'payment
MethodTokenizationParameters': {'tokenizationType': 'NETWORK_TOKEN', 'parameters
': {'key': 'value'}}}}], buildDetails()); | 244 new PaymentRequest([{'supportedMethods': ['https://android.com/pay'], 'data'
: {'environment': 'PRODUCTION', 'merchantName': 'Merchant Inc', 'merchantId': '1
23', 'allowedCardNetworks': ['AMEX', 'DISCOVER', 'MASTERCARD', 'VISA'], 'payment
MethodTokenizationParameters': {'tokenizationType': 'NETWORK_TOKEN', 'parameters
': {'key': 'value'}}}}], buildDetails()); |
245 }, 'Android Pay parameters for produciton environment with network token should
not throw.'); | 245 }, 'Android Pay parameters for produciton environment with network token should
not throw.'); |
246 | 246 |
247 test(function() { | 247 test(function() { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 }] | 364 }] |
365 ]); | 365 ]); |
366 | 366 |
367 var detailNames = ['total', 'displayItems.0', 'shippingOptions.0', 'modifiers.0.
total', 'modifiers.0.additionalDisplayItems.0']; | 367 var detailNames = ['total', 'displayItems.0', 'shippingOptions.0', 'modifiers.0.
total', 'modifiers.0.additionalDisplayItems.0']; |
368 for (var i in detailNames) { | 368 for (var i in detailNames) { |
369 generate_tests(assert_throws, [ | 369 generate_tests(assert_throws, [ |
370 // Invalid currency code formats. | 370 // Invalid currency code formats. |
371 ['Undefined currency code should throw', null, function() { | 371 ['Undefined currency code in ' + detailNames[i] + ' should throw', null,
function() { |
372 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'currency': undefined}), {requestShipping: true}) | 372 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'currency': undefined}), {requestShipping: true}) |
373 }], | 373 }], |
374 | 374 |
375 // Invalid amount formats. | 375 // Invalid amount formats. |
376 ['Invalid amount "-" should throw', null, function() { | 376 ['Invalid amount "-" in ' + detailNames[i] + ' should throw', null, func
tion() { |
377 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '-'}), {requestShipping: true}) | 377 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '-'}), {requestShipping: true}) |
378 }], | 378 }], |
379 ['Invalid amount "notdigits" should throw', null, function() { | 379 ['Invalid amount "notdigits" in ' + detailNames[i] + ' should throw', nu
ll, function() { |
380 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': 'notdigits'}), {requestShipping: true}) | 380 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': 'notdigits'}), {requestShipping: true}) |
381 }], | 381 }], |
382 ['Invalid amount "ALSONOTDIGITS" should throw', null, function() { | 382 ['Invalid amount "ALSONOTDIGITS" in ' + detailNames[i] + ' should throw'
, null, function() { |
383 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': 'ALSONOTDIGITS'}), {requestShipping: true}) | 383 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': 'ALSONOTDIGITS'}), {requestShipping: true}) |
384 }], | 384 }], |
385 ['Invalid amount "10." should throw', null, function() { | 385 ['Invalid amount "10." in ' + detailNames[i] + ' should throw', null, fu
nction() { |
386 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '10.'}), {requestShipping: true}) | 386 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '10.'}), {requestShipping: true}) |
387 }], | 387 }], |
388 ['Invalid amount ".99" should throw', null, function() { | 388 ['Invalid amount ".99" in ' + detailNames[i] + ' should throw', null, fu
nction() { |
389 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '.99'}), {requestShipping: true}) | 389 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '.99'}), {requestShipping: true}) |
390 }], | 390 }], |
391 ['Invalid amount "-10." should throw', null, function() { | 391 ['Invalid amount "-10." in ' + detailNames[i] + ' should throw', null, f
unction() { |
392 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '-10.'}), {requestShipping: true}) | 392 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '-10.'}), {requestShipping: true}) |
393 }], | 393 }], |
394 ['Invalid amount "-.99" should throw', null, function() { | 394 ['Invalid amount "-.99" in ' + detailNames[i] + ' should throw', null, f
unction() { |
395 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '-.99'}), {requestShipping: true}) | 395 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '-.99'}), {requestShipping: true}) |
396 }], | 396 }], |
397 ['Invalid amount "10-" should throw', null, function() { | 397 ['Invalid amount "10-" in ' + detailNames[i] + ' should throw', null, fu
nction() { |
398 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '10-'}), {requestShipping: true}) | 398 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '10-'}), {requestShipping: true}) |
399 }], | 399 }], |
400 ['Invalid amount "1-0" should throw', null, function() { | 400 ['Invalid amount "1-0" in ' + detailNames[i] + ' should throw', null, fu
nction() { |
401 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '1-0'}), {requestShipping: true}) | 401 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '1-0'}), {requestShipping: true}) |
402 }], | 402 }], |
403 ['Invalid amount "1.0.0" should throw', null, function() { | 403 ['Invalid amount "1.0.0" in ' + detailNames[i] + ' should throw', null,
function() { |
404 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '1.0.0'}), {requestShipping: true}) | 404 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '1.0.0'}), {requestShipping: true}) |
405 }], | 405 }], |
406 ['Invalid amount "1/3" should throw', null, function() { | 406 ['Invalid amount "1/3" in ' + detailNames[i] + ' should throw', null, fu
nction() { |
407 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '1/3'}), {requestShipping: true}) | 407 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '1/3'}), {requestShipping: true}) |
408 }], | 408 }], |
409 ['Empty amount should throw', null, function() { | 409 ['Empty amount in ' + detailNames[i] + ' should throw', null, function()
{ |
410 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': ''}), {requestShipping: true}) | 410 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': ''}), {requestShipping: true}) |
411 }], | 411 }], |
412 ['Null amount should throw', null, function() { | 412 ['Null amount in ' + detailNames[i] + ' should throw', null, function()
{ |
413 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': null}), {requestShipping: true}) | 413 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': null}), {requestShipping: true}) |
414 }], | 414 }], |
415 ['Undefined amount should throw', null, function() { | 415 ['Undefined amount in ' + detailNames[i] + ' should throw', null, functi
on() { |
416 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': undefined}), {requestShipping: true}) | 416 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': undefined}), {requestShipping: true}) |
417 }], | 417 }], |
418 ]); | 418 ]); |
419 } | 419 } |
420 </script> | 420 </script> |
OLD | NEW |