From 7559084b22c1a591ad0e751e5049ae5b309d59cb Mon Sep 17 00:00:00 2001 From: Tete17 Date: Thu, 31 Jul 2025 18:26:58 +0200 Subject: [PATCH] LibWeb: Add wpt test for createPolicy and createXXX This gives us at least 72 new tests :) --- .../TrustedTypePolicy-createXXX.txt | 40 +++ ...icyFactory-createPolicy-createXYZTests.txt | 33 +++ ...ory-createPolicy-cspTests-noNamesGiven.txt | 6 + ...y-createPolicy-cspTests-none-none-name.txt | 7 + ...actory-createPolicy-cspTests-none-none.txt | 7 + ...actory-createPolicy-cspTests-none-skip.txt | 8 + ...Factory-createPolicy-cspTests-wildcard.txt | 6 + ...actory-createPolicy-non-tt-policy-name.txt | 10 + ...ePolicyFactory-createPolicy-unenforced.txt | 6 + .../TrustedTypePolicy-createXXX.html | 118 +++++++++ ...cyFactory-createPolicy-createXYZTests.html | 232 ++++++++++++++++++ ...ry-createPolicy-cspTests-noNamesGiven.html | 14 ++ ...-createPolicy-cspTests-none-none-name.html | 17 ++ ...ctory-createPolicy-cspTests-none-none.html | 20 ++ ...ctory-createPolicy-cspTests-none-skip.html | 19 ++ ...actory-createPolicy-cspTests-wildcard.html | 12 + ...ctory-createPolicy-non-tt-policy-name.html | 66 +++++ ...PolicyFactory-createPolicy-unenforced.html | 15 ++ 18 files changed, 636 insertions(+) create mode 100644 Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicy-createXXX.txt create mode 100644 Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-createXYZTests.txt create mode 100644 Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-noNamesGiven.txt create mode 100644 Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none-none-name.txt create mode 100644 Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none-none.txt create mode 100644 Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none-skip.txt create mode 100644 Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-wildcard.txt create mode 100644 Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-non-tt-policy-name.txt create mode 100644 Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-unenforced.txt create mode 100644 Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicy-createXXX.html create mode 100644 Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-createXYZTests.html create mode 100644 Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-noNamesGiven.html create mode 100644 Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none-none-name.html create mode 100644 Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none-none.html create mode 100644 Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none-skip.html create mode 100644 Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-wildcard.html create mode 100644 Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-non-tt-policy-name.html create mode 100644 Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-unenforced.html diff --git a/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicy-createXXX.txt b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicy-createXXX.txt new file mode 100644 index 00000000000..431b87d35a1 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicy-createXXX.txt @@ -0,0 +1,40 @@ +Harness status: OK + +Found 29 tests + +29 Pass +Pass calling undefined callbacks throws +Pass Attributes without type constraints will work as before. +Pass trustedTypes.createPolicy(.., null) creates empty policy. +Pass TestPolicyTrustedHTML0 (TrustedHTML: s => s) +Pass TestPolicyTrustedHTML1 (TrustedHTML: s => null) +Pass TestPolicyTrustedHTML2 (TrustedHTML: s => "well, " + s) +Pass TestPolicyTrustedHTML3 (TrustedHTML: s => { throw new Error() }) +Pass TestPolicyTrustedHTML4 (TrustedHTML: callback_to_capture_this(s) { + return String(this); + }) +Pass TestPolicyTrustedHTML5 (TrustedHTML: s => { aGlobalVarForSideEffectTesting = s; return s }) +Pass TestPolicyTrustedHTML6 (TrustedHTML: s => aGlobalVarForSideEffectTesting + s) +Pass TestPolicyTrustedHTML7 (TrustedHTML: function () { [native code] }) +Pass TestPolicyTrustedHTML8 (TrustedHTML: s => aGlobalFunction(s)) +Pass TestPolicyTrustedScript0 (TrustedScript: s => s) +Pass TestPolicyTrustedScript1 (TrustedScript: s => null) +Pass TestPolicyTrustedScript2 (TrustedScript: s => "well, " + s) +Pass TestPolicyTrustedScript3 (TrustedScript: s => { throw new Error() }) +Pass TestPolicyTrustedScript4 (TrustedScript: callback_to_capture_this(s) { + return String(this); + }) +Pass TestPolicyTrustedScript5 (TrustedScript: s => { aGlobalVarForSideEffectTesting = s; return s }) +Pass TestPolicyTrustedScript6 (TrustedScript: s => aGlobalVarForSideEffectTesting + s) +Pass TestPolicyTrustedScript7 (TrustedScript: function () { [native code] }) +Pass TestPolicyTrustedScript8 (TrustedScript: s => aGlobalFunction(s)) +Pass TestPolicyTrustedScriptURL0 (TrustedScriptURL: s => s) +Pass TestPolicyTrustedScriptURL1 (TrustedScriptURL: s => null) +Pass TestPolicyTrustedScriptURL2 (TrustedScriptURL: s => s + "#duck") +Pass TestPolicyTrustedScriptURL3 (TrustedScriptURL: s => { throw new Error() }) +Pass TestPolicyTrustedScriptURL4 (TrustedScriptURL: callback_to_capture_this(s) { + return String(this); + }) +Pass TestPolicyTrustedScriptURL5 (TrustedScriptURL: s => s + "#" + aGlobalVarForSideEffectTesting) +Pass TestPolicyTrustedScriptURL6 (TrustedScriptURL: function () { [native code] }) +Pass TestPolicyTrustedScriptURL7 (TrustedScriptURL: s => anotherGlobalFunction(s)) diff --git a/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-createXYZTests.txt b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-createXYZTests.txt new file mode 100644 index 00000000000..15de8aee4fc --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-createXYZTests.txt @@ -0,0 +1,33 @@ +Harness status: OK + +Found 28 tests + +28 Pass +Pass html = identity function +Pass html = null +Pass html = string + global string +Pass html = identity function, global string changed +Pass html = callback that throws +Pass html = this bound to an object +Pass html = this without bind +Pass html - calling undefined callback throws +Pass createHTML defined - calling undefined callbacks throws +Pass script = identity function +Pass script = null +Pass script = string + global string +Pass script = identity function, global string changed +Pass script = callback that throws +Pass script = this bound to an object +Pass script = this without bind +Pass script - calling undefined callback throws +Pass createScript defined - calling undefined callbacks throws +Pass script_url = identity function +Pass script_url = null +Pass script_url = string + global string +Pass script_url = identity function, global string changed +Pass script_url = callback that throws +Pass script_url = this bound to an object +Pass script_url = this without bind +Pass script_url - calling undefined callback throws +Pass createScriptURL defined - calling undefined callbacks throws +Pass Arbitrary number of arguments diff --git a/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-noNamesGiven.txt b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-noNamesGiven.txt new file mode 100644 index 00000000000..1339754f080 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-noNamesGiven.txt @@ -0,0 +1,6 @@ +Harness status: OK + +Found 1 tests + +1 Pass +Pass No name list given - policy creation throws diff --git a/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none-none-name.txt b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none-none-name.txt new file mode 100644 index 00000000000..bb3d07fbbcc --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none-none-name.txt @@ -0,0 +1,7 @@ +Harness status: OK + +Found 2 tests + +2 Pass +Pass Can create policy with name 'SomeName' +Pass Cannot create policy with name 'default' - policy creation throws diff --git a/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none-none.txt b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none-none.txt new file mode 100644 index 00000000000..fa71ad2823e --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none-none.txt @@ -0,0 +1,7 @@ +Harness status: OK + +Found 2 tests + +2 Pass +Pass Cannot create policy with name 'SomeName' - policy creation throws +Pass Cannot create policy with name 'default' - policy creation throws diff --git a/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none-skip.txt b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none-skip.txt new file mode 100644 index 00000000000..5c56c4f4538 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none-skip.txt @@ -0,0 +1,8 @@ +Harness status: OK + +Found 3 tests + +3 Pass +Pass Can create policy with name 'SomeName' +Pass Can create a second policy with name 'SomeName' +Pass Can create policy with name 'default' diff --git a/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-wildcard.txt b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-wildcard.txt new file mode 100644 index 00000000000..e96716b1bd1 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-wildcard.txt @@ -0,0 +1,6 @@ +Harness status: OK + +Found 1 tests + +1 Pass +Pass Wildcard given - policy creation works diff --git a/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-non-tt-policy-name.txt b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-non-tt-policy-name.txt new file mode 100644 index 00000000000..69aad2d11f3 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-non-tt-policy-name.txt @@ -0,0 +1,10 @@ +Harness status: OK + +Found 5 tests + +5 Pass +Pass Creating an empty policy name works. +Pass Creating policy names made of a single ASCII character works. +Pass Creating policy names made of multiple ASCII characters works. +Pass Creating policy names containing a non-ASCII BMP character works. +Pass Creating policy names containing a non-BMP character works. diff --git a/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-unenforced.txt b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-unenforced.txt new file mode 100644 index 00000000000..e36bbee1138 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-unenforced.txt @@ -0,0 +1,6 @@ +Harness status: OK + +Found 1 tests + +1 Pass +Pass Duplicate policy names should be tolerated (unless in enforcing mode) diff --git a/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicy-createXXX.html b/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicy-createXXX.html new file mode 100644 index 00000000000..6fe064bcc7e --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicy-createXXX.html @@ -0,0 +1,118 @@ + + + + + + + diff --git a/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-createXYZTests.html b/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-createXYZTests.html new file mode 100644 index 00000000000..f2a94cfeaed --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-createXYZTests.html @@ -0,0 +1,232 @@ + + + + + + diff --git a/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-noNamesGiven.html b/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-noNamesGiven.html new file mode 100644 index 00000000000..57fc4d6bffd --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-noNamesGiven.html @@ -0,0 +1,14 @@ + + + + + + + diff --git a/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none-none-name.html b/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none-none-name.html new file mode 100644 index 00000000000..83ad549c88a --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none-none-name.html @@ -0,0 +1,17 @@ + + + + + + + diff --git a/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none-none.html b/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none-none.html new file mode 100644 index 00000000000..16b4fc5d439 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none-none.html @@ -0,0 +1,20 @@ + + + + + + + + diff --git a/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none-skip.html b/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none-skip.html new file mode 100644 index 00000000000..ad21d5ae81b --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-none-skip.html @@ -0,0 +1,19 @@ + + + + + + + diff --git a/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-wildcard.html b/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-wildcard.html new file mode 100644 index 00000000000..ab5f9777a83 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-cspTests-wildcard.html @@ -0,0 +1,12 @@ + + + + + + diff --git a/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-non-tt-policy-name.html b/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-non-tt-policy-name.html new file mode 100644 index 00000000000..20384ca553e --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-non-tt-policy-name.html @@ -0,0 +1,66 @@ + + + + + + + + + + diff --git a/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-unenforced.html b/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-unenforced.html new file mode 100644 index 00000000000..21212d3e94a --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/trusted-types/TrustedTypePolicyFactory-createPolicy-unenforced.html @@ -0,0 +1,15 @@ + + + + + +