Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automatic beacon patches #109

Merged
merged 6 commits into from
Aug 16, 2023
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 97 additions & 8 deletions spec.bs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/
text: referrerPolicy; url: navigation-referrer-policy
text: attempt to populate the history entry's document; url: attempt-to-populate-the-history-entry's-document
text: navigation params; url: navigation-params
text: snapshot source snapshot params; url: snapshotting-source-snapshot-params
for: navigation params
text: response; url: navigation-params-response
text: navigable; url: navigation-params-navigable
Expand All @@ -147,6 +148,7 @@ spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/
for: document state
text: document; url: document-state-document
text: history policy container; url: document-state-history-policy-container
text: initiator origin; url: document-state-initiator-origin
text: checking if unloading is user-canceled
text: source snapshot params
for: source snapshot params
Expand All @@ -155,6 +157,8 @@ spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/
text: session-history-entry
for: session history entry
text: step; url: she-step
for: source snapshot params
text: has transient activation; url: source-snapshot-params-activation
urlPrefix: interaction.html
text: activation notification; url: activation-notification
text: consume user activation; url: consume-user-activation
Expand All @@ -177,6 +181,7 @@ spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/
urlPrefix: nav-history-apis.html
for: Window
text: navigable; url: window-navigable
text: opener; url: dom-opener
urlPrefix: webappapis.html
for: environment
text: target browsing context; url: concept-environment-target-browsing-context
Expand Down Expand Up @@ -739,6 +744,9 @@ A <dfn export for=fencedframetype>fenced frame reporter</dfn> is a [=struct=] wi

: <dfn>destination</dfn>
:: a [=list=] of {{FenceReportingDestination}}s

: <dfn>once</dfn>
:: a [=boolean=]
</dl>
</dl>

Expand Down Expand Up @@ -1206,6 +1214,7 @@ Several APIs specific to fenced frames are defined on the {{Fence}} interface.
required DOMString eventType;
required DOMString eventData;
required sequence&lt;FenceReportingDestination&gt; destination;
boolean once;
};

typedef (FenceEvent or DOMString) ReportEventType;
Expand Down Expand Up @@ -1272,6 +1281,9 @@ Several APIs specific to fenced frames are defined on the {{Fence}} interface.
: [=automatic beacon data/destination=]
:: |event|'s {{FenceEvent/destination}}

: [=automatic beacon data/once=]
:: |event|'s {{FenceEvent/once}}
blu25 marked this conversation as resolved.
Show resolved Hide resolved

<wpt>
/fenced-frame/set-automatic-beacon.https.html
blu25 marked this conversation as resolved.
Show resolved Hide resolved
</wpt>
Expand Down Expand Up @@ -1348,6 +1360,71 @@ table](https://fetch.spec.whatwg.org/#destination-table) to illustrate that <{fe
* CSP directive of <code>fenced-frame-src</code>
* Features as HTML's <code>&lt;fencedframe&gt;</code>

<h3 id=automatic-reporting>Automatic Reporting</h3>

*This introductory sub-section is non-normative.*

A side effect of the fenced boundary model is that ads will lose the ability to know if a click
resulted in a successful navigation. This is because the page a fenced frame [=navigates=] to will
blu25 marked this conversation as resolved.
Show resolved Hide resolved
not be allowed to report to the fenced frame that it loaded (through something like
<code>window.[=Window/opener=]</code>). Instead, we introduce a special event-level [=pending
event/eventType|reporting type=], `reserved.top_navigation`, which automatically sends an [=report
an event|event-level beacon=] when a fenced frame initiates a successful [=navigate|navigation=] to
a [=top-level traversable=].

<div algorithm>
To <dfn>attempt to send an automatic beacon</dfn> given a [=source snapshot params=]
|sourceSnapshotParams|, an [=origin=] |sourceOrigin|, a {{Document}} |targetDocument|, and a
[=string=] |eventType|, run these steps:

1. [=Assert=]: |eventType| is "`reserved.top_navigation`".

2. If |targetDocument|'s [=node navigable=]'s [=traversable navigable=] is not a [=top-level
blu25 marked this conversation as resolved.
Show resolved Hide resolved
traversable=], terminate these steps.

3. If |sourceSnapshotParams|' [=source snapshot params/has transient activation=] is set to
false, terminate these steps.
blu25 marked this conversation as resolved.
Show resolved Hide resolved

4. Let |config| be |sourceSnapshotParams|' [=source snapshot params/initiator fenced frame
blu25 marked this conversation as resolved.
Show resolved Hide resolved
config instance=].

5. If |config| is null, terminate these steps.
blu25 marked this conversation as resolved.
Show resolved Hide resolved

6. Let |beacon data| be |config|'s [=fenced frame config instance/fenced frame reporter=]'s
[=fenced frame reporter/automatic beacon data=].

7. If |beacon data| is null, terminate these steps.

