Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update payment-handler IDL file #9796

28 changes: 22 additions & 6 deletions interfaces/payment-handler.idl
@@ -1,15 +1,25 @@
// GENERATED CONTENT - DO NOT EDIT
// Content of this file was automatically extracted from the
// "Payment Handler API" spec.
// See: https://w3c.github.io/payment-handler/

partial interface ServiceWorkerRegistration {
[SameObject]
readonly attribute PaymentManager paymentManager;
};
[SecureContext,
Exposed=(Window,Worker)]
interface PaymentManager {
[SameObject]
readonly attribute PaymentInstruments instruments;
[Exposed=Window] static Promise<PermissionState> requestPermission();
attribute DOMString userHint;
};
[SecureContext,
Exposed=(Window,Worker)]
interface PaymentInstruments {
Promise<boolean> delete(DOMString instrumentKey);
Promise<PaymentInstrument> get(DOMString instrumentKey);
Promise<any> get(DOMString instrumentKey);
Promise<sequence<DOMString>> keys();
Promise<boolean> has(DOMString instrumentKey);
Promise<void> set(DOMString instrumentKey,
Expand All @@ -27,36 +37,42 @@ dictionary ImageObject {
DOMString sizes;
DOMString type;
};
partial interface ServiceWorkerGlobalScope {
attribute EventHandler oncanmakepayment;
};
[Constructor(DOMString type, CanMakePaymentEventInit eventInitDict),
Exposed=ServiceWorker]
interface CanMakePaymentEvent : ExtendableEvent {
readonly attribute USVString topLevelOrigin;
readonly attribute USVString topOrigin;
readonly attribute USVString paymentRequestOrigin;
readonly attribute FrozenArray<PaymentMethodData> methodData;
readonly attribute FrozenArray<PaymentDetailsModifier> modifiers;
void respondWith(Promise<boolean> canMakePaymentResponse);
};
dictionary CanMakePaymentEventInit : ExtendableEventInit {
USVString topLevelOrigin;
USVString topOrigin;
USVString paymentRequestOrigin;
sequence<PaymentMethodData> methodData;
sequence<PaymentDetailsModifier> modifiers;
};
partial interface ServiceWorkerGlobalScope {
attribute EventHandler onpaymentrequest;
};
[Constructor(DOMString type, PaymentRequestEventInit eventInitDict),
Exposed=ServiceWorker]
interface PaymentRequestEvent : ExtendableEvent {
readonly attribute USVString topLevelOrigin;
readonly attribute USVString topOrigin;
readonly attribute USVString paymentRequestOrigin;
readonly attribute DOMString paymentRequestId;
readonly attribute FrozenArray<PaymentMethodData> methodData;
readonly attribute object total;
readonly attribute FrozenArray<PaymentDetailsModifier> modifiers;
readonly attribute DOMString instrumentKey;
Promise<WindowClient?> openWindow(USVString url);
void respondWith(Promise<PaymentHandlerResponse> handlerResponse);
void respondWith(Promise<PaymentHandlerResponse> handlerResponsePromise);
};
dictionary PaymentRequestEventInit : ExtendableEventInit {
USVString topLevelOrigin;
USVString topOrigin;
USVString paymentRequestOrigin;
DOMString paymentRequestId;
sequence<PaymentMethodData> methodData;
Expand Down
20 changes: 20 additions & 0 deletions payment-handler/idlharness.https.any.js
@@ -0,0 +1,20 @@
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js

'use strict';

// https://w3c.github.io/payment-handler/

promise_test(async () => {
const idl = await fetch('/interfaces/payment-handler.idl').then(r => r.text());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

const [idl, sw, dw, dom] = Promise.all([
  fetch("/interfaces/ServiceWorker.idl").then(r => r.text()),
  fetch("/interfaces/dedicated-workers.idl").then(r => r.text()),
  fetch("/interfaces/payment-handler.idl").then(r => r.text()),
  fetch("/interfaces/dom.idl").then(r => r.text()),
]);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, probably better (just trying to avoid downloading in sequence):

const idls = [
  "/interfaces/ServiceWorker.idl",
  "/interfaces/dedicated-workers.idl",
  "/interfaces/payment-handler.idl",
  "/interfaces/dom.idl",
];
const [idl, sw, dw, dom] = Promise.all(
  idls.map(url => fetch(url).then(r => r.text()))
);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done (the pattern you see in the update I've actually used all over the show for other tests, not sure why I dropped the ball here).

const sw = await fetch('/interfaces/ServiceWorker.idl').then(r => r.text());
const dw = await fetch('/interfaces/dedicated-workers.idl').then(r => r.text());
const dom = await fetch('/interfaces/dom.idl').then(r => r.text());

const idlArray = new IdlArray();
idlArray.add_idls(idl);
idlArray.add_dependency_idls(sw);
idlArray.add_dependency_idls(dw);
idlArray.add_dependency_idls(dom);
idlArray.test();
}, 'payment-handler interfaces.');