diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /browser/components/preferences/tests/browser_connection_valid_hostname.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/preferences/tests/browser_connection_valid_hostname.js')
-rw-r--r-- | browser/components/preferences/tests/browser_connection_valid_hostname.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/browser/components/preferences/tests/browser_connection_valid_hostname.js b/browser/components/preferences/tests/browser_connection_valid_hostname.js new file mode 100644 index 0000000000..2e22122448 --- /dev/null +++ b/browser/components/preferences/tests/browser_connection_valid_hostname.js @@ -0,0 +1,55 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +add_task(async function test_valid_hostname() { + 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"); + registerCleanupFunction(function () { + Services.prefs.setIntPref("network.proxy.type", oldNetworkProxyType); + 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 httpPref = dialog.Preferences.get("network.proxy.http"); + let httpPortPref = dialog.Preferences.get("network.proxy.http_port"); + proxyType.value = 1; + httpPortPref.value = 1234; + + httpPref.value = "bad://hostname"; + let beforeAcceptCalled = BrowserTestUtils.waitForEvent( + dialogElement, + "beforeaccept" + ); + dialogElement.acceptDialog(); + let event = await beforeAcceptCalled; + Assert.ok(event.defaultPrevented, "The dialog was not accepted"); + + httpPref.value = "goodhostname"; + beforeAcceptCalled = BrowserTestUtils.waitForEvent( + dialogElement, + "beforeaccept" + ); + dialogElement.acceptDialog(); + event = await beforeAcceptCalled; + Assert.ok(!event.defaultPrevented, "The dialog was accepted"); + + gBrowser.removeCurrentTab(); +}); |