Source code
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
import { NetUtil } from "resource://gre/modules/NetUtil.sys.mjs";
export function checkInputAndSerializationMatch(input) {
let uri = NetUtil.newURI(input);
Assert.equal(
uri.spec,
input,
`serialization should match the input: {input}`
);
}
export function checkInputAndSerializationMatchChild(input) {
let uri = Services.io.newURI(input);
Assert.equal(
uri.spec,
input,
`serialization should match the input: {input}`
);
}
export function removeSecondColon(str) {
let colonIndex = str.indexOf(":");
if (colonIndex !== -1) {
colonIndex = str.indexOf(":", colonIndex + 1);
if (colonIndex !== -1) {
return str.slice(0, colonIndex) + str.slice(colonIndex + 1);
}
}
Assert.ok(false, "we expected at least two colons");
return str;
}
export function checkSerializationMissingSecondColon(input) {
let uri = NetUtil.newURI(input);
Assert.equal(
uri.spec,
removeSecondColon(input),
`serialization should be missing second colon from input: {input}`
);
}
export function checkSerializationMissingSecondColonChild(input) {
let uri = Services.io.newURI(input);
Assert.equal(
uri.spec,
removeSecondColon(input),
`serialization should be missing second colon from input: {input}`
);
}
export function runParentTestSuite() {
// sanity check
// special scheme uses nsStanardURL
// no-bypass protocol uses defaultURI
checkSerializationMissingSecondColon(
);
// an unknown protocol in the bypass list (remote settings) uses simpleURI
// pref-specified scheme bypass uses simpleURI
}