| 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 }, 'Duplicate supported payment method identifiers should not throw.'); | 254 }, 'Duplicate supported payment method identifiers should not throw.'); |
| 255 | 255 |
| 256 test(function() { | 256 test(function() { |
| 257 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), '
modifiers': [{'supportedMethods': ['foo', 'foo']}]}); | 257 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), '
modifiers': [{'supportedMethods': ['foo', 'foo']}]}); |
| 258 }, 'Duplicate supported payment method identifiers in modifiers should not throw
.'); | 258 }, 'Duplicate supported payment method identifiers in modifiers should not throw
.'); |
| 259 | 259 |
| 260 test(function() { | 260 test(function() { |
| 261 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), '
modifiers': [{'supportedMethods': ['foo']}, {'supportedMethods': ['foo']}]}); | 261 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), '
modifiers': [{'supportedMethods': ['foo']}, {'supportedMethods': ['foo']}]}); |
| 262 }, 'Duplicate supported payment method identifiers in modifiers should not throw
.'); | 262 }, 'Duplicate supported payment method identifiers in modifiers should not throw
.'); |
| 263 | 263 |
| 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()); |
| 266 }, 'Android Pay parameters for test environment with gateway token should not th
row.'); |
| 267 |
| 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()); |
| 270 }, 'Android Pay parameters for produciton environment with network token should
not throw.'); |
| 271 |
| 272 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()); |
| 274 }, 'Android Pay parameters for network token without environment key should not
throw.'); |
| 275 |
| 276 test(function() { |
| 277 new PaymentRequest([{'supportedMethods': ['https://android.com/pay'], 'data'
: {'merchantName': []}}], buildDetails()); |
| 278 }, 'Invalid Android Pay parameters should not throw.'); |
| 279 |
| 264 promise_test(function(t) { | 280 promise_test(function(t) { |
| 265 return promise_rejects(t, null, new PaymentRequest([{'supportedMethods': ['f
oo']}], buildDetails()).abort()); | 281 return promise_rejects(t, null, new PaymentRequest([{'supportedMethods': ['f
oo']}], buildDetails()).abort()); |
| 266 }, 'abort() without show() should reject with error'); | 282 }, 'abort() without show() should reject with error'); |
| 267 | 283 |
| 268 generate_tests(assert_throws, [ | 284 generate_tests(assert_throws, [ |
| 269 ['PaymentRequest constructor should throw for incorrect parameter types.', n
ull, function() { | 285 ['PaymentRequest constructor should throw for incorrect parameter types.', n
ull, function() { |
| 270 new PaymentRequest('', '', '') | 286 new PaymentRequest('', '', '') |
| 271 }], | 287 }], |
| 272 ['PaymentRequest constructor should throw for undefined required parameters.
', null, function() { | 288 ['PaymentRequest constructor should throw for undefined required parameters.
', null, function() { |
| 273 new PaymentRequest(undefined, undefined) | 289 new PaymentRequest(undefined, undefined) |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 }], | 401 }], |
| 386 ['Null amount should throw', null, function() { | 402 ['Null amount should throw', null, function() { |
| 387 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': null})) | 403 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': null})) |
| 388 }], | 404 }], |
| 389 ['Undefined amount should throw', null, function() { | 405 ['Undefined amount should throw', null, function() { |
| 390 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': undefined})) | 406 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': undefined})) |
| 391 }], | 407 }], |
| 392 ]); | 408 ]); |
| 393 } | 409 } |
| 394 </script> | 410 </script> |
| OLD | NEW |