Revision control
Copy as Markdown
Other Tools
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
const { AppConstants } = ChromeUtils.importESModule(
);
add_task(function test_isValidScheme() {
const fileURL = Services.io.newFileURI(
do_get_file("resources/rss2_example.xml")
);
for (const url of [
fileURL.spec,
]) {
Assert.ok(FeedUtils.isValidScheme(url), `${url} should be valid`);
}
Assert.ok(
FeedUtils.isValidScheme(fileURL),
"a local file nsIURI should be valid"
);
for (const url of [
"mailto:someone@example.org",
"javascript:alert(1)",
"not a url",
]) {
Assert.ok(!FeedUtils.isValidScheme(url), `${url} should not be valid`);
}
});
add_task(
{ skip_if: () => AppConstants.platform != "win" },
function test_isValidScheme_UNC() {
for (const url of [
]) {
Assert.ok(!FeedUtils.isValidScheme(url), `${url} should not be valid`);
}
Assert.ok(
"a file url with a drive letter should be valid"
);
}
);