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:

    -
  1. If the [=current settings object=]'s [=environment settings - object/responsible document=] is not [=allowed to use=] +
  2. Let |document:Document| be the [=current settings object=]'s + [=environment settings object/responsible document=]. +
  3. +
  4. If |document| is not allowed to use "web-share", return [=a promise rejected with=] a {{"NotAllowedError"}} {{DOMException}}.
  5. @@ -188,14 +190,14 @@

  6. [=Consume user activation=] of |window|.
  7. -
  8. Let |base:URL| be [=this=]'s relevant settings object's - [=environment settings object/API base URL=]. -
  9. -
  10. If [=validate share data=] with |data| and |base| returns +
  11. If [=validate share data=] with |data| and |document| returns false, then return [=a promise rejected with=] a {{TypeError}}.
  12. If |data|'s {{ShareData/url}} member is present:
      +
    1. Let |base:URL| be [=this=]'s relevant settings + object's [=environment settings object/API base URL=]. +
    2. Let |url:URL| be the result of running the URL parser on |data|'s {{ShareData/url}} with |base|.
    3. @@ -302,7 +304,7 @@

    4. 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):

      +
    1. If |document| is not [=Document/fully active=], return false. +
    2. If none of |data|'s members {{ShareData/title}}, {{ShareData/text}}, or {{ShareData/url}} or {{ShareData/files}} are present, return false. @@ -345,6 +351,9 @@

    3. If |data|'s {{ShareData/url}} member is present:
        +
      1. Let |base:URL| be [=this=]'s relevant settings + object's [=environment settings object/API base URL=]. +
      2. 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 @@

      3. Let |document:Document| be the [=current settings object=]'s [=environment settings object/responsible document=].
      4. -
      5. If |document| is not allowed to use - "web-share", return [=a promise rejected with=] a - {{"NotAllowedError"}} {{DOMException}}. +
      6. If |document| is not [=Document/fully active=], return [=a + promise rejected with=] an {{"InvalidStateError"}} + {{DOMException}}. +
      7. +
      8. If |document| is not allowed to use "web-share", + return [=a promise rejected with=] a {{"NotAllowedError"}} + {{DOMException}}.
      9. If [=this=].{{Navigator/[[sharePromise]]}} is not `null`, return [=a promise rejected with=] an {{"InvalidStateError"}} @@ -190,14 +194,14 @@

      10. [=Consume user activation=] of |window|.
      11. -
      12. If [=validate share data=] with |data| and |document| returns +
      13. Let |base:URL| be [=this=]'s relevant settings object's + [=environment settings object/API base URL=]. +
      14. +
      15. If [=validate share data=] with |data| and |base| returns false, then return [=a promise rejected with=] a {{TypeError}}.
      16. If |data|'s {{ShareData/url}} member is present:
          -
        1. Let |base:URL| be [=this=]'s relevant settings - object's [=environment settings object/API base URL=]. -
        2. Let |url:URL| be the result of running the URL parser on |data|'s {{ShareData/url}} with |base|.
        3. @@ -298,13 +302,14 @@

          {{ShareData}} |data:ShareData|, run the following steps:

            -
          1. If the [=current settings object=]'s [=environment settings - object/responsible document=] is not allowed to use - "web-share", return false. +
          2. Let |document:Document| be the [=current settings object=]'s + [=environment settings object/responsible document=]. +
          3. +
          4. If |document| is not [=Document/fully active=], return false.
          5. 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:

            -
          1. If |document| is not [=Document/fully active=], return false. -
          2. If none of |data|'s members {{ShareData/title}}, {{ShareData/text}}, or {{ShareData/url}} or {{ShareData/files}} are present, return false. @@ -351,9 +352,6 @@

          3. If |data|'s {{ShareData/url}} member is present:
              -
            1. Let |base:URL| be [=this=]'s relevant settings - object's [=environment settings object/API base URL=]. -
            2. Let |url:URL| be the result of running the [=URL parser=] on |data|'s {{ShareData/url}} member, with |base|, and no encoding override.