зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1649813 test dns api failure when forwarding dns to socks proxy r=mayhemer,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D83006
This commit is contained in:
Родитель
7fb73b1d6c
Коммит
d928462307
|
@ -684,9 +684,8 @@ nsresult nsDNSService::ReadPrefs(const char* name) {
|
|||
}
|
||||
}
|
||||
if (!name || !strcmp(name, kPrefNetworkProxySOCKS)) {
|
||||
if (NS_SUCCEEDED(Preferences::GetUint(kPrefNetworkProxySOCKS, &tmpint))) {
|
||||
nsAutoCString socks;
|
||||
Preferences::GetCString(kPrefNetworkProxySOCKS, socks);
|
||||
nsAutoCString socks;
|
||||
if (NS_SUCCEEDED(Preferences::GetCString(kPrefNetworkProxySOCKS, socks))) {
|
||||
mHasSocksProxy = !socks.IsEmpty();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,14 +4,29 @@
|
|||
// off to get consistent test results.
|
||||
Services.prefs.setBoolPref("network.dns.disableIPv6", true);
|
||||
|
||||
AddonTestUtils.init(this);
|
||||
AddonTestUtils.overrideCertDB();
|
||||
|
||||
AddonTestUtils.createAppInfo(
|
||||
"xpcshell@tests.mozilla.org",
|
||||
"XPCShell",
|
||||
"1",
|
||||
"42"
|
||||
);
|
||||
|
||||
function getExtension(background = undefined) {
|
||||
let manifest = {
|
||||
permissions: ["dns"],
|
||||
permissions: ["dns", "proxy"],
|
||||
};
|
||||
return ExtensionTestUtils.loadExtension({
|
||||
manifest,
|
||||
background() {
|
||||
browser.test.onMessage.addListener(async (msg, data) => {
|
||||
if (msg == "proxy") {
|
||||
await browser.proxy.settings.set({ value: data });
|
||||
browser.test.sendMessage("proxied");
|
||||
return;
|
||||
}
|
||||
browser.test.log(`=== dns resolve test ${JSON.stringify(data)}`);
|
||||
browser.dns
|
||||
.resolve(data.hostname, data.flags)
|
||||
|
@ -28,6 +43,8 @@ function getExtension(background = undefined) {
|
|||
});
|
||||
browser.test.sendMessage("ready");
|
||||
},
|
||||
incognitoOverride: "spanning",
|
||||
useAddonManager: "temporary",
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -79,6 +96,10 @@ const tests = [
|
|||
},
|
||||
];
|
||||
|
||||
add_task(async function startup() {
|
||||
await AddonTestUtils.promiseStartupManager();
|
||||
});
|
||||
|
||||
add_task(async function test_dns_resolve() {
|
||||
let extension = getExtension();
|
||||
await extension.startup();
|
||||
|
@ -117,3 +138,39 @@ add_task(async function test_dns_resolve() {
|
|||
|
||||
await extension.unload();
|
||||
});
|
||||
|
||||
add_task(async function test_dns_resolve_socks() {
|
||||
let extension = getExtension();
|
||||
await extension.startup();
|
||||
await extension.awaitMessage("ready");
|
||||
extension.sendMessage("proxy", {
|
||||
proxyType: "manual",
|
||||
socks: "127.0.0.1",
|
||||
socksVersion: 5,
|
||||
proxyDNS: true,
|
||||
});
|
||||
await extension.awaitMessage("proxied");
|
||||
equal(
|
||||
Services.prefs.getIntPref("network.proxy.type"),
|
||||
1 /* PROXYCONFIG_MANUAL */,
|
||||
"manual proxy"
|
||||
);
|
||||
equal(
|
||||
Services.prefs.getStringPref("network.proxy.socks"),
|
||||
"127.0.0.1",
|
||||
"socks proxy"
|
||||
);
|
||||
ok(
|
||||
Services.prefs.getBoolPref("network.proxy.socks_remote_dns"),
|
||||
"socks remote dns"
|
||||
);
|
||||
extension.sendMessage("resolve", {
|
||||
hostname: "mozilla.org",
|
||||
});
|
||||
let result = await extension.awaitMessage("resolved");
|
||||
ok(
|
||||
/NS_ERROR_UNKNOWN_PROXY_HOST/.test(result.message),
|
||||
`expected error ${result.message}`
|
||||
);
|
||||
await extension.unload();
|
||||
});
|
||||
|
|
|
@ -63,6 +63,7 @@ skip-if = os == 'android' && debug # The generated script takes too long to load
|
|||
skip-if = appname == "thunderbird" || os == "android" # Containers are not exposed to android.
|
||||
[test_ext_debugging_utils.js]
|
||||
[test_ext_dns.js]
|
||||
skip-if = socketprocess_networking
|
||||
[test_ext_downloads.js]
|
||||
[test_ext_downloads_download.js]
|
||||
skip-if = appname == "thunderbird" || os == "android" || tsan # tsan: bug 1612707
|
||||
|
|
Загрузка…
Ссылка в новой задаче