| 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 | 263 |
| 264 test(function() { | 264 test(function() { |
| 265 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()); | 265 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()); |
| 266 }, 'Android Pay parameters for test environment with gateway token should not th
row.'); | 266 }, 'Android Pay parameters for test environment with gateway token should not th
row.'); |
| 267 | 267 |
| 268 test(function() { | 268 test(function() { |
| 269 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()); | 269 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()); |
| 270 }, 'Android Pay parameters for produciton environment with network token should
not throw.'); | 270 }, 'Android Pay parameters for produciton environment with network token should
not throw.'); |
| 271 | 271 |
| 272 test(function() { | 272 test(function() { |
| 273 new PaymentRequest([{'supportedMethods': ['basic-card'], 'data': {'supportedTy
pes': ['debit'], 'supportedNetworks': ['visa']}}], buildDetails()); |
| 274 }, 'Basic card parameters should not throw.'); |
| 275 |
| 276 test(function() { |
| 277 new PaymentRequest([{'supportedMethods': ['basic-card'], 'data': {'supportedTy
pes': [], 'supportedNetworks': []}}], buildDetails()); |
| 278 }, 'Empty basic card parameters should not throw.'); |
| 279 |
| 280 test(function() { |
| 281 new PaymentRequest([{'supportedMethods': ['not-basic-card'], 'data': {'support
edTypes': 0, 'supportedNetworks': 'foo'}}], buildDetails()); |
| 282 }, 'Invalid basic card parameters should not throw when method name is not "basi
c-card".'); |
| 283 |
| 284 test(function() { |
| 285 new PaymentRequest([{'supportedMethods': ['basic-card'], 'data': {'supportedTy
pes': 0, 'supportedNetworks': 'foo'}}], buildDetails()); |
| 286 }, 'Invalid basic card parameters should not throw even when method name is "bas
ic-card".'); |
| 287 |
| 288 test(function() { |
| 273 new PaymentRequest([{'supportedMethods': ['https://android.com/pay'], 'data'
: {'merchantName': 'Merchant Inc', 'merchantId': '123', 'allowedCardNetworks': [
'AMEX', 'DISCOVER', 'MASTERCARD', 'VISA'], 'paymentMethodTokenizationParameters'
: {'tokenizationType': 'NETWORK_TOKEN', 'parameters': {'key': 'value'}}}}], buil
dDetails()); | 289 new PaymentRequest([{'supportedMethods': ['https://android.com/pay'], 'data'
: {'merchantName': 'Merchant Inc', 'merchantId': '123', 'allowedCardNetworks': [
'AMEX', 'DISCOVER', 'MASTERCARD', 'VISA'], 'paymentMethodTokenizationParameters'
: {'tokenizationType': 'NETWORK_TOKEN', 'parameters': {'key': 'value'}}}}], buil
dDetails()); |
| 274 }, 'Android Pay parameters for network token without environment key should not
throw.'); | 290 }, 'Android Pay parameters for network token without environment key should not
throw.'); |
| 275 | 291 |
| 276 test(function() { | 292 test(function() { |
| 277 new PaymentRequest([{'supportedMethods': ['https://android.com/pay'], 'data'
: {'merchantName': []}}], buildDetails()); | 293 new PaymentRequest([{'supportedMethods': ['https://bobpay.com'], 'data': {'a
llowedCardNetworks': 0}}], buildDetails()); |
| 278 }, 'Invalid Android Pay parameters should not throw.'); | 294 }, 'Invalid Android Pay parameters should not throw when method name is not "htt
ps://android.com/pay".'); |
| 295 |
| 296 test(function() { |
| 297 new PaymentRequest([{'supportedMethods': ['https://android.com/pay'], 'data'
: {'allowedCardNetworks': 0}}], buildDetails()); |
| 298 }, 'Invalid Android Pay parameters should not throw even when method name is "ht
tps://android.com/pay".'); |
| 279 | 299 |
| 280 promise_test(function(t) { | 300 promise_test(function(t) { |
| 281 return promise_rejects(t, null, new PaymentRequest([{'supportedMethods': ['f
oo']}], buildDetails()).abort()); | 301 return promise_rejects(t, null, new PaymentRequest([{'supportedMethods': ['f
oo']}], buildDetails()).abort()); |
| 282 }, 'abort() without show() should reject with error'); | 302 }, 'abort() without show() should reject with error'); |
| 283 | 303 |
| 284 generate_tests(assert_throws, [ | 304 generate_tests(assert_throws, [ |
| 285 ['PaymentRequest constructor should throw for incorrect parameter types.', n
ull, function() { | 305 ['PaymentRequest constructor should throw for incorrect parameter types.', n
ull, function() { |
| 286 new PaymentRequest('', '', '') | 306 new PaymentRequest('', '', '') |
| 287 }], | 307 }], |
| 288 ['PaymentRequest constructor should throw for undefined required parameters.
', null, function() { | 308 ['PaymentRequest constructor should throw for undefined required parameters.
', null, function() { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 }], | 430 }], |
| 411 ['Null amount should throw', null, function() { | 431 ['Null amount should throw', null, function() { |
| 412 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': null}), {requestShipping: true}) | 432 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': null}), {requestShipping: true}) |
| 413 }], | 433 }], |
| 414 ['Undefined amount should throw', null, function() { | 434 ['Undefined amount should throw', null, function() { |
| 415 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': undefined}), {requestShipping: true}) | 435 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': undefined}), {requestShipping: true}) |
| 416 }], | 436 }], |
| 417 ]); | 437 ]); |
| 418 } | 438 } |
| 419 </script> | 439 </script> |
| OLD | NEW |