OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta charset="utf-8"> |
| 3 <title>Tests for PaymentRequest interface</title> |
| 4 <script src="../resources/testharness.js"></script> |
| 5 <script src="../resources/testharnessreport.js"></script> |
| 6 <script> |
| 7 test(function() { |
| 8 new PaymentRequest([], {}, {}, {}); |
| 9 }, 'Creating a PaymentRequest with empty parameters should not throw or crash.')
; |
| 10 |
| 11 test(function() { |
| 12 new PaymentRequest([], {}, {}, {}, ''); |
| 13 }, 'Creating a PaymentRequest with extra parameters should not throw or crash.')
; |
| 14 |
| 15 test(function() { |
| 16 new PaymentRequest([], {}); |
| 17 }, 'Creating a PaymentRequest with omitted optional parameters should not throw
or crash.'); |
| 18 |
| 19 test(function() { |
| 20 new PaymentRequest([], {}, undefined, undefined); |
| 21 }, 'Creating a PaymentRequest with undefined optional parameters should not thro
w or crash.'); |
| 22 |
| 23 test(function() { |
| 24 new PaymentRequest([], {}, null, null); |
| 25 }, 'Creating a PaymentRequest with null optional parameters should not throw or
crash.'); |
| 26 |
| 27 generate_tests(assert_throws, [ |
| 28 ['PaymentRequest constructor should throw for incorrect parameter types.', n
ull, function() { |
| 29 new PaymentRequest('', '', '', '') |
| 30 }], |
| 31 ['PaymentRequest constructor should throw for undefined required parameters.
', null, function() { |
| 32 new PaymentRequest(undefined, undefined) |
| 33 }], |
| 34 ['PaymentRequest constructor should throw for null required parameter.', nul
l, function() { |
| 35 new PaymentRequest(null, null) |
| 36 }] |
| 37 ]); |
| 38 |
| 39 test(function() { |
| 40 var request = new PaymentRequest([], {}); |
| 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.'); |
| 43 }, 'PaymentRequest should have readonly shippingAddress and shippingOption prope
rties.'); |
| 44 |
| 45 test(function() { |
| 46 var request = new PaymentRequest([], {}); |
| 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.'); |
| 49 }, 'PaymentRequest should have onShippingAddressChange and onShippingOptionChang
e events.'); |
| 50 |
| 51 |
| 52 test(function() { |
| 53 var request = new PaymentRequest([], {}); |
| 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.'); |
| 56 }, 'PaymentRequest should have methods abort() and show().'); |
| 57 |
| 58 test(function() { |
| 59 var request = new PaymentRequest([], {}); |
| 60 request.abort(); |
| 61 request.show(); |
| 62 }, 'PaymentRequest.abort() and PaymentRequest.show() should take no parameters.'
); |
| 63 </script> |
OLD | NEW |