OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // https://w3c.github.io/webpayments-payment-apps-api/#idl-def-paymentrequesteve
nt | 5 // https://w3c.github.io/webpayments-payment-apps-api/#idl-def-paymentrequesteve
nt |
6 | 6 |
7 [ | 7 [ |
8 RuntimeEnabled=PaymentApp, | 8 RuntimeEnabled=PaymentApp, |
9 Exposed=ServiceWorker | 9 Exposed=ServiceWorker |
10 ] interface PaymentRequestEvent : ExtendableEvent { | 10 ] interface PaymentRequestEvent : ExtendableEvent { |
11 readonly attribute PaymentAppRequestData data; | 11 readonly attribute PaymentAppRequestData data; |
12 // The payment app api spec says that respondWith() should take a union | |
13 // type as follows: | |
14 // - respondWith((Promise<PaymentResponse> or PaymentResponse)); | |
15 // | |
16 // But the web-idl spec says that Promise types are not distinguishable | |
17 // with any other type. Also, if we pass PaymentResponse to respondWith(), | |
18 // then it will just be cast to a promise immediately via Promise.resolve(). | |
19 // | |
20 // We found existing case here: | |
21 // - https://github.com/w3c/ServiceWorker/issues/724 | |
22 // | |
23 // So, we should just use Promise<PaymentResponse> instead of union type. | |
24 // Related spec bug: | |
25 // - https://github.com/w3c/webpayments-payment-apps-api/pull/71 | |
26 void respondWith(Promise<PaymentResponse> response); | 12 void respondWith(Promise<PaymentResponse> response); |
27 }; | 13 }; |
OLD | NEW |