From 99ae3446d56c476e9a7faede3aa2911f5b4f06c1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcos=20C=C3=A1ceres?=
- Note that a
+ Note that a url of
- In response to this call to
+ In response to this call to navigator.share(), the user agent
+ would display a picker or chooser dialog, allowing the user to select a
+ target to share this title and the page URL to.
- The
- User agents that do not support sharing SHOULD NOT expose
- When the share method is called with argument
+ When the share() method is called with argument
data, run the following steps:
.then(console.log('Share successful'));
});
-
url
of ''
- refers to the current page URL, just as it would in a link. Any other
- absolute or relative URL can also be used.
+ ''
refers to the current page
+ URL, just as it would in a link. Any other absolute or relative URL can
+ also be used.
navigator.share
, the
- user agent would display a picker or chooser dialog, allowing the user
- to select a target to share this title and the page URL to.
+
API definition
-
Navigator
interface
Navigator
- interface is defined in [[!HTML]].
+ The Navigator interface is
+ defined in [[!HTML]].
partial interface Navigator {
@@ -95,8 +95,7 @@
share
will
- throw a share() will throw a TypeError
if called
with no arguments. WebIDL mandates that it be optional because the
@@ -104,39 +103,36 @@
"https://github.com/heycam/webidl/issues/130">Issue #130.
share
on the
- Navigator
interface.
+ User agents that do not support sharing SHOULD NOT expose
+ share() on the Navigator interface.
share
is present, there is a
- reasonable expectation that it will work and present the user with at
- least one share target. Clients can use the presence or
- absence of this method to determine whether to show UI that triggers
- its use.
+ share() is present, there is a reasonable expectation that it
+ will work and present the user with at least one share target.
+ Clients can use the presence or absence of this method to determine
+ whether to show UI that triggers its use.
-
share
method
+ share() method
TypeError
, and
- abort these steps.
+ TypeError
, and
+ abort these steps.
and abort these steps.
targets are available, or the identity of the chosen target.
share
always shows some form of
- UI, to give the user a choice of application and get their approval
- to invoke and send data to a potentially native application (which
- carries a security risk). For this reason, user agents are
- prohibited from showing any kind of "always use this target in the
- future" option, or bypassing the UI if there is only a single share
- target.
+ share() always shows some form of UI, to give the user a
+ choice of application and get their approval to invoke and send
+ data to a potentially native application (which carries a security
+ risk). For this reason, user agents are prohibited from showing any
+ kind of "always use this target in the future" option, or bypassing
+ the UI if there is only a single share target.
ShareData
dictionary
The ShareData dictionary consists of several optional - fields: + members:
Each share target MAY be made conditionally available depending on the - ShareData payload delivered to the share - method. + ShareData payload delivered to the share() method.
+
Mapping the ShareData to the share target (or operating system)'s native format can be tricky as some platforms will not have an equivalent set of fields. For example, if the target has a "text" field but not a "URL" field, one solution is to concatenate both the - text and url fields of - ShareData and pass the result in the "text" field of the - target. + text and url fields of ShareData and pass the + result in the "text" field of the target.
navigator.share
, because this information could be
- used for fingerprinting, as well as leaking details about the user's
- device.
+ are installed, or which app was chosen from navigator.share(),
+ because this information could be used for fingerprinting, as well as
+ leaking details about the user's device.
navigator.share
@@ -413,12 +405,11 @@
- The three members title, text, and url, are part of the
- base feature set, and implementations that provide
-
+ The three members title, text, and url, are part
+ of the base feature set, and implementations that provide
+ navigator.share() need to accept all three. Any new members that
+ are added in the future will be individually
feature-detectable, to allow for backwards-compatibility with
older implementations that don't recognise those members. These new
members might also be added as optional "MAY" requirements.
@@ -428,9 +419,8 @@
- The
- The Navigator interface is
- defined in [[!HTML]].
+ The
When the share() method is called with argument
- data, run the following steps:
+ ShareData data, run the following steps:
+
In response to this call to navigator.share(), the user agent
would display a picker or chooser dialog, allowing the user to select a
target to share this title and the page URL to.
From ecd0108ce9ea5dd3b5e21ac05532d48fd5385816 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcos=20C=C3=A1ceres?=
When the share() method is called with argument
- ShareData data, run the following steps:
+ data, run the following steps:
+ The following are defined in [[!WEBIDL]]:
+
- The share() method throws a
Editors of this spec will want to carefully consider the genericity of
From 9fda45d9c505abc84143f48754dd314e234b5ede Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcos=20C=C3=A1ceres?=
+
navigator.share
need to accept all three. Any new
- members that are added in the future will be individually
+
discussion about how to provide feature-detection for dictionary
members. Web Share will use the mechanism produced by that discussion.
-
share
method throws a
-
+ The share() method throws a TypeError
if none of
the specified members are present. The intention is that when a new
member is added, it will also be added to this list of recognised
From 067b8782e6d793d14349298c239f7c2573e11f0f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcos=20C=C3=A1ceres?=
Navigator
interface
Navigator
+ interface is defined in [[!HTML]].
partial interface Navigator {
@@ -119,20 +119,19 @@
+
TypeError
, and
- abort these steps.
+ TypeError
, and
+ abort these steps.
-
+
+
USVString
(as opposed to
@@ -358,23 +365,23 @@
leaking details about the user's device.
navigator.share
- is rejected. Even distinguishing between the case where no targets are
+ revealed in the error message when navigator.share() is
+ rejected. Even distinguishing between the case where no targets are
available and user cancellation could reveal information about which
apps are installed on the user's device.
navigator.share
- presents the user with a dialog asking them to select a target
- application (even if there is only one possible target). This surface
- serves as a security confirmation, ensuring that websites cannot
- silently send data to native applications.
+ navigator.share
is navigator.share() is available only in secure
contexts (such as https://
schemes).
navigator.share
from a Use of navigator.share() from a private browsing mode
might leak private data to a third-party application that does not
respect the user's privacy setting. User agents could present
@@ -382,11 +389,11 @@
browsing mode, but this is not mandated as the chooser UI could be
considered sufficient warning.
navigator.share
might be
- used to exploit buffer overflow or other remote code execution
- vulnerabilities in native applications that receive shares. There is no
- general way to guard against this, but implementors will want to be
- aware that it is a possibility.
+
navigator.share() need to accept all three. Any new members that
are added in the future will be individually
feature-detectable, to allow for backwards-compatibility with
- older implementations that don't recognise those members. These new
+ older implementations that don't recognize those members. These new
members might also be added as optional "MAY" requirements.
The share() method throws a
TypeError
if none of
the specified members are present. The intention is that when a new
- member is added, it will also be added to this list of recognised
+ member is added, it will also be added to this list of recognized
members (so as to not throw an error). This is for future-proofing
implementations: if a web site written against a future version of this
spec uses only new members (e.g.,
From 6f08f69929d932d0ab3ff9b8ca235236bcc7d0b9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcos=20C=C3=A1ceres?=
URL, just as it would in a link. Any other absolute or relative URL can
also be used.
-
TypeError
if called
- with no arguments. WebIDL share() will throw a TypeError if
+ called with no arguments. WebIDL mandates that it be optional because the
dictionary members are all optional. See WebIDL Issue #130.
@@ -126,9 +125,8 @@
"!promises-guide#a-new-promise">a new promise.
TypeError
, and
- abort these steps.
+ or url are present, reject p with
+ TypeError, and abort these steps.
TypeError
,
- and abort these steps.
+ TypeError, and abort these steps.
NotAllowedError
, and
- abort these steps.
+ "!promises-guide#reject-promise">reject p with a
+ "NotAllowedError" DOMException, and abort these steps.
AbortError
, and abort
- these steps.
+ p with "AbortError" DOMException, and
+ abort these steps.
AbortError
, and abort
- these steps.
+ p with "AbortError" DOMException, and
+ abort these steps.
AbortError
, and abort
- these steps.
+ p with "AbortError" DOMException, and
+ abort these steps.
+ Dependencies
+
+
+
+ TypeError
+ DOMException
+ AbortError
+ NotAllowedError
.
+
Security and privacy considerations
@@ -427,19 +443,16 @@
members. Web Share will use the mechanism produced by that discussion.
TypeError
if none of
- the specified members are present. The intention is that when a new
- member is added, it will also be added to this list of recognized
- members (so as to not throw an error). This is for future-proofing
- implementations: if a web site written against a future version of this
- spec uses only new members (e.g.,
- navigator.share({image: x})
), it will be valid in future
- user agents, but a TypeError
on user
- agents implementing an older version of the spec. Developers will be
- asked to feature-detect any new fields they rely on, to avoid having
- errors surface in their program.
+ The share() method throws a TypeError if none of the
+ specified members are present. The intention is that when a new member
+ is added, it will also be added to this list of recognized members (so
+ as to not throw an error). This is for future-proofing implementations:
+ if a web site written against a future version of this spec uses
+ only new members (e.g., navigator.share({image:
+ x})
), it will be valid in future user agents, but a
+ TypeError on user agents implementing an older version of the
+ spec. Developers will be asked to feature-detect any new fields they
+ rely on, to avoid having errors surface in their program.
"!HTML#triggered-by-user-activation">triggered by user
activation
target
, and transmit the converted data to the target. If
an error occurs starting the target or transmitting the data,
reject
- p with "AbortError" DOMException, and
+ p with an "AbortError" DOMException, and
abort these steps.
The following are defined in [[!WEBIDL]]:
-
+ TypeError
- DOMException
@@ -360,9 +357,14 @@
NotAllowedError
.
+ "!WEBIDL#notallowederror">NotAllowedError
TypeError
+ is defined by [[!ECMA-262]].
+
From 69353aea5fc923947ed3bd0847e02a21d5a256e1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcos=20C=C3=A1ceres?=
The ShareData dictionary consists of several optional
members:
-
+
TypeError
- is defined by [[!ECMA-262]].
+ "!ECMASCRIPT#sec-native-error-types-used-in-this-standard-typeerror">TypeError
+ is defined by [[!ECMASCRIPT]].
dictionary ShareData {
- USVString text;
USVString title;
+ USVString text;
USVString url;
};