Skip to content

Commit 5e2ec9d

Browse files
committed
Text directive user activation
1 parent 5dfcccb commit 5e2ec9d

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed
87.8 KB
Loading

source

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2748,6 +2748,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
27482748
<li><dfn data-x-href="https://fetch.spec.whatwg.org/#request-top-level-navigation-initiator-origin">top-level navigation initiator origin</dfn></li>
27492749
<li><dfn data-x-href="https://fetch.spec.whatwg.org/#concept-request-add-range-header">add a range header</dfn></li>
27502750
<li><dfn data-x-href="https://fetch.spec.whatwg.org/#destination-type">destination type</dfn></li>
2751+
<li><dfn data-x="concept-request-text-directive-user-activation" data-x-href="https://fetch.spec.whatwg.org/#concept-request-text-directive-user-activation">text directive user activation</dfn></li>
27512752
</ul>
27522753
</li>
27532754
<li>
@@ -107170,6 +107171,9 @@ location.href = '#foo';</code></pre>
107170107171
care of scrolling.</p>
107171107172
</li>
107172107173

107174+
<li><p>Set <var>navigable</var>'s <span data-x="nav-document">active document</span>'s
107175+
<span>pending text directives</span> to null.</p></li>
107176+
107173107177
<li><p>Let <var>traversable</var> be <var>navigable</var>'s <span
107174107178
data-x="nav-traversable">traversable navigable</span>.</p></li>
107175107179

@@ -115143,12 +115147,60 @@ console.log(document.url.hash); // '#foo:~:bar'
115143115147
<span>list</span> of <span data-x="text directive">text directives</span> or null, initially
115144115148
null.</p>
115145115149

115150+
<p>Each <code>Document</code> has a <dfn>text directive user activation</dfn> which is a boolean,
115151+
initially false.</p>
115152+
115153+
<div class="note">
115154+
<p>The <span>text directive user activation</span> provides the necessary user gesture signal to
115155+
<!-- TODO(domfarolino): Probably clarify, by adding a link to the specific load steps -->
115156+
<!-- TODO(domfarolino): Maybe say when it is also set to false / "used" -->
115157+
allow a single activation of a <span>text directive</span>. It is set to true during document
115158+
loading only if the navigation occurred as a result of a user activation and is propagated
115159+
across client-side redirects.</p>
115160+
115161+
<p>If a <code>Document</code>'s <span>text directive user activation</span> isn't used to
115162+
activate a <span>text directive</span>, rather it is used to set a <span
115163+
data-x="navigation-request">navigation request</span>'s <span
115164+
data-x="concept-request-text-directive-user-activation">text directive user activation</span> to
115165+
true, so than an "unused" <span>text directive user activation</span> can be propagated from one
115166+
<code>Document</code> to another across a navigation.</p>
115167+
115168+
<!-- TODO(bokan): What does it mean for a request's boolean to be set to false when it is "used"? How does that work? -->
115169+
<p>Both <code>Document</code>'s <span>text directive user activation</span> and <span
115170+
data-x="concept-request">request</span>'s <span
115171+
data-x="concept-request-text-directive-user-activation">text directive user activation</span>
115172+
are always set to false when used, such that a single user activation cannot be reused to
115173+
activate more than one text fragment.</p>
115174+
</div>
115175+
115176+
<div class="note">
115177+
<p>This mechanism allows text fragments to activate through a common redirect technique used by
115178+
many popular web sites. Such sites "redirect" users to their intended destination by responding
115179+
with a "<code data-x="">200</code>" status code containing script that triggers a navigation.</p>
115180+
115181+
<p>Unlike real HTTP redirects, these "client-side" redirects cannot propagate the fact that the
115182+
navigation is the result of a user gesture. The <span>text directive user activation</span>
115183+
mechanism allows passing through this specifically scoped user-activation through such
115184+
navigations. This means a page is able to programmatically navigate to a text fragment a single
115185+
time, as if it has a user gesture. However, since this resets the <span>text directive user
115186+
activation</span>, further text fragment navigations cannot activate without a new user
115187+
gesture.</p>
115188+
115189+
<p>The following diagram demonstrates how the flag is used to activate a text fragment through
115190+
this mechanism:</p>
115191+
115192+
<img style="margin-left:auto;margin-right:auto;display:block" width="745" height="671"
115193+
src="/images/text-directive-user-activation-flag.png" alt="Diagram showing how the text directive
115194+
user activation flag is set and used">
115195+
</div>
115196+
115146115197

115147115198
<h4>Syntax</h4>
115148115199

115149115200
<!-- TODO(domfarolino): Is this non-normative? -->
115150115201

115151-
<p>A <span>text directive</span> is specified in the <span>fragment directive</span> with the following format:</p>
115202+
<p>A <span>text directive</span> is specified in the <span>fragment directive</span> with the
115203+
following format:</p>
115152115204

115153115205
<pre>
115154115206
#:~:text=[prefix-,]start[,end][,-suffix]
@@ -116241,6 +116293,10 @@ Add a helper algorithm for removing and returning a fragment directive string fr
116241116293

116242116294
<h4 id="text-directive-security-and-privacy">Security and privacy considerations</h4>
116243116295

116296+
<h5>Motivation</h5>
116297+
116298+
<!-- NON-NORMATIVE SECTION -->
116299+
116244116300
<p>Care must be taken when implementing <span data-x="text directive">text directives</span> so
116245116301
that it cannot be used to exfiltrate information across origins. Scripts can navigate a page to a
116246116302
cross-origin URL with a <span>text directive</span>. If a malicious actor can determine that the
@@ -116263,7 +116319,7 @@ Add a helper algorithm for removing and returning a fragment directive string fr
116263116319
<li><p>navigations that are the result of a user action.</p></li>
116264116320

116265116321
<li><p>in cases where the navigation has a cross-origin initiator, the destination must be opener
116266-
isolated (i.e. no references to its global objects in other documents)</p></li>
116322+
isolated (i.e., no references to its global objects in other documents)</p></li>
116267116323
</ul>
116268116324

116269116325
<h5>Scroll on navigation</h5>

0 commit comments

Comments
 (0)