Skip to content

Commit e7012cb

Browse files
committed
Add user activation interface.
Describe the interface and augment PostMessage options to contain the required fields. Fixes #4008
1 parent 1e92000 commit e7012cb

File tree

1 file changed

+112
-6
lines changed

1 file changed

+112
-6
lines changed

source

+112-6
Original file line numberDiff line numberDiff line change
@@ -73335,7 +73335,7 @@ END:VCARD</pre>
7333573335
seconds, so that the user can possibly perceive the link between an interaction with the page and
7333673336
the page calling the activation-gated API.</p>
7333773337

73338-
<p>These two values imply two boolean user activation states for <var>W</var>:</p>
73338+
<p>These two values imply two boolean <dfn>user activation states</dfn> for <var>W</var>:</p>
7333973339

7334073340
<dl>
7334173341
<dt><dfn data-export="">Sticky activation</dfn></dt>
@@ -73481,6 +73481,74 @@ END:VCARD</pre>
7348173481
</dl>
7348273482

7348373483

73484+
<h4>The <code>UserActivation</code> interface</h4>
73485+
73486+
<p>The <span>user activation states</span> are exposed via the <code>UserActivation</code>
73487+
interface. <code>UserActivation</code> objects can be created either as a live or snapshot object,
73488+
it depends on how the object was referenced. Objects accessed via <code>navigator</code>'s <code
73489+
data-x="dom-Navigator-userActivation">userActivation</code> attribute are live, in that changes
73490+
will in the <span>user activation states</span> will be reflected in the attributes of the object.
73491+
<code>UserActivation</code> objects retrieved via <code>MessageEvent</code>'s <code
73492+
data-x="dom-MessageEvent-userActivation">userActivation</code> attribute will be snapshot objects,
73493+
that is a snapshot of the source's state.</p>
73494+
73495+
<pre><code class="idl" data-x="">[Exposed=(Window,Worker,AudioWorklet)]
73496+
interface <dfn>UserActivation</dfn> {
73497+
readonly attribute boolean <span data-x="dom-UserActivation-hasBeenActive">hasBeenActive</span>;
73498+
readonly attribute boolean <span data-x="dom-UserActivation-isActive">isActive</span>;
73499+
};
73500+
73501+
partial interface <span id="NavigatorUserActivation-partial">Navigator</span> {
73502+
[SameObject] readyonly attribute <code>UserActivation</code> <span data-x="dom-Navigator-userActivation">userActivation</span>;
73503+
};</code></pre>
73504+
73505+
<dl class="domintro">
73506+
73507+
<dt><var>navigator</var> . <code subdfn
73508+
data-x="dom-Navigator-userActivation">userActivation</code></dt>
73509+
73510+
<dd>
73511+
73512+
<p>Returns the a live object representing the current <span>user activation states</span>.</p>
73513+
73514+
</dd>
73515+
73516+
<dt><var>userActivation</var> . <code subdfn
73517+
data-x="dom-UserActivation-hasBeenActive">hasBeenActive</code></dt>
73518+
73519+
<dd>
73520+
73521+
<p>Returns the state of the <span>sticky activation</span>.</p>
73522+
73523+
</dd>
73524+
73525+
<dt><var>userActivation</var> . <code subdfn
73526+
data-x="dom-UserActivation-isActive">isActive</code></dt>
73527+
73528+
<dd>
73529+
73530+
<p>Returns the state of the <span>transient activation</span>.</p>
73531+
73532+
</dd>
73533+
73534+
</dl>
73535+
73536+
<div w-nodev>
73537+
73538+
<p>The <dfn><code data-x="dom-UserActivation-hasBeenActive">hasBeenActive</code></dfn> attribute
73539+
must return the state of the <span>sticky activation</span>. If the object is live it must
73540+
always reflect the current state. If the object is a snapshot it must reflect the state at which
73541+
the time the object was created.</p>
73542+
73543+
<p>The <dfn><code data-x="dom-UserActivation-isActive">isActive</code></dfn> attribute must return
73544+
the state of the <span>transient activation</span>. If the object is live it must always
73545+
reflect the current state. If the object is a snapshot it must reflect the state at which the time
73546+
the object was created.</p>
73547+
73548+
<p>The <dfn><code data-x="dom-Navigator-userActivation">userActivation</code></dfn> attribute must
73549+
return a live representation of the <span>user activation states</span>.</p>
73550+
73551+
</div>
7348473552

