Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion browser/components/preferences/dialogs/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ var gConnectionsDialog = {
.focus();
event.preventDefault();
return;
} else if (!Services.io.isValidHostname(proxyPref.value)) {
} else if (
!Services.io.isValidHostname(proxyPref.value) &&
!(prefName === "socks" && (proxyPref.value.startsWith("file://") || proxyPref.value.startsWith("npipe://")))
) {
document
.getElementById("networkProxy" + prefName.toUpperCase())
.focus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,77 @@ add_task(async function test_valid_hostname() {

gBrowser.removeCurrentTab();
});

add_task(async function test_socks_file_uri() {
await openPreferencesViaOpenPreferencesAPI("general", { leaveOpen: true });
const connectionURL =
"chrome://browser/content/preferences/dialogs/connection.xhtml";
let dialog = await openAndLoadSubDialog(connectionURL);
let dialogElement = dialog.document.getElementById("ConnectionsDialog");

let oldNetworkProxyType = Services.prefs.getIntPref("network.proxy.type");
let oldSocksPort = Services.prefs.getIntPref("network.proxy.socks_port");
registerCleanupFunction(function () {
Services.prefs.setIntPref("network.proxy.type", oldNetworkProxyType);
Services.prefs.setIntPref("network.proxy.socks_port", oldSocksPort);
Services.prefs.clearUserPref("network.proxy.share_proxy_settings");
for (let proxyType of ["http", "ssl", "socks"]) {
Services.prefs.clearUserPref("network.proxy." + proxyType);
Services.prefs.clearUserPref("network.proxy." + proxyType + "_port");
if (proxyType == "http") {
continue;
}
Services.prefs.clearUserPref("network.proxy.backup." + proxyType);
Services.prefs.clearUserPref(
"network.proxy.backup." + proxyType + "_port"
);
}
});

let proxyType = dialog.Preferences.get("network.proxy.type");
let socksPref = dialog.Preferences.get("network.proxy.socks");
let socksPortPref = dialog.Preferences.get("network.proxy.socks_port");
proxyType.value = 1;
socksPortPref.value = 1234;

// file:// URIs should be accepted for SOCKS
socksPref.value = "file:///var/run/socks5.sock";
let beforeAcceptCalled = BrowserTestUtils.waitForEvent(
dialogElement,
"beforeaccept"
);
dialogElement.acceptDialog();
let event = await beforeAcceptCalled;
Assert.ok(
!event.defaultPrevented,
"The dialog was accepted with file:// SOCKS path"
);

// npipe:// URIs should also be accepted for SOCKS (Windows named pipes)
socksPref.value = "npipe:///./pipe/socks";
beforeAcceptCalled = BrowserTestUtils.waitForEvent(
dialogElement,
"beforeaccept"
);
dialogElement.acceptDialog();
event = await beforeAcceptCalled;
Assert.ok(
!event.defaultPrevented,
"The dialog was accepted with npipe:// SOCKS path"
);

// Regular hostnames should still work for SOCKS
socksPref.value = "localhost";
beforeAcceptCalled = BrowserTestUtils.waitForEvent(
dialogElement,
"beforeaccept"
);
dialogElement.acceptDialog();
event = await beforeAcceptCalled;
Assert.ok(
!event.defaultPrevented,
"The dialog was accepted with regular SOCKS hostname"
);

gBrowser.removeCurrentTab();
});
Loading