Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

// Tests for nsITextToSubURI.unEscapeNonAsciiURI
function run_test() {
// Tests whether nsTextToSubURI does UTF-16 unescaping (it shouldn't)
const testURI = "data:text/html,%FE%FF";
Assert.equal(
Services.textToSubURI.unEscapeNonAsciiURI("UTF-16", testURI),
testURI
);
// Tests whether incomplete multibyte sequences throw.
const tests = [
{
throws: Cr.NS_ERROR_ILLEGAL_INPUT,
},
{
throws: Cr.NS_ERROR_ILLEGAL_INPUT,
},
{
},
{
throws: Cr.NS_ERROR_ILLEGAL_INPUT,
},
{
throws: Cr.NS_ERROR_ILLEGAL_INPUT,
},
{
throws: Cr.NS_ERROR_ILLEGAL_INPUT,
},
{
},
];
for (const t of tests) {
if (t.throws !== undefined) {
let thrown = undefined;
try {
Services.textToSubURI.unEscapeNonAsciiURI("UTF-8", t.input);
} catch (e) {
thrown = e.result;
}
Assert.equal(thrown, t.throws);
} else {
Assert.equal(
Services.textToSubURI.unEscapeNonAsciiURI("UTF-8", t.input),
t.expected
);
}
}
}