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:
+ - If {{[[sharePromise]]}} is not `null`, return a promise
+ rejected with {{InvalidStateError}}.
+
- 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}}.
- - Let |p:Promise| be a new promise.
+
- Set {{[[sharePromise]]}} to be a new promise.
- - Return |p| and in parallel:
+
- Return {{[[sharePromise]]}} and in parallel:
- - If there are no share targets available,
- reject |p| with an {{"AbortError"}} {{DOMException}},
- and abort these steps.
+
- If there are no share targets available:
+
+ -
+ Reject {{[[sharePromise]]}} with an
+ "{{AbortError}}" {{DOMException}}.
+
+ - Set {{[[sharePromise]]}} to `null`.
+
+ - Abort these steps.
+
+
- 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.
- - If the user chose to cancel the share operation,
- reject |p| with an {{"AbortError"}} {{DOMException}},
- and abort these steps.
+
- If the user chose to cancel the share operation:
+
+ -
+ Reject {{[[sharePromise]]}} with an
+ "{{AbortError}}" {{DOMException}},
+
+ - Set {{[[sharePromise]]}} to `null`.
+
+ - Abort these steps.
+
+
- 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.
+
+ - If an error occurs starting the target or transmitting the
+ data:
+
+ -
+ reject {{[[sharePromise]]}} with an
+ "{{DataError}}" {{DOMException}}, and abort these steps.
+
+ - Set {{[[sharePromise]]}} to `null`.
+
+ - Abort these steps.
+
+
- Once the data has been successfully transmitted to the
- target, resolve |p| with undefined.
+ target, resolve {{[[sharePromise]]}} with `undefined`.
+
+ - Set {{[[sharePromise]]}} to `null`.