Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

/* Any copyright is dedicated to the Public Domain.
// Checks certain sequences of characters encoded properly in the URL
// As completely duplicating the list in losslessDecodeURI wouldn't make sense
// we just test a few examples from it.
add_task(async function () {
let enc = encodeURIComponent;
let tests = [
[
"https://example.com/ \u{0702}test",
"https://example.com/%20%20 \u{0702}test",
],
[
"https://example.com/ \u{200C} \u{200C} test",
],
[
`https://example.com/${enc("\u{2800}")}test`,
],
[
`https://example.com/${enc("\u{000B}")}test`,
],
[
],
[
"javascript: (() => { alert('test'); } })();",
"javascript: (() => { alert('test'); } })();",
],
["https://example.com/ %3Dtest", `https://example.com/ %3Dtest`],
[
`https://example.com/${enc("\u{E012A}")}test`,
],
[
],
[
`https://example.com/a${enc("\u{00AD}\u{034F}\u{061C}")}b`,
],
];
await BrowserTestUtils.withNewTab(
{
gBrowser,
url: "about:robots",
},
function () {
for (let [url, expected] of tests) {
info("testing: " + url);
gURLBar.setURI({
uri: Services.io.newURI(url),
dueToSessionRestore: true,
});
Assert.equal(gURLBar.untrimmedValue, expected);
}
}
);
});