Skip to content

Commit

Permalink
Specify the tokenizer for window.open's features argument
Browse files Browse the repository at this point in the history
This was specified in CSSOM View but the "noopener" feature did
not use the same tokenizer as the legacy features. Fixes whatwg#2474.

Also specify the aliases screenx, screeny, innerwidth, innerheight
for left, top, width, and height, respectively. Part of whatwg#2464.
Closes w3c/csswg-drafts#1128.

The tokenizer specified here closely follows Edge.
Chromium and WebKit are also very similar to Edge.
Difference from Edge: U+0000 does not end the string.
Difference from Chromium: U+0000 is not a separator.
Difference from WebKit/Chromium/Edge: U+000C is a separator.

For the input `width toolbar=450, height=450`,
Edge tokenizes like `width, toolbar=450, height=450` while
WebKit/Chromium like `width=450, height=450`.
The Edge behavior seems better.

Tests:
web-platform-tests/wpt#5306
web-platform-tests/wpt#5390
  • Loading branch information
zcorpan authored and Alice Boxhall committed Jan 7, 2019
1 parent b75ee39 commit 5616fb9
Showing 1 changed file with 111 additions and 9 deletions.
120 changes: 111 additions & 9 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -2365,6 +2365,9 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<p>The following terms are defined in the WHATWG Infra standard: <ref spec=INFRA></p>

<ul class="brief">
<li>The general iteration terms <dfn data-x-href="https://infra.spec.whatwg.org/#iteration-while">while</dfn>,
<dfn data-x-href="https://infra.spec.whatwg.org/#iteration-continue">continue</dfn>, and
<dfn data-x-href="https://infra.spec.whatwg.org/#iteration-break">break</dfn>.</li>
<li><dfn data-x-href="https://infra.spec.whatwg.org/#code-point">code point</dfn> and its synonym
<dfn data-x-href="https://infra.spec.whatwg.org/#code-point">character</dfn></li>
<li><dfn data-x-href="https://infra.spec.whatwg.org/#surrogate">surrogate</dfn></li>
Expand Down Expand Up @@ -3535,7 +3538,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li><dfn data-x-href="https://drafts.csswg.org/cssom-view/#scroll-to-the-beginning-of-the-document">Scroll to the beginning of the document</dfn></li>
<li>The <dfn data-x="event-resize" data-x-href="https://drafts.csswg.org/cssom-view/#eventdef-window-resize"><code>resize</code></dfn> event</li>
<li>The <dfn data-x="event-scroll" data-x-href="https://drafts.csswg.org/cssom-view/#eventdef-document-scroll"><code>scroll</code></dfn> event</li>
<li><dfn data-x="dom-open-features" data-x-href="https://drafts.csswg.org/cssom-view/#the-features-argument-to-the-open()-method">The <var>features</var> argument of <code data-x="dom-open">window.open</code></dfn>
<li><dfn data-x-href="https://drafts.csswg.org/cssom-view/#set-up-browsing-context-features">set up browsing context features</dfn></li>
</ul>

<p>The following features and terms are defined in the <cite>CSS Syntax</cite> specifications:
Expand Down Expand Up @@ -78574,8 +78577,8 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span

<p>Opens a window to show <var>url</var> (defaults to <code>about:blank</code>), and returns it.
The <var>target</var> argument gives the name of the new window. If a window exists with that
name already, it is reused. The <var data-x="dom-open-features">features</var> argument can be
used to influence the rendering of the new window.</p>
name already, it is reused. The <var>features</var> argument can be used to influence the
rendering of the new window.</p>

</dd>

Expand Down Expand Up @@ -78670,8 +78673,12 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span
indicating a preference for navigating a new <span>top-level browsing context</span>, then let
<var>new</var> be true. Otherwise, let it be false.</p></li>

<li><p>Interpret <var>features</var> <span data-x="dom-open-features">as defined in the CSSOM
View specification</span>. <ref spec="CSSOMVIEW"></p></li>
<li><p>Let <var>tokenizedFeatures</var> be the result of <span
data-x="concept-window-open-features-tokenize">tokenizing</span> <var>features</var>.</p></li>

<li><p>If <var>target browsing context</var> is a new <span>auxiliary browsing context</span>,
then <span>set up browsing context features</span> for <var>target browsing context</var> given
<var>tokenizedFeatures</var>. <ref spec="CSSOMVIEW"></p></li>

<li>

Expand Down Expand Up @@ -78726,10 +78733,9 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span

