Skip to content

Commit

Permalink
Add user activation interface.
Browse files Browse the repository at this point in the history
Describe the interface and augment PostMessage options to contain the
required fields.

Fixes whatwg#4008
  • Loading branch information
dtapuska committed Oct 15, 2019
1 parent 876cadd commit 826eb51
Showing 1 changed file with 111 additions and 5 deletions.
116 changes: 111 additions & 5 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -73409,6 +73409,74 @@ END:VCARD</pre>
</ul>


<h4>The <code>UserActivation</code> interface</h4>

<p>The <span>user activation state</span> is provided via the <code>UserActivation</code>
interface. <code>UserActivation</code> objects can be created either as a live or snapshot object,
it depends on how the object was referenced. Objects accessed via <code>navigator</code>'s <code
data-x="dom-Navigator-userActivation">userActivation</code> attribute are live, in that changes
will in the user activation state will be reflected in the attributes of the object.
<code>UserActivation</code> objects retrieved via <code>MessageEvent</code>'s <code
data-x="dom-MessageEvent-userActivation">userActivation</code> attribute will be snapshot objects,
that is a snapshot of the source's state.</p>

<pre><code class="idl" data-x="">[Exposed=(Window,Worker,AudioWorklet)]
interface <dfn>UserActivation</dfn> {
readonly attribute boolean <span data-x="dom-UserActivation-hasBeenActive">hasBeenActive</span>;
readonly attribute boolean <span data-x="dom-UserActivation-isActive">isActive</span>;
};

partial interface <span id="NavigatorUserActivation-partial">Navigator</span> {
readyonly attribute <code>UserActivation</code> <span data-x="dom-Navigator-userActivation">userActivation</span>;
};</code></pre>

<dl class="domintro">

<dt><var>navigator</var> . <code subdfn
data-x="dom-Navigator-userActivation">userActivation</code></dt>

<dd>

<p>Returns the a live object representing the current <span>user activation state</span>.</p>

</dd>

<dt><var>userActivation</var> . <code subdfn
data-x="dom-UserActivation-hasBeenActive">hasBeenActive</code></dt>

<dd>

<p>Returns the state of the <span>sticky activation flag</span>.</p>

</dd>

<dt><var>userActivation</var> . <code subdfn
data-x="dom-UserActivation-isActive">isActive</code></dt>

<dd>

<p>Returns the state of the <span>transient activation flag</span>.</p>

</dd>

</dl>

<div w-nodev>

<p>The <dfn><code data-x="dom-UserActivation-hasBeenActive">hasBeenActive</code></dfn> attribute
must return the state of the <span>sticky activation flag</span>. If the object is live it must
always reflect the current state. If the object is a snapshot it must reflect the state at which
the time the object was created.</p>

<p>The <dfn><code data-x="dom-UserActivation-isActive">isActive</code></dfn> attribute must return
the state of the <span>transient activation flag</span>. If the object is live it must always
reflect the current state. If the object is a snapshot it must reflect the state at which the time
the object was created.</p>

<p>The <dfn><code data-x="dom-Navigator-userActivation">userActivation</code></dfn> attribute must
return a live representation of the <span>user activation state</span>.</p>

</div>

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

Expand Down Expand Up @@ -96527,6 +96595,7 @@ interface <dfn>MessageEvent</dfn> : <span>Event</span> {
readonly attribute DOMString <span data-x="dom-MessageEvent-lastEventId">lastEventId</span>;
readonly attribute <span>MessageEventSource</span>? <span data-x="dom-MessageEvent-source">source</span>;
readonly attribute FrozenArray&lt;<span>MessagePort</span>&gt; <span data-x="dom-MessageEvent-ports">ports</span>;
readonly attribute <span>UserActivation</span>? <span data-x="dom-MessageEvent-userActivation">userActivation</span>;

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 = []);
};
Expand All @@ -96537,6 +96606,7 @@ dictionary <dfn>MessageEventInit</dfn> : <span>EventInit</span> {
DOMString lastEventId = "";
<span>MessageEventSource</span>? source = null;
sequence&lt;<span>MessagePort</span>&gt; ports = [];
<span>UserActivation</span>? userActivation = null;
};

