Skip to content

Commit

Permalink
Clarify Window's focus() and blur()
Browse files Browse the repository at this point in the history
In particular when there's a null browsing context, for #4363.

Tests: web-platform-tests/wpt#15460.
  • Loading branch information
annevk committed Feb 19, 2019
1 parent b8c084e commit b8aaa49
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -73675,24 +73675,31 @@ END:VCARD</pre>
<code>Document</code> object, when invoked, must return the result of running the <span>has focus
steps</span> with the <code>Document</code> object as the argument.</p>

<p>The <dfn data-dfn-for="Window"><code data-x="dom-window-focus">focus()</code></dfn> method on
the <code>Window</code> object, when invoked, must run the <span>focusing steps</span> with the
<code>Window</code> object's <span>browsing context</span>. Additionally, if this <span>browsing
context</span> is a <span>top-level browsing context</span>, user agents are encouraged to trigger
some sort of notification to indicate to the user that the page is attempting to gain focus.</p>

<p>The <dfn data-dfn-for="Window"><code data-x="dom-window-blur">blur()</code></dfn> method on the
<code>Window</code> object, when invoked, provides a hint to the user agent that the script
believes the user probably is not currently interested in the contents of the <span>browsing
context</span> of the <code>Window</code> object on which the method was invoked, but that the
contents might become interesting again in the future.</p>
<p>The <dfn data-dfn-for="Window"><code data-x="dom-window-focus">focus()</code></dfn> method,
when invoked, must run these steps:</p>

<ol>
<li><p>If this <code>Window</code> object's <span data-x="window bc">browsing context</span> is
null, then return.</p></li>

<li><p>Run the <span>focusing steps</span> with this <code>Window</code> object's <span
data-x="window bc">browsing context</span>. Additionally, if that is a <span>top-level browsing
context</span>, user agents are encouraged to trigger some sort of notification to indicate to
the user that the page is attempting to gain focus.</p></li>
</ol>

<p>The <dfn data-dfn-for="Window"><code data-x="dom-window-blur">blur()</code></dfn> method
provides a hint to the user agent that the script believes the user probably is not currently
interested in the contents of this <code>Window</code> object's <span data-x="window bc">browsing
context</span>, if non-null, but that the contents might become interesting again in the
future.</p>

<p>User agents are encouraged to ignore calls to this <code data-x="dom-window-blur">blur()</code>
method entirely.</p>

<p class="note">Historically, the <code data-x="dom-window-blur">focus()</code> and <code
data-x="dom-window-blur">blur()</code> methods actually affected the system-level focus of the
system widget (e.g. tab or window) that contained the <span>browsing context</span>, but hostile
system widget (e.g., tab or window) that contained the <span>browsing context</span>, but hostile
sites widely abuse this behavior to the user's detriment.</p>

<p>The <dfn><code data-x="dom-focus">focus(<var>options</var>)</code></dfn> method on elements, when
Expand Down

0 comments on commit b8aaa49

Please sign in to comment.