Bug 1770888 - tests r=hsivonen

Differential Revision: https://phabricator.services.mozilla.com/D156800
This commit is contained in:
Frederik Braun 2022-09-20 08:29:55 +00:00
parent 09f6372676
commit 92f896ab7e
2 changed files with 21 additions and 3 deletions

View File

@ -1010,4 +1010,20 @@ var vectors = [
data: "<svg><template></template></svg>",
sanitized: "<html><head></head><body></body></html>",
},
{
data: "<svg><use href='http://example.com/test.svg'></svg>",
flags: 1, // ParserUtils.SanitizerAllowStyle
sanitized: "<html><head></head><body><svg><use></use></svg></body></html>",
},
{
// fragments that reference the same document are allowed.
data: "<svg><use href='#x'></svg>",
flags: 1, // ParserUtils.SanitizerAllowStyle
sanitized: '<html><head></head><body><svg><use href="#x"></use></svg></body></html>',
},
{
data: '<svg><use xlink:href="http://example/#baz"/></svg>',
flags: 1, // ParserUtils.SanitizerAllowStyl,
sanitized: "<html><head></head><body><svg><use></use></svg></body></html>",
},
];

View File

@ -43,9 +43,11 @@ function run_test() {
// and default settings
for (var item in vectors) {
var evil = vectors[item].data;
var sanitized = vectors[item].sanitized;
var out = ParserUtils.sanitize(evil, sanitizeFlags);
let { data, sanitized, flags } = vectors[item];
if (!flags) {
flags = sanitizeFlags;
}
var out = ParserUtils.sanitize(data, flags);
Assert.equal(sanitized, out);
}
}