From 636fadd668a0682176cb992e3362ea1207cd85ca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcos=20C=C3=A1ceres?=
Date: Fri, 3 Sep 2021 14:07:45 +1000
Subject: [PATCH 1/2] Handle non-fully-active documents
---
index.html | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/index.html b/index.html
index 8cf299c..c1f7d75 100644
--- a/index.html
+++ b/index.html
@@ -172,8 +172,10 @@
|data:ShareData|, run the following steps:
- - If the [=current settings object=]'s [=environment settings
- object/responsible document=] is not [=allowed to use=]
+
- Let |document:Document| be the [=current settings object=]'s
+ [=environment settings object/responsible document=].
+
+ - If |document| is not allowed to use
"web-share", return [=a promise rejected with=] a
{{"NotAllowedError"}} {{DOMException}}.
@@ -188,14 +190,14 @@
- [=Consume user activation=] of |window|.
- - Let |base:URL| be [=this=]'s relevant settings object's
- [=environment settings object/API base URL=].
-
- - If [=validate share data=] with |data| and |base| returns
+
- If [=validate share data=] with |data| and |document| returns
false, then return [=a promise rejected with=] a {{TypeError}}.
- If |data|'s {{ShareData/url}} member is present:
+ - Let |base:URL| be [=this=]'s relevant settings
+ object's [=environment settings object/API base URL=].
+
- Let |url:URL| be the result of running the URL
parser on |data|'s {{ShareData/url}} with |base|.
@@ -302,7 +304,7 @@
- Return the result of [=validate share data=] with |data| and
[=this=]'s [=relevant settings object=]'s [=environment settings
- object/API base URL=].
+ object/responsible document=].
@@ -312,9 +314,13 @@
To validate share data with |data:ShareData| and
- |base:URL|, run the following steps:
+ |document:Document|, run the following steps. The algorithm runs in
+ the [=this=] context from where it is invoked (i.e. {{Navigator}}
+ instance):
+ - If |document| is not [=Document/fully active=], return false.
+
- If none of |data|'s members {{ShareData/title}},
{{ShareData/text}}, or {{ShareData/url}} or {{ShareData/files}} are
present, return false.
@@ -345,6 +351,9 @@
- If |data|'s {{ShareData/url}} member is present:
+ - Let |base:URL| be [=this=]'s relevant settings
+ object's [=environment settings object/API base URL=].
+
- Let |url:URL| be the result of running the [=URL parser=]
on |data|'s {{ShareData/url}} member, with |base|, and no
encoding override.
From 6884cce3b2fb4bb162ed64c24ef0e74f2c51197c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcos=20C=C3=A1ceres?=
Date: Thu, 9 Sep 2021 14:12:28 +1000
Subject: [PATCH 2/2] Do check earlier
---
index.html | 36 +++++++++++++++++-------------------
1 file changed, 17 insertions(+), 19 deletions(-)
diff --git a/index.html b/index.html
index c1f7d75..9187411 100644
--- a/index.html
+++ b/index.html
@@ -175,9 +175,13 @@
- Let |document:Document| be the [=current settings object=]'s
[=environment settings object/responsible document=].
- - If |document| is not allowed to use
- "web-share", return [=a promise rejected with=] a
- {{"NotAllowedError"}} {{DOMException}}.
+
- If |document| is not [=Document/fully active=], return [=a
+ promise rejected with=] an {{"InvalidStateError"}}
+ {{DOMException}}.
+
+ - If |document| is not allowed to use "web-share",
+ return [=a promise rejected with=] a {{"NotAllowedError"}}
+ {{DOMException}}.
- If [=this=].{{Navigator/[[sharePromise]]}} is not `null`,
return [=a promise rejected with=] an {{"InvalidStateError"}}
@@ -190,14 +194,14 @@
- [=Consume user activation=] of |window|.
- - If [=validate share data=] with |data| and |document| returns
+
- Let |base:URL| be [=this=]'s relevant settings object's
+ [=environment settings object/API base URL=].
+
+ - If [=validate share data=] with |data| and |base| returns
false, then return [=a promise rejected with=] a {{TypeError}}.
- If |data|'s {{ShareData/url}} member is present:
- - Let |base:URL| be [=this=]'s relevant settings
- object's [=environment settings object/API base URL=].
-
- Let |url:URL| be the result of running the URL
parser on |data|'s {{ShareData/url}} with |base|.
@@ -298,13 +302,14 @@
{{ShareData}} |data:ShareData|, run the following steps:
- - If the [=current settings object=]'s [=environment settings
- object/responsible document=] is not allowed to use
- "web-share", return false.
+
- Let |document:Document| be the [=current settings object=]'s
+ [=environment settings object/responsible document=].
+
+ - If |document| is not [=Document/fully active=], return false.
- Return the result of [=validate share data=] with |data| and
[=this=]'s [=relevant settings object=]'s [=environment settings
- object/responsible document=].
+ object/API base URL=].
@@ -314,13 +319,9 @@
To validate share data with |data:ShareData| and
- |document:Document|, run the following steps. The algorithm runs in
- the [=this=] context from where it is invoked (i.e. {{Navigator}}
- instance):
+ |base:URL|, run the following steps:
- - If |document| is not [=Document/fully active=], return false.
-
- If none of |data|'s members {{ShareData/title}},
{{ShareData/text}}, or {{ShareData/url}} or {{ShareData/files}} are
present, return false.
@@ -351,9 +352,6 @@
- If |data|'s {{ShareData/url}} member is present:
- - Let |base:URL| be [=this=]'s relevant settings
- object's [=environment settings object/API base URL=].
-
- Let |url:URL| be the result of running the [=URL parser=]
on |data|'s {{ShareData/url}} member, with |base|, and no
encoding override.