Skip to content

Commit

Permalink
Investigate a new document.open()
Browse files Browse the repository at this point in the history
For #1698, #3564, ... Needs many tests.
  • Loading branch information
annevk committed May 3, 2018
1 parent fdbeb95 commit fc36e7d
Showing 1 changed file with 11 additions and 57 deletions.
68 changes: 11 additions & 57 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -9171,7 +9171,7 @@ partial interface <dfn id="document" data-lt="">Document</dfn> {
readonly attribute <span>HTMLOrSVGScriptElement</span>? <span data-x="dom-document-currentScript">currentScript</span>; // classic scripts in a document tree only

// <span>dynamic markup insertion</span>
[<span>CEReactions</span>] <span>Document</span> <span data-x="dom-document-open">open</span>(optional DOMString type, optional DOMString replace = ""); // type is ignored
[<span>CEReactions</span>] <span>Document</span> <span data-x="dom-document-open">open</span>(optional DOMString type, optional DOMString replace); // type and replace are ignored
<span>WindowProxy</span> <span data-x="dom-document-open">open</span>(USVString url, DOMString name, DOMString features);
[<span>CEReactions</span>] void <span data-x="dom-document-close">close</span>();
[<span>CEReactions</span>] void <span data-x="dom-document-write">write</span>(DOMString... text);
Expand Down Expand Up @@ -76914,14 +76914,12 @@ dictionary <dfn>DragEventInit</dfn> : <span>MouseEventInit</span> {

<p class="note">In general, there is a 1-to-1 mapping from the <code>Window</code> object to the
<code>Document</code> object, as long as the <code>Document</code> object has a <span
data-x="concept-document-bc">browsing context</span>. There are two exceptions. First, a
data-x="concept-document-bc">browsing context</span>. There is one exception. A
<code>Window</code> can be reused for the presentation of a second <code>Document</code> in the
same <span>browsing context</span>, such that the mapping is then 1-to-2. This occurs when a
<span>browsing context</span> is <span data-x="navigate">navigated</span> from the initial
<code>about:blank</code> <code>Document</code> to another, with <span>replacement enabled</span>.
Second, a <code>Document</code> can end up being reused for several <code>Window</code> objects
when the <code data-x="dom-document-open">document.open()</code> method is used, such that the
mapping is then many-to-1.</p>
<code>about:blank</code> <code>Document</code> to another, with <span>replacement
enabled</span>.</p>

<p class="note">A <code>Document</code> does not necessarily have a <span
data-x="concept-document-bc">browsing context</span> associated with it. In particular, data
Expand Down Expand Up @@ -79476,6 +79474,7 @@ interface <dfn>BarProp</dfn> {
the <code>Document</code>'s <span data-x="concept-document-url">URL</span> to
"<code>about:blank</code>". Therefore the <span>origin</span> is assigned when the
<code>Document</code> is created.</p>
<!-- TODO it's unclear whether it always mutates the URL -->
</dd>


Expand Down Expand Up @@ -90543,18 +90542,13 @@ document.body.appendChild(frame)</pre>
with different numbers of arguments.</p>

<dl class="domintro">
<dt><var>document</var> = <var>document</var> . <code subdfn data-x="dom-document-open">open</code>( [ <var>type</var> [, <var>replace</var> ] ] )</dt>
<dt><var>document</var> = <var>document</var> . <code subdfn data-x="dom-document-open">open</code>()</dt>
<dd>
<p>Causes the <code>Document</code> to be replaced in-place, as if it was a new
<code>Document</code> object, but reusing the previous object, which is then returned.</p>

<p>The resulting <code>Document</code> has an HTML parser associated with it, which can be given
data to parse using <code data-x="dom-document-write">document.write()</code>. (The
<var>type</var> argument is ignored.)</p>

<p>If the <var>replace</var> argument is present and has the value "<code
data-x="">replace</code>", the existing entries in the session history for the
<code>Document</code> object are removed.</p>
data to parse using <code data-x="dom-document-write">document.write()</code>.</p>

<p>The method has no effect if the <code>Document</code> is still being parsed.</p>

Expand All @@ -90577,8 +90571,7 @@ document.body.appendChild(frame)</pre>
unloaded</span>. Initially, the counter must be set to zero.</p> <!--
https://www.hixie.ch/tests/adhoc/dom/level0/document/open/unload/ -->

<p>The <dfn>document open steps</dfn>, given a <var>document</var> and <var>replaceInput</var>,
are as follows:</p>
<p>The <dfn>document open steps</dfn>, given a <var>document</var>, are as follows:</p>

<ol>
<li><p>If <var>document</var> is an <span data-x="XML documents">XML document</span>, then throw
Expand Down Expand Up @@ -90615,21 +90608,6 @@ document.body.appendChild(frame)</pre>
handler while the <code>Document</code> is being unloaded.</p>
</li>

<li><p>Let <var>replace</var> be false.

<li>
<p>If <var>replaceInput</var> is an <span>ASCII case-insensitive</span> match for "<code
data-x="">replace</code>", then set <var>replace</var> to true.</p>

<p>Otherwise, if <var>document</var>'s <span>browsing context</span>'s <span>session
history</span> contains only one <code>Document</code> object, and that was the
<code>about:blank</code> <code>Document</code> created when <var>document</var>'s <span>browsing
context</span> was <span data-x="creating a new browsing context">created</span>, and that
<code>Document</code> object has never had the <span>unload a document</span> algorithm invoked
on it (e.g., by a previous call to <code data-x="dom-document-open">document.open()</code>),
then set <var>replace</var> to true.</p>
</li>

<li><p>Set <var>document</var>'s <i data-x="concept-document-salvageable">salvageable</i> state
to false.</p></li>

Expand All @@ -90652,6 +90630,7 @@ document.body.appendChild(frame)</pre>
<li><p><span data-x="concept-node-replace-all">Replace all</span> with null within
<var>document</var>, without firing any mutation events.</p></li>

<<<<<<< HEAD
<li>
<p>Call the JavaScript <span
data-x="js-InitializeHostDefinedRealm">InitializeHostDefinedRealm()</span> abstract operation
Expand Down Expand Up @@ -90721,30 +90700,6 @@ document.body.appendChild(frame)</pre>
<li><p>Set the <span>current document readiness</span> of <var>document</var> to "<code
data-x="">loading</code>".</p></li>

<li><p>Remove any <span data-x="concept-task">tasks</span> queued by the <span>history traversal
task source</span> that are associated with any <code>Document</code> objects in the
<span>top-level browsing context</span>'s <span>document family</span>.</p></li>

<li>
<p>Remove all the entries in the <span>browsing context</span>'s <span>session history</span>
after the <span>current entry</span>. If the <span>current entry</span> is the last entry in the
session history, then no entries are removed.</p>

<p class="note">This <a href="#history-notes">doesn't necessarily have to affect</a> the user
agent's user interface.</p>
</li>

<li><p>Remove any earlier entries whose <code>Document</code> object is
<var>document</var>.</p></li>

<li><p>If <var>replace</var> is false, then add a new entry, just before the last entry,
and associate with the new entry the text that was parsed by the previous parser associated with
<var>document</var>, as well as the state of <var>document</var> at the start of these steps.
This allows the user to step backwards in the session history to see the page before it was blown
away by the <code data-x="dom-document-open">document.open()</code> call. This new entry does not
have a <code>Document</code> object, so a new one will be created if the session history is
traversed to that entry.</p></li>

<li><p>Set <var>document</var>'s <span>fired unload</span> flag to false. (It could have been set
to true during the <span data-x="unload a document">unload</span> step above.)</p></li>

Expand All @@ -90755,9 +90710,8 @@ document.body.appendChild(frame)</pre>
</ol>

<p>When invoked with two arguments or fewer, the <code
data-x="dom-document-open">document.open(<var>type</var>, <var>replace</var>)</code> method must
return the result of running the <span>document open steps</span> with this <code>Document</code>
object and <var>replace</var>.
data-x="dom-document-open">document.open(<var>type</var>)</code> method must return the result of
running the <span>document open steps</span> with this <code>Document</code> object.

<p class="note">The <var>type</var> argument is ignored. Also, the <code
data-x="dom-document-open">document.open()</code> method does not affect whether a
Expand Down

0 comments on commit fc36e7d

Please sign in to comment.