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

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

Issue 1753543002: PaymentRequest Mojo bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@interface
Patch Set: Created 4 years, 9 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 test(function() { 7 test(function() {
8 new PaymentRequest([], {}, {}, {}); 8 new PaymentRequest(["foo"], {}, {}, {});
9 }, 'Creating a PaymentRequest with empty parameters should not throw or crash.') ; 9 }, 'Creating a PaymentRequest with empty parameters should not throw or crash.') ;
10 10
11 test(function() { 11 test(function() {
12 new PaymentRequest([], {}, {}, {}, ''); 12 new PaymentRequest(["foo"], {}, {}, {}, '');
13 }, 'Creating a PaymentRequest with extra parameters should not throw or crash.') ; 13 }, 'Creating a PaymentRequest with extra parameters should not throw or crash.') ;
14 14
15 test(function() { 15 test(function() {
16 new PaymentRequest([], {}); 16 new PaymentRequest(["foo"], {});
17 }, 'Creating a PaymentRequest with omitted optional parameters should not throw or crash.'); 17 }, 'Creating a PaymentRequest with omitted optional parameters should not throw or crash.');
18 18
19 test(function() { 19 test(function() {
20 new PaymentRequest([], {}, undefined, undefined); 20 new PaymentRequest(["foo"], {}, undefined, undefined);
21 }, 'Creating a PaymentRequest with undefined optional parameters should not thro w or crash.'); 21 }, 'Creating a PaymentRequest with undefined optional parameters should not thro w or crash.');
22 22
23 test(function() { 23 test(function() {
24 new PaymentRequest([], {}, null, null); 24 new PaymentRequest(["foo"], {}, null, null);
25 }, 'Creating a PaymentRequest with null optional parameters should not throw or crash.'); 25 }, 'Creating a PaymentRequest with null optional parameters should not throw or crash.');
26 26
27 generate_tests(assert_throws, [ 27 generate_tests(assert_throws, [
28 ['PaymentRequest constructor should throw for incorrect parameter types.', n ull, function() { 28 ['PaymentRequest constructor should throw for incorrect parameter types.', n ull, function() {
29 new PaymentRequest('', '', '', '') 29 new PaymentRequest('', '', '', '')
30 }], 30 }],
31 ['PaymentRequest constructor should throw for undefined required parameters. ', null, function() { 31 ['PaymentRequest constructor should throw for undefined required parameters. ', null, function() {
32 new PaymentRequest(undefined, undefined) 32 new PaymentRequest(undefined, undefined)
33 }], 33 }],
34 ['PaymentRequest constructor should throw for null required parameter.', nul l, function() { 34 ['PaymentRequest constructor should throw for null required parameter.', nul l, function() {
35 new PaymentRequest(null, null) 35 new PaymentRequest(null, null)
36 }] 36 }]
37 ]); 37 ]);
38 38
39 test(function() { 39 test(function() {
40 var request = new PaymentRequest([], {}); 40 var request = new PaymentRequest(["foo"], {});
41 assert_readonly(request, "shippingAddress", 'PaymentRequest should have a re adonly shippingAddress property.'); 41 assert_readonly(request, "shippingAddress", 'PaymentRequest should have a re adonly shippingAddress property.');
42 assert_readonly(request, "shippingOption", 'PaymentRequest should have a rea donly shippingOption property.'); 42 assert_readonly(request, "shippingOption", 'PaymentRequest should have a rea donly shippingOption property.');
43 }, 'PaymentRequest should have readonly shippingAddress and shippingOption prope rties.'); 43 }, 'PaymentRequest should have readonly shippingAddress and shippingOption prope rties.');
44 44
45 test(function() { 45 test(function() {
46 var request = new PaymentRequest([], {}); 46 var request = new PaymentRequest(["foo"], {});
47 assert_not_equals(request.onshippingaddresschange, undefined, 'PaymentReques t should have onShippingAddressChange event.'); 47 assert_not_equals(request.onshippingaddresschange, undefined, 'PaymentReques t should have onShippingAddressChange event.');
48 assert_not_equals(request.onshippingoptionchange, undefined, 'PaymentRequest should have onShippingOptionChange event.'); 48 assert_not_equals(request.onshippingoptionchange, undefined, 'PaymentRequest should have onShippingOptionChange event.');
49 }, 'PaymentRequest should have onShippingAddressChange and onShippingOptionChang e events.'); 49 }, 'PaymentRequest should have onShippingAddressChange and onShippingOptionChang e events.');
50 50
51 51
52 test(function() { 52 test(function() {
53 var request = new PaymentRequest([], {}); 53 var request = new PaymentRequest(["foo"], {});
54 assert_not_equals(request.abort, undefined, 'PaymentRequest should have abor t() method.'); 54 assert_not_equals(request.abort, undefined, 'PaymentRequest should have abor t() method.');
55 assert_not_equals(request.show, undefined, 'PaymentRequest should have show( ) method.'); 55 assert_not_equals(request.show, undefined, 'PaymentRequest should have show( ) method.');
56 }, 'PaymentRequest should have methods abort() and show().'); 56 }, 'PaymentRequest should have methods abort() and show().');
57 57
58 test(function() { 58 test(function() {
59 var request = new PaymentRequest([], {}); 59 var request = new PaymentRequest(["foo"], {});
60 request.show();
60 request.abort(); 61 request.abort();
62 }, 'PaymentRequest.abort() and PaymentRequest.show() should take no parameters.' );
63
64 test(function() {
65 var request = new PaymentRequest(
66 ["foo"],
67 {
68 "items": [{"id": "total", "label": "Total", "amount": {"currency Code": "USD", "value": "10.00"}}],
69 "shippingOptions": [{"id": "self", "label": "Pick up", "amount": {"currencyCode": "USD", "value": "-5.00"}}]
70 },
71 {"requestShipping": true},
72 {"foo": {"gateway": "bar"}});
61 request.show(); 73 request.show();
62 }, 'PaymentRequest.abort() and PaymentRequest.show() should take no parameters.' ); 74 request.abort();
75 }, 'Valid data causes no errors.');
63 </script> 76 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698