Skip to content

Commit 48b7d78

Browse files
committed
Restore Trusted Types from BCD 6.0.24
1 parent 7fe6559 commit 48b7d78

13 files changed

+2322
-113
lines changed

baselines/dom.generated.d.ts

Lines changed: 202 additions & 16 deletions
Large diffs are not rendered by default.

baselines/serviceworker.generated.d.ts

Lines changed: 190 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,12 @@ interface Transformer<I = any, O = any> {
717717
writableType?: undefined;
718718
}
719719

720+
interface TrustedTypePolicyOptions {
721+
createHTML?: CreateHTMLCallback;
722+
createScript?: CreateScriptCallback;
723+
createScriptURL?: CreateScriptURLCallback;
724+
}
725+
720726
interface URLPatternComponentResult {
721727
groups?: Record<string, string | undefined>;
722728
input?: string;
@@ -6942,7 +6948,7 @@ interface ServiceWorkerContainer extends EventTarget {
69426948
*
69436949
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ServiceWorkerContainer/register)
69446950
*/
6945-
register(scriptURL: string | URL, options?: RegistrationOptions): Promise<ServiceWorkerRegistration>;
6951+
register(scriptURL: TrustedScriptURL | string, options?: RegistrationOptions): Promise<ServiceWorkerRegistration>;
69466952
/**
69476953
* The **`startMessages()`** method of the ServiceWorkerContainer interface explicitly starts the flow of messages being dispatched from a service worker to pages under its control (e.g., sent via Client.postMessage()).
69486954
*
@@ -7550,6 +7556,170 @@ declare var TransformStreamDefaultController: {
75507556
new(): TransformStreamDefaultController;
75517557
};
75527558

7559+
/**
7560+
* The **`TrustedHTML`** interface of the Trusted Types API represents a string that a developer can insert into an injection sink that will render it as HTML.
7561+
*
7562+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TrustedHTML)
7563+
*/
7564+
interface TrustedHTML {
7565+
/**
7566+
* The **`toJSON()`** method of the TrustedHTML interface returns a JSON representation of the stored data.
7567+
*
7568+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TrustedHTML/toJSON)
7569+
*/
7570+
toJSON(): string;
7571+
toString(): string;
7572+
}
7573+
7574+
declare var TrustedHTML: {
7575+
prototype: TrustedHTML;
7576+
new(): TrustedHTML;
7577+
};
7578+
7579+
/**
7580+
* The **`TrustedScript`** interface of the Trusted Types API represents a string with an uncompiled script body that a developer can insert into an injection sink that might execute the script.
7581+
*
7582+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TrustedScript)
7583+
*/
7584+
interface TrustedScript {
7585+
/**
7586+
* The **`toJSON()`** method of the TrustedScript interface returns a JSON representation of the stored data.
7587+
*
7588+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TrustedScript/toJSON)
7589+
*/
7590+
toJSON(): string;
7591+
toString(): string;
7592+
}
7593+
7594+
declare var TrustedScript: {
7595+
prototype: TrustedScript;
7596+
new(): TrustedScript;
7597+
};
7598+
7599+
/**
7600+
* The **`TrustedScriptURL`** interface of the Trusted Types API represents a string that a developer can insert into an injection sink that will parse it as a URL of an external script.
7601+
*
7602+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TrustedScriptURL)
7603+
*/
7604+
interface TrustedScriptURL {
7605+
/**
7606+
* The **`toJSON()`** method of the TrustedScriptURL interface returns a JSON representation of the stored data.
7607+
*
7608+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TrustedScriptURL/toJSON)
7609+
*/
7610+
toJSON(): string;
7611+
toString(): string;
7612+
}
7613+
7614+
declare var TrustedScriptURL: {
7615+
prototype: TrustedScriptURL;
7616+
new(): TrustedScriptURL;
7617+
};
7618+
7619+
/**
7620+
* The **`TrustedTypePolicy`** interface of the Trusted Types API defines a group of functions which create `TrustedType` objects.
7621+
*
7622+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TrustedTypePolicy)
7623+
*/
7624+
interface TrustedTypePolicy {
7625+
/**
7626+
* The **`name`** read-only property of the TrustedTypePolicy interface returns the name of the policy.
7627+
*
7628+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TrustedTypePolicy/name)
7629+
*/
7630+
readonly name: string;
7631+
/**
7632+
* The **`createHTML()`** method of the TrustedTypePolicy interface creates a TrustedHTML object using a policy created by TrustedTypePolicyFactory.createPolicy().
7633+
*
7634+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TrustedTypePolicy/createHTML)
7635+
*/
7636+
createHTML(input: string, ...arguments: any[]): TrustedHTML;
7637+
/**
7638+
* The **`createScript()`** method of the TrustedTypePolicy interface creates a TrustedScript object using a policy created by TrustedTypePolicyFactory.createPolicy().
7639+
*
7640+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TrustedTypePolicy/createScript)
7641+
*/
7642+
createScript(input: string, ...arguments: any[]): TrustedScript;
7643+
/**
7644+
* The **`createScriptURL()`** method of the TrustedTypePolicy interface creates a TrustedScriptURL object using a policy created by TrustedTypePolicyFactory.createPolicy().
7645+
*
7646+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TrustedTypePolicy/createScriptURL)
7647+
*/
7648+
createScriptURL(input: string, ...arguments: any[]): TrustedScriptURL;
7649+
}
7650+
7651+
declare var TrustedTypePolicy: {
7652+
prototype: TrustedTypePolicy;
7653+
new(): TrustedTypePolicy;
7654+
};
7655+
7656+
/**
7657+
* The **`TrustedTypePolicyFactory`** interface of the Trusted Types API creates policies and allows the verification of Trusted Type objects against created policies.
7658+
*
7659+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TrustedTypePolicyFactory)
7660+
*/
7661+
interface TrustedTypePolicyFactory {
7662+
/**
7663+
* The **`defaultPolicy`** read-only property of the TrustedTypePolicyFactory interface returns the default TrustedTypePolicy or null if this is empty.
7664+
*
7665+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TrustedTypePolicyFactory/defaultPolicy)
7666+
*/
7667+
readonly defaultPolicy: TrustedTypePolicy | null;
7668+
/**
7669+
* The **`emptyHTML`** read-only property of the TrustedTypePolicyFactory interface returns a TrustedHTML object containing an empty string.
7670+
*
7671+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TrustedTypePolicyFactory/emptyHTML)
7672+
*/
7673+
readonly emptyHTML: TrustedHTML;
7674+
/**
7675+
* The **`emptyScript`** read-only property of the TrustedTypePolicyFactory interface returns a TrustedScript object containing an empty string.
7676+
*
7677+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TrustedTypePolicyFactory/emptyScript)
7678+
*/
7679+
readonly emptyScript: TrustedScript;
7680+
/**
7681+
* The **`createPolicy()`** method of the TrustedTypePolicyFactory interface creates a TrustedTypePolicy object that implements the rules passed as `policyOptions`.
7682+
*
7683+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TrustedTypePolicyFactory/createPolicy)
7684+
*/
7685+
createPolicy(policyName: string, policyOptions?: TrustedTypePolicyOptions): TrustedTypePolicy;
7686+
/**
7687+
* The **`getAttributeType()`** method of the TrustedTypePolicyFactory interface allows web developers to check if a Trusted Type is required for an element, and if so which Trusted Type is used.
7688+
*
7689+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TrustedTypePolicyFactory/getAttributeType)
7690+
*/
7691+
getAttributeType(tagName: string, attribute: string, elementNs?: string | null, attrNs?: string | null): string | null;
7692+
/**
7693+
* The **`getPropertyType()`** method of the TrustedTypePolicyFactory interface allows web developers to check if a Trusted Type is required for an element's property.
7694+
*
7695+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TrustedTypePolicyFactory/getPropertyType)
7696+
*/
7697+
getPropertyType(tagName: string, property: string, elementNs?: string | null): string | null;
7698+
/**
7699+
* The **`isHTML()`** method of the TrustedTypePolicyFactory interface returns true if it is passed a valid TrustedHTML object.
7700+
*
7701+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TrustedTypePolicyFactory/isHTML)
7702+
*/
7703+
isHTML(value: any): boolean;
7704+
/**
7705+
* The **`isScript()`** method of the TrustedTypePolicyFactory interface returns true if it is passed a valid TrustedScript object.
7706+
*
7707+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TrustedTypePolicyFactory/isScript)
7708+
*/
7709+
isScript(value: any): boolean;
7710+
/**
7711+
* The **`isScriptURL()`** method of the TrustedTypePolicyFactory interface returns true if it is passed a valid TrustedScriptURL object.
7712+
*
7713+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TrustedTypePolicyFactory/isScriptURL)
7714+
*/
7715+
isScriptURL(value: any): boolean;
7716+
}
7717+
7718+
declare var TrustedTypePolicyFactory: {
7719+
prototype: TrustedTypePolicyFactory;
7720+
new(): TrustedTypePolicyFactory;
7721+
};
7722+
75537723
/**
75547724
* The **`URL`** interface is used to parse, construct, normalize, and encode URL.
75557725
*
@@ -10601,6 +10771,8 @@ interface WindowOrWorkerGlobalScope {
1060110771
readonly origin: string;
1060210772
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/performance) */
1060310773
readonly performance: Performance;
10774+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/trustedTypes) */
10775+
readonly trustedTypes: TrustedTypePolicyFactory;
1060410776
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/atob) */
1060510777
atob(data: string): string;
1060610778
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/btoa) */
@@ -10676,7 +10848,7 @@ interface WorkerGlobalScope extends EventTarget, FontFaceSource, WindowOrWorkerG
1067610848
*
1067710849
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WorkerGlobalScope/importScripts)
1067810850
*/
10679-
importScripts(...urls: (string | URL)[]): void;
10851+
importScripts(...urls: (TrustedScriptURL | string)[]): void;
1068010852
addEventListener<K extends keyof WorkerGlobalScopeEventMap>(type: K, listener: (this: WorkerGlobalScope, ev: WorkerGlobalScopeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
1068110853
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
1068210854
removeEventListener<K extends keyof WorkerGlobalScopeEventMap>(type: K, listener: (this: WorkerGlobalScope, ev: WorkerGlobalScopeEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
@@ -11190,6 +11362,18 @@ interface Console {
1119011362

1119111363
declare var console: Console;
1119211364

11365+
interface CreateHTMLCallback {
11366+
(input: string, ...arguments: any[]): string | null;
11367+
}
11368+
11369+
interface CreateScriptCallback {
11370+
(input: string, ...arguments: any[]): string | null;
11371+
}
11372+
11373+
interface CreateScriptURLCallback {
11374+
(input: string, ...arguments: any[]): string | null;
11375+
}
11376+
1119311377
interface LockGrantedCallback<T> {
1119411378
(lock: Lock | null): T;
1119511379
}
@@ -11345,7 +11529,7 @@ declare var self: WorkerGlobalScope & typeof globalThis;
1134511529
*
1134611530
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WorkerGlobalScope/importScripts)
1134711531
*/
11348-
declare function importScripts(...urls: (string | URL)[]): void;
11532+
declare function importScripts(...urls: (TrustedScriptURL | string)[]): void;
1134911533
/**
1135011534
* The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.
1135111535
*
@@ -11372,6 +11556,8 @@ declare var isSecureContext: boolean;
1137211556
declare var origin: string;
1137311557
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/performance) */
1137411558
declare var performance: Performance;
11559+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/trustedTypes) */
11560+
declare var trustedTypes: TrustedTypePolicyFactory;
1137511561
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/atob) */
1137611562
declare function atob(data: string): string;
1137711563
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/btoa) */
@@ -11447,7 +11633,7 @@ type ReadableStreamReader<T> = ReadableStreamDefaultReader<T> | ReadableStreamBY
1144711633
type ReportList = Report[];
1144811634
type RequestInfo = Request | string;
1144911635
type TexImageSource = ImageBitmap | ImageData | OffscreenCanvas;
11450-
type TimerHandler = string | Function;
11636+
type TimerHandler = string | Function | TrustedScript;
1145111637
type Transferable = OffscreenCanvas | ImageBitmap | MessagePort | ReadableStream | WritableStream | TransformStream | ArrayBuffer;
1145211638
type URLPatternInput = string | URLPatternInit;
1145311639
type Uint32List = Uint32Array<ArrayBufferLike> | GLuint[];

0 commit comments

Comments
 (0)