Skip to content

Commit

Permalink
Backed out changeset ccdbd76fc479 (bug 1662710) for Browser-chrome fa…
Browse files Browse the repository at this point in the history
…ilures in toolkit/components/passwordmgr/test/browser/browser_exceptions_dialog.js. CLOSED TREE
  • Loading branch information
dgluca committed May 27, 2021
1 parent 20d4059 commit 9707849
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 476 deletions.
73 changes: 13 additions & 60 deletions browser/components/preferences/dialogs/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ const permissionExceptionsL10n = {
window: "permissions-exceptions-saved-logins-window",
description: "permissions-exceptions-saved-logins-desc",
},
"https-only-load-insecure": {
window: "permissions-exceptions-https-only-window",
description: "permissions-exceptions-https-only-desc",
},
install: {
window: "permissions-exceptions-addons-window",
description: "permissions-exceptions-addons-desc",
Expand Down Expand Up @@ -70,11 +66,9 @@ var gPermissionManager = {
this._removeButton = document.getElementById("removePermission");
this._removeAllButton = document.getElementById("removeAllPermissions");

this._btnCookieSession = document.getElementById("btnCookieSession");
this._btnSession = document.getElementById("btnSession");
this._btnBlock = document.getElementById("btnBlock");
this._btnAllow = document.getElementById("btnAllow");
this._btnHttpsOnlyOff = document.getElementById("btnHttpsOnlyOff");
this._btnHttpsOnlyOffTmp = document.getElementById("btnHttpsOnlyOffTmp");

let permissionsText = document.getElementById("permissionsText");

Expand All @@ -95,15 +89,7 @@ var gPermissionManager = {
]);

document.getElementById("btnBlock").hidden = !params.blockVisible;
document.getElementById("btnCookieSession").hidden = !(
params.sessionVisible && this._type == "cookie"
);
document.getElementById("btnHttpsOnlyOff").hidden = !(
this._type == "https-only-load-insecure"
);
document.getElementById("btnHttpsOnlyOffTmp").hidden = !(
params.sessionVisible && this._type == "https-only-load-insecure"
);
document.getElementById("btnSession").hidden = !params.sessionVisible;
document.getElementById("btnAllow").hidden = !params.allowVisible;

this.onHostInput(this._urlField);
Expand Down Expand Up @@ -181,38 +167,26 @@ var gPermissionManager = {
return (
capability == Ci.nsIPermissionManager.ALLOW_ACTION ||
capability == Ci.nsIPermissionManager.DENY_ACTION ||
capability == Ci.nsICookiePermission.ACCESS_SESSION ||
capability == Ci.nsIHttpsOnlyModePermission.LOAD_INSECURE_ALLOW_SESSION
capability == Ci.nsICookiePermission.ACCESS_SESSION
);
},

_getCapabilityL10nId(capability) {
// HTTPS-Only Mode phrases exceptions as turning it off
if (this._type == "https-only-load-insecure") {
return this._getHttpsOnlyCapabilityL10nId(capability);
}

let stringKey = null;
switch (capability) {
case Ci.nsIPermissionManager.ALLOW_ACTION:
return "permissions-capabilities-listitem-allow";
stringKey = "permissions-capabilities-listitem-allow";
break;
case Ci.nsIPermissionManager.DENY_ACTION:
return "permissions-capabilities-listitem-block";
stringKey = "permissions-capabilities-listitem-block";
break;
case Ci.nsICookiePermission.ACCESS_SESSION:
return "permissions-capabilities-listitem-allow-session";
stringKey = "permissions-capabilities-listitem-allow-session";
break;
default:
throw new Error(`Unknown capability: ${capability}`);
}
},

_getHttpsOnlyCapabilityL10nId(capability) {
switch (capability) {
case Ci.nsIPermissionManager.ALLOW_ACTION:
return "permissions-capabilities-listitem-off";
case Ci.nsIHttpsOnlyModePermission.LOAD_INSECURE_ALLOW_SESSION:
return "permissions-capabilities-listitem-off-temporarily";
default:
throw new Error(`Unknown HTTPS-Only Mode capability: ${capability}`);
}
return stringKey;
},

_addPermissionToList(perm) {
Expand Down Expand Up @@ -402,19 +376,12 @@ var gPermissionManager = {
document.getElementById("btnAllow").click();
} else if (!document.getElementById("btnBlock").hidden) {
document.getElementById("btnBlock").click();
} else if (!document.getElementById("btnHttpsOnlyOff").hidden) {
document.getElementById("btnHttpsOnlyOff").click();
}
}
},

