Skip to content

Commit

Permalink
Change URL parsing sequence for window open steps
Browse files Browse the repository at this point in the history
Previously, we would only check at the last minute. This would be buggy in the case where we create a new navigable, and then throw an exception. Instead we should be sure to throw before creating a new navigable.

In addition to fixing this somewhat-obviously-wrong bug, this also causes validation to happen before popup blocking or other window-choosing steps. Previously, if trying to open a window to an unparseable URL with the popup blocker active, the window open steps would return null; now, they throw an exception.

Closes #10681.
  • Loading branch information
domenic authored Nov 15, 2024
1 parent 326677b commit 316b83b
Showing 1 changed file with 20 additions and 25 deletions.
45 changes: 20 additions & 25 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -89800,6 +89800,20 @@ dictionary <dfn dictionary>WindowPostMessageOptions</dfn> : <span>StructuredSeri
<li><p>Let <var>sourceDocument</var> be the <span>entry global object</span>'s <span
data-x="concept-document-window">associated <code>Document</code></span>.</p></li>

<li><p>Let <var>urlRecord</var> be null.</p></li>

<li>
<p>If <var>url</var> is not the empty string, then:</p>

<ol>
<li><p>Set <var>urlRecord</var> to the result of <span>encoding-parsing a URL</span> given
<var>url</var>, relative to <var>sourceDocument</var>.</p></li>

<li><p>If <var>urlRecord</var> is failure, then throw a <span>"<code>SyntaxError</code>"</span>
<code>DOMException</code>.</p></li>
</ol>
</li>

<li><p>If <var>target</var> is the empty string, then set <var>target</var> to "<code
data-x="">_blank</code>".</p></li>

Expand Down Expand Up @@ -89871,15 +89885,8 @@ dictionary <dfn dictionary>WindowPostMessageOptions</dfn> : <span>StructuredSeri
data-x="nav-bc">active browsing context</span> given
<var>tokenizedFeatures</var>. <ref>CSSOMVIEW</ref></p></li>

<li><p>Let <var>urlRecord</var> be the <span>URL record</span>
<code>about:blank</code>.</p></li>

<li><p>If <var>url</var> is not the empty string, then set <var>urlRecord</var> to the result
of <span>encoding-parsing a URL</span> given <var>url</var>, relative to the <span>entry
settings object</span>.</p></li>

<li><p>If <var>urlRecord</var> is failure, then throw a <span>"<code>SyntaxError</code>"</span>
<code>DOMException</code>.</p></li>
<li><p>If <var>urlRecord</var> is null, then set <var>urlRecord</var> to a <span>URL
record</span> representing <code>about:blank</code>.</p></li>

<li>
<p>If <var>urlRecord</var> <span>matches <code>about:blank</code></span>, then perform the
Expand All @@ -89902,22 +89909,10 @@ dictionary <dfn dictionary>WindowPostMessageOptions</dfn> : <span>StructuredSeri
<p>Otherwise:</p>

<ol>
<li>
<p>If <var>url</var> is not the empty string, then:</p>

<ol>
<li><p>Let <var>urlRecord</var> be the result of <span>encoding-parsing a URL</span>
<var>url</var>, relative to the <span>entry settings object</span>.</p></li>

<li><p>If <var>urlRecord</var> is failure, then throw a
<span>"<code>SyntaxError</code>"</span> <code>DOMException</code>.</p></li>

<li><p><span>Navigate</span><!--DONAV window.open()--> <var>targetNavigable</var> to
<var>urlRecord</var> using <var>sourceDocument</var>, with <i
data-x="navigation-referrer-policy">referrerPolicy</i> set to <var>referrerPolicy</var> and
<i><span>exceptionsEnabled</span></i> set to true.</p></li>
</ol>
</li>
<li><!--DONAV window.open()--><p>If <var>urlRecord</var> is not null, then
<span>navigate</span> <var>targetNavigable</var> to <var>urlRecord</var> using
<var>sourceDocument</var>, with <i data-x="navigation-referrer-policy">referrerPolicy</i> set
to <var>referrerPolicy</var> and <i><span>exceptionsEnabled</span></i> set to true.</p></li>

<li><p>If <var>noopener</var> is false, then set <var>targetNavigable</var>'s <span
data-x="nav-bc">active browsing context</span>'s <span>opener browsing context</span> to
Expand Down

0 comments on commit 316b83b

Please sign in to comment.