From cc17c226beb910131ed193916862d7eb21cb09f0 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Thu, 30 Mar 2017 15:23:59 +0900 Subject: [PATCH 1/3] Small fixes to show(), mostly editorial * Return a rejected promise, instead of throwing, in the first step * Use less verbose and confusing ways of manipulating internal slots * Be sure to return a promise when optionally aborting the algorithm * Make it clear we're aborting the in-parallel steps, later --- index.html | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index 2f2de395..1c500696 100644 --- a/index.html +++ b/index.html @@ -617,17 +617,16 @@

  • Let request be the PaymentRequest object on which the method is called.
  • -
  • If the value of request.[[\state]] is not - "created" then throw an "InvalidStateError" +
  • If request.[[\state]] is not "created" + then return a promise rejected with an "InvalidStateError" DOMException.
  • -
  • Set the value of request.[[\state]] to - "interactive". +
  • Set request.[[\state]] to "interactive".
  • Let acceptPromise be a new Promise.
  • -
  • Set acceptPromise in - request.[[\acceptPromise]]. +
  • Set request.[[\acceptPromise]] to + acceptPromise.
  • @@ -639,7 +638,7 @@

  • Set request.[[\state]] to "closed".
  • -
  • Abort this algorithm. +
  • Return acceptPromise.
  • @@ -667,7 +666,7 @@

  • If this consultation produced no supported method of paying, then reject acceptPromise with a "NotSupportedError" - DOMException, and abort this algorithm. + DOMException, and abort these steps.
  • From ab71e0db35bc4c2bd07d24d3571b71d7dc94c6fb Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Thu, 30 Mar 2017 15:41:26 +0900 Subject: [PATCH 2/3] Properly queue tasks for user accepts/aborts algorithms We previously worked on this and thought we fixed it in #405, but we missed some in the accepts algorithm. Additionally, we should ideally not be *reading* internal slots of user-visible objects without first queuing a task. --- index.html | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/index.html b/index.html index 1c500696..f890d2b8 100644 --- a/index.html +++ b/index.html @@ -2501,7 +2501,8 @@

    The user accepts the payment request algorithm runs when the user accepts the - payment request and confirms that they want to pay. It MUST run the + payment request and confirms that they want to pay. It MUST queue + a task on the user interaction task source to perform the following steps:

      @@ -2601,8 +2602,9 @@

      The user aborts the payment request algorithm runs when the user aborts the payment - request through the currently interactive user interface. It MUST run - the following steps: + request through the currently interactive user interface. It MUST + queue a task on the user interaction task source to + perform the following steps:

      1. Let request be the PaymentRequest object that @@ -2617,17 +2619,10 @@

        further action. The user agent user interface should ensure that this never occurs.

      2. -
      3. - Queue a task on the user interaction task source to - perform the following steps: -
          -
        1. Set request.[[\state]] to "closed". -
        2. -
        3. Reject the promise - request.[[\acceptPromise]] with an - "AbortError" DOMException. -
        4. -
        +
      4. Set request.[[\state]] to "closed". +
      5. +
      6. Reject the promise request.[[\acceptPromise]] + with an "AbortError" DOMException.
      From 99d2f7d2ba620ea57e8c4dbe4aa970770516754f Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Thu, 30 Mar 2017 15:49:25 +0900 Subject: [PATCH 3/3] Disallow multiple showing payment requests per user agent Closes #462. --- index.html | 47 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index f890d2b8..e82c004b 100644 --- a/index.html +++ b/index.html @@ -236,6 +236,12 @@

      page to exchange information with the user agent while the user is providing input before approving or denying a payment request.

      +

      + The user agent as a whole has a single payment request is + showing boolean, initially false. This is used to prevent + multiple PaymentRequests from being shown, via their + show() method, at the same time. +

      The shippingAddress, shippingOption, and shippingType attributes are populated during processing if the @@ -602,14 +608,23 @@

      show() method

      -

      - The show() method is called when the page wants to begin user - interaction for the payment request. The show() method returns - a Promise that will be resolved when the user accepts the - payment request. Some kind of user interface will be presented to - the user to facilitate the payment request after the show() - method returns. -

      +
      +

      + The show() method is called when the page wants to begin + user interaction for the payment request. The show() method + returns a Promise that will be resolved when the user + accepts the payment request. Some kind of user interface will + be presented to the user to facilitate the payment request after + the show() method returns. +

      +

      + It is not possible to show multiple PaymentRequests at the + same time within one user agent. Calling show() if + another PaymentRequest is already showing, even due to some + other site, will return a promise rejected with an + "AbortError" DOMException. +

      +

      The show() method MUST act as follows:

      @@ -621,6 +636,10 @@

      then return a promise rejected with an "InvalidStateError" DOMException. +
    1. If the user agent's payment request is showing + boolean is true, then return a promise rejected with an + "AbortError" DOMException. +
    2. Set request.[[\state]] to "interactive".
    3. Let acceptPromise be a new Promise. @@ -649,6 +668,9 @@

      advantage of this step.

    4. +
    5. Set the user agent's payment request is showing + boolean to true. +
    6. Return acceptPromise and perform the remaining steps in parallel.
    7. @@ -666,7 +688,8 @@

    8. If this consultation produced no supported method of paying, then reject acceptPromise with a "NotSupportedError" - DOMException, and abort these steps. + DOMException, and set the user agent's payment + request is showing boolean to false.
    9. @@ -2589,6 +2612,9 @@

    10. Set request.[[\state]] to "closed".
    11. +
    12. Set the user agent's payment request is showing + boolean to false. +
    13. Resolve the pending promise request.[[\acceptPromise]] with response. @@ -2621,6 +2647,9 @@

    14. Set request.[[\state]] to "closed".
    15. +
    16. Set the user agent's payment request is showing + boolean to false. +
    17. Reject the promise request.[[\acceptPromise]] with an "AbortError" DOMException.