onHostInput(siteField) {
this._btnCookieSession.disabled =
this._btnCookieSession.hidden || !siteField.value;
this._btnHttpsOnlyOff.disabled =
this._btnHttpsOnlyOff.hidden || !siteField.value;
this._btnHttpsOnlyOffTmp.disabled =
this._btnHttpsOnlyOffTmp.hidden || !siteField.value;
this._btnSession.disabled = this._btnSession.hidden || !siteField.value;
this._btnBlock.disabled = this._btnBlock.hidden || !siteField.value;
this._btnAllow.disabled = this._btnAllow.hidden || !siteField.value;
},
Expand Down Expand Up @@ -463,21 +430,7 @@ var gPermissionManager = {
}

for (let p of this._permissionsToAdd.values()) {
// If this sets the HTTPS-Only exemption only for this
// session, then the expire-type has to be set.
if (
p.capability ==
Ci.nsIHttpsOnlyModePermission.LOAD_INSECURE_ALLOW_SESSION
) {
Services.perms.addFromPrincipal(
p.principal,
p.type,
p.capability,
Ci.nsIPermissionManager.EXPIRE_SESSION
);
} else {
Services.perms.addFromPrincipal(p.principal, p.type, p.capability);
}
Services.perms.addFromPrincipal(p.principal, p.type, p.capability);
}
},

Expand Down
7 changes: 1 addition & 6 deletions browser/components/preferences/dialogs/permissions.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
data-l10n-attrs="buttonlabelaccept, buttonaccesskeyaccept">

<linkset>
<html:link rel="localization" href="branding/brand.ftl"/>
<html:link rel="localization" href="browser/preferences/permissions.ftl"/>
</linkset>

Expand All @@ -47,14 +46,10 @@
<hbox pack="end">
<button id="btnBlock" disabled="true" data-l10n-id="permissions-block"
oncommand="gPermissionManager.addPermission(Ci.nsIPermissionManager.DENY_ACTION);"/>
<button id="btnCookieSession" disabled="true" data-l10n-id="permissions-session"
<button id="btnSession" disabled="true" data-l10n-id="permissions-session"
oncommand="gPermissionManager.addPermission(Ci.nsICookiePermission.ACCESS_SESSION);"/>
<button id="btnAllow" disabled="true" data-l10n-id="permissions-allow"
oncommand="gPermissionManager.addPermission(Ci.nsIPermissionManager.ALLOW_ACTION);"/>
<button id="btnHttpsOnlyOff" disabled="true" data-l10n-id="permissions-button-off"
oncommand="gPermissionManager.addPermission(Ci.nsIPermissionManager.ALLOW_ACTION);"/>
<button id="btnHttpsOnlyOffTmp" disabled="true" data-l10n-id="permissions-button-off-temporarily"
oncommand="gPermissionManager.addPermission(Ci.nsIHttpsOnlyModePermission.LOAD_INSECURE_ALLOW_SESSION);"/>
</hbox>
<separator class="thin"/>
<listheader>
Expand Down
12 changes: 0 additions & 12 deletions browser/components/preferences/privacy.inc.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,6 @@
<vbox>
<!-- Please don't remove the wrapping hbox/vbox/box for these elements. It's used to properly compute the search tooltip position. -->
<hbox>
<vbox flex="1">
<radiogroup id="httpsOnlyRadioGroup">
<radio id="httpsOnlyRadioEnabled"
data-l10n-id="httpsonly-radio-enabled"
Expand All @@ -1002,17 +1001,6 @@
data-l10n-id="httpsonly-radio-disabled"
value="disabled"/>
</radiogroup>
</vbox>
<vbox align="end">
<button id="httpsOnlyExceptionButton" is="highlightable-button" class="accessory-button" disabled="true"
data-l10n-id="sitedata-cookies-exceptions" search-l10n-ids="
permissions-address,
permissions-allow.label,
permissions-remove.label,
permissions-remove-all.label,
permissions-exceptions-https-only-desc,
" />
</vbox>
</hbox>
</vbox>
</groupbox>
Expand Down
29 changes: 0 additions & 29 deletions browser/components/preferences/privacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,19 +434,13 @@ var gPrivacyPane = {
"dom.security.https_only_mode_pbm"
);
let httpsOnlyRadioGroup = document.getElementById("httpsOnlyRadioGroup");
let httpsOnlyExceptionButton = document.getElementById(
"httpsOnlyExceptionButton"
);

