w3c / payment-request

Payment Request API
https://www.w3.org/TR/payment-request/
Other
488 stars 135 forks source link

Do we need "doc is fully active" checks on `response.complete()`? #731

Closed marcoscaceres closed 6 years ago

marcoscaceres commented 6 years ago

@domenic can you sanity check something for me... we don't currently check if document is "fully active" on response.complete().

But, in theory:

const iframe = getSomeIframe();
const response = await getResponseFrom(iframe);
await new Promise(resolve => {
  iframe.onload = resolve;
  iframe.src = "some/new/location";
}
// oh noes!
await response.complete("success"); // <- should probably reject, AbortError?

Similarly:

const iframe = getSomeIframe();
const response = await getResponseFrom(iframe);
const completePromise = response.complete("success");
await new Promise(resolve => {
  iframe.onload = resolve;
  iframe.src = "some/new/location";
}
await completePromise; // <- should probably reject, AbortError?
marcoscaceres commented 6 years ago

Cleaned up above a little bit.

domenic commented 6 years ago

Yeah, good catch.

The first example I understand. The second example seems pretty hard to hit in practice, but probably still worth guarding against.