7348573553
<h3 id="activation">Activation behavior of elements</h3>
7348673554

@@ -96717,6 +96785,7 @@ interface <dfn>MessageEvent</dfn> : <span>Event</span> {
9671796785
readonly attribute DOMString <span data-x="dom-MessageEvent-lastEventId">lastEventId</span>;
9671896786
readonly attribute <span>MessageEventSource</span>? <span data-x="dom-MessageEvent-source">source</span>;
9671996787
readonly attribute FrozenArray&lt;<span>MessagePort</span>&gt; <span data-x="dom-MessageEvent-ports">ports</span>;
96788+
readonly attribute <span>UserActivation</span>? <span data-x="dom-MessageEvent-userActivation">userActivation</span>;
9672096789

9672196790
void <span data-x="dom-MessageEvent-initMessageEvent">initMessageEvent</span>(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false, optional any data = null, optional USVString origin = "", optional DOMString lastEventId = "", optional <span>MessageEventSource</span>? source = null, optional sequence&lt;<span>MessagePort</span>&gt; ports = []);
9672296791
};
@@ -96727,6 +96796,7 @@ dictionary <dfn>MessageEventInit</dfn> : <span>EventInit</span> {
9672796796
DOMString lastEventId = "";
9672896797
<span>MessageEventSource</span>? source = null;
9672996798
sequence&lt;<span>MessagePort</span>&gt; ports = [];
96799+
<span>UserActivation</span>? userActivation = null;
9673096800
};
9673196801

