Skip to content

Commit

Permalink
Allow not executing scripts inserted by document.write()
Browse files Browse the repository at this point in the history
This allows user agents to experiment with better heuristics for not executing such scripts, as per WICG/interventions#17.
  • Loading branch information
domenic authored and zcorpan committed Sep 1, 2016
1 parent 2f3c8cd commit 708f0ae
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -57390,7 +57390,8 @@ interface <dfn>HTMLScriptElement</dfn> : <span>HTMLElement</span> {
<!--TOPIC:HTML-->

<p class="note">When inserted using the <code data-x="dom-document-write">document.write()</code>
method, <code>script</code> elements execute (typically blocking further script execution or HTML parsing), but when inserted using
method, <code>script</code> elements <a href="#document-written-scripts-intervention">usually</a>
execute (typically blocking further script execution or HTML parsing). When inserted using the
<code data-x="dom-innerHTML">innerHTML</code> and <code data-x="dom-outerHTML">outerHTML</code>
attributes, they do not execute at all.</p>

Expand Down Expand Up @@ -90111,8 +90112,10 @@ document.body.appendChild(frame)</pre>
"<code data-x="">&lt;plaintext&gt;</code>" or "<code data-x="">&lt;!--</code>"). In other cases,
the call can clear the current page first, as if <code
data-x="dom-document-open">document.open()</code> had been called. In yet more cases, the method
is simply ignored, or throws an exception. To make matters worse, the exact behavior of this
method can in some cases be dependent on network latency<!--
is simply ignored, or throws an exception. Users agents are <a
href="#document-written-scripts-intervention">explicitly allowed to avoid executing
<code>script</code> elements inserted via this method</a>. And to make matters even worse, the
exact behavior of this method can in some cases be dependent on network latency<!--

Namely, in the following case:

Expand Down Expand Up @@ -104340,6 +104343,14 @@ document.body.appendChild(text);
algorithm</span>, then mark the <code>script</code> element as <span>"already started"</span>.
(<span>fragment case</span>)</p></li>

<li id="document-written-scripts-intervention"><p>If the parser was invoked via the <code
data-x="dom-document-write">document.write()</code> or <code
data-x="dom-document-writeln">document.writeln()</code> methods, then optionally mark the
<code>script</code> element as <span>"already started"</span>. (For example, the user agent
might use this clause to prevent execution of <span data-x="origin">cross-origin</span> scripts
inserted via <code data-x="dom-document-write">document.write()</code> under slow network
conditions, or when the page has already taken a long time to load.)</p></li>

<li><p>Insert the newly created element at the <var>adjusted insertion
location</var>.</p></li>

Expand Down Expand Up @@ -119763,6 +119774,7 @@ INSERT INTERFACES HERE
Keith Yeung,
Kelly Ford,
Kelly Norton,
Kenji Baheux,
Kevin Benson,
Kevin Gadd,
Kevin Cole,
Expand Down Expand Up @@ -120016,6 +120028,7 @@ INSERT INTERFACES HERE
Shaun Inman,
Shiino Yuki, <!-- yuki3 on GitHub -->
Shiki Okasaka,
Shivani Sharma,
Shubheksha Jalan,
Sierk Bornemann,
Sigbj&oslash;rn Finne,
Expand Down

0 comments on commit 708f0ae

Please sign in to comment.