From 214830c7600ef999d166c677b1993b0eedfeac2a Mon Sep 17 00:00:00 2001 From: Mark Foltz Date: Fri, 20 Sep 2024 11:52:19 -0700 Subject: [PATCH] Fix task queueing. (#524) * Fix task queueing * Convert more tasks * Address feedback from tidoust * Make further adjustments * Fix typo * Further adjust termiantion steps * Update algo to handle a termination confirmation --- index.html | 131 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 82 insertions(+), 49 deletions(-) diff --git a/index.html b/index.html index 1746c40..b1a8801 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', @@ -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]].

@@ -835,7 +836,14 @@

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 @@ -1104,16 +1112,16 @@

Then run the following steps:
  1. - Reject P with a {{NotFoundError}} - exception. + Queue a Presentation API 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 Presentation API 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. @@ -1175,6 +1183,8 @@

      +
    1. Run the following steps in parallel. +
    2. Let presentationUrls be the presentation request URLs of presentationRequest.
    3. @@ -1221,6 +1231,9 @@

        +
      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 @@ -1246,14 +1259,14 @@

      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 task to [=fire an event=] named connectionavailable, that uses the - PresentationConnectionAvailableEvent interface, with the - Queue a Presentation API 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. @@ -1313,8 +1326,8 @@

        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: @@ -1341,8 +1354,8 @@

          PresentationConnection.

        6. - 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. - Resolve P with newConnection. + Queue a Presentation API task to resolve + P with newConnection.
        9. - Queue a 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. - Reject P with a {{NotFoundError}} exception. + Queue a Presentation API task to reject + P with a {{NotFoundError}} exception.
      @@ -1620,8 +1635,8 @@

      then:
      1. - 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. @@ -1631,8 +1646,9 @@

        presentationRequest is not null, then:
        1. - 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. @@ -1657,7 +1673,8 @@

        4. - Resolve P with A. + Queue a Presentation API task to resolve + P with A.
        @@ -1674,6 +1691,9 @@

        steps:

          +
        1. + Assert: this is running in parallel. +
        2. Let availabilitySet be a shallow copy of the set of presentation availability objects.
        3. @@ -1741,8 +1761,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 Presentation API + task to run the following steps:
          1. Set A's value property to newAvailability. @@ -2025,6 +2045,9 @@

              +
            1. + Assert: this is running in parallel. +
            2. If the presentation connection state of presentationConnection is not connecting, then abort all @@ -2035,8 +2058,8 @@

              identifier of presentationConnection MUST be sent with this request.

            3. -
            4. If connection completes successfully, queue a 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. +
                2. If the state property of presentationConnection is not connected, abort these steps. @@ -2220,8 +2246,8 @@

              2. - Queue a task to [=fire an event|fire=] event at - presentationConnection. + Queue a Presentation API task to [=fire an event|fire=] + event at presentationConnection.

              @@ -2386,7 +2412,7 @@

              presentationConnection, then abort the remaining steps.

            6. - Queue a 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 connection is connected or connecting, - then queue a 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
              2. - 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.
              @@ -2535,10 +2563,10 @@

              the user interface and discard it.

            7. For each connection in - connectedControllers, queue a 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. @@ -2559,7 +2587,9 @@

              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 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
                    +
                  1. + Assert: this is running in parallel. +
                  2. If presentationId and I are not equal, refuse the connection and abort all remaining steps.
                  3. @@ -2920,9 +2953,9 @@

                    the set of presentation controllers.
                  4. If the presentation controllers promise is not - null, 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. @@ -2934,8 +2967,8 @@

                    the set of presentation controllers.
                  7. - Queue a task to [=fire an event=] named - Queue a Presentation API task to [=fire an event=] + named connectionavailable, that uses the PresentationConnectionAvailableEvent interface, with the