diff --git a/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicy-CSP-no-name.txt b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicy-CSP-no-name.txt new file mode 100644 index 00000000000..9c317281995 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicy-CSP-no-name.txt @@ -0,0 +1,6 @@ +Harness status: OK + +Found 1 tests + +1 Pass +Pass No name list given - policy creation fails. \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicy-CSP-wildcard.txt b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicy-CSP-wildcard.txt new file mode 100644 index 00000000000..071debc88b1 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicy-CSP-wildcard.txt @@ -0,0 +1,6 @@ +Harness status: OK + +Found 1 tests + +1 Pass +Pass CSP supports wildcards. \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-constants.txt b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-constants.txt new file mode 100644 index 00000000000..765e3f251a2 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-constants.txt @@ -0,0 +1,11 @@ +Harness status: OK + +Found 6 tests + +6 Pass +Pass trustedTypes.emptyHTML returns the intended value. +Pass trustedTypes.emptyHTML cannot be redefined. +Pass trustedTypes.emptyHTML cannot be redefined via defineProperty. +Pass trustedTypes.emptyScript returns the intended value. +Pass trustedTypes.emptyScript cannot be redefined. +Pass trustedTypes.emptyScript cannot be redefined via defineProperty. \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/trusted-types/idlharness.window.txt b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/idlharness.window.txt new file mode 100644 index 00000000000..70b0a0c6b50 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/idlharness.window.txt @@ -0,0 +1,105 @@ +Harness status: OK + +Found 100 tests + +100 Pass +Pass idl_test setup +Pass idl_test validation +Pass Partial interface mixin WindowOrWorkerGlobalScope: original interface mixin defined +Pass Partial interface mixin WindowOrWorkerGlobalScope: member names are unique +Pass Partial interface Window: member names are unique +Pass Window includes GlobalEventHandlers: member names are unique +Pass Window includes WindowEventHandlers: member names are unique +Pass Window includes WindowOrWorkerGlobalScope: member names are unique +Pass WorkerGlobalScope includes WindowOrWorkerGlobalScope: member names are unique +Pass Window includes AnimationFrameProvider: member names are unique +Pass Window includes WindowSessionStorage: member names are unique +Pass Window includes WindowLocalStorage: member names are unique +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 interface: operation toJSON() +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 TrustedHTML interface: window.trustedTypes.createPolicy("SomeName1", { createHTML: s => s }).createHTML("A string") must inherit property "toJSON()" with the proper type +Pass TrustedHTML interface: toJSON operation on 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 interface: operation toJSON() +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 TrustedScript interface: window.trustedTypes.createPolicy("SomeName2", { createScript: s => s }).createScript("A string") must inherit property "toJSON()" with the proper type +Pass TrustedScript interface: toJSON operation on 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 interface: operation toJSON() +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 TrustedScriptURL interface: window.trustedTypes.createPolicy("SomeName3", { createScriptURL: s => s }).createScriptURL("A string") must inherit property "toJSON()" with the proper type +Pass TrustedScriptURL interface: toJSON operation on 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 +Pass TrustedTypePolicyFactory interface: operation createPolicy(DOMString, optional TrustedTypePolicyOptions) +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 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 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, any...) +Pass TrustedTypePolicy interface: operation createScript(DOMString, any...) +Pass TrustedTypePolicy interface: operation createScriptURL(DOMString, any...) +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, any...)" with the proper type +Pass TrustedTypePolicy interface: calling createHTML(DOMString, any...) 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, any...)" with the proper type +Pass TrustedTypePolicy interface: calling createScript(DOMString, any...) 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(DOMString, any...)" with the proper type +Pass TrustedTypePolicy interface: calling createScriptURL(DOMString, any...) on window.trustedTypes.createPolicy("SomeName", { createHTML: s => s }) with too few arguments must throw TypeError +Pass Window interface: attribute trustedTypes \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/interfaces/trusted-types.idl b/Tests/LibWeb/Text/input/wpt-import/interfaces/trusted-types.idl new file mode 100644 index 00000000000..b6008e18725 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/interfaces/trusted-types.idl @@ -0,0 +1,65 @@ +// GENERATED CONTENT - DO NOT EDIT +// Content was automatically extracted by Reffy into webref +// (https://github.com/w3c/webref) +// Source: Trusted Types (https://w3c.github.io/trusted-types/dist/spec/) + +[Exposed=(Window,Worker)] +interface TrustedHTML { + stringifier; + DOMString toJSON(); +}; + +[Exposed=(Window,Worker)] +interface TrustedScript { + stringifier; + DOMString toJSON(); +}; + +[Exposed=(Window,Worker)] +interface TrustedScriptURL { + stringifier; + USVString toJSON(); +}; + +[Exposed=(Window,Worker)] interface TrustedTypePolicyFactory { + 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; +}; + +[Exposed=(Window,Worker)] +interface TrustedTypePolicy { + readonly attribute DOMString name; + TrustedHTML createHTML(DOMString input, any... arguments); + TrustedScript createScript(DOMString input, any... arguments); + TrustedScriptURL createScriptURL(DOMString input, any... arguments); +}; + +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); + +typedef (TrustedHTML or TrustedScript or TrustedScriptURL) TrustedType; + +partial interface mixin WindowOrWorkerGlobalScope { + readonly attribute TrustedTypePolicyFactory trustedTypes; +}; diff --git a/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicy-CSP-no-name.html b/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicy-CSP-no-name.html new file mode 100644 index 00000000000..1dd49d5197e --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicy-CSP-no-name.html @@ -0,0 +1,16 @@ + + + + + + +
+ + diff --git a/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicy-CSP-wildcard.html b/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicy-CSP-wildcard.html new file mode 100644 index 00000000000..e843116559d --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicy-CSP-wildcard.html @@ -0,0 +1,12 @@ + + + + + + + diff --git a/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-constants.html b/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-constants.html new file mode 100644 index 00000000000..87ef8c83875 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-constants.html @@ -0,0 +1,43 @@ + + + + + + + diff --git a/Tests/LibWeb/Text/input/wpt-import/trusted-types/idlharness.window.html b/Tests/LibWeb/Text/input/wpt-import/trusted-types/idlharness.window.html new file mode 100644 index 00000000000..3391b94c2aa --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/trusted-types/idlharness.window.html @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/Tests/LibWeb/Text/input/wpt-import/trusted-types/idlharness.window.js b/Tests/LibWeb/Text/input/wpt-import/trusted-types/idlharness.window.js new file mode 100644 index 00000000000..07847fdb39e --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/trusted-types/idlharness.window.js @@ -0,0 +1,16 @@ +// META: script=/resources/WebIDLParser.js +// META: script=/resources/idlharness.js + +idl_test( + ['trusted-types'], + ['html', 'dom'], + 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")'], + }); + } +);