Skip to content

Commit 22a0b1e

Browse files
Allow manifest processing to be invoked without going through an HTML document (#1069)
* Processing the manifest: Simplify the interface. Replaces the link and response parameters with document URL and manifest URL. These parameters were only used to get the document URL and manifest URL, respectively, so it doesn't make sense to accept the much bulkier HTML objects. This was limiting the ability to call the processing algorithm from outside an HTML document context, which is a future direction we wish to explore. Note that the only call to this algorithm is in the HTML spec, which needs to be updated simultaneously to use the new interface. Pre-work for #668. * Added new normative text (with a non-normative note) allowing user agents to invoke the processing steps without a document, provided that they supply a valid document URL. * Reword non-normative note. * Correctly link. (Actually this makes the wrong link, but it's a respec bug: https://github.com/w3c/respec/issues/4435 * Added a SHOULD to set CORS correctly. Note: There's a reference error here because HTML doesn't export a term. I'm getting it exported. * Move all this text to its own section; it's getting a bit much. * Use variables to avoid repeating complex sentences. * Rewrote processing without a document section for clarity and correctness. - Changed MUST into a SHOULD. We can't really expect all uses to directly verify this. - Removed the "or" clause that the document be same-origin as manifest; you still want a link from the document to the manifest either way. - Added "at least at some point in the past", to acknowledge that you don't need to verify this at install time, just whenever you did the caching. - Clarify that the CORS request is only needed if the manifest is not same-origin as the document. * Apply suggestions from code review Co-authored-by: Marcos Cáceres <[email protected]> * Respond to review. --------- Co-authored-by: Marcos Cáceres <[email protected]>
1 parent 0252939 commit 22a0b1e

File tree

1 file changed

+56
-9
lines changed

1 file changed

+56
-9
lines changed

index.html

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,15 +1254,10 @@ <h3>
12541254
<p>
12551255
The steps for <dfn data-export="" data-local-lt=
12561256
"processing">processing a manifest</dfn> are given by the following
1257-
algorithm. The algorithm takes [^link^] |el:HTMLLinkElement|, a
1258-
[=Response=] |response|, and a [=byte sequence=] |bodyBytes|.
1257+
algorithm. The algorithm takes a [=URL=] |document URL:URL|, a
1258+
[=URL=] |manifest URL:URL|, and a [=byte sequence=] |bodyBytes|.
12591259
</p>
12601260
<ol class="algorithm">
1261-
<li>Let |document URL:URL| be |el|'s [=Node/node document=]'s
1262-
[=Document/URL=].
1263-
</li>
1264-
<li>Assert: |document URL:URL| is not null.
1265-
</li>
12661261
<li>Let |json| be the result of [=parse JSON bytes to an Infra
12671262
value=] passing |bodyBytes|.
12681263
</li>
@@ -1285,8 +1280,6 @@ <h3>
12851280
<li>[=Process a text member=] passing |json|, |manifest|, and
12861281
"short_name".
12871282
</li>
1288-
<li>Let |manifest URL:URL| be |response|'s [=response/URL=].
1289-
</li>
12901283
<li>[=Process the `start_url` member=] passing |json|, |manifest|,
12911284
|manifest URL|, and |document URL|.
12921285
</li>
@@ -1382,6 +1375,60 @@ <h2>
13821375
</li>
13831376
</ol>
13841377
</section>
1378+
<section>
1379+
<h3>
1380+
Processing the manifest without a document
1381+
</h3>
1382+
<p>
1383+
The [=processing a manifest=] steps are invoked by [[HTML]]'s
1384+
processing steps for the [^link^] element, but MAY also be invoked
1385+
by the user agent to process a manifest without an associated
1386+
[=document=].
1387+
</p>
1388+
<p>
1389+
In this case, to match the guarantees made by the corresponding
1390+
steps in [[HTML]], the user agent SHOULD ensure that at least at
1391+
some point in the past:
1392+
</p>
1393+
<ul>
1394+
<li>there was at least one [=document=] that is [=same origin=] as
1395+
|document URL:URL| that has a [^link^] element
1396+
|linkElement:HTMLLinkElement| with a [^link/rel^] of
1397+
[^link/rel/manifest^] and a [^link/href^] that resolves to
1398+
|manifest URL:URL|, and that
1399+
</li>
1400+
<li>if |manifest URL| is not [=same origin=] as |document URL|, the
1401+
|bodyBytes:byte sequence| data was [=fetch|fetched=] with a [=CORS
1402+
Request=] whose <a data-xref-type="http-header">`Origin`</a> is
1403+
|document URL|'s [=url/origin=], and whose [=Request/credentials
1404+
mode=] is set to the [=CORS settings attribute credentials mode=]
1405+
for |linkElement|'s [^link/crossorigin^] attribute.
1406+
</li>
1407+
</ul>
1408+
<aside class="note" title="The rationale for these checks">
1409+
<p>
1410+
This provision allows user agents to perform app installations
1411+
using a manifest without having to first load a document that
1412+
links to the manifest (e.g. when installing an app onto the
1413+
user's device via a sync service). But the above recommendations
1414+
ask the user agent to verify that, when an application scope is
1415+
on origin A and the manifest is on a different origin B, there is
1416+
a bidirectional relationship between the two origins.
1417+
</p>
1418+
<p>
1419+
The first check ensures that at least some page on origin A links
1420+
to the manifest on origin B (otherwise, it would be possible for
1421+
a manifest on origin B to control the metadata for an
1422+
unaffiliated app on origin A).
1423+
</p>
1424+
<p>
1425+
The second check ensures that origin B allows (via the [=CORS
1426+
protocol=]) its manifest to be applied by origin A, and also that
1427+
the manifest is fetched with or without credentials, as agreed by
1428+
both origins, as it would if going directly through the document.
1429+
</p>
1430+
</aside>
1431+
</section>
13851432
<section>
13861433
<h3 id="applying">
13871434
Applying the manifest

0 commit comments

Comments
 (0)