Chromium Code Reviews| 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 }, 'Absence of supportedMethods in modifiers should throw TypeError.'); | 199 }, 'Absence of supportedMethods in modifiers should throw TypeError.'); |
| 200 | 200 |
| 201 test(function() { | 201 test(function() { |
| 202 assert_throws(new TypeError(), function() { | 202 assert_throws(new TypeError(), function() { |
| 203 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': []}]}); | 203 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': []}]}); |
| 204 }); | 204 }); |
| 205 }, 'Empty supportedMethods in modifiers should throw TypeError.'); | 205 }, 'Empty supportedMethods in modifiers should throw TypeError.'); |
| 206 | 206 |
| 207 test(function() { | 207 test(function() { |
| 208 assert_throws(new TypeError(), function() { | 208 assert_throws(new TypeError(), function() { |
| 209 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': ['foo', 'foo']}]}); | |
| 210 }); | |
| 211 }, 'Duplicate supported payment method identifiers in modifiers should throw Typ eError.'); | |
| 212 | |
| 213 test(function() { | |
| 214 assert_throws(new TypeError(), function() { | |
| 215 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': ['foo']}, {'supportedMethods': ['foo']}]}) ; | |
| 216 }); | |
| 217 }, 'Duplicate supported payment method identifiers in modifiers should throw Typ eError.'); | |
|
please use gerrit instead
2016/07/06 07:31:56
Can you put your assert_throws() tests together in
pals
2016/07/07 05:14:13
Done.
| |
| 218 | |
| 219 test(function() { | |
| 220 assert_throws(new TypeError(), function() { | |
| 209 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': undefined}]}); | 221 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': undefined}]}); |
| 210 }); | 222 }); |
| 211 }, 'Undefined supportedMethods in modifiers should throw TypeError.'); | 223 }, 'Undefined supportedMethods in modifiers should throw TypeError.'); |
| 212 | 224 |
| 213 test(function() { | 225 test(function() { |
| 214 assert_throws(new TypeError(), function() { | 226 assert_throws(new TypeError(), function() { |
| 215 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': null}]}); | 227 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'modifiers': [{'supportedMethods': null}]}); |
| 216 }); | 228 }); |
| 217 }, 'Null supportedMethods in modifiers should throw TypeError.'); | 229 }, 'Null supportedMethods in modifiers should throw TypeError.'); |
| 218 | 230 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 236 }], | 248 }], |
| 237 ['PaymentRequest constructor should throw for undefined required parameters. ', null, function() { | 249 ['PaymentRequest constructor should throw for undefined required parameters. ', null, function() { |
| 238 new PaymentRequest(undefined, undefined) | 250 new PaymentRequest(undefined, undefined) |
| 239 }], | 251 }], |
| 240 ['PaymentRequest constructor should throw for null required parameter.', nul l, function() { | 252 ['PaymentRequest constructor should throw for null required parameter.', nul l, function() { |
| 241 new PaymentRequest(null, null) | 253 new PaymentRequest(null, null) |
| 242 }], | 254 }], |
| 243 ['Empty list of supported payment method identifiers should throw TypeError. ', new TypeError(), function() { | 255 ['Empty list of supported payment method identifiers should throw TypeError. ', new TypeError(), function() { |
| 244 new PaymentRequest([], buildDetails()) | 256 new PaymentRequest([], buildDetails()) |
| 245 }], | 257 }], |
| 258 ['Duplicate supported payment method identifiers should throw TypeError.', n ull, function() { | |
| 259 new PaymentRequest([{'supportedMethods': ['foo', 'foo']}], buildDetails( ), {}) | |
| 260 }], | |
| 261 ['Duplicate supported payment method identifiers should throw TypeError.', n ull, function() { | |
| 262 new PaymentRequest([{'supportedMethods': ['foo']}, {'supportedMethods': ['foo']}], buildDetails(), {}) | |
| 263 }], | |
| 246 ['Empty details should throw', null, function() { | 264 ['Empty details should throw', null, function() { |
| 247 new PaymentRequest([{'supportedMethods': ['foo']}], {}) | 265 new PaymentRequest([{'supportedMethods': ['foo']}], {}) |
| 248 }], | 266 }], |
| 249 ['Null items should throw', new TypeError(), function() { | 267 ['Null items should throw', new TypeError(), function() { |
| 250 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'displayItems': null}); | 268 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'displayItems': null}); |
| 251 }], | 269 }], |
| 252 ['Null shipping options should throw', new TypeError(), function() { | 270 ['Null shipping options should throw', new TypeError(), function() { |
| 253 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'displayItems': [buildItem()], 'shippingOptions': null}); | 271 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'displayItems': [buildItem()], 'shippingOptions': null}); |
| 254 }], | 272 }], |
| 255 | 273 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 }], | 359 }], |
| 342 ['Null amount should throw', null, function() { | 360 ['Null amount should throw', null, function() { |
| 343 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': null})) | 361 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': null})) |
| 344 }], | 362 }], |
| 345 ['Undefined amount should throw', null, function() { | 363 ['Undefined amount should throw', null, function() { |
| 346 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': undefined})) | 364 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': undefined})) |
| 347 }], | 365 }], |
| 348 ]); | 366 ]); |
| 349 } | 367 } |
| 350 </script> | 368 </script> |
| OLD | NEW |