Re: [w3c/payment-handler] Does PaymentManager need to be exposed to Worker scope? (#340)

Hi, @danyao 

I left inline comments :)

> The PaymentManager interface currently has [Exposed=(Window,Worker)] in the spec. I wonder if the Worker scope is necessary.

Do you have any special reasons to introduce the restriction? For example, `requestPermission()` contained a permission UI prompt. As you know, the UI should be invoked on main thread. So the `[Exposed=Window]` restriction was added to `requestPermission()`.

On the other hand, the `PaymentManager` is exposed as an attribute to extended `ServiceWorkerRegistration`. Today, we can access the `ServiceWorkerRegistration` in Worker scope(including ServiceWorker) as well as Window scope[1]. Therefore, it is reasonable that the attribute is exposed to the equivalent scope as `ServiceWorkerRegistration` if there is no special reasons.

> Currently PaymentManager is only ever used through the service worker registration's paymentManager instance. Chrome's current implementation doesn't use [Exposed], which defaults to Window.

It might be a Chrome bug. Looking into the history at Chromium[2], when I implemented this feature first(2016), there was no "Exposed" extended attribute in the spec. After that, while implementing/standardizing `requestPermission()`, we have added a restriction that expose the method to Window scope only because of a permission UI prompt. And I realized that we missed `Exposed` extended attribute for `PaymentManager`. So, I added it as well. (2017)
However, I forgot to reflect the spec change to Chromium/Blink and the PaymentHandler was just shipped without fixing the change in Chrome.

Thank you.

[1] https://w3c.github.io/ServiceWorker/#serviceworkerregistration-interface
[2] https://chromium.googlesource.com/chromium/src/+/60a84ca8de6308a26f8500600ad8ba7c1ce2a41c/third_party/WebKit/Source/modules/payments/PaymentAppManager.idl

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/payment-handler/issues/340#issuecomment-513070589

Received on Friday, 19 July 2019 02:55:34 UTC