forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1671122 - Fixed bug where second click on HTTPS-Only Mode enable-…
…checkbox disables it again. r=ckerschb,preferences-reviewers,Gijs Differential Revision: https://phabricator.services.mozilla.com/D93519
- Loading branch information
1 parent
0fdda83
commit f1ca4d6
Showing
4 changed files
with
88 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
browser/components/preferences/tests/browser_https_only_section.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* Any copyright is dedicated to the Public Domain. | ||
* http://creativecommons.org/publicdomain/zero/1.0/ */ | ||
|
||
// Bug 1671122 - Fixed bug where second click on HTTPS-Only Mode enable-checkbox disables it again. | ||
// https://bugzilla.mozilla.org/bug/1671122 | ||
"use strict"; | ||
|
||
const HTTPS_ONLY_ENABLED = "enabled"; | ||
const HTTPS_ONLY_PBM_ONLY = "privateOnly"; | ||
const HTTPS_ONLY_DISABLED = "disabled"; | ||
|
||
add_task(async function httpsOnlyRadioGroupIsWorking() { | ||
// Make sure HTTPS-Only mode is only enabled for PBM | ||
|
||
registerCleanupFunction(async function() { | ||
Services.prefs.clearUserPref("dom.security.https_only_mode"); | ||
Services.prefs.clearUserPref("dom.security.https_only_mode_pbm"); | ||
}); | ||
|
||
await SpecialPowers.setBoolPref("dom.security.https_only_mode", false); | ||
await SpecialPowers.setBoolPref("dom.security.https_only_mode_pbm", true); | ||
|
||
await openPreferencesViaOpenPreferencesAPI("privacy", { leaveOpen: true }); | ||
|
||
const doc = gBrowser.selectedBrowser.contentDocument; | ||
const radioGroup = doc.getElementById("httpsOnlyRadioGroup"); | ||
const enableAllRadio = doc.getElementById("httpsOnlyRadioEnabled"); | ||
const enablePbmRadio = doc.getElementById("httpsOnlyRadioEnabledPBM"); | ||
const disableRadio = doc.getElementById("httpsOnlyRadioDisabled"); | ||
|
||
// Check if UI | ||
check(radioGroup, HTTPS_ONLY_PBM_ONLY); | ||
|
||
// Check if UI updated on pref-change | ||
await SpecialPowers.setBoolPref("dom.security.https_only_mode_pbm", false); | ||
check(radioGroup, HTTPS_ONLY_DISABLED); | ||
|
||
// Check if prefs change if clicked on radio button | ||
enableAllRadio.click(); | ||
check(radioGroup, HTTPS_ONLY_ENABLED); | ||
|
||
// Check if prefs stay the same if clicked on same | ||
// radio button again (see bug 1671122) | ||
enableAllRadio.click(); | ||
check(radioGroup, HTTPS_ONLY_ENABLED); | ||
|
||
// Check if prefs are set correctly for PBM-only mode. | ||
enablePbmRadio.click(); | ||
check(radioGroup, HTTPS_ONLY_PBM_ONLY); | ||
|
||
// Check if prefs are set correctly when disabled again. | ||
disableRadio.click(); | ||
check(radioGroup, HTTPS_ONLY_DISABLED); | ||
|
||
BrowserTestUtils.removeTab(gBrowser.selectedTab); | ||
}); | ||
|
||
function check(radioGroupElement, expectedValue) { | ||
is( | ||
radioGroupElement.value, | ||
expectedValue, | ||
"Radio Group value should match expected value" | ||
); | ||
is( | ||
SpecialPowers.getBoolPref("dom.security.https_only_mode"), | ||
expectedValue === HTTPS_ONLY_ENABLED, | ||
"HTTPS-Only pref should match expected value." | ||
); | ||
is( | ||
SpecialPowers.getBoolPref("dom.security.https_only_mode_pbm"), | ||
expectedValue === HTTPS_ONLY_PBM_ONLY, | ||
"HTTPS-Only PBM pref should match expected value." | ||
); | ||
} |