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

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

Issue 2685343002: Update the shippingType option to not allow invalid strings. (Closed)
Patch Set: layout test Created 3 years, 10 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/payments/PaymentOptions.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildDetai ls(), {'requestShipping': true, 'shippingType': 'delivery'}); 185 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildDetai ls(), {'requestShipping': true, 'shippingType': 'delivery'});
186 assert_equals('delivery', request.shippingType); 186 assert_equals('delivery', request.shippingType);
187 }, 'Shipping type should be \'delivery\' if shipping type is specified as \'deli very\'.'); 187 }, 'Shipping type should be \'delivery\' if shipping type is specified as \'deli very\'.');
188 188
189 test(function() { 189 test(function() {
190 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildDetai ls(), {'requestShipping': true, 'shippingType': 'pickup'}); 190 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildDetai ls(), {'requestShipping': true, 'shippingType': 'pickup'});
191 assert_equals('pickup', request.shippingType); 191 assert_equals('pickup', request.shippingType);
192 }, 'Shipping type should be \'pickup\' if shipping type is specified as \'pickup \'.'); 192 }, 'Shipping type should be \'pickup\' if shipping type is specified as \'pickup \'.');
193 193
194 test(function() { 194 test(function() {
195 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildDetai ls(), {'requestShipping': true, 'shippingType': 'invalid'});
196 assert_equals('shipping', request.shippingType);
197 }, 'Shipping type should be \'shipping\' if shipping type is specified as invali d string.');
198
199 test(function() {
200 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildDetai ls(), {'requestShipping': true, 'shippingType': null});
201 assert_equals('shipping', request.shippingType);
202 }, 'Shipping type should be \'shipping\' if shipping type is specified as null.' );
203
204 test(function() {
205 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildDetai ls(), {'requestShipping': true, 'shippingType': undefined}); 195 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildDetai ls(), {'requestShipping': true, 'shippingType': undefined});
206 assert_equals('shipping', request.shippingType); 196 assert_equals('shipping', request.shippingType);
207 }, 'Shipping type should be \'shipping\' if shipping type is specified as undefi ned.'); 197 }, 'Shipping type should be \'shipping\' if shipping type is specified as undefi ned.');
208 198
209 test(function() { 199 test(function() {
210 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildDetai ls(), {'requestShipping': true, 'shippingType': []});
211 assert_equals('shipping', request.shippingType);
212 }, 'Shipping type should be \'shipping\' if shipping type is specified as [].');
213
214 test(function() {
215 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildDetai ls(), {'requestShipping': true, 'shippingType': {}});
216 assert_equals('shipping', request.shippingType);
217 }, 'Shipping type should be \'shipping\' if shipping type is specified as {}.');
218
219 test(function() {
220 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildDetai ls(), {'requestShipping': true, 'shippingType': 0});
221 assert_equals('shipping', request.shippingType);
222 }, 'Shipping type should be \'shipping\' if shipping type is specified as a numb er.');
223
224 test(function() {
225 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), ' displayItems': undefined}); 200 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), ' displayItems': undefined});
226 }, 'Undefined display items should not throw.'); 201 }, 'Undefined display items should not throw.');
227 202
228 test(function() { 203 test(function() {
229 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), ' displayItems': []}); 204 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), ' displayItems': []});
230 }, 'Empty display items should not throw.'); 205 }, 'Empty display items should not throw.');
231 206
232 test(function() { 207 test(function() {
233 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails('total', {' value': '0'})); 208 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails('total', {' value': '0'}));
234 }, 'Non-negative total value should not throw.'); 209 }, 'Non-negative total value should not throw.');
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 }], 318 }],
344 ['Empty details should throw', null, function() { 319 ['Empty details should throw', null, function() {
345 new PaymentRequest([{'supportedMethods': ['foo']}], {}) 320 new PaymentRequest([{'supportedMethods': ['foo']}], {})
346 }], 321 }],
347 ['Null items should throw', new TypeError(), function() { 322 ['Null items should throw', new TypeError(), function() {
348 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'displayItems': null}); 323 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'displayItems': null});
349 }], 324 }],
350 ['Null shipping options should throw', new TypeError(), function() { 325 ['Null shipping options should throw', new TypeError(), function() {
351 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'displayItems': [buildItem()], 'shippingOptions': null}); 326 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem( ), 'displayItems': [buildItem()], 'shippingOptions': null});
352 }], 327 }],
328 ['Undefined PaymentShippingType value for shppingType should throw a TypeErr or', new TypeError(), function() {
foolip 2017/02/14 13:32:05 This test does not test undefined, but an invalid
329 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildD etails(), {'requestShipping': true, 'shippingType': 'invalid'});
330 }],
331 ['Null for shppingType should throw a TypeError', new TypeError(), function( ) {
332 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildD etails(), {'requestShipping': true, 'shippingType': null});
333 }],
334 ['Array value for shppingType should throw a TypeError', new TypeError(), fu nction() {
335 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildD etails(), {'requestShipping': true, 'shippingType': []});
336 }],
337 ['Object value for shppingType should throw a TypeError', new TypeError(), f unction() {
338 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildD etails(), {'requestShipping': true, 'shippingType': {}});
339 }],
340 ['Numeric value for shppingType should throw a TypeError', new TypeError(), function() {
341 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildD etails(), {'requestShipping': true, 'shippingType': 0});
342 }],
353 343
354 // Payment method specific data should be a JSON-serializable object. 344 // Payment method specific data should be a JSON-serializable object.
355 ['Array value for payment method specific data parameter should throw', null , function() { 345 ['Array value for payment method specific data parameter should throw', null , function() {
356 new PaymentRequest([{'supportedMethods': ['foo'], 'data': []}], buildDet ails(), {}) 346 new PaymentRequest([{'supportedMethods': ['foo'], 'data': []}], buildDet ails(), {})
357 }], 347 }],
358 ['String value for payment method specific data parameter should throw', nul l, function() { 348 ['String value for payment method specific data parameter should throw', nul l, function() {
359 new PaymentRequest([{'supportedMethods': ['foo'], 'data': 'foo'}], build Details(), {}) 349 new PaymentRequest([{'supportedMethods': ['foo'], 'data': 'foo'}], build Details(), {})
360 }], 350 }],
361 ['Numeric value for payment method specific data parameter should throw', nu ll, function() { 351 ['Numeric value for payment method specific data parameter should throw', nu ll, function() {
362 new PaymentRequest([{'supportedMethods': ['foo'], 'data': 42}], buildDet ails(), {}) 352 new PaymentRequest([{'supportedMethods': ['foo'], 'data': 42}], buildDet ails(), {})
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 }], 420 }],
431 ['Null amount should throw', null, function() { 421 ['Null amount should throw', null, function() {
432 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': null}), {requestShipping: true}) 422 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': null}), {requestShipping: true})
433 }], 423 }],
434 ['Undefined amount should throw', null, function() { 424 ['Undefined amount should throw', null, function() {
435 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': undefined}), {requestShipping: true}) 425 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det ailNames[i], {'value': undefined}), {requestShipping: true})
436 }], 426 }],
437 ]); 427 ]);
438 } 428 }
439 </script> 429 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/payments/PaymentOptions.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698