Commit e14b9063 authored by Maja Kabus's avatar Maja Kabus Committed by Commit Bot

Idlharness.js tests added for Trusted Types API

Added Idlharness tests for Trusted Types interfaces.
Removed "Worker" from "Exposed=(...)" in TrustedXXX .idl files.

Bug: 739170
Change-Id: Id8834affcdded63f3ebb9ebd4d288cfd01ef24a8
Reviewed-on: https://chromium-review.googlesource.com/1204150
Commit-Queue: Maja Kabus <kabusm@google.com>
Reviewed-by: default avatarMike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589146}
parent 3006696f
// https://github.com/wicg/trusted-types
typedef (DOMString or TrustedHTML) HTMLString;
typedef (DOMString or TrustedScript) ScriptString;
typedef (DOMString or TrustedScriptURL) ScriptURLString;
typedef (USVString or TrustedURL) URLString;
[Exposed=Window]
interface TrustedHTML {
stringifier;
};
[Exposed=Window]
interface TrustedScript {
stringifier;
};
[Exposed=Window]
interface TrustedScriptURL {
stringifier;
};
[Exposed=Window]
interface TrustedURL {
stringifier;
};
[Exposed=Window]
interface TrustedTypePolicyFactory {
TrustedTypePolicy createPolicy(DOMString policyName, TrustedTypePolicyOptions policyOptions);
// All the policy object names that have been created
sequence<DOMString> getPolicyNames();
};
[Exposed=Window]
interface TrustedTypePolicy {
readonly attribute DOMString name;
TrustedHTML createHTML(DOMString input);
TrustedScript createScript(DOMString input);
TrustedScriptURL createScriptURL(DOMString input);
TrustedURL createURL(DOMString input);
};
dictionary TrustedTypePolicyOptions {
CreateHTMLCallback createHTML;
CreateScriptCallback createScript;
CreateURLCallback createScriptURL;
CreateURLCallback createURL;
};
callback CreateHTMLCallback = DOMString (DOMString input);
callback CreateScriptCallback = DOMString (DOMString input);
callback CreateURLCallback = USVString (DOMString input);
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js
idl_test(
['trusted-types.tentative'],
['dom', 'html'],
idl_array => {
idl_array.add_objects({
TrustedTypePolicyFactory: ['window.TrustedTypes'],
TrustedTypePolicy: ['window.TrustedTypes.createPolicy("SomeName", { createHTML: s => s })'],
TrustedHTML: ['window.TrustedTypes.createPolicy("SomeName1", { createHTML: s => s }).createHTML("A string")'],
TrustedScript: ['window.TrustedTypes.createPolicy("SomeName2", { createScript: s => s }).createScript("A string")'],
TrustedScriptURL: ['window.TrustedTypes.createPolicy("SomeName3", { createScriptURL: s => s }).createScriptURL("A string")'],
TrustedURL: ['window.TrustedTypes.createPolicy("SomeName4", { createURL: s => s }).createURL("A string")']
});
},
'Trusted Types'
);
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
typedef (DOMString or TrustedHTML) HTMLString; typedef (DOMString or TrustedHTML) HTMLString;
[ [
Exposed=(Window,Worker), Exposed=Window,
RuntimeEnabled=TrustedDOMTypes RuntimeEnabled=TrustedDOMTypes
] interface TrustedHTML { ] interface TrustedHTML {
stringifier; stringifier;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
typedef (DOMString or TrustedScript) ScriptString; typedef (DOMString or TrustedScript) ScriptString;
[ [
Exposed=(Window,Worker), Exposed=Window,
RuntimeEnabled=TrustedDOMTypes RuntimeEnabled=TrustedDOMTypes
] interface TrustedScript { ] interface TrustedScript {
stringifier; stringifier;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
typedef (DOMString or TrustedScriptURL) ScriptURLString; typedef (DOMString or TrustedScriptURL) ScriptURLString;
[ [
Exposed=(Window,Worker), Exposed=Window,
RuntimeEnabled=TrustedDOMTypes RuntimeEnabled=TrustedDOMTypes
] interface TrustedScriptURL { ] interface TrustedScriptURL {
stringifier; stringifier;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
typedef (DOMString or TrustedHTML or TrustedScript or TrustedScriptURL or TrustedURL) TrustedString; typedef (DOMString or TrustedHTML or TrustedScript or TrustedScriptURL or TrustedURL) TrustedString;
[ [
Exposed=(Window), Exposed=Window,
RuntimeEnabled=TrustedDOMTypes RuntimeEnabled=TrustedDOMTypes
] interface TrustedTypePolicy { ] interface TrustedTypePolicy {
readonly attribute DOMString name; readonly attribute DOMString name;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// https://github.com/wicg/trusted-types // https://github.com/wicg/trusted-types
[ [
Exposed=(Window), Exposed=Window,
RuntimeEnabled=TrustedDOMTypes RuntimeEnabled=TrustedDOMTypes
] interface TrustedTypePolicyFactory { ] interface TrustedTypePolicyFactory {
[RaisesException] TrustedTypePolicy createPolicy(DOMString policyName, TrustedTypePolicyOptions policyOptions, optional boolean exposed = false); [RaisesException] TrustedTypePolicy createPolicy(DOMString policyName, TrustedTypePolicyOptions policyOptions, optional boolean exposed = false);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
typedef (USVString or TrustedURL) URLString; typedef (USVString or TrustedURL) URLString;
[ [
Exposed=(Window,Worker), Exposed=Window,
RuntimeEnabled=TrustedDOMTypes RuntimeEnabled=TrustedDOMTypes
] interface TrustedURL { ] interface TrustedURL {
stringifier; stringifier;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment