Skip to content

Introduce [[sharePromise]] internal slot #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 63 additions & 13 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,25 @@ <h3>
target</a>. Clients can use the presence or absence of this method to
determine whether to show UI that triggers its use.
</div>
<section>
<h4>
Internal Slots
</h4>
<p>
This API adds the following internal slot to the {{Navigator}}
interface.
</p>
<dl>
<dt>
{{Promise}}? <dfn>[[\sharePromise]]</dfn>
</dt>
<dd>
The {{[[sharePromise]]}} is a promise that represents a user's
current intent to share some data with a <a>share target</a>. It
is initialized to `null`.
</dd>
</dl>
</section>
<section>
<h4>
<dfn>share()</dfn> method
Expand All @@ -113,6 +132,9 @@ <h4>
|data:ShareData|, run the following steps:
</p>
<ol class="algorithm">
<li>If {{[[sharePromise]]}} is not `null`, return <a>a promise
rejected with</a> {{InvalidStateError}}.
</li>
<li>If none of |data|'s members {{ShareData/title}},
{{ShareData/text}}, or {{ShareData/url}} are present, return <a>a
promise rejected with</a> a {{TypeError}}.
Expand Down Expand Up @@ -140,32 +162,60 @@ <h4>
return <a>a promise rejected with</a> with a {{"NotAllowedError"}}
{{DOMException}}.
</li>
<li>Let |p:Promise| be <a>a new promise</a>.
<li>Set {{[[sharePromise]]}} to be <a>a new promise</a>.
</li>
<li>Return |p| and <a>in parallel</a>:
<li>Return {{[[sharePromise]]}} and <a>in parallel</a>:
<ol>
<li>If there are no <a>share targets</a> available,
<a>reject</a> |p| with an {{"AbortError"}} {{DOMException}},
and abort these steps.
<li>If there are no <a>share targets</a> available:
<ol>
<li>
<a>Reject</a> {{[[sharePromise]]}} with an
"{{AbortError}}" {{DOMException}}.
</li>
<li>Set {{[[sharePromise]]}} to `null`.
</li>
<li>Abort these steps.
</li>
</ol>
</li>
<li>Present the user with a choice of one or more <a>share
targets</a>, 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.
</li>
<li>If the user chose to cancel the share operation,
<a>reject</a> |p| with an {{"AbortError"}} {{DOMException}},
and abort these steps.
<li>If the user chose to cancel the share operation:
<ol>
<li>
<a>Reject</a> {{[[sharePromise]]}} with an
"{{AbortError}}" {{DOMException}},
</li>
<li>Set {{[[sharePromise]]}} to `null`.
</li>
<li>Abort these steps.
</li>
</ol>
</li>
<li>Activate the chosen <a>share target</a>, <a>convert |data|
to a format suitable for ingestion into the target</a>, and
transmit the converted data to the target. If an error occurs
starting the target or transmitting the data, <a>reject</a> |p|
with an {{"AbortError"}} {{DOMException}}, and abort these
steps.
transmit the converted data to the target.
</li>
<li>If an error occurs starting the target or transmitting the
data:
<ol>
<li>
<a>reject</a> {{[[sharePromise]]}} with an
"{{DataError}}" {{DOMException}}, and abort these steps.
</li>
<li>Set {{[[sharePromise]]}} to `null`.
</li>
<li>Abort these steps.
</li>
</ol>
</li>
<li>Once the data has been successfully transmitted to the
target, <a>resolve</a> |p| with <b>undefined</b>.
target, <a>resolve</a> {{[[sharePromise]]}} with `undefined`.
</li>
<li>Set {{[[sharePromise]]}} to `null`.
</li>
</ol>
</li>
Expand Down