Skip to content

Commit 931ecf4

Browse files
authored
Prevent [[CryptographicNonce]] from being emptied
Also clarify some prose around the nonce content attribute, including that it does in fact update the slot upon removal. Tests: web-platform-tests/wpt#21853. Fixes #5288.
1 parent db55877 commit 931ecf4

File tree

1 file changed

+37
-12
lines changed

1 file changed

+37
-12
lines changed

source

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2824,6 +2824,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
28242824
<li><dfn data-x-href="https://heycam.github.io/webidl/#dfn-legacy-platform-object">legacy platform object</dfn></li>
28252825
<li><dfn data-x-href="https://heycam.github.io/webidl/#dfn-primary-interface">primary interface</dfn></li>
28262826
<li><dfn data-x-href="https://heycam.github.io/webidl/#dfn-interface-object">interface object</dfn></li>
2827+
<li><dfn data-x-href="https://heycam.github.io/webidl/#include">include</dfn></li>
28272828
<li><dfn data-x-href="https://heycam.github.io/webidl/#dfn-interface-prototype-object">interface prototype object</dfn></li>
28282829
<li><dfn data-x-href="https://heycam.github.io/webidl/#es-platform-objects">[[Realm]] field of a platform object</dfn></li>
28292830
<li><dfn data-x-href="https://heycam.github.io/webidl/#dfn-callback-context">callback context</dfn></li>
@@ -7118,11 +7119,11 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
71187119

71197120
<p>Elements that have a <code data-x="attr-nonce">nonce</code> content attribute ensure that the
71207121
crytographic nonce is only exposed to script (and not to side-channels like CSS attribute
7121-
selectors) by extracting the value from the content attribute, moving it into an internal slot
7122+
selectors) by taking the value from the content attribute, moving it into an internal slot
71227123
named <dfn data-export="" data-dfn-for="HTMLOrSVGElement"
7123-
data-dfn-type="attribute">[[CryptographicNonce]]</dfn>, and exposing it to script via the
7124-
<code>HTMLOrSVGElement</code> interface mixin. Unless otherwise specified, the slot's value
7125-
is the empty string.</p>
7124+
data-dfn-type="attribute">[[CryptographicNonce]]</dfn>, exposing it to script via the
7125+
<code>HTMLOrSVGElement</code> interface mixin, and setting the content attribute to the empty
7126+
string. Unless otherwise specified, the slot's value is the empty string.</p>
71267127

71277128
<dl class="domintro">
71287129
<dt><var>element</var> . <code data-x="">nonce</code></dt>
@@ -7147,12 +7148,26 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
71477148
<a href="https://github.com/whatwg/html/issues/2369">issue #2369</a>, where this behavior was
71487149
introduced.</p>
71497150

7150-
<p>Whenever an element including <code>HTMLOrSVGElement</code> has its <code
7151-
data-x="attr-nonce">nonce</code> attribute is set or changed, set this element's
7152-
<span>[[CryptographicNonce]]</span> to the given value.</p>
7151+
<p>The following <span data-x="concept-element-attributes-change-ext">attribute change
7152+
steps</span> are used for the <code data-x="attr-nonce">nonce</code> content attribute:
7153+
7154+
<ol>
7155+
<li><p>If <var>element</var> does not <span>include</span> <code>HTMLOrSVGElement</code>, then
7156+
return.</p></li>
7157+
7158+
<li><p>If <var>localName</var> is not <code data-x="attr-nonce">nonce</code> or
7159+
<var>namespace</var> is not null, then return.</p></li>
71537160

7154-
<p>Whenever an element including <code>HTMLOrSVGElement</code> <span>becomes browsing-context
7155-
connected</span>, the user agent must execute the following steps on the <var>element</var>:</p>
7161+
<li><p>If <var>value</var> is null, then set <var>element</var>'s
7162+
<span>[[CryptographicNonce]]</span> to the empty string.</p></li>
7163+
7164+
<li><p>Otherwise, set <var>element</var>'s <span>[[CryptographicNonce]]</span> to
7165+
<var>value</var>.</p></li>
7166+
</ol>
7167+
7168+
<p>Whenever an element <span data-x="include">including</span> <code>HTMLOrSVGElement</code>
7169+
<span>becomes browsing-context connected</span>, the user agent must execute the following steps
7170+
on the <var>element</var>:</p>
71567171

71577172
<ol>
71587173
<li><p>Let <var>CSP list</var> be <var>element</var>'s <span data-x="shadow-including
@@ -7165,10 +7180,19 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
71657180
<var>attr</var> whose value is not the empty string, then:</p>
71667181

71677182
<ol>
7183+
<li><p>Let <var>nonce</var> be <var>element</var>'s
7184+
<span>[[CryptographicNonce]]</span>.</p></li>
7185+
71687186
<li><p><span data-x="concept-element-attributes-set-value">Set an attribute value</span> for
71697187
<var>element</var> using "<code data-x="attr-nonce">nonce</code>" and the empty
71707188
string.</p></li>
7189+
7190+
<li><p>Set <var>element</var>'s <span>[[CryptographicNonce]]</span> to
7191+
<var>nonce</var>.</p></li>
71717192
</ol>
7193+
7194+
<p class="note">If <var>element</var>'s <span>[[CryptographicNonce]]</span> were not restored it
7195+
would be the empty string at this point.</p>
71727196
</li>
71737197
</ol>
71747198

@@ -7178,9 +7202,10 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
71787202
set during <span data-x="create-the-document-object"><code data-x="">Document</code>
71797203
creation and initialization</span>.</p>
71807204

7181-
<p>The <span data-x="concept-node-clone-ext">cloning steps</span> for elements that include
7182-
<code>HTMLOrSVGElement</code> must set the <span>[[CryptographicNonce]]</span> slot on the copy
7183-
to the value of the slot on the element being cloned.</p>
7205+
<p>The <span data-x="concept-node-clone-ext">cloning steps</span> for elements that
7206+
<span>include</span> <code>HTMLOrSVGElement</code> must set the
7207+
<span>[[CryptographicNonce]]</span> slot on the copy to the value of the slot on the element being
7208+
cloned.</p>
71847209

71857210
<h4>Lazy loading attributes</h4>
71867211

0 commit comments

Comments
 (0)