From f2a3126fad1cfc2f1a6f01ee2312c7b0a1b5b90d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Mon, 8 Jul 2019 12:07:40 +1000 Subject: [PATCH] Introduce [[sharePromise]] internal slot --- index.html | 76 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 13 deletions(-) diff --git a/index.html b/index.html index 663b545..d1ed982 100644 --- a/index.html +++ b/index.html @@ -104,6 +104,25 @@

target. Clients can use the presence or absence of this method to determine whether to show UI that triggers its use. +
+

+ Internal Slots +

+

+ This API adds the following internal slot to the {{Navigator}} + interface. +

+
+
+ {{Promise}}? [[\sharePromise]] +
+
+ The {{[[sharePromise]]}} is a promise that represents a user's + current intent to share some data with a share target. It + is initialized to `null`. +
+
+

share() method @@ -113,6 +132,9 @@

|data:ShareData|, run the following steps:

    +
  1. If {{[[sharePromise]]}} is not `null`, return a promise + rejected with {{InvalidStateError}}. +
  2. If none of |data|'s members {{ShareData/title}}, {{ShareData/text}}, or {{ShareData/url}} are present, return a promise rejected with a {{TypeError}}. @@ -140,32 +162,60 @@

    return a promise rejected with with a {{"NotAllowedError"}} {{DOMException}}.

  3. -
  4. Let |p:Promise| be a new promise. +
  5. Set {{[[sharePromise]]}} to be a new promise.
  6. -
  7. Return |p| and in parallel: +
  8. Return {{[[sharePromise]]}} and in parallel:
      -
    1. If there are no share targets available, - reject |p| with an {{"AbortError"}} {{DOMException}}, - and abort these steps. +
    2. If there are no share targets available: +
        +
      1. + Reject {{[[sharePromise]]}} with an + "{{AbortError}}" {{DOMException}}. +
      2. +
      3. Set {{[[sharePromise]]}} to `null`. +
      4. +
      5. Abort these steps. +
      6. +
    3. Present the user with a choice of one or more share targets, selected at the user agent's discretion. The user MUST be given the option to cancel rather than choosing any of the share targets. Wait for the user's choice.
    4. -
    5. If the user chose to cancel the share operation, - reject |p| with an {{"AbortError"}} {{DOMException}}, - and abort these steps. +
    6. If the user chose to cancel the share operation: +
        +
      1. + Reject {{[[sharePromise]]}} with an + "{{AbortError}}" {{DOMException}}, +
      2. +
      3. Set {{[[sharePromise]]}} to `null`. +
      4. +
      5. Abort these steps. +
      6. +
    7. Activate the chosen share target, convert |data| to a format suitable for ingestion into the target, and - transmit the converted data to the target. If an error occurs - starting the target or transmitting the data, reject |p| - with an {{"AbortError"}} {{DOMException}}, and abort these - steps. + transmit the converted data to the target. +
    8. +
    9. If an error occurs starting the target or transmitting the + data: +
        +
      1. + reject {{[[sharePromise]]}} with an + "{{DataError}}" {{DOMException}}, and abort these steps. +
      2. +
      3. Set {{[[sharePromise]]}} to `null`. +
      4. +
      5. Abort these steps. +
      6. +
    10. Once the data has been successfully transmitted to the - target, resolve |p| with undefined. + target, resolve {{[[sharePromise]]}} with `undefined`. +
    11. +
    12. Set {{[[sharePromise]]}} to `null`.