1
0
Fork 0
firefox/testing/web-platform/tests/url/url-setters.any.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

33 lines
1.1 KiB
JavaScript

// META: script=/common/subset-tests-by-key.js
// META: variant=?include=file
// META: variant=?include=javascript
// META: variant=?include=mailto
// META: variant=?exclude=(file|javascript|mailto)
// Keep this file in sync with url-setters-a-area.window.js.
promise_test(() => fetch("resources/setters_tests.json").then(res => res.json()).then(runURLSettersTests), "Loading data…");
function runURLSettersTests(allTestCases) {
for (const [propertyToBeSet, testCases] of Object.entries(allTestCases)) {
if (propertyToBeSet === "comment") {
continue;
}
for (const test_case of testCases) {
const name = `Setting <${test_case.href}>.${propertyToBeSet} = '${test_case.new_value}'${
test_case.comment ? ` ${test_case.comment}` : ''
}`;
const key = test_case.href.split(":")[0];
subsetTestByKey(key, test, () => {
const url = new URL(test_case.href);
url[propertyToBeSet] = test_case.new_value;
for (const [property, expectedValue] of Object.entries(test_case.expected)) {
assert_equals(url[property], expectedValue);
}
}, `URL: ${name}`);
}
}
}