| 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 test(function() { | 174 test(function() { |
| 175 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails('displayIte
ms', {'value': '-0.01'})); | 175 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails('displayIte
ms', {'value': '-0.01'})); |
| 176 }, 'Negative line item value should not throw.'); | 176 }, 'Negative line item value should not throw.'); |
| 177 | 177 |
| 178 test(function() { | 178 test(function() { |
| 179 assert_throws(new TypeError(), function() { | 179 assert_throws(new TypeError(), function() { |
| 180 new PaymentRequest([{'supportedMethods': ['foo']}], {'displayItems': [bu
ildItem()]}); | 180 new PaymentRequest([{'supportedMethods': ['foo']}], {'displayItems': [bu
ildItem()]}); |
| 181 }); | 181 }); |
| 182 }, 'Absence of total should throw TypeError.'); | 182 }, 'Absence of total should throw TypeError.'); |
| 183 | 183 |
| 184 promise_test(function(t) { |
| 185 return promise_rejects(t, null, new PaymentRequest([{'supportedMethods': ['f
oo']}], buildDetails()).abort()); |
| 186 }, 'abort() without show() should reject with error'); |
| 187 |
| 184 generate_tests(assert_throws, [ | 188 generate_tests(assert_throws, [ |
| 185 ['PaymentRequest constructor should throw for incorrect parameter types.', n
ull, function() { | 189 ['PaymentRequest constructor should throw for incorrect parameter types.', n
ull, function() { |
| 186 new PaymentRequest('', '', '') | 190 new PaymentRequest('', '', '') |
| 187 }], | 191 }], |
| 188 ['PaymentRequest constructor should throw for undefined required parameters.
', null, function() { | 192 ['PaymentRequest constructor should throw for undefined required parameters.
', null, function() { |
| 189 new PaymentRequest(undefined, undefined) | 193 new PaymentRequest(undefined, undefined) |
| 190 }], | 194 }], |
| 191 ['PaymentRequest constructor should throw for null required parameter.', nul
l, function() { | 195 ['PaymentRequest constructor should throw for null required parameter.', nul
l, function() { |
| 192 new PaymentRequest(null, null) | 196 new PaymentRequest(null, null) |
| 193 }], | 197 }], |
| 194 ['Empty list of supported payment method identifiers should throw TypeError.
', new TypeError(), function() { | 198 ['Empty list of supported payment method identifiers should throw TypeError.
', new TypeError(), function() { |
| 195 new PaymentRequest([], buildDetails()) | 199 new PaymentRequest([], buildDetails()) |
| 196 }], | 200 }], |
| 197 ['Empty details should throw', null, function() { | 201 ['Empty details should throw', null, function() { |
| 198 new PaymentRequest([{'supportedMethods': ['foo']}], {}) | 202 new PaymentRequest([{'supportedMethods': ['foo']}], {}) |
| 199 }], | 203 }], |
| 200 ['Null items should throw', new TypeError(), function() { | 204 ['Null items should throw', new TypeError(), function() { |
| 201 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(
), 'displayItems': null}); | 205 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(
), 'displayItems': null}); |
| 202 }], | 206 }], |
| 203 ['Null shipping options should throw', new TypeError(), function() { | 207 ['Null shipping options should throw', new TypeError(), function() { |
| 204 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(
), 'displayItems': [buildItem()], 'shippingOptions': null}); | 208 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(
), 'displayItems': [buildItem()], 'shippingOptions': null}); |
| 205 }], | 209 }], |
| 206 ['Aborting before showing should throw.', null, function() { | |
| 207 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails()).abor
t() | |
| 208 }], | |
| 209 | 210 |
| 210 // Payment method specific data should be a JSON-serializable object. | 211 // Payment method specific data should be a JSON-serializable object. |
| 211 ['Array value for payment method specific data parameter should throw', null
, function() { | 212 ['Array value for payment method specific data parameter should throw', null
, function() { |
| 212 new PaymentRequest([{'supportedMethods': ['foo'], 'data': []}], buildDet
ails(), {}) | 213 new PaymentRequest([{'supportedMethods': ['foo'], 'data': []}], buildDet
ails(), {}) |
| 213 }], | 214 }], |
| 214 ['String value for payment method specific data parameter should throw', nul
l, function() { | 215 ['String value for payment method specific data parameter should throw', nul
l, function() { |
| 215 new PaymentRequest([{'supportedMethods': ['foo'], 'data': 'foo'}], build
Details(), {}) | 216 new PaymentRequest([{'supportedMethods': ['foo'], 'data': 'foo'}], build
Details(), {}) |
| 216 }], | 217 }], |
| 217 ['Numeric value for payment method specific data parameter should throw', nu
ll, function() { | 218 ['Numeric value for payment method specific data parameter should throw', nu
ll, function() { |
| 218 new PaymentRequest([{'supportedMethods': ['foo'], 'data': 42}], buildDet
ails(), {}) | 219 new PaymentRequest([{'supportedMethods': ['foo'], 'data': 42}], buildDet
ails(), {}) |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 }], | 296 }], |
| 296 ['Null amount should throw', null, function() { | 297 ['Null amount should throw', null, function() { |
| 297 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': null})) | 298 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': null})) |
| 298 }], | 299 }], |
| 299 ['Undefined amount should throw', null, function() { | 300 ['Undefined amount should throw', null, function() { |
| 300 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': undefined})) | 301 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': undefined})) |
| 301 }], | 302 }], |
| 302 ]); | 303 ]); |
| 303 } | 304 } |
| 304 </script> | 305 </script> |
| OLD | NEW |