Skip to content

Commit ee2330f

Browse files
committed
Allow not executing scripts inserted by document.write()
This allows user agents to experiment with better heuristics for not executing such scripts, as per WICG/interventions#17.
1 parent c2dfb03 commit ee2330f

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

source

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57196,7 +57196,8 @@ dictionary <dfn>RelatedEventInit</dfn> : <span>EventInit</span> {
5719657196
<!--TOPIC:HTML-->
5719757197

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

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

8930289305
Namely, in the following case:
8930389306

@@ -103442,6 +103445,14 @@ document.body.appendChild(text);
103442103445
algorithm</span>, then mark the <code>script</code> element as <span>"already started"</span>.
103443103446
(<span>fragment case</span>)</p></li>
103444103447

103448+
<li id="document-written-scripts-intervention"><p>If the parser was invoked via the <code
103449+
data-x="dom-document-write">document.write()</code> or <code
103450+
data-x="dom-document-writeln">document.writeln()</code> methods, then optionally mark the
103451+
<code>script</code> element as <span>"already started"</span>. (For example, the user agent
103452+
might use this clause to prevent execution of <span data-x="origin">cross-origin</span> scripts
103453+
inserted via <code data-x="dom-document-write">document.write()</code> under slow network
103454+
conditions, or when the page has already taken a long time to load.)</p></li>
103455+
103445103456
<li><p>Insert the newly created element at the <var>adjusted insertion
103446103457
location</var>.</p></li>
103447103458

@@ -118874,6 +118885,7 @@ INSERT INTERFACES HERE
118874118885
Keith Yeung,
118875118886
Kelly Ford,
118876118887
Kelly Norton,
118888+
Kenji Baheux,
118877118889
Kevin Benson,
118878118890
Kevin Gadd,
118879118891
Kevin Cole,
@@ -119120,6 +119132,7 @@ INSERT INTERFACES HERE
119120119132
Shanti Rao,
119121119133
Shaun Inman,
119122119134
Shiki Okasaka,
119135+
Shivani Sharma,
119123119136
Shubheksha Jalan,
119124119137
Sierk Bornemann,
119125119138
Sigbj&oslash;rn Finne,

0 commit comments

Comments
 (0)