aboutsummaryrefslogtreecommitdiffstats
path: root/components/script_bindings
diff options
context:
space:
mode:
Diffstat (limited to 'components/script_bindings')
-rw-r--r--components/script_bindings/codegen/Bindings.conf12
-rw-r--r--components/script_bindings/webidls/TrustedHTML.webidl13
-rw-r--r--components/script_bindings/webidls/TrustedScript.webidl13
-rw-r--r--components/script_bindings/webidls/TrustedScriptURL.webidl13
-rw-r--r--components/script_bindings/webidls/TrustedTypePolicy.webidl15
-rw-r--r--components/script_bindings/webidls/TrustedTypePolicyFactory.webidl38
-rw-r--r--components/script_bindings/webidls/WindowOrWorkerGlobalScope.webidl5
7 files changed, 107 insertions, 2 deletions
diff --git a/components/script_bindings/codegen/Bindings.conf b/components/script_bindings/codegen/Bindings.conf
index a3adf0f39ab..2c94c445778 100644
--- a/components/script_bindings/codegen/Bindings.conf
+++ b/components/script_bindings/codegen/Bindings.conf
@@ -575,6 +575,14 @@ DOMInterfaces = {
'canGc': ['ParentNode', 'PreviousNode', 'NextNode', 'FirstChild', 'LastChild', 'PreviousSibling', 'NextSibling']
},
+'TrustedTypePolicy': {
+ 'canGc': ['CreateHTML', 'CreateScript', 'CreateScriptURL']
+},
+
+'TrustedTypePolicyFactory': {
+ 'canGc': ['CreatePolicy', 'EmptyHTML', 'EmptyScript']
+},
+
'URL': {
'weakReferenceable': True,
'canGc': ['Parse', 'SearchParams'],
@@ -590,7 +598,7 @@ DOMInterfaces = {
},
'Window': {
- 'canGc': ['Stop', 'Fetch', 'Scroll', 'Scroll_','ScrollBy', 'ScrollBy_', 'Stop', 'Fetch', 'Open', 'CreateImageBitmap'],
+ 'canGc': ['Stop', 'Fetch', 'Scroll', 'Scroll_','ScrollBy', 'ScrollBy_', 'Stop', 'Fetch', 'Open', 'CreateImageBitmap', 'TrustedTypes'],
'inRealms': ['Fetch', 'GetOpener'],
'additionalTraits': ['crate::interfaces::WindowHelpers'],
},
@@ -602,7 +610,7 @@ DOMInterfaces = {
'WorkerGlobalScope': {
'inRealms': ['Fetch'],
- 'canGc': ['Fetch', 'CreateImageBitmap', 'ImportScripts'],
+ 'canGc': ['Fetch', 'CreateImageBitmap', 'ImportScripts', 'TrustedTypes'],
},
'Worklet': {
diff --git a/components/script_bindings/webidls/TrustedHTML.webidl b/components/script_bindings/webidls/TrustedHTML.webidl
new file mode 100644
index 00000000000..37fb18bd5e1
--- /dev/null
+++ b/components/script_bindings/webidls/TrustedHTML.webidl
@@ -0,0 +1,13 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+/*
+ * The origin of this IDL file is
+ * https://www.w3.org/TR/trusted-types/#trusted-html
+ */
+
+[Exposed=(Window,Worker), Pref="dom_trusted_types_enabled"]
+interface TrustedHTML {
+ stringifier;
+ DOMString toJSON();
+};
diff --git a/components/script_bindings/webidls/TrustedScript.webidl b/components/script_bindings/webidls/TrustedScript.webidl
new file mode 100644
index 00000000000..3dbee643ddf
--- /dev/null
+++ b/components/script_bindings/webidls/TrustedScript.webidl
@@ -0,0 +1,13 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+/*
+ * The origin of this IDL file is
+ * https://www.w3.org/TR/trusted-types/#trusted-script
+ */
+
+[Exposed=(Window,Worker), Pref="dom_trusted_types_enabled"]
+interface TrustedScript {
+ stringifier;
+ DOMString toJSON();
+};
diff --git a/components/script_bindings/webidls/TrustedScriptURL.webidl b/components/script_bindings/webidls/TrustedScriptURL.webidl
new file mode 100644
index 00000000000..b5fd0249eba
--- /dev/null
+++ b/components/script_bindings/webidls/TrustedScriptURL.webidl
@@ -0,0 +1,13 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+/*
+ * The origin of this IDL file is
+ * https://www.w3.org/TR/trusted-types/#trused-script-url
+ */
+
+[Exposed=(Window,Worker), Pref="dom_trusted_types_enabled"]
+interface TrustedScriptURL {
+ stringifier;
+ DOMString toJSON();
+};
diff --git a/components/script_bindings/webidls/TrustedTypePolicy.webidl b/components/script_bindings/webidls/TrustedTypePolicy.webidl
new file mode 100644
index 00000000000..e9bfa158795
--- /dev/null
+++ b/components/script_bindings/webidls/TrustedTypePolicy.webidl
@@ -0,0 +1,15 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+/*
+ * The origin of this IDL file is
+ * https://www.w3.org/TR/trusted-types/#trusted-type-policy
+ */
+
+[Exposed=(Window,Worker), Pref="dom_trusted_types_enabled"]
+interface TrustedTypePolicy {
+ readonly attribute DOMString name;
+ TrustedHTML createHTML(DOMString input, any... arguments);
+ TrustedScript createScript(DOMString input, any... arguments);
+ TrustedScriptURL createScriptURL(DOMString input, any... arguments);
+};
diff --git a/components/script_bindings/webidls/TrustedTypePolicyFactory.webidl b/components/script_bindings/webidls/TrustedTypePolicyFactory.webidl
new file mode 100644
index 00000000000..a568ec437f4
--- /dev/null
+++ b/components/script_bindings/webidls/TrustedTypePolicyFactory.webidl
@@ -0,0 +1,38 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+/*
+ * The origin of this IDL file is
+ * https://www.w3.org/TR/trusted-types/#trusted-type-policy-factory
+ */
+
+[Exposed=(Window,Worker), Pref="dom_trusted_types_enabled"]
+interface TrustedTypePolicyFactory {
+ [Throws]
+ TrustedTypePolicy createPolicy(
+ DOMString policyName, optional TrustedTypePolicyOptions policyOptions = {});
+ boolean isHTML(any value);
+ boolean isScript(any value);
+ boolean isScriptURL(any value);
+ readonly attribute TrustedHTML emptyHTML;
+ readonly attribute TrustedScript emptyScript;
+ DOMString? getAttributeType(
+ DOMString tagName,
+ DOMString attribute,
+ optional DOMString? elementNs = "",
+ optional DOMString? attrNs = "");
+ DOMString? getPropertyType(
+ DOMString tagName,
+ DOMString property,
+ optional DOMString? elementNs = "");
+ readonly attribute TrustedTypePolicy? defaultPolicy;
+};
+
+dictionary TrustedTypePolicyOptions {
+ CreateHTMLCallback createHTML;
+ CreateScriptCallback createScript;
+ CreateScriptURLCallback createScriptURL;
+};
+callback CreateHTMLCallback = DOMString? (DOMString input, any... arguments);
+callback CreateScriptCallback = DOMString? (DOMString input, any... arguments);
+callback CreateScriptURLCallback = USVString? (DOMString input, any... arguments);
diff --git a/components/script_bindings/webidls/WindowOrWorkerGlobalScope.webidl b/components/script_bindings/webidls/WindowOrWorkerGlobalScope.webidl
index d9204c11774..4ca7b1f2de1 100644
--- a/components/script_bindings/webidls/WindowOrWorkerGlobalScope.webidl
+++ b/components/script_bindings/webidls/WindowOrWorkerGlobalScope.webidl
@@ -45,5 +45,10 @@ partial interface mixin WindowOrWorkerGlobalScope {
readonly attribute boolean isSecureContext;
};
+// https://www.w3.org/TR/trusted-types/#extensions-to-the-windoworworkerglobalscope-interface
+partial interface mixin WindowOrWorkerGlobalScope {
+ readonly attribute TrustedTypePolicyFactory trustedTypes;
+};
+
Window includes WindowOrWorkerGlobalScope;
WorkerGlobalScope includes WindowOrWorkerGlobalScope;