Skip to content

Commit

Permalink
Standardize window.open() popup features and BarProp values
Browse files Browse the repository at this point in the history
Fixes #5872 by standardizing an internal "is popup" boolean, and how it is impacted by various window.open() features. Implementations can use this boolean (in addition to other signals) to determine whether an opened window is a popup or not.

Fixes #4431 by changing the various BarProp visible properties to only reflect this "is popup" boolean, instead of reflecting the actual state of user interface elements, or the passed-in window features.

Adds a "popup" window.open() feature to provide a simpler method of requesting a popup.
  • Loading branch information
arai-a authored Oct 29, 2021
1 parent 3ad5159 commit ab08b9b
Showing 1 changed file with 124 additions and 42 deletions.
166 changes: 124 additions & 42 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -2187,6 +2187,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li><dfn data-x-href="https://infra.spec.whatwg.org/#skip-ascii-whitespace">skip ASCII whitespace</dfn></li>
<li>The <dfn data-x-href="https://infra.spec.whatwg.org/#ordered-map">ordered map</dfn> data structure and the associated definitions for
<dfn data-x="map value" data-x-href="https://infra.spec.whatwg.org/#map-value">value</dfn>,
<dfn data-x="map empty" data-x-href="https://infra.spec.whatwg.org/#map-is-empty">empty</dfn>,
<dfn data-x="map entry" data-x-href="https://infra.spec.whatwg.org/#map-entry">entry</dfn>,
<dfn data-x="map exists" data-x-href="https://infra.spec.whatwg.org/#map-exists">exists</dfn>,
<dfn data-x="map get" data-x-href="https://infra.spec.whatwg.org/#map-get">getting the value of an entry</dfn>,
Expand Down Expand Up @@ -79499,9 +79500,36 @@ popup4.close();</code></pre></div>
export>top-level browsing context</dfn> for itself and all of the browsing contexts for which it
is an <span>ancestor browsing context</span>.</p>

<hr>

<p>A <span>top-level browsing context</span> has an associated <dfn data-x="tlbc
group">group</dfn> (null or a <span>browsing context group</span>). It is initially null.</p>

<p>A <span>top-level browsing context</span> has an <dfn>is popup</dfn> boolean. It is initially
false.</p>

<div class="note">
<p>The only mandatory impact in this specification of <span>is popup</span> is on the
<code data-x="dom-BarProp-visible">visible</code> getter of the relevant <code>BarProp</code>
objects. However, user agents might also use it in the following ways:</p>

<ul>
<li>Deciding whether or not to provide a minimal web browser user interface for the
<span>browsing context</span>.</li>

<li>Performing the <!--non-normative-->optional steps in <span>set up browsing context
features</span>.</li>
</ul>

<p>In both cases user agents might additionally incorporate user preferences, or present a choice
as to whether to go down the popup route.</p>

<p>User agents that provides a minimal web browser user interface for such popups are encouraged
to not hide the browser's location bar.</p>
</div>

<hr>

<p>It is possible to create new browsing contexts that are related to a <span>top-level browsing
context</span> while their <span data-x="bc-container">container</span> is null. Such browsing
contexts are called <dfn data-x="auxiliary browsing context" data-lt="auxiliary browsing context"
Expand Down Expand Up @@ -80840,6 +80868,10 @@ dictionary <dfn dictionary>WindowPostMessageOptions</dfn> : <span>StructuredSeri
data-x="">new with no opener</code>", then:</p>

<ol>
<li><p>Set the <var>target browsing context</var>'s <span>is popup</span> to the result of
<span data-x="popup-window-is-requested">checking if a popup window is requested</span>, given
<var>tokenizedFeatures</var>.</p></li>

<li><p><span>Set up browsing context features</span> for <var>target browsing context</var>
given <var>tokenizedFeatures</var>. <ref spec="CSSOMVIEW"></p></li>

Expand Down Expand Up @@ -81010,6 +81042,68 @@ dictionary <dfn dictionary>WindowPostMessageOptions</dfn> : <span>StructuredSeri
<li><p>Return <var>tokenizedFeatures</var>.</p></li>
</ol>

<p>To <dfn data-x="window-feature-is-set">check if a window feature is set</dfn>, given
<var>tokenizedFeatures</var>, <var>featureName</var>, and <var>defaultValue</var>:</p>

<ol>
<li><p>If <var>tokenizedFeatures</var>[<var>featureName</var>] <span data-x="map
exists">exists</span>, then return the result of <span
data-x="concept-window-open-features-parse-boolean">parsing
<var>tokenizedFeatures</var>[<var>featureName</var>] as a boolean feature</span>.</p></li>

