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

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

Issue 2501593003: Implement the new basic card specification. (Closed)
Patch Set: Rebase Created 3 years, 11 months 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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>
OLDNEW
« no previous file with comments | « components/payments/payment_request.mojom ('k') | third_party/WebKit/Source/modules/modules_idl_files.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698