Skip to content

Commit

Permalink
Bug 1917783 - Add more WPT tests for elementNS/attrNs parameters of `…
Browse files Browse the repository at this point in the history
…getAttributeType`. r=smaug

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
  • Loading branch information
fred-wang committed Oct 22, 2024
1 parent 2b4cba4 commit 65d3954
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@

[ASCII case-insensitivity of tag name and attribute parameters]
expected: FAIL

[getAttributeType with explicit elementNs and attrNs parameters]
expected: FAIL
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 65d3954

Please sign in to comment.