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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 } else { | 54 } else { |
55 details[detailNames[i]] = [buildItem()]; | 55 details[detailNames[i]] = [buildItem()]; |
56 } | 56 } |
57 } | 57 } |
58 } | 58 } |
59 | 59 |
60 return details; | 60 return details; |
61 } | 61 } |
62 | 62 |
63 test(function() { | 63 test(function() { |
64 new PaymentRequest(['foo'], buildDetails(), {}, {}); | 64 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(), {}); |
65 }, 'Creating a PaymentRequest with empty parameters should not throw or crash.')
; | 65 }, 'Creating a PaymentRequest with empty parameters should not throw or crash.')
; |
66 | 66 |
67 test(function() { | 67 test(function() { |
68 new PaymentRequest(['foo'], buildDetails(), {}, {}, ''); | 68 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(), {}, ''); |
69 }, 'Creating a PaymentRequest with extra parameters should not throw or crash.')
; | 69 }, 'Creating a PaymentRequest with extra parameters should not throw or crash.')
; |
70 | 70 |
71 test(function() { | 71 test(function() { |
72 new PaymentRequest(['foo'], buildDetails()); | 72 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails()); |
73 }, 'Creating a PaymentRequest with omitted optional parameters should not throw
or crash.'); | 73 }, 'Creating a PaymentRequest with omitted optional parameters should not throw
or crash.'); |
74 | 74 |
75 test(function() { | 75 test(function() { |
76 new PaymentRequest(['foo'], buildDetails(), undefined, undefined); | 76 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(), undefine
d); |
77 }, 'Creating a PaymentRequest with undefined optional parameters should not thro
w or crash.'); | 77 }, 'Creating a PaymentRequest with undefined optional parameters should not thro
w or crash.'); |
78 | 78 |
79 test(function() { | 79 test(function() { |
80 new PaymentRequest(['foo'], buildDetails(), null, null); | 80 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(), null); |
81 }, 'Creating a PaymentRequest with null optional parameters should not throw or
crash.'); | 81 }, 'Creating a PaymentRequest with null optional parameters should not throw or
crash.'); |
82 | 82 |
83 test(function() { | 83 test(function() { |
84 var request = new PaymentRequest(['foo'], buildDetails()); | 84 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildDetai
ls()); |
85 assert_readonly(request, 'shippingAddress', 'PaymentRequest should have a re
adonly shippingAddress property.'); | 85 assert_readonly(request, 'shippingAddress', 'PaymentRequest should have a re
adonly shippingAddress property.'); |
86 assert_readonly(request, 'shippingOption', 'PaymentRequest should have a rea
donly shippingOption property.'); | 86 assert_readonly(request, 'shippingOption', 'PaymentRequest should have a rea
donly shippingOption property.'); |
87 }, 'PaymentRequest should have readonly shippingAddress and shippingOption prope
rties.'); | 87 }, 'PaymentRequest should have readonly shippingAddress and shippingOption prope
rties.'); |
88 | 88 |
89 test(function() { | 89 test(function() { |
90 var request = new PaymentRequest(['foo'], buildDetails()); | 90 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildDetai
ls()); |
91 assert_not_equals(request.onshippingaddresschange, undefined, 'PaymentReques
t should have onShippingAddressChange event.'); | 91 assert_not_equals(request.onshippingaddresschange, undefined, 'PaymentReques
t should have onShippingAddressChange event.'); |
92 assert_not_equals(request.onshippingoptionchange, undefined, 'PaymentRequest
should have onShippingOptionChange event.'); | 92 assert_not_equals(request.onshippingoptionchange, undefined, 'PaymentRequest
should have onShippingOptionChange event.'); |
93 }, 'PaymentRequest should have onShippingAddressChange and onShippingOptionChang
e events.'); | 93 }, 'PaymentRequest should have onShippingAddressChange and onShippingOptionChang
e events.'); |
94 | 94 |
95 test(function() { | 95 test(function() { |
96 var request = new PaymentRequest(['foo'], buildDetails()); | 96 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildDetai
ls()); |
97 assert_not_equals(request.abort, undefined, 'PaymentRequest should have abor
t() method.'); | 97 assert_not_equals(request.abort, undefined, 'PaymentRequest should have abor
t() method.'); |
98 assert_not_equals(request.show, undefined, 'PaymentRequest should have show(
) method.'); | 98 assert_not_equals(request.show, undefined, 'PaymentRequest should have show(
) method.'); |
99 }, 'PaymentRequest should have methods abort() and show().'); | 99 }, 'PaymentRequest should have methods abort() and show().'); |
100 | 100 |
101 test(function() { | 101 test(function() { |
102 var request = new PaymentRequest(['foo'], buildDetails()); | 102 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildDetai
ls()); |
103 request.show(); | 103 request.show(); |
104 request.abort(); | 104 request.abort(); |
105 }, 'PaymentRequest.abort() and PaymentRequest.show() should take no parameters.'
); | 105 }, 'PaymentRequest.abort() and PaymentRequest.show() should take no parameters.'
); |
106 | 106 |
107 test(function() { | 107 test(function() { |
108 var request = new PaymentRequest(['foo'], buildDetails(), {'requestShipping'
: true}, {'foo': {'gateway': 'bar'}}); | 108 var request = new PaymentRequest([{'supportedMethods': ['foo'], 'data': {'fo
o': {'gateway': 'bar'}}}], buildDetails(), {'requestShipping': true}); |
109 request.show(); | 109 request.show(); |
110 request.abort(); | 110 request.abort(); |
111 }, 'Valid data causes no errors.'); | 111 }, 'Valid data causes no errors.'); |
112 | 112 |
113 test(function() { | 113 test(function() { |
114 var request = new PaymentRequest(['foo'], buildDetails('shippingOptions', {'
id': 'standard'})); | 114 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildDetai
ls('shippingOptions', {'id': 'standard'})); |
115 assert_equals(null, request.shippingOption); | 115 assert_equals(null, request.shippingOption); |
116 }, 'Shipping option identifier should be null if shipping request is omitted.'); | 116 }, 'Shipping option identifier should be null if shipping request is omitted.'); |
117 | 117 |
118 test(function() { | 118 test(function() { |
119 var request = new PaymentRequest(['foo'], buildDetails('shippingOptions', {'
id': 'standard'}), {'requestShipping': false}); | 119 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildDetai
ls('shippingOptions', {'id': 'standard'}), {'requestShipping': false}); |
120 assert_equals(null, request.shippingOption); | 120 assert_equals(null, request.shippingOption); |
121 }, 'Shipping option identifier should be null if shipping is explicitly not requ
ested.'); | 121 }, 'Shipping option identifier should be null if shipping is explicitly not requ
ested.'); |
122 | 122 |
123 test(function() { | 123 test(function() { |
124 var request = new PaymentRequest(['foo'], {'total': buildItem(), 'displayIte
ms': [buildItem()]}, {'requestShipping': true}); | 124 var request = new PaymentRequest([{'supportedMethods': ['foo']}], {'total':
buildItem(), 'displayItems': [buildItem()]}, {'requestShipping': true}); |
125 assert_equals(null, request.shippingOption); | 125 assert_equals(null, request.shippingOption); |
126 }, 'Shipping option identifier should be null if no shipping options are provide
d.'); | 126 }, 'Shipping option identifier should be null if no shipping options are provide
d.'); |
127 | 127 |
128 test(function() { | 128 test(function() { |
129 var request = new PaymentRequest(['foo'], buildDetails('shippingOptions', {'
selected': false}), {'requestShipping': true}); | 129 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildDetai
ls('shippingOptions', {'selected': false}), {'requestShipping': true}); |
130 assert_equals(null, request.shippingOption); | 130 assert_equals(null, request.shippingOption); |
131 }, 'Shipping option identifier should be null if the single provided option is n
ot selected.'); | 131 }, 'Shipping option identifier should be null if the single provided option is n
ot selected.'); |
132 | 132 |
133 test(function() { | 133 test(function() { |
134 var request = new PaymentRequest(['foo'], buildDetails('shippingOptions', {'
id': 'standard', 'selected': true}), {'requestShipping': true}); | 134 var request = new PaymentRequest([{'supportedMethods': ['foo']}], buildDetai
ls('shippingOptions', {'id': 'standard', 'selected': true}), {'requestShipping':
true}); |
135 assert_equals('standard', request.shippingOption); | 135 assert_equals('standard', request.shippingOption); |
136 }, 'Shipping option identifier should default to the single provided option if i
t is selected.'); | 136 }, 'Shipping option identifier should default to the single provided option if i
t is selected.'); |
137 | 137 |
138 test(function() { | 138 test(function() { |
139 var shippingOptions = [buildItem({'id': 'standard'}), buildItem({'id': 'expr
ess'})]; | 139 var shippingOptions = [buildItem({'id': 'standard'}), buildItem({'id': 'expr
ess'})]; |
140 var request = new PaymentRequest(['foo'], {'total': buildItem(), 'displayIte
ms': [buildItem()], 'shippingOptions': shippingOptions}, {'requestShipping': tru
e}); | 140 var request = new PaymentRequest([{'supportedMethods': ['foo']}], {'total':
buildItem(), 'displayItems': [buildItem()], 'shippingOptions': shippingOptions},
{'requestShipping': true}); |
141 assert_equals(null, request.shippingOption); | 141 assert_equals(null, request.shippingOption); |
142 }, 'Shipping option identifier should be null if multiple unselected shipping op
tions are provided.'); | 142 }, 'Shipping option identifier should be null if multiple unselected shipping op
tions are provided.'); |
143 | 143 |
144 test(function() { | 144 test(function() { |
145 var shippingOptions = [buildItem({'id': 'standard', 'selected': true}), buil
dItem({'id': 'express'})]; | 145 var shippingOptions = [buildItem({'id': 'standard', 'selected': true}), buil
dItem({'id': 'express'})]; |
146 var request = new PaymentRequest(['foo'], {'total': buildItem(), 'displayIte
ms': [buildItem()], 'shippingOptions': shippingOptions}, {'requestShipping': tru
e}); | 146 var request = new PaymentRequest([{'supportedMethods': ['foo']}], {'total':
buildItem(), 'displayItems': [buildItem()], 'shippingOptions': shippingOptions},
{'requestShipping': true}); |
147 assert_equals('standard', request.shippingOption); | 147 assert_equals('standard', request.shippingOption); |
148 }, 'Shipping option identifier should default to the selected shipping option.')
; | 148 }, 'Shipping option identifier should default to the selected shipping option.')
; |
149 | 149 |
150 test(function() { | 150 test(function() { |
151 var shippingOptions = [buildItem({'id': 'standard', 'selected': true}), buil
dItem({'id': 'express', 'selected': true})]; | 151 var shippingOptions = [buildItem({'id': 'standard', 'selected': true}), buil
dItem({'id': 'express', 'selected': true})]; |
152 var request = new PaymentRequest(['foo'], {'total': buildItem(), 'displayIte
ms': [buildItem()], 'shippingOptions': shippingOptions}, {'requestShipping': tru
e}); | 152 var request = new PaymentRequest([{'supportedMethods': ['foo']}], {'total':
buildItem(), 'displayItems': [buildItem()], 'shippingOptions': shippingOptions},
{'requestShipping': true}); |
153 assert_equals('express', request.shippingOption); | 153 assert_equals('express', request.shippingOption); |
154 }, 'Shipping option identifier should default to the last selected shipping opti
on, if multiple are selected.'); | 154 }, 'Shipping option identifier should default to the last selected shipping opti
on, if multiple are selected.'); |
155 | 155 |
156 test(function() { | 156 test(function() { |
157 new PaymentRequest(['foo'], {'total': buildItem(), 'displayItems': undefined
}); | 157 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), '
displayItems': undefined}); |
158 }, 'Undefined display items should not throw.'); | 158 }, 'Undefined display items should not throw.'); |
159 | 159 |
160 test(function() { | 160 test(function() { |
161 new PaymentRequest(['foo'], {'total': buildItem(), 'displayItems': []}); | 161 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(), '
displayItems': []}); |
162 }, 'Empty display items should not throw.'); | 162 }, 'Empty display items should not throw.'); |
163 | 163 |
164 test(function() { | 164 test(function() { |
165 new PaymentRequest(['foo'], buildDetails('total', {'value': '0'})); | 165 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails('total', {'
value': '0'})); |
166 }, 'Non-negative total value should not throw.'); | 166 }, 'Non-negative total value should not throw.'); |
167 | 167 |
168 test(function() { | 168 test(function() { |
169 assert_throws(new TypeError(), function() { | 169 assert_throws(new TypeError(), function() { |
170 new PaymentRequest(['foo'], buildDetails('total', {'value': '-0.01'})); | 170 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails('total'
, {'value': '-0.01'})); |
171 }); | 171 }); |
172 }, 'Negative total value should throw a TypeError.'); | 172 }, 'Negative total value should throw a TypeError.'); |
173 | 173 |
174 test(function() { | 174 test(function() { |
175 new PaymentRequest(['foo'], buildDetails('displayItems', {'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(['foo'], {'displayItems': [buildItem()]}); | 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 generate_tests(assert_throws, [ | 184 generate_tests(assert_throws, [ |
185 ['PaymentRequest constructor should throw for incorrect parameter types.', n
ull, function() { | 185 ['PaymentRequest constructor should throw for incorrect parameter types.', n
ull, function() { |
186 new PaymentRequest('', '', '', '') | 186 new PaymentRequest('', '', '') |
187 }], | 187 }], |
188 ['PaymentRequest constructor should throw for undefined required parameters.
', null, function() { | 188 ['PaymentRequest constructor should throw for undefined required parameters.
', null, function() { |
189 new PaymentRequest(undefined, undefined) | 189 new PaymentRequest(undefined, undefined) |
190 }], | 190 }], |
191 ['PaymentRequest constructor should throw for null required parameter.', nul
l, function() { | 191 ['PaymentRequest constructor should throw for null required parameter.', nul
l, function() { |
192 new PaymentRequest(null, null) | 192 new PaymentRequest(null, null) |
193 }], | 193 }], |
194 ['Empty list of supported payment method identifiers should throw TypeError.
', new TypeError(), function() { | 194 ['Empty list of supported payment method identifiers should throw TypeError.
', new TypeError(), function() { |
195 new PaymentRequest([], buildDetails()) | 195 new PaymentRequest([], buildDetails()) |
196 }], | 196 }], |
197 ['Keys in payment method specific data object should match accepted method i
dentifiers.', null, function() { | |
198 new PaymentRequest(['foo'], buildDetails(), {}, {'bar': {'gateway': 'baz
'}}) | |
199 }], | |
200 ['Empty details should throw', null, function() { | 197 ['Empty details should throw', null, function() { |
201 new PaymentRequest(['foo'], {}) | 198 new PaymentRequest([{'supportedMethods': ['foo']}], {}) |
202 }], | 199 }], |
203 ['Null items should throw', new TypeError(), function() { | 200 ['Null items should throw', new TypeError(), function() { |
204 new PaymentRequest(['foo'], {'total': buildItem(), 'displayItems': null}
); | 201 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(
), 'displayItems': null}); |
205 }], | 202 }], |
206 ['Null shipping options should throw', new TypeError(), function() { | 203 ['Null shipping options should throw', new TypeError(), function() { |
207 new PaymentRequest(['foo'], {'total': buildItem(), 'displayItems': [buil
dItem()], 'shippingOptions': null}); | 204 new PaymentRequest([{'supportedMethods': ['foo']}], {'total': buildItem(
), 'displayItems': [buildItem()], 'shippingOptions': null}); |
208 }], | 205 }], |
209 ['Aborting before showing should throw.', null, function() { | 206 ['Aborting before showing should throw.', null, function() { |
210 new PaymentRequest(['foo'], buildDetails()).abort() | 207 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails()).abor
t() |
211 }], | 208 }], |
212 | 209 |
213 // Payment method specific data should be a JSON-serializable object. | 210 // Payment method specific data should be a JSON-serializable object. |
214 ['Array value for payment method specific data parameter should throw', null
, function() { | 211 ['Array value for payment method specific data parameter should throw', null
, function() { |
215 new PaymentRequest(['foo'], buildDetails(), {}, []) | 212 new PaymentRequest([{'supportedMethods': ['foo'], 'data': []}], buildDet
ails(), {}) |
216 }], | 213 }], |
217 ['String value for payment method specific data parameter should throw', nul
l, function() { | 214 ['String value for payment method specific data parameter should throw', nul
l, function() { |
218 new PaymentRequest(['foo'], buildDetails(), {}, 'foo') | 215 new PaymentRequest([{'supportedMethods': ['foo'], 'data': 'foo'}], build
Details(), {}) |
219 }], | 216 }], |
220 ['Numeric value for payment method specific data parameter should throw', nu
ll, function() { | 217 ['Numeric value for payment method specific data parameter should throw', nu
ll, function() { |
221 new PaymentRequest(['foo'], buildDetails(), {}, 42) | 218 new PaymentRequest([{'supportedMethods': ['foo'], 'data': 42}], buildDet
ails(), {}) |
222 }], | 219 }], |
223 ['Infinite JSON value for one of the payment method specific data pieces sho
uld throw', null, function() { | 220 ['Infinite JSON value for one of the payment method specific data pieces sho
uld throw', null, function() { |
224 var infiniteData = {'foo': {}}; | 221 var infiniteData = {'foo': {}}; |
225 infiniteData.foo = infiniteData; | 222 infiniteData.foo = infiniteData; |
226 new PaymentRequest(['foo'], buildDetails(), {}, infiniteData) | 223 new PaymentRequest([{'supportedMethods': ['foo'], 'data': infiniteData}]
, buildDetails()) |
227 }], | 224 }], |
228 | 225 ['Null for payment method specific data parameter should throw', null, funct
ion() { |
229 // Values in payment method specific data object should be JSON-serializable
objects. | 226 new PaymentRequest([{'supportedMethods': ['foo'], 'data': null}], buildD
etails()) |
230 ['Array value for one of the payment method specific data pieces should thro
w', null, function() { | |
231 new PaymentRequest(['foo'], buildDetails(), {}, {'foo': []}) | |
232 }], | 227 }], |
233 ['String value for one of the payment method specific data pieces should thr
ow', null, function() { | 228 ['Empty string for payment method specific data parameter should throw', nul
l, function() { |
234 new PaymentRequest(['foo'], buildDetails(), {}, {'foo': 'bar'}) | 229 new PaymentRequest([{'supportedMethods': ['foo'], 'data': ''}], buildDet
ails()) |
235 }], | 230 }] |
236 ['Numeric value for one of the payment method specific data pieces should th
row', null, function() { | |
237 new PaymentRequest(['foo'], buildDetails(), {}, {'foo': 42}) | |
238 }], | |
239 ]); | 231 ]); |
240 | 232 |
241 var detailNames = ['total', 'displayItems', 'shippingOptions']; | 233 var detailNames = ['total', 'displayItems', 'shippingOptions']; |
242 for (var i in detailNames) { | 234 for (var i in detailNames) { |
243 generate_tests(assert_throws, [ | 235 generate_tests(assert_throws, [ |
244 // Invalid currency code formats. | 236 // Invalid currency code formats. |
245 ['Invalid currency code US1 should throw', null, function() { | 237 ['Invalid currency code US1 should throw', null, function() { |
246 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'currency'
: 'US1'})) | 238 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'currency': 'US1'})) |
247 }], | 239 }], |
248 ['Invalid currency code US should throw', null, function() { | 240 ['Invalid currency code US should throw', null, function() { |
249 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'currency'
: 'US'})) | 241 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'currency': 'US'})) |
250 }], | 242 }], |
251 ['Invalid currency code USDO should throw', null, function() { | 243 ['Invalid currency code USDO should throw', null, function() { |
252 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'currency'
: 'USDO'})) | 244 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'currency': 'USDO'})) |
253 }], | 245 }], |
254 ['Invalid currency code usd should throw', null, function() { | 246 ['Invalid currency code usd should throw', null, function() { |
255 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'currency'
: 'usd'})) | 247 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'currency': 'usd'})) |
256 }], | 248 }], |
257 ['Empty currency code should throw', null, function() { | 249 ['Empty currency code should throw', null, function() { |
258 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'currency'
: ''})) | 250 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'currency': ''})) |
259 }], | 251 }], |
260 ['Null currency code should throw', null, function() { | 252 ['Null currency code should throw', null, function() { |
261 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'currency'
: null})) | 253 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'currency': null})) |
262 }], | 254 }], |
263 ['Undefined currency code should throw', null, function() { | 255 ['Undefined currency code should throw', null, function() { |
264 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'currency'
: undefined})) | 256 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'currency': undefined})) |
265 }], | 257 }], |
266 | 258 |
267 // Invalid amount formats. | 259 // Invalid amount formats. |
268 ['Invalid amount "-" should throw', null, function() { | 260 ['Invalid amount "-" should throw', null, function() { |
269 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': '
-'})) | 261 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '-'})) |
270 }], | 262 }], |
271 ['Invalid amount "notdigits" should throw', null, function() { | 263 ['Invalid amount "notdigits" should throw', null, function() { |
272 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': '
notdigits'})) | 264 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': 'notdigits'})) |
273 }], | 265 }], |
274 ['Invalid amount "ALSONOTDIGITS" should throw', null, function() { | 266 ['Invalid amount "ALSONOTDIGITS" should throw', null, function() { |
275 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': '
ALSONOTDIGITS'})) | 267 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': 'ALSONOTDIGITS'})) |
276 }], | 268 }], |
277 ['Invalid amount "10." should throw', null, function() { | 269 ['Invalid amount "10." should throw', null, function() { |
278 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': '
10.'})) | 270 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '10.'})) |
279 }], | 271 }], |
280 ['Invalid amount ".99" should throw', null, function() { | 272 ['Invalid amount ".99" should throw', null, function() { |
281 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': '
.99'})) | 273 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '.99'})) |
282 }], | 274 }], |
283 ['Invalid amount "-10." should throw', null, function() { | 275 ['Invalid amount "-10." should throw', null, function() { |
284 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': '
-10.'})) | 276 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '-10.'})) |
285 }], | 277 }], |
286 ['Invalid amount "-.99" should throw', null, function() { | 278 ['Invalid amount "-.99" should throw', null, function() { |
287 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': '
-.99'})) | 279 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '-.99'})) |
288 }], | 280 }], |
289 ['Invalid amount "10-" should throw', null, function() { | 281 ['Invalid amount "10-" should throw', null, function() { |
290 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': '
10-'})) | 282 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '10-'})) |
291 }], | 283 }], |
292 ['Invalid amount "1-0" should throw', null, function() { | 284 ['Invalid amount "1-0" should throw', null, function() { |
293 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': '
1-0'})) | 285 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '1-0'})) |
294 }], | 286 }], |
295 ['Invalid amount "1.0.0" should throw', null, function() { | 287 ['Invalid amount "1.0.0" should throw', null, function() { |
296 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': '
1.0.0'})) | 288 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '1.0.0'})) |
297 }], | 289 }], |
298 ['Invalid amount "1/3" should throw', null, function() { | 290 ['Invalid amount "1/3" should throw', null, function() { |
299 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': '
1/3'})) | 291 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': '1/3'})) |
300 }], | 292 }], |
301 ['Empty amount should throw', null, function() { | 293 ['Empty amount should throw', null, function() { |
302 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': '
'})) | 294 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': ''})) |
303 }], | 295 }], |
304 ['Null amount should throw', null, function() { | 296 ['Null amount should throw', null, function() { |
305 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': n
ull})) | 297 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': null})) |
306 }], | 298 }], |
307 ['Undefined amount should throw', null, function() { | 299 ['Undefined amount should throw', null, function() { |
308 new PaymentRequest(['foo'], buildDetails(detailNames[i], {'value': u
ndefined})) | 300 new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(det
ailNames[i], {'value': undefined})) |
309 }], | 301 }], |
310 ]); | 302 ]); |
311 } | 303 } |
312 </script> | 304 </script> |
OLD | NEW |