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

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

Issue 2271113002: Accept any string for currency code in PaymentRequest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Allow null as per spec Created 4 years, 3 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 }], 268 }],
269 ['Empty string for payment method specific data parameter should throw', nul l, function() { 269 ['Empty string for payment method specific data parameter should throw', nul l, function() {
270 new PaymentRequest([{'supportedMethods': ['foo'], 'data': ''}], buildDet ails()) 270 new PaymentRequest([{'supportedMethods': ['foo'], 'data': ''}], buildDet ails())
271 }] 271 }]
272 ]); 272 ]);
273 273
274 var detailNames = ['total', 'displayItems.0', 'shippingOptions.0', 'modifiers.0. total', 'modifiers.0.additionalDisplayItems.0']; 274 var detailNames = ['total', 'displayItems.0', 'shippingOptions.0', 'modifiers.0. total', 'modifiers.0.additionalDisplayItems.0'];
275 for (var i in detailNames) { 275 for (var i in detailNames) {
276 generate_tests(assert_throws, [ 276 generate_tests(assert_throws, [
277 // Invalid currency code formats. 277 // Invalid currency code formats.
278 ['Invalid currency code US1 should throw', null, function() {
279 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'currency': 'US1'}))
280 }],
281 ['Invalid currency code US should throw', null, function() {
282 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'currency': 'US'}))
283 }],
284 ['Invalid currency code USDO should throw', null, function() {
285 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'currency': 'USDO'}))
286 }],
287 ['Invalid currency code usd should throw', null, function() {
288 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'currency': 'usd'}))
289 }],
290 ['Empty currency code should throw', null, function() {
291 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'currency': ''}))
292 }],
293 ['Null currency code should throw', null, function() {
294 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'currency': null}))
295 }],
296 ['Undefined currency code should throw', null, function() { 278 ['Undefined currency code should throw', null, function() {
297 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'currency': undefined})) 279 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'currency': undefined}))
298 }], 280 }],
299 281
300 // Invalid amount formats. 282 // Invalid amount formats.
301 ['Invalid amount "-" should throw', null, function() { 283 ['Invalid amount "-" should throw', null, function() {
302 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': '-'})) 284 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': '-'}))
303 }], 285 }],
304 ['Invalid amount "notdigits" should throw', null, function() { 286 ['Invalid amount "notdigits" should throw', null, function() {
305 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': 'notdigits'})) 287 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': 'notdigits'}))
(...skipping 30 matching lines...) Expand all
336 }], 318 }],
337 ['Null amount should throw', null, function() { 319 ['Null amount should throw', null, function() {
338 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': null})) 320 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': null}))
339 }], 321 }],
340 ['Undefined amount should throw', null, function() { 322 ['Undefined amount should throw', null, function() {
341 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': undefined})) 323 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': undefined}))
342 }], 324 }],
343 ]); 325 ]);
344 } 326 }
345 </script> 327 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698