Commit fdc7a4b3 authored by Daniel Vogelheim's avatar Daniel Vogelheim Committed by Chromium LUCI CQ

[Trusted Types] Use same .idl for code generation and testing.

Fix-it week: Fix failing WPT test.

Change-Id: I3bf43d39f19bc9b690bb943185e7ddb8961699da
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2574951Reviewed-by: default avatarYifan Luo <lyf@chromium.org>
Commit-Queue: Daniel Vogelheim <vogelheim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834636}
parent d3ae6478
......@@ -18,7 +18,9 @@ namespace blink {
TrustedTypePolicy::TrustedTypePolicy(const String& policy_name,
TrustedTypePolicyOptions* policy_options)
: name_(policy_name), policy_options_(policy_options) {}
: name_(policy_name), policy_options_(policy_options) {
DCHECK(policy_options_);
}
TrustedHTML* TrustedTypePolicy::createHTML(ScriptState* script_state,
const String& input,
......
......@@ -26,6 +26,14 @@
namespace blink {
TrustedTypePolicy* TrustedTypePolicyFactory::createPolicy(
const String& policy_name,
ExceptionState& exception_state) {
return createPolicy(policy_name,
MakeGarbageCollected<TrustedTypePolicyOptions>(),
exception_state);
}
TrustedTypePolicy* TrustedTypePolicyFactory::createPolicy(
const String& policy_name,
const TrustedTypePolicyOptions* policy_options,
......
......@@ -31,6 +31,7 @@ class CORE_EXPORT TrustedTypePolicyFactory final
explicit TrustedTypePolicyFactory(ExecutionContext*);
// TrustedTypePolicyFactory.idl
TrustedTypePolicy* createPolicy(const String&, ExceptionState&);
TrustedTypePolicy* createPolicy(const String&,
const TrustedTypePolicyOptions*,
ExceptionState&);
......
......@@ -8,7 +8,7 @@
Exposed=(Window, Worker),
RuntimeEnabled=TrustedDOMTypes
] interface TrustedTypePolicyFactory : EventTarget {
[RaisesException] TrustedTypePolicy createPolicy(DOMString policyName, TrustedTypePolicyOptions policyOptions);
[RaisesException] TrustedTypePolicy createPolicy(DOMString policyName, optional TrustedTypePolicyOptions policyOptions);
// All the policy object names that have been created
[CallWith=ScriptState] boolean isHTML(any checkedObject);
[CallWith=ScriptState] boolean isScript(any checkedObject);
......
This is a testharness.js-based test.
Found 85 tests; 84 PASS, 1 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS idl_test setup
PASS idl_test validation
PASS TrustedHTML interface: existence and properties of interface object
PASS TrustedHTML interface object length
PASS TrustedHTML interface object name
PASS TrustedHTML interface: existence and properties of interface prototype object
PASS TrustedHTML interface: existence and properties of interface prototype object's "constructor" property
PASS TrustedHTML interface: existence and properties of interface prototype object's @@unscopables property
PASS TrustedHTML interface: stringifier
PASS TrustedHTML must be primary interface of window.trustedTypes.createPolicy("SomeName1", { createHTML: s => s }).createHTML("A string")
PASS Stringification of window.trustedTypes.createPolicy("SomeName1", { createHTML: s => s }).createHTML("A string")
PASS TrustedScript interface: existence and properties of interface object
PASS TrustedScript interface object length
PASS TrustedScript interface object name
PASS TrustedScript interface: existence and properties of interface prototype object
PASS TrustedScript interface: existence and properties of interface prototype object's "constructor" property
PASS TrustedScript interface: existence and properties of interface prototype object's @@unscopables property
PASS TrustedScript interface: stringifier
PASS TrustedScript must be primary interface of window.trustedTypes.createPolicy("SomeName2", { createScript: s => s }).createScript("A string")
PASS Stringification of window.trustedTypes.createPolicy("SomeName2", { createScript: s => s }).createScript("A string")
PASS TrustedScriptURL interface: existence and properties of interface object
PASS TrustedScriptURL interface object length
PASS TrustedScriptURL interface object name
PASS TrustedScriptURL interface: existence and properties of interface prototype object
PASS TrustedScriptURL interface: existence and properties of interface prototype object's "constructor" property
PASS TrustedScriptURL interface: existence and properties of interface prototype object's @@unscopables property
PASS TrustedScriptURL interface: stringifier
PASS TrustedScriptURL must be primary interface of window.trustedTypes.createPolicy("SomeName3", { createScriptURL: s => s }).createScriptURL("A string")
PASS Stringification of window.trustedTypes.createPolicy("SomeName3", { createScriptURL: s => s }).createScriptURL("A string")
PASS TrustedTypePolicyFactory interface: existence and properties of interface object
PASS TrustedTypePolicyFactory interface object length
PASS TrustedTypePolicyFactory interface object name
PASS TrustedTypePolicyFactory interface: existence and properties of interface prototype object
PASS TrustedTypePolicyFactory interface: existence and properties of interface prototype object's "constructor" property
PASS TrustedTypePolicyFactory interface: existence and properties of interface prototype object's @@unscopables property
FAIL TrustedTypePolicyFactory interface: operation createPolicy(DOMString, optional TrustedTypePolicyOptions) assert_equals: property has wrong .length expected 1 but got 2
PASS TrustedTypePolicyFactory interface: operation isHTML(any)
PASS TrustedTypePolicyFactory interface: operation isScript(any)
PASS TrustedTypePolicyFactory interface: operation isScriptURL(any)
PASS TrustedTypePolicyFactory interface: attribute emptyHTML
PASS TrustedTypePolicyFactory interface: attribute emptyScript
PASS TrustedTypePolicyFactory interface: operation getAttributeType(DOMString, DOMString, optional DOMString, optional DOMString)
PASS TrustedTypePolicyFactory interface: operation getPropertyType(DOMString, DOMString, optional DOMString)
PASS TrustedTypePolicyFactory interface: attribute defaultPolicy
PASS TrustedTypePolicyFactory interface: operation getTypeMapping(optional DOMString)
PASS TrustedTypePolicyFactory interface: attribute onbeforecreatepolicy
PASS TrustedTypePolicyFactory must be primary interface of window.trustedTypes
PASS Stringification of window.trustedTypes
PASS TrustedTypePolicyFactory interface: window.trustedTypes must inherit property "createPolicy(DOMString, optional TrustedTypePolicyOptions)" with the proper type
PASS TrustedTypePolicyFactory interface: calling createPolicy(DOMString, optional TrustedTypePolicyOptions) on window.trustedTypes with too few arguments must throw TypeError
PASS TrustedTypePolicyFactory interface: window.trustedTypes must inherit property "isHTML(any)" with the proper type
PASS TrustedTypePolicyFactory interface: calling isHTML(any) on window.trustedTypes with too few arguments must throw TypeError
PASS TrustedTypePolicyFactory interface: window.trustedTypes must inherit property "isScript(any)" with the proper type
PASS TrustedTypePolicyFactory interface: calling isScript(any) on window.trustedTypes with too few arguments must throw TypeError
PASS TrustedTypePolicyFactory interface: window.trustedTypes must inherit property "isScriptURL(any)" with the proper type
PASS TrustedTypePolicyFactory interface: calling isScriptURL(any) on window.trustedTypes with too few arguments must throw TypeError
PASS TrustedTypePolicyFactory interface: window.trustedTypes must inherit property "emptyHTML" with the proper type
PASS TrustedTypePolicyFactory interface: window.trustedTypes must inherit property "emptyScript" with the proper type
PASS TrustedTypePolicyFactory interface: window.trustedTypes must inherit property "getAttributeType(DOMString, DOMString, optional DOMString, optional DOMString)" with the proper type
PASS TrustedTypePolicyFactory interface: calling getAttributeType(DOMString, DOMString, optional DOMString, optional DOMString) on window.trustedTypes with too few arguments must throw TypeError
PASS TrustedTypePolicyFactory interface: window.trustedTypes must inherit property "getPropertyType(DOMString, DOMString, optional DOMString)" with the proper type
PASS TrustedTypePolicyFactory interface: calling getPropertyType(DOMString, DOMString, optional DOMString) on window.trustedTypes with too few arguments must throw TypeError
PASS TrustedTypePolicyFactory interface: window.trustedTypes must inherit property "defaultPolicy" with the proper type
PASS TrustedTypePolicyFactory interface: window.trustedTypes must inherit property "getTypeMapping(optional DOMString)" with the proper type
PASS TrustedTypePolicyFactory interface: calling getTypeMapping(optional DOMString) on window.trustedTypes with too few arguments must throw TypeError
PASS TrustedTypePolicyFactory interface: window.trustedTypes must inherit property "onbeforecreatepolicy" with the proper type
PASS TrustedTypePolicy interface: existence and properties of interface object
PASS TrustedTypePolicy interface object length
PASS TrustedTypePolicy interface object name
PASS TrustedTypePolicy interface: existence and properties of interface prototype object
PASS TrustedTypePolicy interface: existence and properties of interface prototype object's "constructor" property
PASS TrustedTypePolicy interface: existence and properties of interface prototype object's @@unscopables property
PASS TrustedTypePolicy interface: attribute name
PASS TrustedTypePolicy interface: operation createHTML(DOMString)
PASS TrustedTypePolicy interface: operation createScript(DOMString)
PASS TrustedTypePolicy interface: operation createScriptURL(USVString)
PASS TrustedTypePolicy must be primary interface of window.trustedTypes.createPolicy("SomeName", { createHTML: s => s })
PASS Stringification of window.trustedTypes.createPolicy("SomeName", { createHTML: s => s })
PASS TrustedTypePolicy interface: window.trustedTypes.createPolicy("SomeName", { createHTML: s => s }) must inherit property "name" with the proper type
PASS TrustedTypePolicy interface: window.trustedTypes.createPolicy("SomeName", { createHTML: s => s }) must inherit property "createHTML(DOMString)" with the proper type
PASS TrustedTypePolicy interface: calling createHTML(DOMString) on window.trustedTypes.createPolicy("SomeName", { createHTML: s => s }) with too few arguments must throw TypeError
PASS TrustedTypePolicy interface: window.trustedTypes.createPolicy("SomeName", { createHTML: s => s }) must inherit property "createScript(DOMString)" with the proper type
PASS TrustedTypePolicy interface: calling createScript(DOMString) on window.trustedTypes.createPolicy("SomeName", { createHTML: s => s }) with too few arguments must throw TypeError
PASS TrustedTypePolicy interface: window.trustedTypes.createPolicy("SomeName", { createHTML: s => s }) must inherit property "createScriptURL(USVString)" with the proper type
PASS TrustedTypePolicy interface: calling createScriptURL(USVString) on window.trustedTypes.createPolicy("SomeName", { createHTML: s => s }) with too few arguments must throw TypeError
Harness: the test ran to completion.
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