Skip to content

Commit

Permalink
Update support for dynamic code compilation (#464)
Browse files Browse the repository at this point in the history
SHA: 2f7de8e
Reason: push, by lukewarlow

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
lukewarlow and github-actions[bot] committed Mar 7, 2024
1 parent 252a991 commit bdab22b
Showing 1 changed file with 41 additions and 12 deletions.
53 changes: 41 additions & 12 deletions dist/spec/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link href="https://www.w3.org/StyleSheets/TR/2021/W3C-ED" rel="stylesheet">
<meta content="Bikeshed version 82ce88815, updated Thu Sep 7 16:33:55 2023 -0700" name="generator">
<link href="https://w3c.github.io/trusted-types/dist/spec/" rel="canonical">
<meta content="075e1f8e9142c66bcea5e2bc740dc540e293a5a6" name="document-revision">
<meta content="2f7de8e5f983da9be957fde80c3a5fd3cc8acb88" name="document-revision">
<style>/* Boilerplate: style-autolinks */
.css.css, .property.property, .descriptor.descriptor {
color: var(--a-normal-text);
Expand Down Expand Up @@ -2003,7 +2003,7 @@ <h3 class="heading settled" data-level="3.2" id="create-a-trusted-type-algorithm
name <var>trustedTypeName</var>, with its <code>[[Data]]</code> internal slot value
set to <var>dataString</var>.</p>
<li data-md>
<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>
<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>
<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>
<li data-md>
<p>Return <var>trustedObject</var>.</p>
Expand Down Expand Up @@ -2112,7 +2112,7 @@ <h3 class="heading settled" data-level="3.5" id="process-value-with-a-default-po
name <var>trustedTypeName</var>, with its <code>[[Data]]</code> internal slot value
set to <var>dataString</var>.</p>
<li data-md>
<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>
<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>
<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>
<li data-md>
<p>Return <var>trustedObject</var>.</p>
Expand Down Expand Up @@ -2816,17 +2816,46 @@ <h4 class="heading settled" data-level="4.8.7" id="csp-eval"><span class="secno"
</div>
<p>
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>),
<ins> a string (<var>source</var>), an enum (<var>compilationType</var>), and a boolean <var>wasCodeLike</var></ins>
, this algorithm returns normally if compilation is allowed, and
throws an "<code>EvalError</code>" if not:
<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
throws an "<code>EvalError</code>" if not:</ins>
</p>
<ol>
<li data-md>
<ins>If <var>wasCodeLike</var> is true, let <var>sourceToValidate</var> be a new instance of
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
set to <var>source</var>. Otherwise, let <var>sourceToValidate</var> be <var>source</var>.</ins>
<li data-md>
<ins>Let <var>compilationSink</var> be <code>"Function"</code> if <var>compilationType</var> is <code>*FUNCTION*</code>, otherwise <code>"Eval"</code>.</ins>
<li data-md>
<ins>Let <var>isTrusted</var> be <code>true</code>.</ins>
<li data-md>
<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>
<li data-md>
<ins>
If <var>isTrusted</var> is <code>true</code> then:
<ol>
<li data-md>
<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>
</ol>
</ins>
<li data-md>
<ins>If <var>isTrusted</var> is <code>true</code>, then:</ins>
<ol>
<li data-md>
<ins> For each <var>arg</var> in <var>parameterArgs</var>:</ins>
<ol>
<li data-md>
<ins>Let <var>index</var> be the index of <var>arg</var> in <var>parameterArgs</var>.</ins>
<li data-md>
<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>
<li data-md>
<ins>If <var>isTrusted</var> is <code>true</code>, then:</ins>
<ol>
<li data-md>
<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>
</ol>
</ol>
</ol>
<li data-md>
<ins>If <var>isTrusted</var> is <code>true</code>, let <var>sourceToValidate</var> be a new instance of
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
set to <var>source</var>. Otherwise, let <var>sourceToValidate</var> be <var>source</var>.</ins>
<li data-md>
<ins>
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:
Expand All @@ -2840,7 +2869,7 @@ <h4 class="heading settled" data-level="4.8.7" id="csp-eval"><span class="secno"
<li data-md>
<p><code>'script'</code> as <var>sinkGroup</var>,</p>
<li data-md>
<p><code class="idl"><a data-link-type="idl" href="#trustedscript" id="ref-for-trustedscript①⑧">TrustedScript</a></code> as <var>expectedType</var>.</p>
<p><code class="idl"><a data-link-type="idl" href="#trustedscript" id="ref-for-trustedscript②⓪">TrustedScript</a></code> as <var>expectedType</var>.</p>
</ul>
</ins>
<li data-md>
Expand Down Expand Up @@ -4208,7 +4237,7 @@ <h2 class="no-num no-ref heading settled" id="issues-index"><span class="content
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};
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};
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};
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};
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};
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};
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};
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};
Expand Down

0 comments on commit bdab22b

Please sign in to comment.