mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-22 09:18:55 +00:00
LibWeb: Add more WPT test for TrustedTypes
We now implement 100% of the idlharness :)
This commit is contained in:
parent
b6a16ed3c6
commit
848020a9a1
Notes:
github-actions[bot]
2025-09-01 15:20:35 +00:00
Author: https://github.com/tete17
Commit: 848020a9a1
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5828
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/Lubrsi ✅
10 changed files with 289 additions and 0 deletions
|
@ -0,0 +1,6 @@
|
||||||
|
Harness status: OK
|
||||||
|
|
||||||
|
Found 1 tests
|
||||||
|
|
||||||
|
1 Pass
|
||||||
|
Pass No name list given - policy creation fails.
|
|
@ -0,0 +1,6 @@
|
||||||
|
Harness status: OK
|
||||||
|
|
||||||
|
Found 1 tests
|
||||||
|
|
||||||
|
1 Pass
|
||||||
|
Pass CSP supports wildcards.
|
|
@ -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.
|
|
@ -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
|
|
@ -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;
|
||||||
|
};
|
|
@ -0,0 +1,16 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<script src="../resources/testharness.js" ></script>
|
||||||
|
<script src="../resources/testharnessreport.js"></script>
|
||||||
|
<script src="support/helper.sub.js"></script>
|
||||||
|
|
||||||
|
<meta http-equiv="Content-Security-Policy" content="trusted-types">
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
// No name given test
|
||||||
|
test(t => {
|
||||||
|
assert_throws_js(TypeError,
|
||||||
|
() => window.trustedTypes.createPolicy('SomeName', { createHTML: s => s } ),
|
||||||
|
"createPolicy with an empty trusted-types CSP directive");
|
||||||
|
}, "No name list given - policy creation fails.");
|
||||||
|
</script>
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<script src="../resources/testharness.js" ></script>
|
||||||
|
<script src="../resources/testharnessreport.js"></script>
|
||||||
|
<script src="support/helper.sub.js"></script>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
test(t => {
|
||||||
|
let policy = window.trustedTypes.createPolicy('SomeName', { createHTML: s => s } );
|
||||||
|
assert_equals(policy.name, 'SomeName');
|
||||||
|
}, "CSP supports wildcards.");
|
||||||
|
</script>
|
|
@ -0,0 +1,43 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<script src="../resources/testharness.js"></script>
|
||||||
|
<script src="../resources/testharnessreport.js"></script>
|
||||||
|
<script src="support/helper.sub.js"></script>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
test(t => {
|
||||||
|
const empty = trustedTypes.emptyHTML;
|
||||||
|
assert_true(trustedTypes.isHTML(empty));
|
||||||
|
assert_equals(empty.toString(), "");
|
||||||
|
}, 'trustedTypes.emptyHTML returns the intended value.');
|
||||||
|
|
||||||
|
test(t => {
|
||||||
|
try { trustedTypes.emptyHTML = 'fake'; } catch { }
|
||||||
|
assert_true(trustedTypes.isHTML(trustedTypes.emptyHTML));
|
||||||
|
assert_equals(trustedTypes.emptyHTML.toString(), "");
|
||||||
|
}, 'trustedTypes.emptyHTML cannot be redefined.');
|
||||||
|
|
||||||
|
test(t => {
|
||||||
|
try { Object.defineProperty(TrustedTypes, 'emptyHTML', 'fake'); } catch { }
|
||||||
|
assert_true(trustedTypes.isHTML(trustedTypes.emptyHTML));
|
||||||
|
assert_equals(trustedTypes.emptyHTML.toString(), "");
|
||||||
|
}, 'trustedTypes.emptyHTML cannot be redefined via defineProperty.');
|
||||||
|
|
||||||
|
test(t => {
|
||||||
|
const empty = trustedTypes.emptyScript;
|
||||||
|
assert_true(trustedTypes.isScript(empty));
|
||||||
|
assert_equals(empty.toString(), "");
|
||||||
|
}, 'trustedTypes.emptyScript returns the intended value.');
|
||||||
|
|
||||||
|
test(t => {
|
||||||
|
try { trustedTypes.emptyScript = 'fake'; } catch { }
|
||||||
|
assert_true(trustedTypes.isScript(trustedTypes.emptyScript));
|
||||||
|
assert_equals(trustedTypes.emptyScript.toString(), "");
|
||||||
|
}, 'trustedTypes.emptyScript cannot be redefined.');
|
||||||
|
|
||||||
|
test(t => {
|
||||||
|
try { Object.defineProperty(TrustedTypes, 'emptyScript', 'fake'); } catch { }
|
||||||
|
assert_true(trustedTypes.isScript(trustedTypes.emptyScript));
|
||||||
|
assert_equals(trustedTypes.emptyScript.toString(), "");
|
||||||
|
}, 'trustedTypes.emptyScript cannot be redefined via defineProperty.');
|
||||||
|
</script>
|
|
@ -0,0 +1,9 @@
|
||||||
|
<!doctype html>
|
||||||
|
<meta charset=utf-8>
|
||||||
|
|
||||||
|
<script src="../resources/testharness.js"></script>
|
||||||
|
<script src="../resources/testharnessreport.js"></script>
|
||||||
|
<script src="../resources/WebIDLParser.js"></script>
|
||||||
|
<script src="../resources/idlharness.js"></script>
|
||||||
|
<div id=log></div>
|
||||||
|
<script src="../trusted-types/idlharness.window.js"></script>
|
|
@ -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")'],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
Loading…
Add table
Add a link
Reference in a new issue