<li><p>Return <var>defaultValue</var>.</p></li>
</ol>

<p>To <dfn data-x="popup-window-is-requested">check if a popup window is requested</dfn>, given
<var>tokenizedFeatures</var>:</p>

<ol>
<li><p>If <var>tokenizedFeatures</var> is <span data-x="map empty">empty</span>, then return
false.</p></li>

<li><p>If <var>tokenizedFeatures</var>["<code data-x="">popup</code>"] <span data-x="map
exists">exists</span>, then return the result of <span
data-x="concept-window-open-features-parse-boolean">parsing
<var>tokenizedFeatures</var>["<code data-x="">popup</code>"] as a boolean
feature</span>.</p></li>

<li><p>Let <var>location</var> be the result of <span data-x="window-feature-is-set">checking if
a window feature is set</span>, given <var>tokenizedFeatures</var>, "<code
data-x="">location</code>", and false.</p></li>

<li><p>Let <var>toolbar</var> be the result of <span data-x="window-feature-is-set">checking if
a window feature is set</span>, given <var>tokenizedFeatures</var>, "<code
data-x="">toolbar</code>", and false.</p></li>

<li><p>If <var>location</var> and <var>toolbar</var> are both false, then return true.</p></li>

<li><p>Let <var>menubar</var> be the result of <span data-x="window-feature-is-set">checking if
a window feature is set</span>, given <var>tokenizedFeatures</var>, <code
data-x="">menubar</code>", and false.</p></li>

<li><p>If <var>menubar</var> is false, then return true.</p></li>

<li><p>Let <var>resizable</var> be the result of <span data-x="window-feature-is-set">checking if
a window feature is set</span>, given <var>tokenizedFeatures</var>, "<code
data-x="">resizable</code>", and true.</p></li>

<li><p>If <var>resizable</var> is false, then return true.</p></li>

<li><p>Let <var>scrollbars</var> be the result of <span data-x="window-feature-is-set">checking
if a window feature is set</span>, given <var>tokenizedFeatures</var>, "<code
data-x="">scrollbars</code>", and false.</p></li>

<li><p>If <var>scrollbars</var> is false, then return true.</p></li>

<li><p>Let <var>status</var> be the result of <span data-x="window-feature-is-set">checking if
a window feature is set</span>, given <var>tokenizedFeatures</var>, "<code
data-x="">status</code>", and false.</p></li>

<li><p>If <var>status</var> is false, then return true.</p></li>

<li><p>Return false.</p></li>
</ol>

<p>A code point is a <dfn>feature separator</dfn> if it is <span>ASCII whitespace</span>, U+003D
(=), or U+002C (,).</p>

Expand Down Expand Up @@ -81388,8 +81482,12 @@ dictionary <dfn dictionary>WindowPostMessageOptions</dfn> : <span>StructuredSeri

<h4>Browser interface elements</h4>

<p>To allow web pages to integrate with web browsers, certain web browser interface elements are
exposed in a limited way to scripts in web pages.</p>
<p>For historical reasons, the <code>Window</code> interface had some attributes that represented
the visibility of certain web browser interface elements.</p>

<p>For privacy and interoperability reasons, those attributes now return values that represent
whether the <code>Window</code>'s <span data-x="window bc">browsing context</span>'s <span>is
popup</span> property is true or false.</p>

<p>Each interface element is represented by a <code>BarProp</code> object:</p>

