mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-19 15:43:20 +00:00
LibWeb: Add new passing WPT tests
This commit is contained in:
parent
18199f8f2a
commit
460ffcbe1d
Notes:
github-actions[bot]
2025-10-13 12:23:08 +00:00
Author: https://github.com/tete17
Commit: 460ffcbe1d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6424
Reviewed-by: https://github.com/Lubrsi ✅
Reviewed-by: https://github.com/tcl3
8 changed files with 210 additions and 0 deletions
|
@ -0,0 +1,8 @@
|
|||
Harness status: OK
|
||||
|
||||
Found 3 tests
|
||||
|
||||
3 Pass
|
||||
Pass Create Worker via ScriptTestUrl
|
||||
Pass Block Worker creation via string
|
||||
Pass Create Worker via string with default policy.
|
|
@ -0,0 +1,6 @@
|
|||
Harness status: OK
|
||||
|
||||
Found 1 tests
|
||||
|
||||
1 Pass
|
||||
Pass range.createContextualFragment assigned via policy (successful HTML transformation).
|
|
@ -0,0 +1,8 @@
|
|||
Harness status: OK
|
||||
|
||||
Found 3 tests
|
||||
|
||||
3 Pass
|
||||
Pass Create SharedWorker via ScriptTestUrl
|
||||
Pass Block SharedWorker creation via string
|
||||
Pass Create SharedWorker via string with default policy.
|
|
@ -0,0 +1,10 @@
|
|||
Harness status: OK
|
||||
|
||||
Found 5 tests
|
||||
|
||||
5 Pass
|
||||
Pass range.createContextualFragment assigned via policy (successful HTML transformation).
|
||||
Pass `range.createContextualFragment(string)` throws.
|
||||
Pass `range.createContextualFragment(null)` throws.
|
||||
Pass `range.createContextualFragment(string)` assigned via default policy (successful HTML transformation).
|
||||
Pass `range.createContextualFragment(null)` assigned via default policy does not throw.
|
|
@ -0,0 +1,52 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script';">
|
||||
<script src="../resources/testharness.js"></script>
|
||||
<script src="../resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
|
||||
const test_url = "support/WorkerGlobalScope-importScripts.https.js"
|
||||
const trusted_url = trustedTypes.createPolicy("anythinggoes", {
|
||||
createScriptURL: x => x}).createScriptURL(test_url);
|
||||
const default_url = "support/WorkerGlobalScope-importScripts.potato.js"
|
||||
|
||||
test(() => {
|
||||
try {
|
||||
new Worker(trusted_url);
|
||||
} catch (e) {
|
||||
assert_unreached("Worker creation failed: " + e);
|
||||
}
|
||||
}, "Create Worker via ScriptTestUrl");
|
||||
|
||||
test(() => {
|
||||
assert_throws_js(TypeError, () => new Worker(test_url));
|
||||
}, "Block Worker creation via string");
|
||||
|
||||
// Tests with default policy.
|
||||
let seenTrustedTypeName;
|
||||
let seenSinkName;
|
||||
function resetSeenArguments() {
|
||||
seenTrustedTypeName = undefined;
|
||||
seenSinkName = undefined;
|
||||
}
|
||||
|
||||
trustedTypes.createPolicy("default", {
|
||||
createScriptURL: (input, trustedTypeName, sinkName) => {
|
||||
seenTrustedTypeName = trustedTypeName;
|
||||
seenSinkName = sinkName;
|
||||
return input.replace("potato", "https");
|
||||
}
|
||||
});
|
||||
|
||||
test(t => {
|
||||
t.add_cleanup(resetSeenArguments);
|
||||
new Worker(default_url);
|
||||
assert_equals(seenTrustedTypeName, "TrustedScriptURL");
|
||||
assert_equals(seenSinkName, "Worker constructor");
|
||||
}, "Create Worker via string with default policy.");
|
||||
|
||||
</script>
|
||||
</body>
|
|
@ -0,0 +1,15 @@
|
|||
<!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 p = createHTML_policy(window, 1);
|
||||
let html = p.createHTML(INPUTS.HTML);
|
||||
var range = document.createRange();
|
||||
range.selectNodeContents(document.documentElement);
|
||||
var result = range.createContextualFragment(html);
|
||||
assert_equals(result.textContent, RESULTS.HTML);
|
||||
}, "range.createContextualFragment assigned via policy (successful HTML transformation).");
|
||||
</script>
|
|
@ -0,0 +1,52 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script';">
|
||||
<script src="../resources/testharness.js"></script>
|
||||
<script src="../resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
|
||||
const test_url = "support/WorkerGlobalScope-importScripts.https.js"
|
||||
const trusted_url = trustedTypes.createPolicy("anythinggoes", {
|
||||
createScriptURL: x => x}).createScriptURL(test_url);
|
||||
const default_url = "support/WorkerGlobalScope-importScripts.potato.js"
|
||||
|
||||
test(() => {
|
||||
try {
|
||||
new SharedWorker(trusted_url);
|
||||
} catch (e) {
|
||||
assert_unreached("SharedWorker creation failed: " + e);
|
||||
}
|
||||
}, "Create SharedWorker via ScriptTestUrl");
|
||||
|
||||
test(() => {
|
||||
assert_throws_js(TypeError, () => new SharedWorker(test_url));
|
||||
}, "Block SharedWorker creation via string");
|
||||
|
||||
// Tests with default policy.
|
||||
let seenTrustedTypeName;
|
||||
let seenSinkName;
|
||||
function resetSeenArguments() {
|
||||
seenTrustedTypeName = undefined;
|
||||
seenSinkName = undefined;
|
||||
}
|
||||
|
||||
trustedTypes.createPolicy("default", {
|
||||
createScriptURL: (input, trustedTypeName, sinkName) => {
|
||||
seenTrustedTypeName = trustedTypeName;
|
||||
seenSinkName = sinkName;
|
||||
return input.replace("potato", "https");
|
||||
}
|
||||
});
|
||||
|
||||
test(t => {
|
||||
t.add_cleanup(resetSeenArguments);
|
||||
new SharedWorker(default_url);
|
||||
assert_equals(seenTrustedTypeName, "TrustedScriptURL");
|
||||
assert_equals(seenSinkName, "SharedWorker constructor");
|
||||
}, "Create SharedWorker via string with default policy.");
|
||||
|
||||
</script>
|
||||
</body>
|
|
@ -0,0 +1,59 @@
|
|||
<!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="require-trusted-types-for 'script';">
|
||||
<body>
|
||||
<script>
|
||||
// TrustedHTML assignments do not throw.
|
||||
test(t => {
|
||||
let p = createHTML_policy(window, 1);
|
||||
let html = p.createHTML(INPUTS.HTML);
|
||||
var range = document.createRange();
|
||||
range.selectNodeContents(document.documentElement);
|
||||
var result = range.createContextualFragment(html);
|
||||
assert_equals(result.textContent, RESULTS.HTML);
|
||||
}, "range.createContextualFragment assigned via policy (successful HTML transformation).");
|
||||
|
||||
// String assignments throw.
|
||||
test(t => {
|
||||
var range = document.createRange();
|
||||
range.selectNodeContents(document.documentElement);
|
||||
assert_throws_js(TypeError, _ => {
|
||||
var result = range.createContextualFragment("A string");
|
||||
});
|
||||
}, "`range.createContextualFragment(string)` throws.");
|
||||
|
||||
// Null assignment throws.
|
||||
test(t => {
|
||||
var range = document.createRange();
|
||||
range.selectNodeContents(document.documentElement);
|
||||
assert_throws_js(TypeError, _ => {
|
||||
var result = range.createContextualFragment(null);
|
||||
});
|
||||
}, "`range.createContextualFragment(null)` throws.");
|
||||
|
||||
// After default policy creation string assignment implicitly calls createHTML
|
||||
test(t => {
|
||||
let p = window.trustedTypes.createPolicy("default", { createHTML:
|
||||
(value, _, sink) => {
|
||||
assert_equals(sink, "Range createContextualFragment");
|
||||
return createHTMLJS(value);
|
||||
}
|
||||
});
|
||||
|
||||
var range = document.createRange();
|
||||
range.selectNodeContents(document.documentElement);
|
||||
var result = range.createContextualFragment(INPUTS.HTML);
|
||||
assert_equals(result.textContent, RESULTS.HTML);
|
||||
}, "`range.createContextualFragment(string)` assigned via default policy (successful HTML transformation).");
|
||||
|
||||
// After default policy creation null assignment implicitly calls createHTML
|
||||
test(t => {
|
||||
var range = document.createRange();
|
||||
range.selectNodeContents(document.documentElement);
|
||||
var result = range.createContextualFragment(null);
|
||||
assert_equals(result.textContent, "null");
|
||||
}, "`range.createContextualFragment(null)` assigned via default policy does not throw.");
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue