Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 21 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /trusted-types/TrustedTypePolicyFactory-getAttributeType-namespace.tentative.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<script src="/resources/testharness.js" ></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
// Tests for getAttributeType with namespaces, based on
const parser = new DOMParser();
[
parser.parseFromString(
'<!doctype html><html><head><script src="./foo.js"><'+'/script></head></html>',
'text/html'),
parser.parseFromString(
'application/xhtml+xml'),
parser.parseFromString(
'application/xml')
].forEach((doc, index) => {
const attribute = element.getAttributeNode("src");
test(_ => {
assert_equals(trustedTypes.getAttributeType(
element.localName, attribute.name, element.namespaceURI, attribute.namespaceURI),
"TrustedScriptURL");
}, `${index}: getAttributeType with full namespace info.`);
test(_ => {
assert_equals(trustedTypes.getAttributeType(
element.localName, attribute.name, element.namespaceURI, undefined),
"TrustedScriptURL");
},`${index}: getAttributeType with element namespace and empty attribute namespace`);
test(_ => {
assert_equals(trustedTypes.getAttributeType(
element.localName, attribute.name, undefined, undefined), "TrustedScriptURL");
}, `${index}: getAttributeType without namespaces.`);
test(_ => {
assert_equals(trustedTypes.getAttributeType(
element.localName, attribute.name, undefined, ""), "TrustedScriptURL");
}, `${index}: getAttributeType with undefined and empty namespace.`);
test(_ => {
assert_equals(trustedTypes.getAttributeType(
element.localName, attribute.name, "", undefined), "TrustedScriptURL");
}, `${index}: getAttributeType with empty and undefined namespace.`);
test(_ => {
assert_equals(trustedTypes.getAttributeType(
element.localName, attribute.name, "", ""), "TrustedScriptURL");
}, `${index}: getAttributeType with empty namespaces.`);
test(_ => {
assert_equals(trustedTypes.getAttributeType(
element.localName, attribute.name, element.namespaceURI, ""), "TrustedScriptURL");
}, `${index}: getAttributeType with element namespace and empty attribute namespace.`);
});
</script>
</body>