9673296802
typedef (<span>WindowProxy</span> or <span>MessagePort</span> or <span>ServiceWorker</span>) <dfn>MessageEventSource</dfn>;</code></pre>
@@ -96779,6 +96849,15 @@ typedef (<span>WindowProxy</span> or <span>MessagePort</span> or <span>ServiceWo
9677996849

9678096850
</dd>
9678196851

96852+
<dt><var>event</var> . <code subdfn data-x="dom-MessageEvent-userActivation">userActivation</code></dt>
96853+
96854+
<dd>
96855+
96856+
<p>Returns a snapshot of the <code>UserActivation</code> state in the
96857+
source at the time of <code data-x="dom-window-postMessage">postMessage()</code>.</p>
96858+
96859+
</dd>
96860+
9678296861
<!-- initMessageEvent is deprecated -->
9678396862

9678496863
</dl>
@@ -96811,6 +96890,10 @@ typedef (<span>WindowProxy</span> or <span>MessagePort</span> or <span>ServiceWo
9681196890
value it was initialized to. It represents, in <span>cross-document messaging</span> and
9681296891
<span>channel messaging</span>, the <code>MessagePort</code> array being sent.</p>
9681396892

96893+
<p>The <dfn><code data-x="dom-MessageEvent-userActivation">userActivation</code></dfn> attribute
96894+
must return the value it was initialized to. It represents the <span>UserActivation</span> state
96895+
at the source.</p>
96896+
9681496897
<!-- handwavy, file bugs if there are interop issues -->
9681596898
<p>The <dfn><code data-x="dom-MessageEvent-initMessageEvent">initMessageEvent()</code></dfn>
9681696899
method must initialize the event in a manner analogous to the similarly-named <code
@@ -98751,6 +98834,12 @@ function receiver(e) {
9875198834
window, in same-origin cases. See discussion at
9875298835
https://github.com/whatwg/html/issues/1542#issuecomment-233502636 -->
9875398836

98837+
<li><p>Let userActivationSnapshot be null</p></li>
98838+
98839+
<li><p>If <var>options</var>'s <code data-x="">includeUserActivation</code> member is true, set
98840+
userActivationSnapshot to be <var>incumbent settings</var>'s <span>global object</span>'s (if
98841+
available) <span>user activation states</span>.</p></li>
98842+
9875498843
<li><p>Let <var>targetOrigin</var> be <var>options</var>["<code
9875598844
data-x="">targetOrigin</code>"].</p></li>
9875698845

@@ -98824,8 +98913,10 @@ function receiver(e) {
9882498913
attribute initialized to <var>origin</var>, the <code
9882598914
data-x="dom-MessageEvent-source">source</code> attribute initialized to <var>source</var>, the
9882698915
<code data-x="dom-MessageEvent-data">data</code> attribute initialized to
98827-
<var>messageClone</var>, and the <code data-x="dom-MessageEvent-ports">ports</code> attribute
98828-
initialized to <var>newPorts</var>.</p></li>
98916+
<var>messageClone</var>, the <code data-x="dom-MessageEvent-ports">ports</code> attribute
98917+
initialized to <var>newPorts</var>, and the <code
98918+
data-x="dom-MessageEvent-userActivation">userActivation</code> attribute initialized to
98919+
<var>userActivationSnapshot</var>.</p></li>
9882998920
</ol>
9883098921
</li>
9883198922
</ol>
@@ -99140,6 +99231,7 @@ interface <dfn>MessagePort</dfn> : <span>EventTarget</span> {
9914099231

9914199232
dictionary <dfn>PostMessageOptions</dfn> {
9914299233
sequence&lt;<span data-x="idl-object">object</span>&gt; transfer = [];
99234+
boolean includeUserActivation = false;
9914399235
};</code></pre>
9914499236

9914599237
<dl class="domintro">
@@ -99304,6 +99396,14 @@ dictionary <dfn>PostMessageOptions</dfn> {
9930499396
<code>MessagePort</code>, then throw a <span>"<code>DataCloneError</code>"</span>
9930599397
<code>DOMException</code>.</p></li>
9930699398

99399+
<li><p>Let userActivationSnapshot be null.</p></li>
99400+
99401+
<li><p>Let <var>incumbent settings</var> be the <span>incumbent settings object</span>.</p></li>
99402+
99403+
<li><p>If <var>options</var>'s <code data-x="">includeUserActivation</code> member is true, set
99404+
userActivationSnapshot to be <var>incumbent settings</var>'s <span>global object</span>'s (if
99405+
available) <span>user activation states</span>.</p></li>
99406+
9930799407
<li><p>Let <var>doomed</var> be false.</p></li>
9930899408

9930999409
<li><p>If <var>targetPort</var> is not null and <var>transfer</var> <span data-x="list
@@ -99358,9 +99458,10 @@ dictionary <dfn>PostMessageOptions</dfn> {
9935899458
<li><p><span data-x="concept-event-fire">Fire an event</span> named <code
9935999459
data-x="event-message">message</code> at <var>finalTargetPort</var>, using
9936099460
<code>MessageEvent</code>, with the <code data-x="dom-MessageEvent-data">data</code> attribute
99361-
initialized to <var>messageClone</var> and the <code
99362-
data-x="dom-MessageEvent-ports">ports</code> attribute initialized to
99363-
<var>newPorts</var>.</p></li>
99461+
initialized to <var>messageClone</var>, the <code data-x="dom-MessageEvent-ports">ports</code>
99462+
attribute initialized to <var>newPorts</var>, and the <code
99463+
data-x="dom-MessageEvent-userActivation">userActivation</code> attribute initialized to
99464+
<var>userActivationSnapshot</var>.</p></li>
9936499465
</ol>
9936599466
</li>
9936699467
</ol>
@@ -99430,6 +99531,11 @@ dictionary <dfn>PostMessageOptions</dfn> {
9943099531
message queue</span> must be enabled, as if the <code data-x="dom-MessagePort-start">start()</code>
9943199532
method had been called.</p>
9943299533

99534+
<p>If a <code>MessagePort</code> object's <code
99535+
data-x="handler-MessagePort-onmessage">onmessage</code> IDL attribute is set, the port's <span>port
99536+
message queue</span> must be enabled, as if the <code data-x="dom-MessagePort-start">start()</code>
99537+
method had been called.</p>
99538+
9943399539
</div>
9943499540

9943599541

0 commit comments

Comments
 (0)