From 8b604c0fc747fbceb4b8e9b8e2a8f5d46090e121 Mon Sep 17 00:00:00 2001 From: "mark a. foltz" Date: Sun, 15 Sep 2024 11:52:00 -0700 Subject: [PATCH 1/7] Fix task queueing --- index.html | 69 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/index.html b/index.html index 1746c40..c48635e 100644 --- a/index.html +++ b/index.html @@ -291,8 +291,9 @@

context of {{Promise}} objects are used as defined in [[!ECMASCRIPT]].

- The terms Accept-Language - and HTTP authentication are + The terms Accept-Language and + HTTP authentication are used as defined in [[!RFC9110]].

@@ -840,6 +841,10 @@

Unless otherwise specified, the JavaScript realm for script objects constructed by algorithm steps is the current realm. + Unless otherwise specified, all global tasks use the networking task source associated + with the global object of the + current realm.

@@ -1037,6 +1042,10 @@

Selecting a presentation display

+

+ The global tasks queued in these steps use the user interaction task source. +

When the start method is called, the @@ -1104,16 +1113,17 @@

Then run the following steps:
  1. - Reject P with a {{NotFoundError}} - exception. + Queue a global + task to reject P with a + {{NotFoundError}} exception.
  2. Abort all remaining steps.
-
  • If the user denies permission to use a display, reject - P with an {{NotAllowedError}} exception, and abort all - remaining steps. +
  • If the user denies permission to use a display, + queue a global task to reject P with an + {{NotAllowedError}} exception, and abort all remaining steps.
  • Otherwise, the user grants permission to use a display; let D be that display. @@ -1250,10 +1260,10 @@

    S.

  • - Queue a task to [=fire an event=] named connectionavailable, that uses the - PresentationConnectionAvailableEvent interface, with the - Queue a global task to [=fire an event=] named + connectionavailable, + that uses the PresentationConnectionAvailableEvent + interface, with the connection attribute initialized to S, at presentationRequest. The event must not bubble and must not be cancelable. @@ -1341,8 +1351,8 @@

    PresentationConnection.

  • - Resolve P with - existingConnection. + Queue a global task to resolve P + with existingConnection.
  • If the presentation connection state of existingConnection is presentations.
  • - Resolve P with newConnection. + Queue a global task to resolve P + with newConnection.
  • - Queue a task to [=fire an event=] named + Queue a global task to [=fire an event=] named connectionavailable, that uses the PresentationConnectionAvailableEvent interface, with @@ -1426,7 +1437,8 @@

  • - Reject P with a {{NotFoundError}} exception. + Queue a global task to reject P with a + {{NotFoundError}} exception.
  • @@ -1620,8 +1632,8 @@

    then:
    1. - Reject P with a {{NotSupportedError}} - exception. + Queue a global task to reject P with + a {{NotSupportedError}} exception.
    2. Abort all the remaining steps.
    3. @@ -1631,8 +1643,8 @@

      presentationRequest is not null, then:
      1. - Resolve P with the request's - presentation display availability. + Queue a global task to resolve P + with the request's presentation display availability.
      2. Abort all the remaining steps.
      3. @@ -1657,7 +1669,8 @@

      4. - Resolve P with A. + Queue a global task to resolve P with + A.
      @@ -2220,8 +2233,8 @@

  • - Queue a task to [=fire an event|fire=] event at - presentationConnection. + Queue a global task to [=fire an event|fire=] + event at presentationConnection.
  • @@ -2386,7 +2399,7 @@

    presentationConnection, then abort the remaining steps.
  • - Queue a task to run the following steps: + Queue a global task to run the following steps:
    1. If the presentation connection state of presentationConnection is not the set of presentation controllers.
    2. If the presentation controllers promise is not - null, resolve the presentation - controllers promise with the presentation controllers - monitor. + null, queue a global task to resolve + the presentation controllers promise with the + presentation controllers monitor.
    3. Abort all remaining steps.
    4. @@ -2934,7 +2947,7 @@

      the set of presentation controllers.
    5. - Queue a task to [=fire an event=] named + Queue a global task to [=fire an event=] named connectionavailable, that uses the PresentationConnectionAvailableEvent From e46541349d7d0751f2689ca3a67f2a313b5be377 Mon Sep 17 00:00:00 2001 From: "mark a. foltz" Date: Sun, 15 Sep 2024 12:06:58 -0700 Subject: [PATCH 2/7] Convert more tasks --- index.html | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index c48635e..5acb821 100644 --- a/index.html +++ b/index.html @@ -1113,9 +1113,8 @@

    Then run the following steps:
    1. - Queue a global - task to reject P with a - {{NotFoundError}} exception. + Queue a global task to reject P with + a {{NotFoundError}} exception.
    2. Abort all remaining steps.
    3. @@ -1754,8 +1753,8 @@

      newAvailability and skip the following step.
    4. If previousAvailability is not equal to - newAvailability, then queue a task to run the - following steps: + newAvailability, then queue a global task to + run the following steps:
      1. Set A's value property to newAvailability. @@ -2048,8 +2047,8 @@

        identifier of presentationConnection MUST be sent with this request.

      2. -
      3. If connection completes successfully, queue a task to - run the following steps: +
      4. If connection completes successfully, queue a global + task to run the following steps:
        1. Set the presentation connection state of presentationConnection to connection is connected or connecting, - then queue a task to run the following steps: + then queue a global task to run the following steps:
          1. Set the presentation connection state of known connection to the user interface and discard it.
          2. For each connection in - connectedControllers, queue a task to send a - termination confirmation for P using an implementation + connectedControllers, queue a global task to send + a termination confirmation for P using an implementation specific mechanism to the controlling user agent that owns the destination browsing context for connection.

            @@ -2572,7 +2571,7 @@

            1. For each connection in the set of controlled presentations that was connected to P, queue a - task to run the following steps: + global task to run the following steps:
              1. If the presentation connection state of connection is not Date: Mon, 16 Sep 2024 12:39:38 -0700 Subject: [PATCH 3/7] Address feedback from tidoust --- index.html | 117 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 71 insertions(+), 46 deletions(-) diff --git a/index.html b/index.html index 5acb821..1c0c5f4 100644 --- a/index.html +++ b/index.html @@ -836,15 +836,18 @@

                The task source for the tasks mentioned in this specification - is the presentation task source. + is the presentation task source. +

                +

                + When an algorithm queues + a Presentation API task T, the user agent + MUST queue a global task T on the presentation + task source using the global + object of the current realm.

                Unless otherwise specified, the JavaScript realm for script objects constructed by algorithm steps is the current realm. - Unless otherwise specified, all global tasks use the networking task source associated - with the global object of the - current realm.

                @@ -1042,10 +1045,6 @@

                Selecting a presentation display

                -

                - The global tasks queued in these steps use the user interaction task source. -

                When the start method is called, the @@ -1113,15 +1112,15 @@

              Then run the following steps:
              1. - Queue a global task to reject P with - a {{NotFoundError}} exception. + Queue a Presentation API task to reject + P with a {{NotFoundError}} exception.
              2. Abort all remaining steps.
            2. If the user denies permission to use a display, - queue a global task to reject P with an + queue a Presentation API task to reject P with an {{NotAllowedError}} exception, and abort all remaining steps.
            3. Otherwise, the user grants permission to use a @@ -1230,6 +1229,10 @@

                +
              1. + Assert: this is running in + parallel. +
              2. Let I be a new valid presentation identifier unique among all presentation identifiers for known presentation connections in the set of controlled @@ -1255,11 +1258,11 @@

              3. Add S to the set of controlled presentations.
              4. -
              5. If P is provided, resolve P with - S. +
              6. If P is provided, queue a Presentation API + task to resolve P with S.
              7. - Queue a global task to [=fire an event=] named + Queue a Presentation API task to [=fire an event=] named connectionavailable, that uses the PresentationConnectionAvailableEvent interface, with the
                1. Let P be a new {{Promise}}.
                2. -
                3. Return P, but continue running these steps in - parallel. +
                4. Return P, but continue running these steps in + parallel.
                5. Search the set of controlled presentations for a PresentationConnection that meets the following criteria: @@ -1350,8 +1353,8 @@

                  PresentationConnection.

                6. - Queue a global task to resolve P - with existingConnection. + Queue a Presentation API task to resolve + P with existingConnection.
                7. If the presentation connection state of existingConnection is presentations.
                8. - Queue a global task to resolve P - with newConnection. + Queue a Presentation API task to resolve + P with newConnection.
                9. - Queue a global task to [=fire an event=] named - Queue a Presentation API task to [=fire an event=] + named connectionavailable, that uses the PresentationConnectionAvailableEvent interface, with the
              8. - Queue a global task to reject P with a - {{NotFoundError}} exception. + Queue a Presentation API task to reject + P with a {{NotFoundError}} exception.
              @@ -1631,8 +1634,8 @@

              then:
              1. - Queue a global task to reject P with - a {{NotSupportedError}} exception. + Queue a Presentation API task to reject + P with a {{NotSupportedError}} exception.
              2. Abort all the remaining steps.
              3. @@ -1642,8 +1645,9 @@

                presentationRequest is not null, then:
                1. - Queue a global task to resolve P - with the request's presentation display availability. + Queue a Presentation API task to resolve + P with the request's presentation display + availability.
                2. Abort all the remaining steps.
                3. @@ -1668,8 +1672,8 @@

                4. - Queue a global task to resolve P with - A. + Queue a Presentation API task to resolve + P with A.
                @@ -1686,6 +1690,10 @@

                steps:

                  +
                1. + Assert: this is running in + parallel. +
                2. Let availabilitySet be a shallow copy of the set of presentation availability objects.
                3. @@ -1753,8 +1761,8 @@

                  newAvailability and skip the following step.
                4. If previousAvailability is not equal to - newAvailability, then queue a global task to - run the following steps: + newAvailability, then queue a Presentation API + task to run the following steps:
                  1. Set A's value property to newAvailability. @@ -2037,6 +2045,10 @@

                      +
                    1. + Assert: this is running in + parallel. +
                    2. If the presentation connection state of presentationConnection is not connecting, then abort all @@ -2203,6 +2215,10 @@

                        +
                      1. + Assert: this is running in + parallel. +
                      2. If the state property of presentationConnection is not connected, abort these steps. @@ -2232,7 +2248,7 @@

                    3. - Queue a global task to [=fire an event|fire=] + Queue a Presentation API task to [=fire an event|fire=] event at presentationConnection.
                    @@ -2398,7 +2414,7 @@

                    presentationConnection, then abort the remaining steps.

                  2. - Queue a global task to run the following steps: + Queue a Presentation API task to run the following steps:
                    1. If the presentation connection state of presentationConnection is not MUST run the following steps:

                        +
                      1. + Assert: this is running in + parallel. +
                      2. If the presentation connection state of connection is not connected or connection is connected or connecting, - then queue a global task to run the following steps: + then queue a Presentation API task to run the + following steps:
                        1. Set the presentation connection state of known connection to the user interface and discard it.
                        2. For each connection in - connectedControllers, queue a global task to send - a termination confirmation for P using an implementation - specific mechanism to the controlling user agent that owns - the destination browsing context for connection. + connectedControllers, send a termination confirmation + for P using an implementation specific mechanism to the + controlling user agent that owns the destination browsing + context for connection.

                          Only one termination confirmation needs to be sent per controlling user agent. @@ -2571,7 +2592,7 @@

                          1. For each connection in the set of controlled presentations that was connected to P, queue a - global task to run the following steps: + Presentation API task to run the following steps:
                            1. If the presentation connection state of connection is not
                                +
                              1. + Assert: this is running in + parallel. +
                              2. If presentationId and I are not equal, refuse the connection and abort all remaining steps.
                              3. @@ -2932,9 +2957,9 @@

                                the set of presentation controllers.
                              4. If the presentation controllers promise is not - null, queue a global task to resolve - the presentation controllers promise with the - presentation controllers monitor. + null, queue a Presentation API task to + resolve the presentation controllers promise with + the presentation controllers monitor.
                              5. Abort all remaining steps.
                              6. @@ -2946,8 +2971,8 @@

                                the set of presentation controllers.
                              7. - Queue a global task to [=fire an event=] named - queue a Presentation API task to [=fire an event=] + named connectionavailable, that uses the PresentationConnectionAvailableEvent interface, with the Date: Tue, 17 Sep 2024 17:36:37 -0700 Subject: [PATCH 4/7] Make further adjustments --- index.html | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/index.html b/index.html index 1c0c5f4..cbd8c47 100644 --- a/index.html +++ b/index.html @@ -49,7 +49,7 @@ sotdAfterWGinfo: true, group: 'secondscreen', github: 'https://github.com/w3c/presentation-api', - xref: ['dom', 'fileapi', 'secure-contexts', 'html', 'url', 'webidl', 'webrtc', 'websockets'], + xref: ['dom', 'fileapi', 'secure-contexts', 'html', 'url', 'webidl', 'webrtc', 'websockets', 'infra'], localBiblio: { DIAL: { title: 'DIscovery And Launch Protocol Specification', @@ -842,8 +842,8 @@

                                When an algorithm queues a Presentation API task T, the user agent MUST queue a global task T on the presentation - task source using the global - object of the current realm. + task source using the global object of the current + realm.

                                Unless otherwise specified, the JavaScript realm for script @@ -1183,6 +1183,8 @@

                                  +
                                1. Run the following steps in parallel +
                                2. .
                                3. Let presentationUrls be the presentation request URLs of presentationRequest.
                                4. @@ -1230,8 +1232,7 @@

                                  1. - Assert: this is running in - parallel. + Assert: this is running in parallel.
                                  2. Let I be a new valid presentation identifier unique among all presentation identifiers for known @@ -1691,8 +1692,7 @@

                                    1. - Assert: this is running in - parallel. + Assert: this is running in parallel.
                                    2. Let availabilitySet be a shallow copy of the set of presentation availability objects. @@ -2046,8 +2046,7 @@

                                      1. - Assert: this is running in - parallel. + Assert: this is running in parallel.
                                      2. If the presentation connection state of presentationConnection is not identifier of presentationConnection MUST be sent with this request.
                                      3. -
                                      4. If connection completes successfully, queue a global - task to run the following steps: +
                                      5. If connection completes successfully, queue a Presentation + API task to run the following steps:
                                        1. Set the presentation connection state of presentationConnection to
                                          1. - Assert: this is running in - parallel. + Assert: this is running in parallel.
                                          2. If the state property of presentationConnection is not

                                            1. - Assert: this is running in - parallel. + Assert: this is running in parallel.
                                            2. If the presentation connection state of connection is not
                                          3. - Send a termination request for the presentation to its - receiving user agent using an implementation specific - mechanism. + In parallel, send a termination request for the + presentation to its receiving user agent using an + implementation specific mechanism.
                                          @@ -2917,8 +2914,7 @@

                                          1. - Assert: this is running in - parallel. + Assert: this is running in parallel.
                                          2. If presentationId and I are not equal, refuse the connection and abort all remaining steps. @@ -2971,7 +2967,7 @@

                                            the set of presentation controllers.

                                          3. - queue a Presentation API task to [=fire an event=] + Queue a Presentation API task to [=fire an event=] named connectionavailable, that uses the PresentationConnectionAvailableEvent From 55cbd00bcbe71bed1072ee74b08952e25546aa50 Mon Sep 17 00:00:00 2001 From: "mark a. foltz" Date: Tue, 17 Sep 2024 17:44:36 -0700 Subject: [PATCH 5/7] Fix typo --- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index cbd8c47..f447c10 100644 --- a/index.html +++ b/index.html @@ -1183,8 +1183,8 @@

                                              -
                                            1. Run the following steps in parallel -
                                            2. . +
                                            3. Run the following steps in parallel. +
                                            4. Let presentationUrls be the presentation request URLs of presentationRequest.
                                            5. From 68b0f72df0e879abba3390558109aed99ea2bbf5 Mon Sep 17 00:00:00 2001 From: "mark a. foltz" Date: Wed, 18 Sep 2024 09:57:33 -0700 Subject: [PATCH 6/7] Further adjust termiantion steps --- index.html | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index f447c10..0e11c96 100644 --- a/index.html +++ b/index.html @@ -2463,9 +2463,6 @@

                                              MUST run the following steps:

                                                -
                                              1. - Assert: this is running in parallel. -
                                              2. If the presentation connection state of connection is not connected or connection is connected or connecting, - then queue a Presentation API task to run the - following steps: + then queue a global task on the presentation task + source given known connection's relevant + global object to run the following steps:
                                                1. Set the presentation connection state of known connection to Date: Thu, 19 Sep 2024 11:30:53 -0700 Subject: [PATCH 7/7] Update algo to handle a termination confirmation --- index.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 0e11c96..b1a8801 100644 --- a/index.html +++ b/index.html @@ -2587,7 +2587,9 @@

                                                  1. For each connection in the set of controlled presentations that was connected to P, queue a - Presentation API task to run the following steps: + global task on the presentation task source given + connection's relevant global object to run the + following steps:
                                                    1. If the presentation connection state of connection is not