зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset ccdbd76fc479 (bug 1662710) for Browser-chrome failures in toolkit/components/passwordmgr/test/browser/browser_exceptions_dialog.js. CLOSED TREE
This commit is contained in:
Родитель
20d4059a6f
Коммит
9707849e5b
|
@ -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",
|
||||
|
@ -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");
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
},
|
||||
|
@ -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);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
|
|
@ -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"
|
||||
|
@ -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>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -582,11 +576,6 @@ var gPrivacyPane = {
|
|||
"command",
|
||||
gPrivacyPane.showCookieExceptions
|
||||
);
|
||||
setEventListener(
|
||||
"httpsOnlyExceptionButton",
|
||||
"command",
|
||||
gPrivacyPane.showHttpsOnlyModeExceptions
|
||||
);
|
||||
setEventListener(
|
||||
"clearDataSettings",
|
||||
"command",
|
||||
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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");
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,274 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* First Test
|
||||
* Checks if buttons are disabled/enabled and visible/hidden correctly.
|
||||
*/
|
||||
add_task(async function testButtons() {
|
||||
// Let's make sure HTTPS-Only Mode is off.
|
||||
await setHttpsOnlyPref("off");
|
||||
|
||||
// Open the privacy-pane in about:preferences
|
||||
await openPreferencesViaOpenPreferencesAPI("panePrivacy", {
|
||||
leaveOpen: true,
|
||||
});
|
||||
|
||||
// Get button-element to open the exceptions-dialog
|
||||
const exceptionButton = gBrowser.contentDocument.getElementById(
|
||||
"httpsOnlyExceptionButton"
|
||||
);
|
||||
|
||||
is(
|
||||
exceptionButton.disabled,
|
||||
true,
|
||||
"HTTPS-Only exception button should be disabled when HTTPS-Only Mode is disabled."
|
||||
);
|
||||
|
||||
await setHttpsOnlyPref("private");
|
||||
is(
|
||||
exceptionButton.disabled,
|
||||
true,
|
||||
"HTTPS-Only exception button should be disabled when HTTPS-Only Mode is only enabled in private browsing."
|
||||
);
|
||||
|
||||
await setHttpsOnlyPref("everywhere");
|
||||
is(
|
||||
exceptionButton.disabled,
|
||||
false,
|
||||
"HTTPS-Only exception button should be enabled when HTTPS-Only Mode enabled everywhere."
|
||||
);
|
||||
|
||||
// Now that the button is clickable, we open the dialog
|
||||
// to check if the correct buttons are visible
|
||||
let promiseSubDialogLoaded = promiseLoadSubDialog(
|
||||
"chrome://browser/content/preferences/dialogs/permissions.xhtml"
|
||||
);
|
||||
exceptionButton.doCommand();
|
||||
|
||||
let win = await promiseSubDialogLoaded;
|
||||
|
||||
const dialogDoc = win.document;
|
||||
|
||||
is(
|
||||
dialogDoc.getElementById("btnBlock").hidden,
|
||||
true,
|
||||
"Block button should not be visible in HTTPS-Only Dialog."
|
||||
);
|
||||
is(
|
||||
dialogDoc.getElementById("btnCookieSession").hidden,
|
||||
true,
|
||||
"Cookie specific allow button should not be visible in HTTPS-Only Dialog."
|
||||
);
|
||||
is(
|
||||
dialogDoc.getElementById("btnHttpsOnlySession").hidden,
|
||||
false,
|
||||
"HTTPS-Only allow button should be visible in HTTPS-Only Dialog."
|
||||
);
|
||||
is(
|
||||
dialogDoc.getElementById("btnAllow").hidden,
|
||||
false,
|
||||
"Block button should be visible in HTTPS-Only Dialog."
|
||||
);
|
||||
|
||||
// Reset prefs and close the tab
|
||||
await SpecialPowers.flushPrefEnv();
|
||||
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||
});
|
||||
|
||||
/**
|
||||
* Second Test
|
||||
* Checks permissions are added and removed correctly.
|
||||
*
|
||||
* Each test opens a new dialog, performs an action (second argument),
|
||||
* then closes the dialog and checks if the changes were made (third argument).
|
||||
*/
|
||||
add_task(async function checkDialogFunctionality() {
|
||||
// Enable HTTPS-Only Mode for every window, so the exceptions dialog is accessible.
|
||||
await setHttpsOnlyPref("everywhere");
|
||||
|
||||
// Open the privacy-pane in about:preferences
|
||||
await openPreferencesViaOpenPreferencesAPI("panePrivacy", {
|
||||
leaveOpen: true,
|
||||
});
|
||||
const preferencesDoc = gBrowser.contentDocument;
|
||||
|
||||
// Test if we can add permanent exceptions
|
||||
await runTest(
|
||||
preferencesDoc,
|
||||
elements => {
|
||||
assertListContents(elements, []);
|
||||
|
||||
elements.url.value = "test.com";
|
||||
elements.btnAllow.doCommand();
|
||||
|
||||
assertListContents(elements, [
|
||||
["http://test.com", elements.allowL10nId],
|
||||
["https://test.com", elements.allowL10nId],
|
||||
]);
|
||||
},
|
||||
() => [
|
||||
{
|
||||
type: "https-only-load-insecure",
|
||||
origin: "http://test.com",
|
||||
data: "added",
|
||||
capability: Ci.nsIPermissionManager.ALLOW_ACTION,
|
||||
expireType: Ci.nsIPermissionManager.EXPIRE_NEVER,
|
||||
},
|
||||
{
|
||||
type: "https-only-load-insecure",
|
||||
origin: "https://test.com",
|
||||
data: "added",
|
||||
capability: Ci.nsIPermissionManager.ALLOW_ACTION,
|
||||
expireType: Ci.nsIPermissionManager.EXPIRE_NEVER,
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
// Test if items are retained, and if temporary exceptions are added correctly
|
||||
await runTest(
|
||||
preferencesDoc,
|
||||
elements => {
|
||||
assertListContents(elements, [
|
||||
["http://test.com", elements.allowL10nId],
|
||||
["https://test.com", elements.allowL10nId],
|
||||
]);
|
||||
|
||||
elements.url.value = "1.1.1.1:8080";
|
||||
elements.btnAllowSession.doCommand();
|
||||
|
||||
assertListContents(elements, [
|
||||
["http://test.com", elements.allowL10nId],
|
||||
["https://test.com", elements.allowL10nId],
|
||||
["http://1.1.1.1:8080", elements.allowSessionL10nId],
|
||||
["https://1.1.1.1:8080", elements.allowSessionL10nId],
|
||||
]);
|
||||
},
|
||||
() => [
|
||||
{
|
||||
type: "https-only-load-insecure",
|
||||
origin: "http://1.1.1.1:8080",
|
||||
data: "added",
|
||||
capability: Ci.nsIHttpsOnlyModePermission.LOAD_INSECURE_ALLOW_SESSION,
|
||||
expireType: Ci.nsIPermissionManager.EXPIRE_SESSION,
|
||||
},
|
||||
{
|
||||
type: "https-only-load-insecure",
|
||||
origin: "https://1.1.1.1:8080",
|
||||
data: "added",
|
||||
capability: Ci.nsIHttpsOnlyModePermission.LOAD_INSECURE_ALLOW_SESSION,
|
||||
expireType: Ci.nsIPermissionManager.EXPIRE_SESSION,
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
await runTest(
|
||||
preferencesDoc,
|
||||
elements => {
|
||||
while (elements.richlistbox.itemCount) {
|
||||
elements.richlistbox.selectedIndex = 0;
|
||||
elements.btnRemove.doCommand();
|
||||
}
|
||||
assertListContents(elements, []);
|
||||
},
|
||||
elements => {
|
||||
let richlistItems = elements.richlistbox.getElementsByAttribute(
|
||||
"origin",
|
||||
"*"
|
||||
);
|
||||
let observances = [];
|
||||
for (let item of richlistItems) {
|
||||
observances.push({
|
||||
type: "https-only-load-insecure",
|
||||
origin: item.getAttribute("origin"),
|
||||
data: "deleted",
|
||||
});
|
||||
}
|
||||
return observances;
|
||||
}
|
||||
);
|
||||
|
||||
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||
});
|
||||
|
||||
/**
|
||||
* Changes HTTPS-Only Mode pref
|
||||
* @param {string} state "everywhere", "private", "off"
|
||||
*/
|
||||
async function setHttpsOnlyPref(state) {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["dom.security.https_only_mode", state === "everywhere"],
|
||||
["dom.security.https_only_mode_pbm", state === "private"],
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens new exceptions dialog, runs test function
|
||||
* @param {HTMLElement} preferencesDoc document of about:preferences tab
|
||||
* @param {function} test function to call when dialog is open
|
||||
* @param {Array} observances permission changes to observe (order is important)
|
||||
*/
|
||||
async function runTest(preferencesDoc, test, observancesFn) {
|
||||
// Click on exception-button and wait for dialog to open
|
||||
let promiseSubDialogLoaded = promiseLoadSubDialog(
|
||||
"chrome://browser/content/preferences/dialogs/permissions.xhtml"
|
||||
);
|
||||
preferencesDoc.getElementById("httpsOnlyExceptionButton").doCommand();
|
||||
|
||||
let win = await promiseSubDialogLoaded;
|
||||
|
||||
// Create a bunch of references to UI-elements for the test-function
|
||||
const doc = win.document;
|
||||
let elements = {
|
||||
richlistbox: doc.getElementById("permissionsBox"),
|
||||
url: doc.getElementById("url"),
|
||||
btnAllow: doc.getElementById("btnAllow"),
|
||||
btnAllowSession: doc.getElementById("btnHttpsOnlySession"),
|
||||
btnRemove: doc.getElementById("removePermission"),
|
||||
allowL10nId: win.gPermissionManager._getCapabilityL10nId(
|
||||
Ci.nsIPermissionManager.ALLOW_ACTION
|
||||
),
|
||||
allowSessionL10nId: win.gPermissionManager._getCapabilityL10nId(
|
||||
Ci.nsIHttpsOnlyModePermission.LOAD_INSECURE_ALLOW_SESSION
|
||||
),
|
||||
};
|
||||
|
||||
// Some observances need to be computed based on the current state.
|
||||
const observances = observancesFn(elements);
|
||||
|
||||
// Run test function
|
||||
await test(elements);
|
||||
|
||||
// Click on "Save changes" and wait for permission changes.
|
||||
let btnApplyChanges = doc.querySelector("dialog").getButton("accept");
|
||||
let observeAllPromise = createObserveAllPromise(observances);
|
||||
|
||||
btnApplyChanges.doCommand();
|
||||
await observeAllPromise;
|
||||
}
|
||||
|
||||
function assertListContents(elements, expected) {
|
||||
is(
|
||||
elements.richlistbox.itemCount,
|
||||
expected.length,
|
||||
"Richlistbox should match the expected amount of exceptions."
|
||||
);
|
||||
|
||||
for (let i = 0; i < expected.length; i++) {
|
||||
let website = expected[i][0];
|
||||
let listItem = elements.richlistbox.getElementsByAttribute(
|
||||
"origin",
|
||||
website
|
||||
);
|
||||
is(listItem.length, 1, "Each origin should be unique");
|
||||
is(
|
||||
listItem[0]
|
||||
.querySelector(".website-capability-value")
|
||||
.getAttribute("data-l10n-id"),
|
||||
expected[i][1],
|
||||
"List item capability should match expected l10n-id"
|
||||
);
|
||||
}
|
||||
}
|
|
@ -80,7 +80,7 @@ add_task(async function checkCookiePermissions() {
|
|||
});
|
||||
let win = gBrowser.selectedBrowser.contentWindow;
|
||||
let doc = win.document;
|
||||
let buttonIds = ["btnBlock", "btnCookieSession", "btnAllow"];
|
||||
let buttonIds = ["btnBlock", "btnSession", "btnAllow"];
|
||||
|
||||
let dialog = await _checkAndOpenCookiesDialog(doc);
|
||||
_checkCookiesDialog(dialog, buttonIds);
|
||||
|
|
|
@ -262,59 +262,3 @@ class DefinitionServer {
|
|||
return definition;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates observer that waits for and then compares all perm-changes with the observances in order.
|
||||
* @param {Array} observances permission changes to observe (order is important)
|
||||
* @returns {Promise} Promise object that resolves once all permission changes have been observed
|
||||
*/
|
||||
function createObserveAllPromise(observances) {
|
||||
// Create new promise that resolves once all items
|
||||
// in observances array have been observed.
|
||||
return new Promise(resolve => {
|
||||
let permObserver = {
|
||||
observe(aSubject, aTopic, aData) {
|
||||
if (aTopic != "perm-changed") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!observances.length) {
|
||||
// See bug 1063410
|
||||
return;
|
||||
}
|
||||
|
||||
let permission = aSubject.QueryInterface(Ci.nsIPermission);
|
||||
let expected = observances.shift();
|
||||
|
||||
info(
|
||||
`observed perm-changed for ${permission.principal.origin} (remaining ${observances.length})`
|
||||
);
|
||||
|
||||
is(aData, expected.data, "type of message should be the same");
|
||||
for (let prop of ["type", "capability", "expireType"]) {
|
||||
if (expected[prop]) {
|
||||
is(
|
||||
permission[prop],
|
||||
expected[prop],
|
||||
`property: "${prop}" should be equal (${permission.principal.origin})`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (expected.origin) {
|
||||
is(
|
||||
permission.principal.origin,
|
||||
expected.origin,
|
||||
`property: "origin" should be equal (${permission.principal.origin})`
|
||||
);
|
||||
}
|
||||
|
||||
if (!observances.length) {
|
||||
Services.obs.removeObserver(permObserver, "perm-changed");
|
||||
executeSoon(resolve);
|
||||
}
|
||||
},
|
||||
};
|
||||
Services.obs.addObserver(permObserver, "perm-changed");
|
||||
});
|
||||
}
|
||||
|
|
|
@ -24,14 +24,6 @@ permissions-allow =
|
|||
.label = Allow
|
||||
.accesskey = A
|
||||
|
||||
permissions-button-off =
|
||||
.label = Turn Off
|
||||
.accesskey = O
|
||||
|
||||
permissions-button-off-temporarily =
|
||||
.label = Turn Off Temporarily
|
||||
.accesskey = T
|
||||
|
||||
permissions-site-name =
|
||||
.label = Website
|
||||
|
||||
|
@ -76,11 +68,6 @@ permissions-capabilities-listitem-block =
|
|||
permissions-capabilities-listitem-allow-session =
|
||||
.value = Allow for Session
|
||||
|
||||
permissions-capabilities-listitem-off =
|
||||
.value = Off
|
||||
permissions-capabilities-listitem-off-temporarily =
|
||||
.value = Off temporarily
|
||||
|
||||
## Invalid Hostname Dialog
|
||||
|
||||
permissions-invalid-uri-title = Invalid Hostname Entered
|
||||
|
@ -100,13 +87,6 @@ permissions-exceptions-cookie-window =
|
|||
.style = { permissions-window.style }
|
||||
permissions-exceptions-cookie-desc = You can specify which websites are always or never allowed to use cookies and site data. Type the exact address of the site you want to manage and then click Block, Allow for Session, or Allow.
|
||||
|
||||
## Exceptions - HTTPS-Only Mode
|
||||
|
||||
permissions-exceptions-https-only-window =
|
||||
.title = Exceptions - HTTPS-Only Mode
|
||||
.style = { permissions-window.style }
|
||||
permissions-exceptions-https-only-desc = You can turn off HTTPS-Only Mode for specific websites. { -brand-short-name } won’t attempt to upgrade the connection to secure HTTPS for those sites. Exceptions do not apply to private windows.
|
||||
|
||||
## Exceptions - Pop-ups
|
||||
|
||||
permissions-exceptions-popup-window =
|
||||
|
|
|
@ -70,22 +70,14 @@ add_task(async function test_block_button_with_enter_key() {
|
|||
await BrowserTestUtils.waitForEvent(dialog, "load");
|
||||
await new Promise(resolve => waitForFocus(resolve, dialog));
|
||||
let btnBlock = dialog.document.getElementById("btnBlock");
|
||||
let btnCookieSession = dialog.document.getElementById("btnCookieSession");
|
||||
let btnHttpsOnlySession = dialog.document.getElementById(
|
||||
"btnHttpsOnlySession"
|
||||
);
|
||||
let btnSession = dialog.document.getElementById("btnSession");
|
||||
let btnAllow = dialog.document.getElementById("btnAllow");
|
||||
|
||||
ok(!btnBlock.hidden, "Block button is visible");
|
||||
ok(btnCookieSession.hidden, "Cookie session button is not visible");
|
||||
ok(btnHttpsOnlySession.hidden, "HTTPS-Only session button is not visible");
|
||||
ok(btnSession.hidden, "Session button is not visible");
|
||||
ok(btnAllow.hidden, "Allow button is not visible");
|
||||
ok(btnBlock.disabled, "Block button is initially disabled");
|
||||
ok(btnCookieSession.disabled, "Cookie session button is initially disabled");
|
||||
ok(
|
||||
btnHttpsOnlySession.disabled,
|
||||
"HTTPS-Only session button is initially disabled"
|
||||
);
|
||||
ok(btnSession.disabled, "Session button is initially disabled");
|
||||
ok(btnAllow.disabled, "Allow button is initially disabled");
|
||||
|
||||
EventUtils.sendString(LOGIN_HOST, dialog);
|
||||
|
@ -95,12 +87,8 @@ add_task(async function test_block_button_with_enter_key() {
|
|||
"Block button is enabled after entering text in the URL input"
|
||||
);
|
||||
ok(
|
||||
btnCookieSession.disabled,
|
||||
"Cookie session button is still disabled after entering text in the URL input"
|
||||
);
|
||||
ok(
|
||||
btnHttpsOnlySession.disabled,
|
||||
"HTTPS-Only session button is still disabled after entering text in the URL input"
|
||||
btnSession.disabled,
|
||||
"Session button is still disabled after entering text in the URL input"
|
||||
);
|
||||
ok(
|
||||
btnAllow.disabled,
|
||||
|
|
Загрузка…
Ссылка в новой задаче