typedef (<span>WindowProxy</span> or <span>MessagePort</span> or <span>ServiceWorker</span>) <dfn>MessageEventSource</dfn>;</code></pre>
Expand Down Expand Up @@ -96589,6 +96659,15 @@ typedef (<span>WindowProxy</span> or <span>MessagePort</span> or <span>ServiceWo

</dd>

<dt><var>event</var> . <code subdfn data-x="dom-MessageEvent-userActivation">userActivation</code></dt>

<dd>

<p>Returns a snapshot of the <code>UserActivation</code> state in the
source at the time of <code data-x="dom-window-postMessage">postMessage()</code>.</p>

</dd>

<!-- initMessageEvent is deprecated -->

</dl>
Expand Down Expand Up @@ -96621,6 +96700,10 @@ typedef (<span>WindowProxy</span> or <span>MessagePort</span> or <span>ServiceWo
value it was initialized to. It represents, in <span>cross-document messaging</span> and
<span>channel messaging</span>, the <code>MessagePort</code> array being sent.</p>

<p>The <dfn><code data-x="dom-MessageEvent-userActivation">userActivation</code></dfn> attribute
must return the value it was initialized to. It represents the <span>UserActivation</span> state
at the source.</p>

<!-- handwavy, file bugs if there are interop issues -->
<p>The <dfn><code data-x="dom-MessageEvent-initMessageEvent">initMessageEvent()</code></dfn>
method must initialize the event in a manner analogous to the similarly-named <code
Expand Down Expand Up @@ -98562,6 +98645,12 @@ function receiver(e) {
window, in same-origin cases. See discussion at
https://github.com/whatwg/html/issues/1542#issuecomment-233502636 -->

<li><p>Let userActivationSnapshot be null</p></li>

<li><p>If <var>options</var>'s <code data-x="">includeUserActivation</code> member is true, set
userActivationSnapshot to be <var>incumbent settings</var>'s <span>global object</span>'s (if
available) <span>user activation state</span>.</p></li>

<li><p>Let <var>targetOrigin</var> be <var>options</var>["<code
data-x="">targetOrigin</code>"].</p></li>

Expand Down Expand Up @@ -98635,8 +98724,10 @@ function receiver(e) {
attribute initialized to <var>origin</var>, the <code
data-x="dom-MessageEvent-source">source</code> attribute initialized to <var>source</var>, the
<code data-x="dom-MessageEvent-data">data</code> attribute initialized to
<var>messageClone</var>, and the <code data-x="dom-MessageEvent-ports">ports</code> attribute
initialized to <var>newPorts</var>.</p></li>
<var>messageClone</var>, the <code data-x="dom-MessageEvent-ports">ports</code> attribute
initialized to <var>newPorts</var>, and the <code
data-x="dom-MessageEvent-userActivation">userActivation</code> attribute initialized to
<var>userActivationSnapshot</var>.</p></li>
</ol>
</li>
</ol>
Expand Down Expand Up @@ -98951,6 +99042,7 @@ interface <dfn>MessagePort</dfn> : <span>EventTarget</span> {

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

<dl class="domintro">
Expand Down Expand Up @@ -99115,6 +99207,14 @@ dictionary <dfn>PostMessageOptions</dfn> {
<code>MessagePort</code>, then throw a <span>"<code>DataCloneError</code>"</span>
<code>DOMException</code>.</p></li>

<li><p>Let userActivationSnapshot be null.</p></li>

<li><p>Let <var>incumbent settings</var> be the <span>incumbent settings object</span>.</p></li>

<li><p>If <var>options</var>'s <code data-x="">includeUserActivation</code> member is true, set
userActivationSnapshot to be <var>incumbent settings</var>'s <span>global object</span>'s (if
available) <span>user activation state</span>.</p></li>

<li><p>Let <var>doomed</var> be false.</p></li>

<li><p>If <var>targetPort</var> is not null and <var>transfer</var> <span data-x="list
Expand Down Expand Up @@ -99169,9 +99269,10 @@ dictionary <dfn>PostMessageOptions</dfn> {
<li><p><span data-x="concept-event-fire">Fire an event</span> named <code
data-x="event-message">message</code> at <var>finalTargetPort</var>, using
<code>MessageEvent</code>, with the <code data-x="dom-MessageEvent-data">data</code> attribute
initialized to <var>messageClone</var> and the <code
data-x="dom-MessageEvent-ports">ports</code> attribute initialized to
<var>newPorts</var>.</p></li>
initialized to <var>messageClone</var>, the <code data-x="dom-MessageEvent-ports">ports</code>
attribute initialized to <var>newPorts</var>, and the <code
data-x="dom-MessageEvent-userActivation">userActivation</code> attribute initialized to
<var>userActivationSnapshot</var>.</p></li>
</ol>
</li>
</ol>
Expand Down Expand Up @@ -99241,6 +99342,11 @@ dictionary <dfn>PostMessageOptions</dfn> {
message queue</span> must be enabled, as if the <code data-x="dom-MessagePort-start">start()</code>
method had been called.</p>

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

</div>


Expand Down

0 comments on commit 826eb51

Please sign in to comment.