From 76fed9830123ae32ac5a928e0fadee6d2b1f6c34 Mon Sep 17 00:00:00 2001 From: alancutter Date: Wed, 9 Nov 2022 13:54:01 +1100 Subject: [PATCH] Rewrite web app launch procedures in terms of the web-app-launch spec algorithm (#63) Fixes: WICG/web-app-launch#67 This updates 3 launch sites in manifest-incubations (note taking, protocol handlers and file handlers) to make use of the [=launch a web application with handling=] algorithm being added by: https://github.com/WICG/web-app-launch/pull/79/files Note that the removal of Launch queue and launch params from this spec is due to these concepts already existing in https://wicg.github.io/web-app-launch/#script-interfaces-to-app-launches. https://github.com/WICG/manifest-incubations/pull/63 --- index.html | 158 ++++++++++------------------------------------------- 1 file changed, 29 insertions(+), 129 deletions(-) diff --git a/index.html b/index.html index a50655d..6865142 100644 --- a/index.html +++ b/index.html @@ -281,10 +281,8 @@

  • If the type of |manifest|["note_taking"]["new_note_url"] is not [=URL=], return.
  • -
  • Let |browsing context:Browsing Context| be the result of creating - a new [=top-level browsing context=]. -
  • -
  • [=Navigate=] |browsing context| to resource +
  • Run the steps to [=launch a web application=] setting |manifest| + to |manifest| and |target URL| to |manifest|["note_taking"]["new_note_url"].
  • @@ -476,9 +474,14 @@

    When a protocol handler description protocol_handler having [=manifest=] manifest is invoked, it goes through the same steps used to [=invoke a - protocol handler=] defined in [=HTML=], where the user agent SHOULD - navigate to [=url=] and the appropriate browsing context is set to - a new top level browsing context. + protocol handler=] where the user agent, instead of [=navigating=] + to resultURL, SHOULD [=launch a web application=] + passing manifest and resultURL. +

    +

    + This should not invoke and alter [=invoke a protocol handler=] in + this way. The computation of resultURL should be + extracted out into a separate algorithm for general use.

    @@ -851,12 +854,17 @@

    1. [=list/for each=] |file| of |files|
        -
      1. Let |params:LaunchParams| be a new {{LaunchParams}} - with {{LaunchParams/files}} set to a {{FrozenArray}} with - a single element that is a {{FileSystemHandle}} - corresponding to |file|. + +
      2. Let |params:LaunchParams| be a new + + LaunchParams with + + files set to a {{FrozenArray}} with a single element + that is a {{FileSystemHandle}} corresponding to |file|.
      3. -
      4. [=launch a web app=] with |params|. +
      5. + Launch a web application with handling passing + |manifest| and |params|.
    2. @@ -864,12 +872,16 @@

    3. Else,
        -
      1. Let |params:LaunchParams| be a new {{LaunchParams}} with - {{LaunchParams/files}} set to a {{FrozenArray}} of - {{FileSystemHandle}}s that correspond to the file paths named - by |files|. +
      2. Let |params:LaunchParams| be a new + + LaunchParams with + + files set to a {{FrozenArray}} of {{FileSystemHandle}}s + that correspond to the file paths named by |files|.
      3. -
      4. [=launch a web app=] with |params|. +
      5. + Launch a web application with handling passing |manifest| + and |params|.
    4. @@ -1358,118 +1370,6 @@

      -
      -

      - Launch queue and launch params -

      -
      -

      - LaunchParams interface -

      -
      -          [Exposed=Window] interface LaunchParams {
      -            readonly attribute DOMString? targetURL;
      -            readonly attribute FrozenArray<FileSystemHandle> files;
      -          };
      -        
      -

      - {{LaunchParams/targetURL}} represents the [=URL=] of the launch which - MUST be [=manifest/within scope=] of the application. -

      -

      - For every |file handle:FileSystemHandle| in {{LaunchParams/files}}, - querying the file system permission with - {{FileSystemPermissionDescriptor/mode}} set to - {{FileSystemPermissionMode/"readwrite"}} MUST return - {{PermissionState/"granted"}}. -

      -
      -
      -

      - LaunchConsumer function -

      -
      -          callback LaunchConsumer = any (LaunchParams params);
      -        
      -
      -
      -

      - LaunchQueue interface -

      -
      -          partial interface Window {
      -            readonly attribute LaunchQueue launchQueue;
      -          };
      -
      -          [Exposed=Window] interface LaunchQueue {
      -            undefined setConsumer(LaunchConsumer consumer);
      -          };
      -        
      -

      - {{LaunchQueue}} has an unconsumed launch params which is a - [=list=] of {{LaunchParams}} that is initially empty. -

      -

      - {{LaunchQueue}} has an assigned launch consumer which is - initially null. -

      -
      -

      - setConsumer method -

      -

      - The {{LaunchQueue/setConsumer(consumer)}} method steps are: -

      -
        -
      1. Set the [=assigned launch consumer=] to |consumer|. -
      2. -
      3. [=list/For each=] |launch_params:LaunchParams| of [=unconsumed - launch params=]: -
          -
        1. Invoke |consumer| with |launch_params|. -
        2. -
        -
      4. -
      5. Set [=unconsumed launch params=] to the empty [=list=]. -
      6. -
      -
      -
      -
      -

      - Handling Web App Launches -

      -

      - The steps to launch a web app are given by the following - algorithm. The algorithm takes {{LaunchParams}} - |params:LaunchParams|. -

      -
        -
      1. If |params| is null, set |params| to a new {{LaunchParams}} with - {{LaunchParams/targetURL}} set to [=manifest/start_url=]. -
      2. -
      3. Create a new top level browsing context and navigate it to - |params.targetUrl|. -
      4. -
      5. Append |params| to the [=unconsumed launch params=] of the - launched document's {{Window.LaunchQueue}}. -
      6. -
      7. If the [=assigned launch consumer=] |consumer| is set: -
          -
        1. [=list/For each=] |launch_params:LaunchParams| of - [=unconsumed launch params=]: -
            -
          1. Invoke |consumer| with |launch_params|. -
          2. -
          -
        2. -
        3. Set [=unconsumed launch params=] to the empty list. -
        4. -
        -
      8. -
      -
      -