Skip to content

Commit bdab22b

Browse files
Update support for dynamic code compilation (#464)
SHA: 2f7de8e Reason: push, by lukewarlow Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 252a991 commit bdab22b

File tree

1 file changed

+41
-12
lines changed

1 file changed

+41
-12
lines changed

dist/spec/index.html

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<link href="https://www.w3.org/StyleSheets/TR/2021/W3C-ED" rel="stylesheet">
88
<meta content="Bikeshed version 82ce88815, updated Thu Sep 7 16:33:55 2023 -0700" name="generator">
99
<link href="https://w3c.github.io/trusted-types/dist/spec/" rel="canonical">
10-
<meta content="075e1f8e9142c66bcea5e2bc740dc540e293a5a6" name="document-revision">
10+
<meta content="2f7de8e5f983da9be957fde80c3a5fd3cc8acb88" name="document-revision">
1111
<style>/* Boilerplate: style-autolinks */
1212
.css.css, .property.property, .descriptor.descriptor {
1313
color: var(--a-normal-text);
@@ -2003,7 +2003,7 @@ <h3 class="heading settled" data-level="3.2" id="create-a-trusted-type-algorithm
20032003
name <var>trustedTypeName</var>, with its <code>[[Data]]</code> internal slot value
20042004
set to <var>dataString</var>.</p>
20052005
<li data-md>
2006-
<p>If <var>trustedObject</var> is a <code class="idl"><a data-link-type="idl" href="#trustedscript" id="ref-for-trustedscript⑥">TrustedScript</a></code>, set its <code>[[HostDefinedCodeLike]]</code> internal slot value to the value in its <code>[[Data]]</code> slot.</p>
2006+
<p>If <var>trustedObject</var> is a <code class="idl"><a data-link-type="idl" href="#trustedscript" id="ref-for-trustedscript⑥">TrustedScript</a></code>, set its <code>[[HostDefinedIsCodeLike]]</code> internal slot value to <code>true</code>.</p>
20072007
<p class="note" role="note"><span class="marker">Note:</span> This adds an integration point with <a href="https://tc39.es/proposal-dynamic-code-brand-checks/">dynamic-code-brand-checks proposal</a>.</p>
20082008
<li data-md>
20092009
<p>Return <var>trustedObject</var>.</p>
@@ -2112,7 +2112,7 @@ <h3 class="heading settled" data-level="3.5" id="process-value-with-a-default-po
21122112
name <var>trustedTypeName</var>, with its <code>[[Data]]</code> internal slot value
21132113
set to <var>dataString</var>.</p>
21142114
<li data-md>
2115-
<p>If <var>trustedObject</var> is a <code class="idl"><a data-link-type="idl" href="#trustedscript" id="ref-for-trustedscript⑦">TrustedScript</a></code>, set its <code>[[HostDefinedCodeLike]]</code> internal slot value to the value in its <code>[[Data]]</code> slot.</p>
2115+
<p>If <var>trustedObject</var> is a <code class="idl"><a data-link-type="idl" href="#trustedscript" id="ref-for-trustedscript⑦">TrustedScript</a></code>, set its <code>[[HostDefinedIsCodeLike]]</code> internal slot value to <code>true</code>.</p>
21162116
<p class="note" role="note"><span class="marker">Note:</span> This adds an integration point with <a href="https://tc39.es/proposal-dynamic-code-brand-checks/">dynamic-code-brand-checks proposal</a>.</p>
21172117
<li data-md>
21182118
<p>Return <var>trustedObject</var>.</p>
@@ -2816,17 +2816,46 @@ <h4 class="heading settled" data-level="4.8.7" id="csp-eval"><span class="secno"
28162816
</div>
28172817
<p>
28182818
Given a <a href="https://tc39.es/ecma262/multipage/#realm">realm</a> (<var>calleeRealm</var>), a list of strings (<var>parameterStrings</var>), a string (<var>bodyString</var>),
2819-
<ins> a string (<var>source</var>), an enum (<var>compilationType</var>), and a boolean <var>wasCodeLike</var></ins>
2820-
, this algorithm returns normally if compilation is allowed, and
2821-
throws an "<code>EvalError</code>" if not:
2819+
<ins> a string (<var>source</var>), an enum (<var>compilationType</var>), a list of ECMAScript language values (<var>parameterArgs</var>), and an ECMAScript language value (<var>bodyArg</var>), this algorithm returns normally if compilation is allowed, and
2820+
throws an "<code>EvalError</code>" if not:</ins>
28222821
</p>
28232822
<ol>
2824-
<li data-md>
2825-
<ins>If <var>wasCodeLike</var> is true, let <var>sourceToValidate</var> be a new instance of
2826-
the <code class="idl"><a data-link-type="idl" href="#trustedscript" id="ref-for-trustedscript①⑦">TrustedScript</a></code> interface, with its <code>[[Data]]</code> internal slot value
2827-
set to <var>source</var>. Otherwise, let <var>sourceToValidate</var> be <var>source</var>.</ins>
28282823
<li data-md>
28292824
<ins>Let <var>compilationSink</var> be <code>"Function"</code> if <var>compilationType</var> is <code>*FUNCTION*</code>, otherwise <code>"Eval"</code>.</ins>
2825+
<li data-md>
2826+
<ins>Let <var>isTrusted</var> be <code>true</code>.</ins>
2827+
<li data-md>
2828+
<ins>If <var>bodyArg</var> is not a <code class="idl"><a data-link-type="idl" href="#trustedscript" id="ref-for-trustedscript①⑦">TrustedScript</a></code> object, set <var>isTrusted</var> to <code>false</code>.</ins>
2829+
<li data-md>
2830+
<ins>
2831+
If <var>isTrusted</var> is <code>true</code> then:
2832+
<ol>
2833+
<li data-md>
2834+
<ins>If <var>bodyString</var> is not equal to <var>bodyArg</var>’s <code>[[Data]]</code> internal slot, set <var>isTrusted</var> to <code>false</code>.</ins>
2835+
</ol>
2836+
</ins>
2837+
<li data-md>
2838+
<ins>If <var>isTrusted</var> is <code>true</code>, then:</ins>
2839+
<ol>
2840+
<li data-md>
2841+
<ins> For each <var>arg</var> in <var>parameterArgs</var>:</ins>
2842+
<ol>
2843+
<li data-md>
2844+
<ins>Let <var>index</var> be the index of <var>arg</var> in <var>parameterArgs</var>.</ins>
2845+
<li data-md>
2846+
<ins>If <var>arg</var> is not a <code class="idl"><a data-link-type="idl" href="#trustedscript" id="ref-for-trustedscript①⑧">TrustedScript</a></code> object, set <var>isTrusted</var> to <code>false</code>.</ins>
2847+
<li data-md>
2848+
<ins>If <var>isTrusted</var> is <code>true</code>, then:</ins>
2849+
<ol>
2850+
<li data-md>
2851+
<ins>if <var>parameterStrings</var>[<var>index</var>] is not equal to <var>arg</var>’s <code>[[Data]]</code> internal slot, set <var>isTrusted</var> to <code>false</code>.</ins>
2852+
</ol>
2853+
</ol>
2854+
</ol>
2855+
<li data-md>
2856+
<ins>If <var>isTrusted</var> is <code>true</code>, let <var>sourceToValidate</var> be a new instance of
2857+
the <code class="idl"><a data-link-type="idl" href="#trustedscript" id="ref-for-trustedscript①⑨">TrustedScript</a></code> interface, with its <code>[[Data]]</code> internal slot value
2858+
set to <var>source</var>. Otherwise, let <var>sourceToValidate</var> be <var>source</var>.</ins>
28302859
<li data-md>
28312860
<ins>
28322861
Let <var>sourceString</var> be the result of executing the <a data-link-type="abstract-op" href="#abstract-opdef-get-trusted-type-compliant-string" id="ref-for-abstract-opdef-get-trusted-type-compliant-string⑥">Get Trusted Type compliant string</a> algorithm, with:
@@ -2840,7 +2869,7 @@ <h4 class="heading settled" data-level="4.8.7" id="csp-eval"><span class="secno"
28402869
<li data-md>
28412870
<p><code>'script'</code> as <var>sinkGroup</var>,</p>
28422871
<li data-md>
2843-
<p><code class="idl"><a data-link-type="idl" href="#trustedscript" id="ref-for-trustedscript①⑧">TrustedScript</a></code> as <var>expectedType</var>.</p>
2872+
<p><code class="idl"><a data-link-type="idl" href="#trustedscript" id="ref-for-trustedscript②⓪">TrustedScript</a></code> as <var>expectedType</var>.</p>
28442873
</ul>
28452874
</ins>
28462875
<li data-md>
@@ -4208,7 +4237,7 @@ <h2 class="no-num no-ref heading settled" id="issues-index"><span class="content
42084237
window.dfnpanelData['trustedhtml'] = {"dfnID": "trustedhtml", "url": "#trustedhtml", "dfnText": "TrustedHTML", "refSections": [{"refs": [{"id": "ref-for-trustedhtml"}], "title": "2.2.1. TrustedHTML"}, {"refs": [{"id": "ref-for-trustedhtml\u2460"}], "title": "2.3. Policies"}, {"refs": [{"id": "ref-for-trustedhtml\u2461"}, {"id": "ref-for-trustedhtml\u2462"}, {"id": "ref-for-trustedhtml\u2463"}, {"id": "ref-for-trustedhtml\u2464"}], "title": "2.3.1. TrustedTypePolicyFactory"}, {"refs": [{"id": "ref-for-trustedhtml\u2465"}], "title": "2.3.2. TrustedTypePolicy"}, {"refs": [{"id": "ref-for-trustedhtml\u2466"}, {"id": "ref-for-trustedhtml\u2467"}], "title": "3.7. Get Trusted Types-compliant attribute value"}, {"refs": [{"id": "ref-for-trustedhtml\u2468"}, {"id": "ref-for-trustedhtml\u2460\u24ea"}], "title": "4. Integrations"}, {"refs": [{"id": "ref-for-trustedhtml\u2460\u2460"}], "title": "4.2. [StringContext]"}, {"refs": [{"id": "ref-for-trustedhtml\u2460\u2461"}], "title": "4.7. Integration with execCommand"}], "external": false};
42094238
window.dfnpanelData['dom-trustedhtml-tojson'] = {"dfnID": "dom-trustedhtml-tojson", "url": "#dom-trustedhtml-tojson", "dfnText": "toJSON()", "refSections": [{"refs": [{"id": "ref-for-dom-trustedhtml-tojson"}], "title": "2.2.1. TrustedHTML"}], "external": false};
42104239
window.dfnpanelData['trustedhtml-stringification-behavior'] = {"dfnID": "trustedhtml-stringification-behavior", "url": "#trustedhtml-stringification-behavior", "dfnText": "stringification behavior", "refSections": [{"refs": [{"id": "ref-for-trustedhtml-stringification-behavior"}], "title": "2.2.1. TrustedHTML"}], "external": false};
4211-
window.dfnpanelData['trustedscript'] = {"dfnID": "trustedscript", "url": "#trustedscript", "dfnText": "TrustedScript", "refSections": [{"refs": [{"id": "ref-for-trustedscript"}], "title": "2.2.2. TrustedScript"}, {"refs": [{"id": "ref-for-trustedscript\u2460"}, {"id": "ref-for-trustedscript\u2461"}, {"id": "ref-for-trustedscript\u2462"}, {"id": "ref-for-trustedscript\u2463"}], "title": "2.3.1. TrustedTypePolicyFactory"}, {"refs": [{"id": "ref-for-trustedscript\u2464"}], "title": "2.3.2. TrustedTypePolicy"}, {"refs": [{"id": "ref-for-trustedscript\u2465"}], "title": "3.2. Create a Trusted Type"}, {"refs": [{"id": "ref-for-trustedscript\u2466"}], "title": "3.5. Process value with a default policy"}, {"refs": [{"id": "ref-for-trustedscript\u2467"}], "title": "3.7. Get Trusted Types-compliant attribute value"}, {"refs": [{"id": "ref-for-trustedscript\u2468"}, {"id": "ref-for-trustedscript\u2460\u24ea"}], "title": "4. Integrations"}, {"refs": [{"id": "ref-for-trustedscript\u2460\u2460"}], "title": "4.2. [StringContext]"}, {"refs": [{"id": "ref-for-trustedscript\u2460\u2461"}, {"id": "ref-for-trustedscript\u2460\u2462"}], "title": "4.3.5. Enforcement in timer functions"}, {"refs": [{"id": "ref-for-trustedscript\u2460\u2463"}], "title": "4.3.6. Enforcement in event handler content attributes"}, {"refs": [{"id": "ref-for-trustedscript\u2460\u2464"}, {"id": "ref-for-trustedscript\u2460\u2465"}], "title": "4.8.1.1. require-trusted-types-for Pre-Navigation check"}, {"refs": [{"id": "ref-for-trustedscript\u2460\u2466"}, {"id": "ref-for-trustedscript\u2460\u2467"}], "title": "4.8.7. Support for dynamic code compilation"}], "external": false};
4240+
window.dfnpanelData['trustedscript'] = {"dfnID": "trustedscript", "url": "#trustedscript", "dfnText": "TrustedScript", "refSections": [{"refs": [{"id": "ref-for-trustedscript"}], "title": "2.2.2. TrustedScript"}, {"refs": [{"id": "ref-for-trustedscript\u2460"}, {"id": "ref-for-trustedscript\u2461"}, {"id": "ref-for-trustedscript\u2462"}, {"id": "ref-for-trustedscript\u2463"}], "title": "2.3.1. TrustedTypePolicyFactory"}, {"refs": [{"id": "ref-for-trustedscript\u2464"}], "title": "2.3.2. TrustedTypePolicy"}, {"refs": [{"id": "ref-for-trustedscript\u2465"}], "title": "3.2. Create a Trusted Type"}, {"refs": [{"id": "ref-for-trustedscript\u2466"}], "title": "3.5. Process value with a default policy"}, {"refs": [{"id": "ref-for-trustedscript\u2467"}], "title": "3.7. Get Trusted Types-compliant attribute value"}, {"refs": [{"id": "ref-for-trustedscript\u2468"}, {"id": "ref-for-trustedscript\u2460\u24ea"}], "title": "4. Integrations"}, {"refs": [{"id": "ref-for-trustedscript\u2460\u2460"}], "title": "4.2. [StringContext]"}, {"refs": [{"id": "ref-for-trustedscript\u2460\u2461"}, {"id": "ref-for-trustedscript\u2460\u2462"}], "title": "4.3.5. Enforcement in timer functions"}, {"refs": [{"id": "ref-for-trustedscript\u2460\u2463"}], "title": "4.3.6. Enforcement in event handler content attributes"}, {"refs": [{"id": "ref-for-trustedscript\u2460\u2464"}, {"id": "ref-for-trustedscript\u2460\u2465"}], "title": "4.8.1.1. require-trusted-types-for Pre-Navigation check"}, {"refs": [{"id": "ref-for-trustedscript\u2460\u2466"}, {"id": "ref-for-trustedscript\u2460\u2467"}, {"id": "ref-for-trustedscript\u2460\u2468"}, {"id": "ref-for-trustedscript\u2461\u24ea"}], "title": "4.8.7. Support for dynamic code compilation"}], "external": false};
42124241
window.dfnpanelData['dom-trustedscript-tojson'] = {"dfnID": "dom-trustedscript-tojson", "url": "#dom-trustedscript-tojson", "dfnText": "toJSON()", "refSections": [{"refs": [{"id": "ref-for-dom-trustedscript-tojson"}], "title": "2.2.2. TrustedScript"}], "external": false};
42134242
window.dfnpanelData['trustedscript-stringification-behavior'] = {"dfnID": "trustedscript-stringification-behavior", "url": "#trustedscript-stringification-behavior", "dfnText": "stringification behavior", "refSections": [{"refs": [{"id": "ref-for-trustedscript-stringification-behavior"}], "title": "2.2.2. TrustedScript"}], "external": false};
42144243
window.dfnpanelData['trustedscripturl'] = {"dfnID": "trustedscripturl", "url": "#trustedscripturl", "dfnText": "TrustedScriptURL", "refSections": [{"refs": [{"id": "ref-for-trustedscripturl"}], "title": "2.2.3. TrustedScriptURL"}, {"refs": [{"id": "ref-for-trustedscripturl\u2460"}], "title": "2.3.1. TrustedTypePolicyFactory"}, {"refs": [{"id": "ref-for-trustedscripturl\u2461"}], "title": "2.3.2. TrustedTypePolicy"}, {"refs": [{"id": "ref-for-trustedscripturl\u2462"}], "title": "3.6. Prepare the script text"}, {"refs": [{"id": "ref-for-trustedscripturl\u2463"}, {"id": "ref-for-trustedscripturl\u2464"}, {"id": "ref-for-trustedscripturl\u2465"}, {"id": "ref-for-trustedscripturl\u2466"}, {"id": "ref-for-trustedscripturl\u2467"}, {"id": "ref-for-trustedscripturl\u2468"}, {"id": "ref-for-trustedscripturl\u2460\u24ea"}], "title": "3.7. Get Trusted Types-compliant attribute value"}, {"refs": [{"id": "ref-for-trustedscripturl\u2460\u2460"}, {"id": "ref-for-trustedscripturl\u2460\u2461"}], "title": "4. Integrations"}, {"refs": [{"id": "ref-for-trustedscripturl\u2460\u2462"}], "title": "4.2. [StringContext]"}, {"refs": [{"id": "ref-for-trustedscripturl\u2460\u2463"}, {"id": "ref-for-trustedscripturl\u2460\u2464"}], "title": "4.5. Integration with SVG"}, {"refs": [{"id": "ref-for-trustedscripturl\u2460\u2465"}, {"id": "ref-for-trustedscripturl\u2460\u2466"}], "title": "5.3. Plugin navigation"}], "external": false};

0 commit comments

Comments
 (0)