From 6a0531a7df5653371bf2ad8dff02f31ec40a5453 Mon Sep 17 00:00:00 2001 From: Jeremy Roman Date: Wed, 10 Jan 2024 18:06:12 -0500 Subject: [PATCH 1/4] Infer a speculation rule's source from the other keys. --- speculation-rules.bs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/speculation-rules.bs b/speculation-rules.bs index 10c7aeb..47dbb06 100644 --- a/speculation-rules.bs +++ b/speculation-rules.bs @@ -371,8 +371,14 @@ add the following step To parse a speculation rule given a [=map=] |input|, a [=document=] |document|, and a [=URL=] |baseURL|, perform the following steps. They return a [=speculation rule=] or null. 1. If |input| has any [=map/key=] other than "`source`", "`urls`", "`where`", "`requires`", "`target_hint`","`referrer_policy`", "`relative_to`", "`eagerness`", and "`expects_no_vary_search`" then return null. - 1. If |input|["`source`"] does not [=map/exist=] or is neither the [=string=] "`list`" nor the [=string=] "`document`", then return null. - 1. Let |source| be |input|["`source`"]. + 1. Let |source| be null. + 1. If |input|["`source`"] exists, then: + 1. Set |source| to |input|["`source`"]. + 1. Otherwise, if |input|["`urls`"] [=map/exists=] and |input|["`where`"] does not [=map/exist=], then: + 1. Set |source| to "`list`". + 1. Otherwise, if |input|["`where`"] [=map/exists=] and |input|["`urls`"] does not [=map/exist=], then: + 1. Set |source| to "`document`". + 1. If |source| is neither the [=string=] "`list`" nor the [=string=] "`document`", then return null. 1. Let |urls| be an empty [=list=]. 1. Let |predicate| be null. 1. If |source| is "`list`": From 5372f52a9f66ef1707b6359cb65698385cc5a5cb Mon Sep 17 00:00:00 2001 From: Jeremy Roman Date: Wed, 10 Jan 2024 18:11:52 -0500 Subject: [PATCH 2/4] don't even validate the source key -- ignore it entirely --- speculation-rules.bs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/speculation-rules.bs b/speculation-rules.bs index 47dbb06..60b36b9 100644 --- a/speculation-rules.bs +++ b/speculation-rules.bs @@ -371,10 +371,10 @@ add the following step To parse a speculation rule given a [=map=] |input|, a [=document=] |document|, and a [=URL=] |baseURL|, perform the following steps. They return a [=speculation rule=] or null. 1. If |input| has any [=map/key=] other than "`source`", "`urls`", "`where`", "`requires`", "`target_hint`","`referrer_policy`", "`relative_to`", "`eagerness`", and "`expects_no_vary_search`" then return null. + +

In a previous version of this specification, it was necessary to specify the type of source of the URLs. This is now automatically inferred from other keys, and the "`source`" key is ignored.

1. Let |source| be null. - 1. If |input|["`source`"] exists, then: - 1. Set |source| to |input|["`source`"]. - 1. Otherwise, if |input|["`urls`"] [=map/exists=] and |input|["`where`"] does not [=map/exist=], then: + 1. If |input|["`urls`"] [=map/exists=] and |input|["`where`"] does not [=map/exist=], then: 1. Set |source| to "`list`". 1. Otherwise, if |input|["`where`"] [=map/exists=] and |input|["`urls`"] does not [=map/exist=], then: 1. Set |source| to "`document`". From ce64b794e67dd12d7eab6516ae5b62c403db7e2f Mon Sep 17 00:00:00 2001 From: Jeremy Roman Date: Wed, 10 Jan 2024 21:08:23 -0500 Subject: [PATCH 3/4] Revert "don't even validate the source key -- ignore it entirely" This reverts commit 5372f52a9f66ef1707b6359cb65698385cc5a5cb. --- speculation-rules.bs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/speculation-rules.bs b/speculation-rules.bs index 60b36b9..47dbb06 100644 --- a/speculation-rules.bs +++ b/speculation-rules.bs @@ -371,10 +371,10 @@ add the following step To parse a speculation rule given a [=map=] |input|, a [=document=] |document|, and a [=URL=] |baseURL|, perform the following steps. They return a [=speculation rule=] or null. 1. If |input| has any [=map/key=] other than "`source`", "`urls`", "`where`", "`requires`", "`target_hint`","`referrer_policy`", "`relative_to`", "`eagerness`", and "`expects_no_vary_search`" then return null. - -

In a previous version of this specification, it was necessary to specify the type of source of the URLs. This is now automatically inferred from other keys, and the "`source`" key is ignored.

1. Let |source| be null. - 1. If |input|["`urls`"] [=map/exists=] and |input|["`where`"] does not [=map/exist=], then: + 1. If |input|["`source`"] exists, then: + 1. Set |source| to |input|["`source`"]. + 1. Otherwise, if |input|["`urls`"] [=map/exists=] and |input|["`where`"] does not [=map/exist=], then: 1. Set |source| to "`list`". 1. Otherwise, if |input|["`where`"] [=map/exists=] and |input|["`urls`"] does not [=map/exist=], then: 1. Set |source| to "`document`". From e928bb7cbf8bb5f4663f43d0b8921b94f0c04bca Mon Sep 17 00:00:00 2001 From: Jeremy Roman Date: Wed, 10 Jan 2024 22:28:03 -0500 Subject: [PATCH 4/4] update explainer to mention implicit "source" and use it in examples where it works and the context is otherwise current --- triggers.md | 41 ++++++++++++++--------------------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/triggers.md b/triggers.md index 087624b..8302ed1 100644 --- a/triggers.md +++ b/triggers.md @@ -88,12 +88,10 @@ The following example illustrates the basic idea: