Skip to content

Commit 83fd72b

Browse files
authored
Rewrite processing shortcuts algorithm to be more precise (#832)
Normative changes: * shortcuts that meet certain failure conditions are ignored. * Checks that name and url are present, URL is valid and within scope of the manifest. Other changes: * Clarify that the ShortcutItem url member needs to be within scope. * Rewrite processing shortcuts algorithm as an ordered list. * Creates a new array and returns it, rather than discarding the result. * Explicitly says where developer warnings should be issued. Closes #831
1 parent a9d989d commit 83fd72b

File tree

1 file changed

+42
-12
lines changed

1 file changed

+42
-12
lines changed

index.html

+42-12
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,7 @@ <h3>
15311531
</li>
15321532
<li>Set <var>manifest</var>["<a>shortcuts</a>"] to the result of
15331533
running <a>processing the <code>shortcuts</code> member</a> given
1534-
<var>manifest URL</var>, and <code>"shortcuts"</code>.
1534+
<var>manifest</var>["<a>shortcuts</a>"] and <var>manifest URL</var>.
15351535
</li>
15361536
<li>
15371537
<a>Extension point</a>: process any proprietary and/or other
@@ -2345,17 +2345,43 @@ <h3>
23452345
are given by the following algorithm. The algorithm takes a
23462346
<a data-cite=
23472347
"WEBIDL#sequence-type">sequence</a>&lt;<a>ShortcutItem</a>&gt;
2348-
<var>shortcuts</var> as an argument. This algorithm returns an
2349-
<a data-cite=
2350-
"WEBIDL#sequence-type">sequence</a>&lt;<a>ShortcutItem</a>&gt;. For
2351-
each <var>shortcut</var> (<a>ShortcutItem</a>) in the sequence, set
2352-
<var>shortcut.icons</var> to the result of running <a>processing
2353-
`ImageResource` members</a> given <var>shortcut.icons</var> and
2354-
<var>manifest URL</var>. For each <var>shortcut</var>
2355-
(<a>ShortcutItem</a>) in the sequence, parse
2356-
<var>shortcut</var>["<a>url</a>"] using <var>manifest URL</var> as
2357-
the base URL.
2348+
<var>shortcuts</var> and a <a>URL</a> <var>manifest URL</var>. This
2349+
algorithm returns a <a data-cite=
2350+
"WEBIDL#sequence-type">sequence</a>&lt;<a>ShortcutItem</a>&gt;.
23582351
</p>
2352+
<ol>
2353+
<li>Let <var>processedShortcuts</var> be a new Array object created
2354+
as if by the expression [].
2355+
</li>
2356+
<li>For each <var>shortcut</var> (<a>ShortcutItem</a>) in the
2357+
sequence:
2358+
<ol>
2359+
<li>If <var>shortcut</var>["name"] or <var>shortcut</var>["url"]
2360+
are undefined, or if <var>shortcut</var>["name"] is the empty
2361+
string, <a>issue a developer warning</a> and <a>continue</a>.
2362+
</li>
2363+
<li>Set <var>shortcut</var>["icons"] to the result of running <a>
2364+
processing `ImageResource` members</a> given
2365+
<var>shortcut</var>["icons"] and <var>manifest URL</var>.
2366+
</li>
2367+
<li>Set <var>shortcut</var>["url"] to the result of
2368+
<a>parsing</a> <var>shortcut</var>["url"] using <var>manifest
2369+
URL</var> as the base URL. If the result is failure, <a>issue a
2370+
developer warning</a> and <a>continue</a>.
2371+
</li>
2372+
<li>If <var>shortcut</var>["url"] is not <a>within scope</a> of
2373+
<var>manifest URL</var>, <a>issue a developer warning</a> and <a>
2374+
continue</a>.
2375+
</li>
2376+
<li>
2377+
<a>Append</a> <var>shortcut</var> to
2378+
<var>processedShortcuts</var>.
2379+
</li>
2380+
</ol>
2381+
</li>
2382+
<li>Return <var>processedShortcuts</var>.
2383+
</li>
2384+
</ol>
23592385
<p>
23602386
A user agent SHOULD expose shortcuts via interactions that are
23612387
consistent with exposure of an application icon's context menu in the
@@ -3022,7 +3048,8 @@ <h3>
30223048
</h3>
30233049
<p>
30243050
The <dfn>url</dfn> member of a <a>ShortcutItem</a> is the <a>URL</a>
3025-
that opens when the associated shortcut is activated.
3051+
<a data-lt="within scope of a manifest">within the application's
3052+
scope</a> that opens when the associated shortcut is activated.
30263053
</p>
30273054
</section>
30283055
<section data-dfn-for="ShortcutItem" data-link-for="ShortcutItem">
@@ -3886,6 +3913,9 @@ <h3>
38863913
<li>
38873914
<dfn data-cite="INFRA#list-contain">contains</dfn>
38883915
</li>
3916+
<li>
3917+
<dfn data-cite="INFRA#iteration-continue">continue</dfn>
3918+
</li>
38893919
</ul>
38903920
</li>
38913921
<li>[[ECMASCRIPT]] defines the following terms:

0 commit comments

Comments
 (0)