OLD | NEW |
1 importScripts('../../serviceworker/resources/worker-testharness.js'); | 1 importScripts('../../serviceworker/resources/worker-testharness.js'); |
2 | 2 |
3 test(() => { | 3 test(() => { |
4 assert_true('PaymentRequestEvent' in self); | 4 assert_true('PaymentRequestEvent' in self); |
5 assert_inherits(PaymentRequestEvent.prototype, 'waitUntil'); | 5 assert_inherits(PaymentRequestEvent.prototype, 'waitUntil'); |
6 assert_own_property(PaymentRequestEvent.prototype, 'topLevelOrigin'); | 6 assert_own_property(PaymentRequestEvent.prototype, 'topLevelOrigin'); |
7 assert_own_property(PaymentRequestEvent.prototype, 'paymentRequestOrigin'); | 7 assert_own_property(PaymentRequestEvent.prototype, 'paymentRequestOrigin'); |
8 assert_own_property(PaymentRequestEvent.prototype, 'paymentRequestId'); | 8 assert_own_property(PaymentRequestEvent.prototype, 'paymentRequestId'); |
9 assert_own_property(PaymentRequestEvent.prototype, 'methodData'); | 9 assert_own_property(PaymentRequestEvent.prototype, 'methodData'); |
10 assert_own_property(PaymentRequestEvent.prototype, 'total'); | 10 assert_own_property(PaymentRequestEvent.prototype, 'total'); |
11 assert_own_property(PaymentRequestEvent.prototype, 'modifiers'); | 11 assert_own_property(PaymentRequestEvent.prototype, 'modifiers'); |
12 assert_own_property(PaymentRequestEvent.prototype, 'instrumentKey'); | 12 assert_own_property(PaymentRequestEvent.prototype, 'instrumentKey'); |
13 assert_own_property(PaymentRequestEvent.prototype, 'respondWith'); | 13 assert_own_property(PaymentRequestEvent.prototype, 'respondWith'); |
14 }); | 14 }); |
| 15 |
| 16 promise_test(() => { |
| 17 return new Promise(resolve => { |
| 18 var eventWithInit = new PaymentRequestEvent('paymentrequest', { |
| 19 topLevelOrigin: 'https://example.com', |
| 20 paymentRequestOrigin: 'https://example.com', |
| 21 paymentRequestId: 'payment-request-id', |
| 22 methodData: [{ |
| 23 supportedMethods: ['basic-card'] |
| 24 }], |
| 25 total: { |
| 26 label: 'Total', |
| 27 amount: { |
| 28 currency: 'USD', |
| 29 value: '55.00' |
| 30 } |
| 31 }, |
| 32 modifiers: [{ |
| 33 supportedMethods: ['basic-card'] |
| 34 }], |
| 35 instrumentKey: 'payment-instrument-key' |
| 36 }); |
| 37 |
| 38 self.addEventListener('paymentrequest', e => { |
| 39 assert_equals(e.topLevelOrigin, 'https://example.com'); |
| 40 assert_equals(e.paymentRequestOrigin, 'https://example.com'); |
| 41 assert_equals(e.paymentRequestId, 'payment-request-id'); |
| 42 assert_equals(e.methodData.length, 1); |
| 43 assert_equals(e.methodData[0].supportedMethods.length, 1); |
| 44 assert_equals(e.methodData[0].supportedMethods[0], 'basic-card'); |
| 45 assert_equals(e.total.label, 'Total'); |
| 46 assert_equals(e.total.amount.currency, 'USD'); |
| 47 assert_equals(e.total.amount.value, '55.00'); |
| 48 assert_equals(e.modifiers.length, 1); |
| 49 assert_equals(e.modifiers[0].supportedMethods.length, 1); |
| 50 assert_equals(e.modifiers[0].supportedMethods[0], 'basic-card'); |
| 51 assert_equals(e.instrumentKey, 'payment-instrument-key'); |
| 52 resolve(); |
| 53 }); |
| 54 |
| 55 self.dispatchEvent(eventWithInit); |
| 56 }); |
| 57 }); |
OLD | NEW |