Permalink
Browse files

Clarify document.open() and refactor window.open()

document.open() should not invoke public window.open().
  • Loading branch information...
annevk authored and domenic committed May 12, 2017
1 parent d43b705 commit 29afad43e373140a6c59e2e99753e8f2da1c7c70
Showing with 45 additions and 65 deletions.
  1. +45 −65 source
View
110 source
@@ -78440,12 +78440,8 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span
<div w-nodev>
<p>The <dfn><code data-x="dom-open">open(<var>url</var>, <var>target</var>,
<var>features</var>)</code></dfn> method on <code>Window</code> objects provides a mechanism for
<span data-x="navigate">navigating</span> an existing <span>browsing context</span> or opening and
navigating an <span>auxiliary browsing context</span>.</p>
<p>When the method is invoked, the user agent must run the following steps:</p>
<p>The <dfn>window open steps</dfn>, given a string <var>url</var>, a string <var>target</var>,
and a string <var>features</var>, are as follows:</p>
<ol>
@@ -78454,8 +78450,8 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span
<li><p>Let <var>source browsing context</var> be the <span>responsible browsing context</span>
specified by <var>entry settings</var>.</p></li>
<li><p>If <var>target</var> is the empty string, let it be the string "<code
data-x="">_blank</code>" instead.</p></li>
<li><p>If <var>target</var> is the empty string, then set <var>target</var> to "<code
data-x="">_blank</code>".</p></li>
<li>
<p>Let <var>target browsing context</var> and <var>new</var> be the result of applying
@@ -78475,65 +78471,46 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span
<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>new</var> is true, then <span>set up browsing context features</span> for
<var>target browsing context</var> given <var>tokenizedFeatures</var>. <ref
spec="CSSOMVIEW"></p></li>
<li>
<p>If <var>url</var> is the empty string, run the appropriate steps from the following list:</p>
<dl>
<dt>If <var>new</var> is false</dt>
<dd><p>Jump to the step labeled <i>end</i>.</p></dd>
<dt>If <var>new</var> is true</dt>
<dd><p>Let <var>resource</var> be the <span>URL</span> "<code>about:blank</code>".</p></dd>
</dl>
<p>Otherwise, <span data-x="parse a url">parse</span> <var>url</var> relative to <var>entry
settings</var>, and let <var>resource</var> be the <span>resulting URL record</span>, if any. If
the <span>parse a URL</span> algorithm failed, then throw a
<span>"<code>SyntaxError</code>"</span> <code>DOMException</code>.</p>
</li>
<li><p>Let <var>resource</var> be the <span>URL</span> "<code>about:blank</code>".</p></li>
<li>
<p>If <var>resource</var> is "<code>about:blank</code>" and <var>new</var> is true, then
<span>queue a task</span> to <span data-x="concept-event-fire">fire an event</span> named <code
data-x="event-load">load</code> at <var>target browsing context</var>'s <code>Window</code>
object, with <var>legacy target override flag</var> set.</p>
<p>Otherwise, <span>navigate</span><!--DONAV window.open()--> <var>target browsing context</var>
to <var>resource</var>, with the <var><span>exceptions enabled flag</span></var> set. If
<var>new</var> is true, then <span data-x="replacement enabled">replacement must be
enabled</span>. The <span>source browsing context</span> is <var>source browsing context</var>.
Rethrow any exceptions.</p>
</li>
<li>
<p><i>End</i>:</p>
<p>If <var>url</var> is not the empty string or <var>new</var> is true, then:
<ol>
<li><p>If <var>url</var> is not the empty string, then <span data-x="parse a url">parse</span>
<var>url</var> relative to <var>entry settings</var>, and set <var>resource</var> to the
<span>resulting URL record</span>, if any. If the <span>parse a URL</span> algorithm failed,
then throw a <span>"<code>SyntaxError</code>"</span> <code>DOMException</code>.</p></li>
<li><p>If <var>resource</var> is "<code>about:blank</code>" and <var>new</var> is true, then
<span>queue a task</span> to <span data-x="concept-event-fire">fire an event</span> named <code
data-x="event-load">load</code> at <var>target browsing context</var>'s <code>Window</code>
object, with the <var>legacy target override flag</var> set.</p>
<li><p>Otherwise, <span>navigate</span><!--DONAV window.open()--> <var>target browsing
context</var> to <var>resource</var>, with the <var><span>exceptions enabled flag</span></var>
set. If <var>new</var> is true, then <span data-x="replacement enabled">replacement must be
enabled</span>. The <span>source browsing context</span> is <var>source browsing context</var>.
Rethrow any exceptions.</p></li>
</ol>
</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>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>
<li><p>Return <var>target browsing context</var>'s <code>WindowProxy</code> object.</p></li>
</ol>
</ol>
<p>The <dfn><code data-x="dom-open">open(<var>url</var>, <var>target</var>,
<var>features</var>)</code></dfn> method on <code>Window</code> objects provides a mechanism for
<span data-x="navigate">navigating</span> an existing <span>browsing context</span> or opening and
navigating an <span>auxiliary browsing context</span>.</p>
</li>
<p>When the method is invoked, the user agent must run the <span>window open steps</span> with
<var>url</var>, <var>target</var>, and <var>features</var>.</p>
</ol>
<hr>
<p>To <dfn data-x="concept-window-open-features-tokenize">tokenize the <var>features</var>
argument</dfn>:</p>
@@ -90777,13 +90754,16 @@ document.body.appendChild(frame)</pre>
whether a <code>Document</code> is <span>ready for post-load tasks</span> or <span>completely
loaded</span>.</p>
<p>When called with three arguments, the <code data-x="dom-document-open">open()</code> method on
the <code>Document</code> object must call the <code data-x="dom-open">open()</code> method on the
<code>Window</code> object of the <code>Document</code> object, with the same arguments as the
original call to the <code data-x="dom-document-open">open()</code> method, and return whatever
that method returned. If the <code>Document</code> object has no <code>Window</code> object, then
the method must throw an <span>"<code>InvalidAccessError</code>"</span>
<code>DOMException</code>.</p>
<p>When invoked with three arguments, the <code data-x="dom-document-open">open(<var>url</var>,
<var>name</var>, <var>features</var>)</code> method must run these steps:</p>
<ol>
<li><p>If this <code>Document</code> object is not an <span>active document</span>, then throw an
<span>"<code>InvalidStateError</code>"</span> <code>DOMException</code> exception.</p></li>
<li><p>Return the result of running the <span>window open steps</span> with <var>url</var>,
<var>name</var>, and <var>features</var>.</p></li>
</ol>
</div>

0 comments on commit 29afad4

Please sign in to comment.