Skip to content

Commit

Permalink
Add more WPT tests for elementNS/attrNs parameters of `getAttributeTy…
Browse files Browse the repository at this point in the history
…pe`.

Note that this overlaps a bit with the following tests:
- TrustedTypePolicyFactory-getAttributeType-namespace.html
- TrustedTypePolicyFactory-getAttributeType-svg.html

Differential Revision: https://phabricator.services.mozilla.com/D226130

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1917783
gecko-commit: d9c1c805ef2d2c32d1795224c230456e44b36e86
gecko-reviewers: smaug
  • Loading branch information
moz-wptsync-bot committed Oct 23, 2024
1 parent 3f6b218 commit 6dc74e8
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,22 @@
});
assert_equals(trustedTypes.getPropertyType("iframe", "srcdoc", NSURI_HTML.toUpperCase()), null, "case-sensitiveness");
}, "getPropertyType with an explicit elementNs parameter");

test(t => {
NSURI_ARRAY.forEach(elementNs => {
const emptyOrHTMLElementNs = (elementNs === NSURI_EMPTY || elementNs === NSURI_HTML);
NSURI_ARRAY.forEach(attrNs => {
const emptyAttrNs = (attrNs === NSURI_EMPTY);
assert_equals(trustedTypes.getAttributeType("iframe", "srcdoc", elementNs, attrNs),
emptyOrHTMLElementNs && emptyAttrNs ? "TrustedHTML" : null);
assert_equals(trustedTypes.getAttributeType("script", "src", elementNs, attrNs),
emptyOrHTMLElementNs && emptyAttrNs ? "TrustedScriptURL" : null);
assert_equals(trustedTypes.getAttributeType("script", "href", elementNs, attrNs),
elementNs === NSURI_SVG && (emptyAttrNs || attrNs === NSURI_XLINK) ? "TrustedScriptURL" : null);
});
});
assert_equals(trustedTypes.getAttributeType("script", "href", NSURI_SVG.toUpperCase(), NSURI_XLINK), null, "case-sensitiveness of elementNs");
assert_equals(trustedTypes.getAttributeType("script", "href", NSURI_SVG, NSURI_XLINK.toUpperCase()), null, "case-sensitiveness of attrNs");
}, "getAttributeType with explicit elementNs and attrNs parameters");
</script>
</body>

0 comments on commit 6dc74e8

Please sign in to comment.