From 167ba9065fa6faa3adb94ff0b5b4c03f527b34b2 Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Mon, 22 Apr 2024 15:26:02 +0100 Subject: [PATCH] Remove StringContext attribute Swap to using a union type and updating the algorithms directly. --- spec/index.bs | 55 ++++++++++----------------------------------------- 1 file changed, 10 insertions(+), 45 deletions(-) diff --git a/spec/index.bs b/spec/index.bs index d03d083..53db6fe 100644 --- a/spec/index.bs +++ b/spec/index.bs @@ -1103,18 +1103,9 @@ Issue: This algorithm should account for event handler attributes. See https://g # Integrations # {#integrations}
-typedef [StringContext=TrustedHTML] DOMString HTMLString;
-typedef [StringContext=TrustedScript] DOMString ScriptString;
-typedef [StringContext=TrustedScriptURL] USVString ScriptURLString;
 typedef (TrustedHTML or TrustedScript or TrustedScriptURL) TrustedType;
 
-## Integration with WebIDL ## {#webidl-integration} - -

[StringContext]

- -Issue: See [https://github.com/whatwg/webidl/pull/1392](https://github.com/whatwg/webidl/pull/1392). - ## Integration with HTML ## {#integration-with-html} {{Window}} and {{Worker}} objects have a trusted type policy factory, @@ -1237,7 +1228,7 @@ The first few steps of the [=prepare the script element=] algorithm are modified This document modifies the {{WindowOrWorkerGlobalScope}} interface mixin:
-typedef (ScriptString or Function) TrustedTimerHandler;
+typedef (DOMString or Function or TrustedScript) TrustedTimerHandler;
 
 partial interface mixin WindowOrWorkerGlobalScope {
   long setTimeout(TrustedTimerHandler handler, optional long timeout = 0, any... arguments);
@@ -1249,6 +1240,15 @@ Note: This makes sure that a {{TrustedScript}} is passed to timer
 functions in place of a string when Trusted Types are enforced, but
 also unconditionally accepts any {{Function}} object.
 
+To the [[HTML5#timer-initialisation-steps|timer initialization steps algorithm]],
+add this step before 8.4.1:
+
+1.  Let |globalName| be `'Window'` if [=this=]'s [=relevant global object=] is a {{Window}} object; 'Worker' otherwise.
+1.  Let |sink| be |globalName| + ` setInterval` if repeat is true; |globalName| + ` setTimeout` otherwise.
+1.  Set |handler| to the result of executing
+    the [$Get Trusted Type compliant string$] algorithm, with {{TrustedScript}}, [=this=]'s [=relevant global object=],
+    |handler|, |sink|, and `'script'` as arguments.
+
 To the [[HTML5#timer-initialisation-steps|timer initialization steps algorithm]],
 change step 8.4.3 as follows:
 
@@ -1271,41 +1271,6 @@ abstract operation. User agents must use the following implementation:
 1.  If |argument| is a {{TrustedScript}} object, return the value of its associated [=TrustedScript/data=].
 1.  Return ~unknown~.
 
-### Validate the string in context ### {#html-validate-the-string-in-context}
-
-This specification defines the validate the string in context algorithm in [[html#integration-with-idl]].
-
-When validate the string in context is invoked, with |platformObject|, |value|, |stringContext|, and |identifier| run these steps:
-
- 1. If |platformObject|'s [=relevant global object=] has a [=Window/trusted type policy factory=]:
-
-    1. Set |sink| to the result of [=concatenating=] the list « |platformObject|'s identifier, |identifier| » with `" "` as |separator|.
-        
- For example, the following annotation and JavaScript code: -
-        typedef [StringContext=TrustedHTML] DOMString HTMLString;
-        [ Exposed=Window, HTMLConstructor] interface HTMLIFrameElement : HTMLElement {
-            attribute HTMLString srcdoc;
-        };
-        
-
-        document.createElement('iframe').srcdoc = foo;
-        document.createElement('iframe').setAttribute('SRCdoc', foo);
-        
- causes the |sink| value to be `"HTMLIFrameElement srcdoc"`. -
- 1. Set |value| to the result of running the [$Get Trusted Type compliant string$] algorithm, passing the following arguments: - * |value| as |input|, - * |stringContext| as |expectedType|, - * |sink| as |sink|, - * `'script'` as |sinkGroup|, - * |platformObject|'s [=relevant global object=] as |global|. - - Issue: Remove hardcoding 'script' when new sink groups are specified. - - 1. If an exception was thrown, rethrow exception and abort further steps. - 1. Return |value|. - ## Integration with Service Workers ## {#sw-integration} Note: See [https://github.com/w3c/ServiceWorker/pull/1709](https://github.com/w3c/ServiceWorker/pull/1709) which upstreams this integration.