| 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, substituteKeyValuePair) { | 7 function substitute(originalObject, substituteKeyValuePair) { |
| 8 for (var key in originalObject) { | 8 for (var key in originalObject) { |
| 9 if (originalObject.hasOwnProperty(key) && substituteKeyValuePair.hasOwnP
roperty(key)) { | 9 if (originalObject.hasOwnProperty(key) && substituteKeyValuePair.hasOwnP
roperty(key)) { |
| 10 originalObject[key] = substituteKeyValuePair[key]; | 10 originalObject[key] = substituteKeyValuePair[key]; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 }, 'PaymentRequest.abort() and PaymentRequest.show() should take no parameters.'
); | 83 }, 'PaymentRequest.abort() and PaymentRequest.show() should take no parameters.'
); |
| 84 | 84 |
| 85 test(function() { | 85 test(function() { |
| 86 var request = new PaymentRequest(['foo'], buildDetails(), {'requestShipping'
: true}, {'foo': {'gateway': 'bar'}}); | 86 var request = new PaymentRequest(['foo'], buildDetails(), {'requestShipping'
: true}, {'foo': {'gateway': 'bar'}}); |
| 87 request.show(); | 87 request.show(); |
| 88 request.abort(); | 88 request.abort(); |
| 89 }, 'Valid data causes no errors.'); | 89 }, 'Valid data causes no errors.'); |
| 90 | 90 |
| 91 test(function() { | 91 test(function() { |
| 92 var request = new PaymentRequest(['foo'], buildDetails('shippingOptions', {'
id': 'standard'})); | 92 var request = new PaymentRequest(['foo'], buildDetails('shippingOptions', {'
id': 'standard'})); |
| 93 assert_equals(null, request.shippingOption); |
| 94 }, 'Shipping option identifier should be null if shipping request is omitted.'); |
| 95 |
| 96 test(function() { |
| 97 var request = new PaymentRequest(['foo'], buildDetails('shippingOptions', {'
id': 'standard'}), {'requestShipping': false}); |
| 98 assert_equals(null, request.shippingOption); |
| 99 }, 'Shipping option identifier should be null if shipping is explicitly not requ
ested.'); |
| 100 |
| 101 test(function() { |
| 102 var request = new PaymentRequest(['foo'], buildDetails('shippingOptions', {'
id': 'standard'}), {'requestShipping': true}); |
| 93 assert_equals('standard', request.shippingOption); | 103 assert_equals('standard', request.shippingOption); |
| 94 }, 'Shipping option identifier should default to the single provided option.'); | 104 }, 'Shipping option identifier should default to the single provided option.'); |
| 95 | 105 |
| 96 test(function() { | 106 test(function() { |
| 97 var request = new PaymentRequest(['foo'], {"items": [buildItem()]}); | 107 var request = new PaymentRequest(['foo'], {"items": [buildItem()]}, {'reques
tShipping': true}); |
| 98 assert_equals(null, request.shippingOption); | 108 assert_equals(null, request.shippingOption); |
| 99 }, 'Shipping option identifier should be null when no shipping options are provi
ded.'); | 109 }, 'Shipping option identifier should be null when no shipping options are provi
ded.'); |
| 100 | 110 |
| 101 test(function() { | 111 test(function() { |
| 102 var request = new PaymentRequest(['foo'], {'items': [buildItem()], 'shipping
Options': [buildItem({'id': 'standard'}), buildItem({'id': 'express'})]}); | 112 var request = new PaymentRequest(['foo'], {'items': [buildItem()], 'shipping
Options': [buildItem({'id': 'standard'}), buildItem({'id': 'express'})]}, {'requ
estShipping': true}); |
| 103 assert_equals(null, request.shippingOption); | 113 assert_equals(null, request.shippingOption); |
| 104 }, 'Shipping option identifier should be null at first when multiple shipping op
tions are provided.'); | 114 }, 'Shipping option identifier should be null at first when multiple shipping op
tions are provided.'); |
| 105 | 115 |
| 106 | 116 |
| 107 generate_tests(assert_throws, [ | 117 generate_tests(assert_throws, [ |
| 108 ['PaymentRequest constructor should throw for incorrect parameter types.', n
ull, function() { | 118 ['PaymentRequest constructor should throw for incorrect parameter types.', n
ull, function() { |
| 109 new PaymentRequest('', '', '', '') | 119 new PaymentRequest('', '', '', '') |
| 110 }], | 120 }], |
| 111 ['PaymentRequest constructor should throw for undefined required parameters.
', null, function() { | 121 ['PaymentRequest constructor should throw for undefined required parameters.
', null, function() { |
| 112 new PaymentRequest(undefined, undefined) | 122 new PaymentRequest(undefined, undefined) |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 }], | 233 }], |
| 224 ['Null amount should throw', null, function() { | 234 ['Null amount should throw', null, function() { |
| 225 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': n
ull})) | 235 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': n
ull})) |
| 226 }], | 236 }], |
| 227 ['Undefined amount should throw', null, function() { | 237 ['Undefined amount should throw', null, function() { |
| 228 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': u
ndefined})) | 238 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': u
ndefined})) |
| 229 }], | 239 }], |
| 230 ]); | 240 ]); |
| 231 } | 241 } |
| 232 </script> | 242 </script> |
| OLD | NEW |