-
Notifications
You must be signed in to change notification settings - Fork 137
Description
There are multiple places in the spec today that requires any outstanding promises to be rejected if the document becomes not fully active, e.g. show(), retry(), complete().
In Blink, this turns out to be difficult to implement because there is no hook to inform the blink::PaymentRequest
object that its associated context is about to be destroy. The only hook is after the context is destroyed. This is too late, as any rejection queue then will not actually be executed. So from web developer's perspective, the promise gets into a limbo state, and never rejects nor resolves (http://crbug.com/941271).
Where this causes a real problem for web developers is when a show()
promise is created from a PaymentRequest
in one context (e.g. an iframe) and passed to a second context (e.g. a parent frame), and the first context navigates away. If the parent frame relies on the promise to resolve or reject to control its UI, it will hang.
@domenic you suggested the following on the platform-architecture-dev thread regarding this issue:
make resolve/reject a no-op if the promise's relevant Realm's global object is a Window, and that Window's associated Document is not fully-active. And then, I guess, remove all uses of rejected promises to signal failures due to document inactivity, like the one opening this thread.
I'm not sure I fully follow what you mean. Can you clarify how this solves the problem?
In the end, I think there are two options out of this problem:
- Change Payment Request API spec to not require outstanding promises be rejected when the document becomes not fully active. I'm not sure how to address the parent frame in limbo question.
- Figure out a way to solve this problem in Blink. Based on a discussion I had with @aestes, WebKit doesn't have this problem because there is a hook just before the context is destroyed. So perhaps Blink can introduce a similar hook.
Any thoughts? @marcoscaceres @domenic @aestes @rsolomakhin @ianbjacobs