<ol>

<li><p>If the result of <span data-x="split a string on commas">splitting <var>features</var>
on commas</span> contains the token "<code data-x="">noopener</code>", then <span
data-x="disowned its opener">disown <var>target browsing context</var>'s opener</span> and
return null.</p></li>
<li><p>If <var>tokenizedFeatures</var> <span data-x="map exists">contains</span> an entry with
the key "<code data-x="">noopener</code>", then <span data-x="disowned its opener">disown
<var>target browsing context</var>'s opener</span> and return null.</p></li>

<li><p>Otherwise, return the <code>WindowProxy</code> object of <var>target browsing
context</var>.</p></li>
Expand All @@ -78740,6 +78746,102 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span

</ol>

<p>To <dfn data-x="concept-window-open-features-tokenize">tokenize the <var>features</var>
argument</dfn>:</p>

<ol>
<li><p>Let <var>tokenizedFeatures</var> be a new <span>ordered map</span>.</p></li>

<li><p>Let <var>position</var> point at the first code point of <var>features</var>.</p></li>

<li>
<p><span>While</span> <var>position</var> is not past the end of <var>features</var>:</p>

<ol>
<li><p>Let <var>name</var> be the empty string.</p></li>

<li><p>Let <var>value</var> be the empty string.</p></li>

<li><p><span>Collect a sequence of code points</span> that are <span data-x="feature
separator">feature separators</span> from <var>features</var> given <var>position</var>. This
skips past leading separators before the name.</p></li>

<li><p><span>Collect a sequence of code points</span> that are not <span data-x="feature
separator">feature separators</span> from <var>features</var> given <var>position</var>. Set
<var>name</var> to the collected characters, <span>converted to ASCII lowercase</span>.</p></li>

<li><p>Set <var>name</var> to the result of <span>normalizing the feature name</span>
<var>name</var>.</p></li>

<li>
<p><span>While</span> <var>position</var> is not past the end of <var>features</var> and the
code point at <var>position</var> in <var>features</var> is not U+003D (=):</p>

<ol>
<li><p>If the code point at <var>position</var> in <var>features</var> is U+002C (,), or if
it is not a <span>feature separator</span>, then <span>break</span>.</p></li>

<li><p>Advance <var>position</var> by 1.</p></li>
</ol>

<p class="note">This skips to the first U+003D (=) but does not skip past a U+002C (,) or a
non-separator.</p>
</li>

<li>
<p>If the code point at <var>position</var> in <var>features</var> is a <span>feature
separator</span>:</p>

<ol>
<li>
<p>While <var>position</var> is not past the end of <var>features</var> and the code point
at <var>position</var> in <var>features</var> is a <span>feature separator</span>:</p>

<ol>
<li><p>If the code point at <var>position</var> in <var>features</var> is U+002C (,), then
<span>break</span>.</p></li>

<li><p>Advance <var>position</var> by 1.</p></li>
</ol>

<p class="note">This skips to the first non-separator but does not skip past a U+002C
(,).</p>
</li>

<li><p><span>Collect a sequence of code points</span> that are not <span data-x="feature
separator">feature separators</span> code points from <var>features</var> given
<var>position</var>. Set <var>value</var> to the collected code points, <span>converted to
ASCII lowercase</span>.</p></li>
</ol>
</li>

<li><p>If <var>name</var> is not the empty string, then set
<var>tokenizedFeatures</var>[<var>name</var>] to <var>value</var>.</p></li>
</ol>
</li>

<li><p>Return <var>tokenizedFeatures</var>.</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>

<p>For legacy reasons, there are some aliases of some feature names. To <dfn data-x="normalizing
the feature name">normalize a feature name</dfn> <var>name</var>, switch on <var>name</var>:</p>

<dl class="switch">
<dt>"<code data-x="">screenx</code>"
<dd>Return "<code data-x="">left</code>".
<dt>"<code data-x="">screeny</code>"
<dd>Return "<code data-x="">top</code>".
<dt>"<code data-x="">innerwidth</code>"
<dd>Return "<code data-x="">width</code>".
<dt>"<code data-x="">innerheight</code>"
<dd>Return "<code data-x="">height</code>".
<dt>Anything else
<dd>Return <var>name</var>.
</dl>

<hr>

<p>The <dfn><code data-x="dom-name">name</code></dfn> attribute of the <code>Window</code> object
Expand Down

0 comments on commit 5616fb9

Please sign in to comment.