Skip to content

Commit 15b258d

Browse files
authored
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 508cf2d commit 15b258d

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
@@ -57437,7 +57437,8 @@ interface <dfn>HTMLScriptElement</dfn> : <span>HTMLElement</span> {
5743757437
</div>
5743857438

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

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

9063190634
Namely, in the following case:
9063290635

@@ -105465,6 +105468,14 @@ document.body.appendChild(text);
105465105468
algorithm</span>, then mark the <code>script</code> element as <span>"already started"</span>.
105466105469
(<span>fragment case</span>)</p></li>
105467105470

105471+
<li id="document-written-scripts-intervention"><p>If the parser was invoked via the <code
105472+
data-x="dom-document-write">document.write()</code> or <code
105473+
data-x="dom-document-writeln">document.writeln()</code> methods, then optionally mark the
105474+
<code>script</code> element as <span>"already started"</span>. (For example, the user agent
105475+
might use this clause to prevent execution of <span data-x="origin">cross-origin</span> scripts
105476+
inserted via <code data-x="dom-document-write">document.write()</code> under slow network
105477+
conditions, or when the page has already taken a long time to load.)</p></li>
105478+
105468105479
<li><p>Insert the newly created element at the <var>adjusted insertion
105469105480
location</var>.</p></li>
105470105481

@@ -120817,6 +120828,7 @@ INSERT INTERFACES HERE
120817120828
Keith Yeung,
120818120829
Kelly Ford,
120819120830
Kelly Norton,
120831+
Kenji Baheux,
120820120832
Kevin Benson,
120821120833
Kevin Cole,
120822120834
Kevin Gadd,
@@ -121089,6 +121101,7 @@ INSERT INTERFACES HERE
121089121101
Shiino Yuki, <!-- yuki3 on GitHub -->
121090121102
贺师俊 (HE Shi-Jun), <!-- hax on GitHub -->
121091121103
Shiki Okasaka,
121104+
Shivani Sharma,
121092121105
Shubheksha Jalan,
121093121106
Sierk Bornemann,
121094121107
Sigbj&oslash;rn Finne,

0 commit comments

Comments
 (0)