Expand All @@ -81400,75 +81498,59 @@ interface <dfn interface>BarProp</dfn> {

<dl class="domintro">
<dt><code data-x=""><var>window</var>.<span subdfn data-x="dom-window-locationbar">locationbar</span>.<span subdfn data-x="dom-BarProp-visible">visible</span></code></dt>
<dd><p>Returns true if the location bar is visible; otherwise, returns false.</p></dd>

<dt><code data-x=""><var>window</var>.<span subdfn data-x="dom-window-menubar">menubar</span>.<span data-x="dom-BarProp-visible">visible</span></code></dt>
<dd><p>Returns true if the menu bar is visible; otherwise, returns false.</p></dd>

<dt><code data-x=""><var>window</var>.<span subdfn data-x="dom-window-personalbar">personalbar</span>.<span data-x="dom-BarProp-visible">visible</span></code></dt>
<dd><p>Returns true if the personal bar is visible; otherwise, returns false.</p></dd>

<dt><code data-x=""><var>window</var>.<span subdfn data-x="dom-window-scrollbars">scrollbars</span>.<span data-x="dom-BarProp-visible">visible</span></code></dt>
<dd><p>Returns true if the scrollbars are visible; otherwise, returns false.</p></dd>

<dt><code data-x=""><var>window</var>.<span subdfn data-x="dom-window-statusbar">statusbar</span>.<span data-x="dom-BarProp-visible">visible</span></code></dt>
<dd><p>Returns true if the status bar is visible; otherwise, returns false.</p></dd>

<dt><code data-x=""><var>window</var>.<span subdfn data-x="dom-window-toolbar">toolbar</span>.<span data-x="dom-BarProp-visible">visible</span></code></dt>
<dd><p>Returns true if the toolbar is visible; otherwise, returns false.</p></dd>
<dd><p>Returns true if the <span>top-level browsing context</span> is not a popup; otherwise,
returns false.</p></dd>
</dl>

<div w-nodev>

<p>The <dfn attribute for="BarProp" data-x="dom-BarProp-visible">visible</dfn> attribute's getter
must run these steps:</p>
<p>The <dfn attribute for="BarProp" data-x="dom-BarProp-visible">visible</dfn> getter steps
are:</p>

<ol>
<li><p>If this <code>BarProp</code> object's <span>relevant global object</span>'s <span
data-x="window bc">browsing context</span> is null, then return false.</p></li>
<li><p>Let <var>browsingContext</var> be <span>this</span>'s <span>relevant global
object</span>'s <span data-x="window bc">browsing context</span>.</p></li>

<li><p>If the user agent does not have a user interface element that the object represents, as
described below, then return true.</p></li>
<li><p>If <var>browsingContext</var> is null, then return true.</p></li>

<li><p>Return true or a value determined by the user agent to most accurately represent the
visibility state of the user interface element that the object represents, as described
below.</p></li>
<li><p>Return the negation of <var>browsingContext</var>'s <span>top-level browsing
context</span>'s <span>is popup</span>.</p></li>
</ol>

<p>The following <code>BarProp</code> objects must exist for each <code>Window</code> object:</p>

<dl>
<dt><dfn>The location bar <code>BarProp</code> object</dfn></dt>
<dd>Represents the user interface element that contains a control that displays the
<span>URL</span> of the <span>active document</span>, or some similar interface concept.</dd>
<dd>Historically represented the user interface element that contains a control that displays the
browser's location bar.</dd>

<dt><dfn>The menu bar <code>BarProp</code> object</dfn></dt>
<dd>Represents the user interface element that contains a list of commands in menu form, or some
similar interface concept.</dd>
<dd>Historically represented the user interface element that contains a list of commands in menu
form, or some similar interface concept.</dd>

<dt><dfn>The personal bar <code>BarProp</code> object</dfn></dt>
<dd>Represents the user interface element that contains links to the user's favorite pages, or
some similar interface concept.</dd>
<dd>Historically represented the user interface element that contains links to the user's
favorite pages, or some similar interface concept.</dd>

<dt><dfn>The scrollbar <code>BarProp</code> object</dfn></dt>
<dd>Represents the user interface element that contains a scrolling mechanism, or some similar
interface concept.</dd>
<dd>Historically represented the user interface element that contains a scrolling mechanism, or
some similar interface concept.</dd>

<dt><dfn>The status bar <code>BarProp</code> object</dfn></dt>
<dd>Represents a user interface element found immediately below or after the document, as
appropriate for the user's media, which typically provides information about ongoing network
activity or information about elements that the user's pointing device is current indicating. If
the user agent has no such user interface element, then the object may act as if the
corresponding user interface element was absent (i.e. its <code
data-x="dom-BarProp-visible">visible</code> attribute may return false).</dd>
<dd>Historically represented a user interface element found immediately below or after the
document, as appropriate for the user's media, which typically provides information about ongoing
network activity or information about elements that the user's pointing device is currently
indicating.</dd>

<dt><dfn>The toolbar <code>BarProp</code> object</dfn></dt>
<dd>Represents the user interface element found immediately above or before the document, as
appropriate for the user's media, which typically provides <span>session history</span> traversal
controls (back and forward buttons, reload buttons, etc.). If the user agent has no such user
interface element, then the object may act as if the corresponding user interface element was
absent (i.e. its <code data-x="dom-BarProp-visible">visible</code> attribute may return
false).</dd>
<dd>Historically represented the user interface element found immediately above or before the
document, as appropriate for the user's media, which typically provides <span>session
history</span> traversal controls (back and forward buttons, reload buttons, etc.).</dd>
</dl>

<p>The <dfn attribute for="Window"><code data-x="dom-window-locationbar">locationbar</code></dfn>
Expand Down

0 comments on commit ab08b9b

Please sign in to comment.