зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1893942 [wpt PR 45950] - WebKit export of https://bugs.webkit.org/show_bug.cgi?id=273312, a=testonly
Automatic update from web-platform-tests Export made from a WebKit repository (#45950) Co-authored-by: Ziran Sun <zsun@igalia.com> -- wpt-commits: 07358b5e59c46e0c60b6629c23d811f88738b993 wpt-pr: 45950
This commit is contained in:
Родитель
05fe9c0ab6
Коммит
1c2029c1e6
|
@ -19,11 +19,6 @@
|
||||||
assert_equals(trustedTypes.getAttributeType("img", "madeup"), null);
|
assert_equals(trustedTypes.getAttributeType("img", "madeup"), null);
|
||||||
}, "sanity check trustedTypes.getAttributeType.");
|
}, "sanity check trustedTypes.getAttributeType.");
|
||||||
|
|
||||||
test(t => {
|
|
||||||
assert_true(!!trustedTypes.getTypeMapping());
|
|
||||||
}, "sanity check trustedTypes.getTypeMapping");
|
|
||||||
|
|
||||||
|
|
||||||
// getPropertyType tests adapted from w3c/trusted-types polyfill:
|
// getPropertyType tests adapted from w3c/trusted-types polyfill:
|
||||||
test(t => {
|
test(t => {
|
||||||
// returns the proper type for attribute-related properties
|
// returns the proper type for attribute-related properties
|
||||||
|
@ -71,24 +66,6 @@
|
||||||
assert_equals(trustedTypes.getAttributeType('img', 'bar'), null);
|
assert_equals(trustedTypes.getAttributeType('img', 'bar'), null);
|
||||||
}, "getAttributeType tests adapted from w3c/trusted-types polyfill");
|
}, "getAttributeType tests adapted from w3c/trusted-types polyfill");
|
||||||
|
|
||||||
|
|
||||||
test(t=> {
|
|
||||||
const map = trustedTypes.getTypeMapping();
|
|
||||||
|
|
||||||
// Spot testing some values.
|
|
||||||
assert_equals(map["script"].attributes.src, "TrustedScriptURL");
|
|
||||||
assert_equals(map["*"].properties.innerHTML, "TrustedHTML");
|
|
||||||
assert_equals(map["foo"], undefined);
|
|
||||||
|
|
||||||
// getTypeMapping returns a 'clean' object, in case the return value has
|
|
||||||
// been modified.
|
|
||||||
map["*"].attributes["foo"] = "bar";
|
|
||||||
assert_equals(trustedTypes.getTypeMapping()["*"].attributes["foo"], undefined);
|
|
||||||
;
|
|
||||||
// Unknown namespaces:
|
|
||||||
assert_equals(trustedTypes.getTypeMapping("http://foo/bar"), null);
|
|
||||||
}, "getTypeMapping tests adapted from w3c/trusted-types polyfill");
|
|
||||||
|
|
||||||
// Test case handling for both attributes and properties.
|
// Test case handling for both attributes and properties.
|
||||||
for (let attr of ["srcDoc", "SRCDOC", "srcdoc"]) {
|
for (let attr of ["srcDoc", "SRCDOC", "srcdoc"]) {
|
||||||
for (let elem of ["iframe", "IFRAME", "iFrAmE"]) {
|
for (let elem of ["iframe", "IFRAME", "iFrAmE"]) {
|
|
@ -33,22 +33,6 @@
|
||||||
let properties = ['madeup', 'id', "onerror", "onclick"];
|
let properties = ['madeup', 'id', "onerror", "onclick"];
|
||||||
const types = [null, "TrustedHTML", "TrustedScript", "TrustedScriptURL"];
|
const types = [null, "TrustedHTML", "TrustedScript", "TrustedScriptURL"];
|
||||||
|
|
||||||
// We'll wrap construction of the elements/properties list in a test, mainly
|
|
||||||
// so we'll get decent error messages when it might fail.
|
|
||||||
test(t => {
|
|
||||||
// Collect all element and property names from getTypeMapping().
|
|
||||||
const map = trustedTypes.getTypeMapping();
|
|
||||||
for (let elem in map) {
|
|
||||||
elements.push(elem);
|
|
||||||
properties = properties.concat(Object.keys(map[elem].properties));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove "*" entries and de-duplicate properties.
|
|
||||||
elements = elements.filter(s => !s.includes("*"));
|
|
||||||
properties = properties.filter(s => !s.includes("*"));
|
|
||||||
properties = Array.from(new Set(properties));
|
|
||||||
}, "Prepare parameters for generic test series below.");
|
|
||||||
|
|
||||||
// Iterate one test for each combination of element, property, and sink type.
|
// Iterate one test for each combination of element, property, and sink type.
|
||||||
const target = document.getElementById("target");
|
const target = document.getElementById("target");
|
||||||
for (elem of elements) {
|
for (elem of elements) {
|
Загрузка…
Ссылка в новой задаче