Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- Manifest: netwerk/test/browser/browser.toml
/* 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
ChromeUtils.defineESModuleGetters(this, {
});
const {
checkInputAndSerializationMatch,
checkInputAndSerializationMatchChild,
checkSerializationMissingSecondColon,
checkSerializationMissingSecondColonChild,
removeSecondColon,
} = ChromeUtils.importESModule(
);
add_setup(async () => {
await SpecialPowers.pushPrefEnv({
set: [
["network.url.useDefaultURI", true],
["network.url.simple_uri_unknown_schemes_enabled", true],
["network.url.simple_uri_unknown_schemes", "simpleprotocol,otherproto"],
],
});
});
add_task(async function test_bypass_remote_settings_static_parent() {
// sanity check
// nsStandardURL removes second colon when nesting protocols
// no-bypass unknown protocol uses defaultURI
checkSerializationMissingSecondColon(
);
// simpleURI keeps the second colon
// an unknown protocol in the bypass list will use simpleURI
// despite network.url.useDefaultURI being enabled
checkInputAndSerializationMatch(same);
// scheme bypass from static remote-settings
// check the pref-specified scheme again (remote settings shouldn't overwrite)
checkInputAndSerializationMatch(same);
});
add_task(async function test_bypass_remote_settings_static_child() {
const tab = BrowserTestUtils.addTab(gBrowser, URL_EXAMPLE);
const browser = gBrowser.getBrowserForTab(tab);
await BrowserTestUtils.browserLoaded(browser);
await SpecialPowers.spawn(
browser,
[
removeSecondColon.toString(),
checkSerializationMissingSecondColonChild.toString(),
checkInputAndSerializationMatchChild.toString(),
],
(rscSource, csmscSource, ciasmcSource) => {
/* eslint-disable no-eval */
// eslint-disable-next-line no-unused-vars
let removeSecondColon = eval(`(${rscSource})`); // used by check fns
let checkSerializationMissingSecondColonChild = eval(`(${csmscSource})`);
let checkInputAndSerializationMatchChild = eval(`(${ciasmcSource})`);
/* eslint-enable no-eval */
// nsStandardURL removes second colon when nesting protocols
// no-bypass protocol uses defaultURI
checkSerializationMissingSecondColonChild(
);
// simpleURI keeps the second colon
// an unknown protocol in the bypass list will use simpleURI
// despite network.url.useDefaultURI being enabled
checkInputAndSerializationMatchChild(same);
// scheme bypass from static remote-settings
// pref-specified scheme shouldn't be overwritten by remote settings schemes
checkInputAndSerializationMatchChild(same);
}
);
// Cleanup
BrowserTestUtils.removeTab(tab);
Services.cookies.removeAll();
});