if (httpsOnlyOnPref) {
httpsOnlyRadioGroup.value = "enabled";
httpsOnlyExceptionButton.disabled = false;
} else if (httpsOnlyOnPBMPref) {
httpsOnlyRadioGroup.value = "privateOnly";
httpsOnlyExceptionButton.disabled = true;
} else {
httpsOnlyRadioGroup.value = "disabled";
httpsOnlyExceptionButton.disabled = true;
}
},

Expand Down Expand Up @@ -582,11 +576,6 @@ var gPrivacyPane = {
"command",
gPrivacyPane.showCookieExceptions
);
setEventListener(
"httpsOnlyExceptionButton",
"command",
gPrivacyPane.showHttpsOnlyModeExceptions
);
setEventListener(
"clearDataSettings",
"command",
Expand Down Expand Up @@ -1865,24 +1854,6 @@ var gPrivacyPane = {
);
},

/**
* Displays per-site preferences for HTTPS-Only Mode exceptions.
*/
showHttpsOnlyModeExceptions() {
var params = {
blockVisible: false,
sessionVisible: true,
allowVisible: false,
prefilledHost: "",
permissionType: "https-only-load-insecure",
};
gSubDialog.open(
"chrome://browser/content/preferences/dialogs/permissions.xhtml",
undefined,
params
);
},

showSiteDataSettings() {
gSubDialog.open(
"chrome://browser/content/preferences/dialogs/siteDataSettings.xhtml"
Expand Down
1 change: 0 additions & 1 deletion browser/components/preferences/tests/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ skip-if = true || !healthreport # Bug 1185403 for the "true"
[browser_homepages_filter_aboutpreferences.js]
[browser_homepages_use_bookmark.js]
[browser_homepage_default.js]
[browser_https_only_exceptions.js]
[browser_https_only_section.js]
[browser_extension_controlled.js]
skip-if = tsan || ccov && (os == 'linux' || os == 'win') # Linux: bug 1613530, Windows: bug 1437051
Expand Down
48 changes: 48 additions & 0 deletions browser/components/preferences/tests/browser_cookies_exceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -537,3 +537,51 @@ async function runTest(test, getObservances) {

BrowserTestUtils.removeTab(gBrowser.selectedTab);
}

function createObserveAllPromise(observances) {
return new Promise(resolve => {
let permObserver = {
observe(aSubject, aTopic, aData) {
if (aTopic != "perm-changed") {
return;
}

if (!observances.length) {
// Should fail here as we are not expecting a notification, but we
// don't. See bug 1063410.
return;
}

info(`observed perm-changed (remaining ${observances.length - 1})`);

let permission = aSubject.QueryInterface(Ci.nsIPermission);
let expected = observances.shift();

is(aData, expected.data, "type of message should be the same");
for (let prop of ["type", "capability"]) {
if (expected[prop]) {
is(
permission[prop],
expected[prop],
'property: "' + prop + '" should be equal'
);
}
}

if (expected.origin) {
is(
permission.principal.origin,
expected.origin,
'property: "origin" should be equal'
);
}

if (!observances.length) {
Services.obs.removeObserver(permObserver, "perm-changed");
executeSoon(resolve);
}
},
};
Services.obs.addObserver(permObserver, "perm-changed");
});
}
Loading

0 comments on commit 9707849

Please sign in to comment.