Skip to content

Commit 214830c

Browse files
authored
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
1 parent 74d1a41 commit 214830c

File tree

1 file changed

+82
-49
lines changed

1 file changed

+82
-49
lines changed

index.html

+82-49
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
sotdAfterWGinfo: true,
5050
group: 'secondscreen',
5151
github: 'https://github.com/w3c/presentation-api',
52-
xref: ['dom', 'fileapi', 'secure-contexts', 'html', 'url', 'webidl', 'webrtc', 'websockets'],
52+
xref: ['dom', 'fileapi', 'secure-contexts', 'html', 'url', 'webidl', 'webrtc', 'websockets', 'infra'],
5353
localBiblio: {
5454
DIAL: {
5555
title: 'DIscovery And Launch Protocol Specification',
@@ -291,8 +291,9 @@ <h2>
291291
context of {{Promise}} objects are used as defined in [[!ECMASCRIPT]].
292292
</p>
293293
<p>
294-
The terms <dfn data-cite="rfc9110#field.accept-language">Accept-Language</dfn>
295-
and <dfn data-cite="rfc9110#authentication">HTTP authentication</dfn> are
294+
The terms <dfn data-cite=
295+
"rfc9110#field.accept-language">Accept-Language</dfn> and
296+
<dfn data-cite="rfc9110#authentication">HTTP authentication</dfn> are
296297
used as defined in [[!RFC9110]].
297298
</p>
298299
<p>
@@ -835,7 +836,14 @@ <h3>
835836
</p>
836837
<p>
837838
The <a>task source</a> for the tasks mentioned in this specification
838-
is the <var>presentation task source</var>.
839+
is the <dfn>presentation task source</dfn>.
840+
</p>
841+
<p>
842+
When an algorithm <dfn data-lt="queue a Presentation API task">queues
843+
a Presentation API task</dfn> <var>T</var>, the <a>user agent</a>
844+
MUST <a>queue a global task</a> <var>T</var> on the <a>presentation
845+
task source</a> using the <a>global object</a> of the <a>current
846+
realm</a>.
839847
</p>
840848
<p>
841849
Unless otherwise specified, the <a>JavaScript realm</a> for script
@@ -1104,16 +1112,16 @@ <h4>
11041112
</ol>Then run the following steps:
11051113
<ol>
11061114
<li>
1107-
<a>Reject</a> <var>P</var> with a {{NotFoundError}}
1108-
exception.
1115+
<a>Queue a Presentation API task</a> to <a>reject</a>
1116+
<var>P</var> with a {{NotFoundError}} exception.
11091117
</li>
11101118
<li>Abort all remaining steps.
11111119
</li>
11121120
</ol>
11131121
</li>
1114-
<li>If the user <em>denies permission</em> to use a display, reject
1115-
<var>P</var> with an {{NotAllowedError}} exception, and abort all
1116-
remaining steps.
1122+
<li>If the user <em>denies permission</em> to use a display,
1123+
<a>queue a Presentation API task</a> to reject <var>P</var> with an
1124+
{{NotAllowedError}} exception, and abort all remaining steps.
11171125
</li>
11181126
<li>Otherwise, the user <em>grants permission</em> to use a
11191127
display; let <var>D</var> be that display.
@@ -1175,6 +1183,8 @@ <h4>
11751183
</dd>
11761184
</dl>
11771185
<ol>
1186+
<li>Run the following steps <a>in parallel</a>.
1187+
</li>
11781188
<li>Let <var>presentationUrls</var> be the <a>presentation request
11791189
URLs</a> of <var>presentationRequest</var>.
11801190
</li>
@@ -1221,6 +1231,9 @@ <h4>
12211231
</dd>
12221232
</dl>
12231233
<ol>
1234+
<li>
1235+
<a>Assert</a>: this is running <a>in parallel</a>.
1236+
</li>
12241237
<li>Let <var>I</var> be a new <a>valid presentation identifier</a>
12251238
unique among all <a>presentation identifiers</a> for known
12261239
<a>presentation connections</a> in the <a>set of controlled
@@ -1246,14 +1259,14 @@ <h4>
12461259
</li>
12471260
<li>Add <var>S</var> to the <a>set of controlled presentations</a>.
12481261
</li>
1249-
<li>If <var>P</var> is provided, <a>resolve</a> <var>P</var> with
1250-
<var>S</var>.
1262+
<li>If <var>P</var> is provided, <a>queue a Presentation API
1263+
task</a> to <a>resolve</a> <var>P</var> with <var>S</var>.
12511264
</li>
12521265
<li>
1253-
<a>Queue a task</a> to [=fire an event=] named <a data-link-for=
1254-
"PresentationRequest">connectionavailable</a>, that uses the
1255-
<a>PresentationConnectionAvailableEvent</a> interface, with the
1256-
<a data-link-for=
1266+
<a>Queue a Presentation API task</a> to [=fire an event=] named
1267+
<a data-link-for="PresentationRequest">connectionavailable</a>,
1268+
that uses the <a>PresentationConnectionAvailableEvent</a>
1269+
interface, with the <a data-link-for=
12571270
"PresentationConnectionAvailableEvent">connection</a> attribute
12581271
initialized to <var>S</var>, at <var>presentationRequest</var>.
12591272
The event must not bubble and must not be cancelable.
@@ -1313,8 +1326,8 @@ <h4>
13131326
<ol>
13141327
<li>Let <var>P</var> be a new {{Promise}}.
13151328
</li>
1316-
<li>Return <var>P</var>, but continue running these steps in
1317-
parallel.
1329+
<li>Return <var>P</var>, but continue running these steps <a>in
1330+
parallel</a>.
13181331
</li>
13191332
<li>Search the <a>set of controlled presentations</a> for a
13201333
<a>PresentationConnection</a> that meets the following criteria:
@@ -1341,8 +1354,8 @@ <h4>
13411354
<a>PresentationConnection</a>.
13421355
</li>
13431356
<li>
1344-
<a>Resolve</a> <var>P</var> with
1345-
<var>existingConnection</var>.
1357+
<a>Queue a Presentation API task</a> to <a>resolve</a>
1358+
<var>P</var> with <var>existingConnection</var>.
13461359
</li>
13471360
<li>If the <a>presentation connection state</a> of
13481361
<var>existingConnection</var> is <a data-link-for=
@@ -1404,11 +1417,12 @@ <h4>
14041417
presentations</a>.
14051418
</li>
14061419
<li>
1407-
<a>Resolve</a> <var>P</var> with <var>newConnection</var>.
1420+
<a>Queue a Presentation API task</a> to <a>resolve</a>
1421+
<var>P</var> with <var>newConnection</var>.
14081422
</li>
14091423
<li>
1410-
<a>Queue a task</a> to [=fire an event=] named
1411-
<a data-link-for=
1424+
<a>Queue a Presentation API task</a> to [=fire an event=]
1425+
named <a data-link-for=
14121426
"PresentationRequest">connectionavailable</a>, that uses the
14131427
<a>PresentationConnectionAvailableEvent</a> interface, with
14141428
the <a data-link-for=
@@ -1426,7 +1440,8 @@ <h4>
14261440
</ol>
14271441
</li>
14281442
<li>
1429-
<a>Reject</a> <var>P</var> with a {{NotFoundError}} exception.
1443+
<a>Queue a Presentation API task</a> to <a>reject</a>
1444+
<var>P</var> with a {{NotFoundError}} exception.
14301445
</li>
14311446
</ol>
14321447
</section>
@@ -1620,8 +1635,8 @@ <h4>
16201635
then:
16211636
<ol>
16221637
<li>
1623-
<a>Reject</a> <var>P</var> with a {{NotSupportedError}}
1624-
exception.
1638+
<a>Queue a Presentation API task</a> to <a>reject</a>
1639+
<var>P</var> with a {{NotSupportedError}} exception.
16251640
</li>
16261641
<li>Abort all the remaining steps.
16271642
</li>
@@ -1631,8 +1646,9 @@ <h4>
16311646
<var>presentationRequest</var> is not <code>null</code>, then:
16321647
<ol>
16331648
<li>
1634-
<a>Resolve</a> <var>P</var> with the request's
1635-
<a>presentation display availability</a>.
1649+
<a>Queue a Presentation API task</a> to <a>resolve</a>
1650+
<var>P</var> with the request's <a>presentation display
1651+
availability</a>.
16361652
</li>
16371653
<li>Abort all the remaining steps.
16381654
</li>
@@ -1657,7 +1673,8 @@ <h4>
16571673
</div>
16581674
</li>
16591675
<li>
1660-
<a>Resolve</a> <var>P</var> with <var>A</var>.
1676+
<a>Queue a Presentation API task</a> to <a>resolve</a>
1677+
<var>P</var> with <var>A</var>.
16611678
</li>
16621679
</ol>
16631680
</section>
@@ -1674,6 +1691,9 @@ <h4>
16741691
steps:
16751692
</p>
16761693
<ol>
1694+
<li>
1695+
<a>Assert</a>: this is running <a>in parallel</a>.
1696+
</li>
16771697
<li>Let <var>availabilitySet</var> be a shallow copy of the <a>set
16781698
of presentation availability objects</a>.
16791699
</li>
@@ -1741,8 +1761,8 @@ <h4>
17411761
<var>newAvailability</var> and skip the following step.
17421762
</li>
17431763
<li>If <var>previousAvailability</var> is not equal to
1744-
<var>newAvailability</var>, then <a>queue a task</a> to run the
1745-
following steps:
1764+
<var>newAvailability</var>, then <a>queue a Presentation API
1765+
task</a> to run the following steps:
17461766
<ol>
17471767
<li>Set <var>A</var>'s <a>value</a> property to
17481768
<var>newAvailability</var>.
@@ -2025,6 +2045,9 @@ <h4>
20252045
</dd>
20262046
</dl>
20272047
<ol>
2048+
<li>
2049+
<a>Assert</a>: this is running <a>in parallel</a>.
2050+
</li>
20282051
<li>If the <a>presentation connection state</a> of
20292052
<var>presentationConnection</var> is not <a data-link-for=
20302053
"PresentationConnectionState">connecting</a>, then abort all
@@ -2035,8 +2058,8 @@ <h4>
20352058
identifier</a> of <var>presentationConnection</var> MUST be sent
20362059
with this request.
20372060
</li>
2038-
<li>If connection completes successfully, <a>queue a task</a> to
2039-
run the following steps:
2061+
<li>If connection completes successfully, <a>queue a Presentation
2062+
API task</a> to run the following steps:
20402063
<ol>
20412064
<li>Set the <a>presentation connection state</a> of
20422065
<var>presentationConnection</var> to <a data-link-for=
@@ -2191,6 +2214,9 @@ <h4>
21912214
</dd>
21922215
</dl>
21932216
<ol data-link-for="PresentationConnection">
2217+
<li>
2218+
<a>Assert</a>: this is running <a>in parallel</a>.
2219+
</li>
21942220
<li>If the <a>state</a> property of
21952221
<var>presentationConnection</var> is not <a data-link-for=
21962222
"PresentationConnectionState">connected</a>, abort these steps.
@@ -2220,8 +2246,8 @@ <h4>
22202246
</ol>
22212247
</li>
22222248
<li>
2223-
<a>Queue a task</a> to [=fire an event|fire=] <var>event</var> at
2224-
<var>presentationConnection</var>.
2249+
<a>Queue a Presentation API task</a> to [=fire an event|fire=]
2250+
<var>event</var> at <var>presentationConnection</var>.
22252251
</li>
22262252
</ol>
22272253
<p>
@@ -2386,7 +2412,7 @@ <h4>
23862412
<var>presentationConnection</var>, then abort the remaining steps.
23872413
</li>
23882414
<li>
2389-
<a>Queue a task</a> to run the following steps:
2415+
<a>Queue a Presentation API task</a> to run the following steps:
23902416
<ol>
23912417
<li>If the <a>presentation connection state</a> of
23922418
<var>presentationConnection</var> is not <a data-link-for=
@@ -2453,7 +2479,9 @@ <h4>
24532479
connection</var> is <a data-link-for=
24542480
"PresentationConnectionState">connected</a> or
24552481
<a data-link-for="PresentationConnectionState">connecting</a>,
2456-
then <a>queue a task</a> to run the following steps:
2482+
then <a>queue a global task</a> on the <a>presentation task
2483+
source</a> given <var>known connection</var>'s <a>relevant
2484+
global object</a> to run the following steps:
24572485
<ol>
24582486
<li>Set the <a>presentation connection state</a> of
24592487
<var>known connection</var> to <a data-link-for=
@@ -2467,9 +2495,9 @@ <h4>
24672495
</ol>
24682496
</li>
24692497
<li>
2470-
<dfn>Send a termination request</dfn> for the presentation to its
2471-
<a>receiving user agent</a> using an implementation specific
2472-
mechanism.
2498+
<a>In parallel</a>, <dfn>send a termination request</dfn> for the
2499+
presentation to its <a>receiving user agent</a> using an
2500+
implementation specific mechanism.
24732501
</li>
24742502
</ol>
24752503
</section>
@@ -2535,10 +2563,10 @@ <h4>
25352563
the user interface and discard it.
25362564
</li>
25372565
<li>For each <var>connection</var> in
2538-
<var>connectedControllers</var>, <a>queue a task</a> to send a
2539-
termination confirmation for <var>P</var> using an implementation
2540-
specific mechanism to the <a>controlling user agent</a> that owns
2541-
the <a>destination browsing context</a> for <var>connection</var>.
2566+
<var>connectedControllers</var>, send a termination confirmation
2567+
for <var>P</var> using an implementation specific mechanism to the
2568+
<a>controlling user agent</a> that owns the <a>destination browsing
2569+
context</a> for <var>connection</var>.
25422570
<p class="note">
25432571
Only one termination confirmation needs to be sent per
25442572
<a>controlling user agent</a>.
@@ -2559,7 +2587,9 @@ <h4>
25592587
<ol>
25602588
<li>For each <var>connection</var> in the <a>set of controlled
25612589
presentations</a> that was connected to <var>P</var>, <a>queue a
2562-
task</a> to run the following steps:
2590+
global task</a> on the <a>presentation task source</a> given <var>
2591+
connection</var>'s <a>relevant global object</a> to run the
2592+
following steps:
25632593
<ol>
25642594
<li>If the <a>presentation connection state</a> of
25652595
<var>connection</var> is not <a data-link-for=
@@ -2883,6 +2913,9 @@ <h4>
28832913
</dd>
28842914
</dl>
28852915
<ol>
2916+
<li>
2917+
<a>Assert</a>: this is running <a>in parallel</a>.
2918+
</li>
28862919
<li>If <var>presentationId</var> and <var>I</var> are not equal,
28872920
refuse the connection and abort all remaining steps.
28882921
</li>
@@ -2920,9 +2953,9 @@ <h4>
29202953
the <a>set of presentation controllers</a>.
29212954
</li>
29222955
<li>If the <a>presentation controllers promise</a> is not
2923-
<code>null</code>, <a>resolve</a> the <a>presentation
2924-
controllers promise</a> with the <a>presentation controllers
2925-
monitor</a>.
2956+
<code>null</code>, <a>queue a Presentation API task</a> to <a>
2957+
resolve</a> the <a>presentation controllers promise</a> with
2958+
the <a>presentation controllers monitor</a>.
29262959
</li>
29272960
<li>Abort all remaining steps.
29282961
</li>
@@ -2934,8 +2967,8 @@ <h4>
29342967
the <a>set of presentation controllers</a>.
29352968
</li>
29362969
<li>
2937-
<a>Queue a task</a> to [=fire an event=] named
2938-
<a data-link-for=
2970+
<a>Queue a Presentation API task</a> to [=fire an event=]
2971+
named <a data-link-for=
29392972
"PresentationConnectionList">connectionavailable</a>, that
29402973
uses the <a>PresentationConnectionAvailableEvent</a>
29412974
interface, with the <a data-link-for=

0 commit comments

Comments
 (0)