8. If |sourceOrigin| is not [=same origin=] with |config|'s [=fenced frame config instance/mapped
url=]'s [=url/origin=], terminate these steps.

9. [=list/For each=] |destination| of |beacon data|'s [=automatic beacon data/destination=]:

1. Run [=report an event=] using |config|'s [=fenced frame config instance/fenced frame
reporter=] with |destination|, |eventType|, and |beacon data|'s [=automatic beacon data/
eventData=].

10. If |beacon data|'s [=automatic beacon data/once=] is true, set |config|'s [=fenced frame
config instance/fenced frame reporter=]'s [=fenced frame reporter/automatic beacon data=] to
null.

<wpt>
/fenced-frame/automatic-beacon-click-handler.https.html
/fenced-frame/automatic-beacon-two-events-clear.https.html
/fenced-frame/automatic-beacon-two-events-persist.https.html
/fenced-frame/automatic-beacon-unfenced-top.https.html
</wpt>
domfarolino marked this conversation as resolved.
Show resolved Hide resolved
</div>

<div algorithm="automatic beacon patch">
Modify [[HTML]]'s [=attempt to populate the history entry's document=] algorithm. In step 6,
substep 11, add a new step after step 5 that reads:

6. if <var ignore>failure</var> is false, then [=attempt to send an automatic beacon=] given <var
ignore>sourceSnapshotParams</var>, <var ignore>entry</var>'s [=document state=]'s [=document
state/initiator origin=], <var ignore>document</var>, and "`reserved.top_navigation`".
</div>

<h2 id=html-integration>HTML Integration</h2>

<h3 id=window-extension>Extensions to the {{Window}} interface</h3>
Expand Down Expand Up @@ -1988,12 +2065,24 @@ CORP violation report=] algorithm, as leaving it unfenced may cause a privacy le
<h4 id=navigation-changes>Actual navigation changes</h4>

<div algorithm=source-snapshot-param-config>
Add a new [=struct/item=] to the [=source snapshot params=] [=struct=]:
Add 2 new [=struct/item=]s to the [=source snapshot params=] [=struct=]:
blu25 marked this conversation as resolved.
Show resolved Hide resolved

: <dfn for="source snapshot params">initiator fenced frame config instance</dfn>
:: a [=fenced frame config instance=] or null, initially null.

: <dfn for="source snapshot params">fenced frame config</dfn>
: <dfn for="source snapshot params">target fenced frame config</dfn>
blu25 marked this conversation as resolved.
Show resolved Hide resolved
:: a [=fenced frame config=] or null, initially null.
</div>

<div algorithm=snapshot-source-snapshot-params>
Modify the [=snapshot source snapshot params=] algorithm to return a [=source snapshot params=]
with an additional field:

: [=source snapshot params/initiator fenced frame config instance=]
:: <var ignore>sourceDocument</var>'s [=browsing context=]'s [=browsing context/fenced frame
config instance=]
</div>

<div algorithm=navigate>
Modify step 7 of [[HTML]]'s [=navigate=] algorithm to include the following condition:

Expand Down Expand Up @@ -2036,8 +2125,8 @@ CORP violation report=] algorithm, as leaving it unfenced may cause a privacy le
any subsequent embedder-initiated navigations, <span class=allow-2119>should</span> they
occur, by the usual mechanism that tracks the [=navigable/ongoing navigation=].

1. Set <var ignore>sourceSnapshotParams</var>'s [=source snapshot params/fenced frame config=]
to |config|.
1. Set <var ignore>sourceSnapshotParams</var>'s [=source snapshot params/target fenced frame
config=] to |config|.

1. [=Assert=] |config|'s [=fenced frame config/mapped url=]'s [=mapped url/value=] is a
[=URL=] whose [=url/scheme=] is "`https`".
Expand All @@ -2061,7 +2150,7 @@ CORP violation report=] algorithm, as leaving it unfenced may cause a privacy le

<br>

The below patches make use of the previously-assigned [=source snapshot params/fenced frame
The below patches make use of the previously-assigned [=source snapshot params/target fenced frame
config=], [=instantiate a config|instantiating=] it in preparation for use when the navigation is
finalized.

Expand All @@ -2082,9 +2171,9 @@ finalized.
returns a [=navigation params=] has the following additional assignment:

: [=navigation params/fenced frame config instance=]
:: If |sourceSnapshotParams|'s [=source snapshot params/fenced frame config=] is null, then null;
otherwise, the result of [=instantiate a config|instantiating=] |sourceSnapshotParams|'s
[=source snapshot params/fenced frame config=].
:: If |sourceSnapshotParams|'s [=source snapshot params/target fenced frame config=] is null, then
null; otherwise, the result of [=instantiate a config|instantiating=] |sourceSnapshotParams|'s
[=source snapshot params/target fenced frame config=].
</div>

<br>
Expand Down