зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1750466 - Stop adding default mailto: handlers in Thunderbird. r=mkaply
Differential Revision: https://phabricator.services.mozilla.com/D136291
This commit is contained in:
Родитель
8dd4b286bd
Коммит
dc79c103b5
|
@ -158,6 +158,11 @@ HandlerService.prototype = {
|
|||
// don't care what's already in the file, we just want to do the
|
||||
// equivalent of appending into the database. So let's just go do that:
|
||||
for (let scheme of Object.keys(localeHandlers.schemes)) {
|
||||
if (scheme == "mailto" && AppConstants.MOZ_APP_NAME == "thunderbird") {
|
||||
// Thunderbird IS a mailto handler, it doesn't need handlers added.
|
||||
continue;
|
||||
}
|
||||
|
||||
let existingSchemeInfo = this._store.data.schemes[scheme];
|
||||
if (!existingSchemeInfo) {
|
||||
// Haven't seen this scheme before. Default to asking which app the
|
||||
|
|
|
@ -155,7 +155,11 @@ function run_test() {
|
|||
// OS default exists, injected default exists, explicit warning pref: false
|
||||
prefSvc.setBoolPref(kExternalWarningPrefPrefix + "mailto", false);
|
||||
protoInfo = protoSvc.getProtocolHandlerInfo("mailto");
|
||||
Assert.equal(1, protoInfo.possibleApplicationHandlers.length);
|
||||
if (AppConstants.MOZ_APP_NAME == "thunderbird") {
|
||||
Assert.equal(0, protoInfo.possibleApplicationHandlers.length);
|
||||
} else {
|
||||
Assert.equal(1, protoInfo.possibleApplicationHandlers.length);
|
||||
}
|
||||
|
||||
// Win7+ or Linux's GIO might not have a default mailto: handler
|
||||
if (noMailto) {
|
||||
|
@ -167,16 +171,19 @@ function run_test() {
|
|||
// OS default exists, injected default exists, explicit warning pref: true
|
||||
prefSvc.setBoolPref(kExternalWarningPrefPrefix + "mailto", true);
|
||||
protoInfo = protoSvc.getProtocolHandlerInfo("mailto");
|
||||
Assert.equal(1, protoInfo.possibleApplicationHandlers.length);
|
||||
// Win7+ or Linux's GIO may have no default mailto: handler, so we'd ask
|
||||
// anyway. Otherwise, the default handlers will not have stored preferred
|
||||
// actions etc., so re-requesting them after the warning pref has changed
|
||||
// will use the updated pref value. So both when we have and do not have
|
||||
// a default mailto: handler, we'll ask:
|
||||
Assert.ok(protoInfo.alwaysAskBeforeHandling);
|
||||
// As soon as anyone actually stores updated defaults into the profile
|
||||
// database, that default will stop tracking the warning pref.
|
||||
|
||||
if (AppConstants.MOZ_APP_NAME == "thunderbird") {
|
||||
Assert.equal(0, protoInfo.possibleApplicationHandlers.length);
|
||||
} else {
|
||||
Assert.equal(1, protoInfo.possibleApplicationHandlers.length);
|
||||
// Win7+ or Linux's GIO may have no default mailto: handler, so we'd ask
|
||||
// anyway. Otherwise, the default handlers will not have stored preferred
|
||||
// actions etc., so re-requesting them after the warning pref has changed
|
||||
// will use the updated pref value. So both when we have and do not have
|
||||
// a default mailto: handler, we'll ask:
|
||||
Assert.ok(protoInfo.alwaysAskBeforeHandling);
|
||||
// As soon as anyone actually stores updated defaults into the profile
|
||||
// database, that default will stop tracking the warning pref.
|
||||
}
|
||||
// Now set the value stored in RDF to true, and the pref to false, to make
|
||||
// sure we still get the right value. (Basically, same thing as above but
|
||||
// with the values reversed.)
|
||||
|
@ -184,8 +191,12 @@ function run_test() {
|
|||
protoInfo.alwaysAskBeforeHandling = true;
|
||||
handlerSvc.store(protoInfo);
|
||||
protoInfo = protoSvc.getProtocolHandlerInfo("mailto");
|
||||
Assert.equal(1, protoInfo.possibleApplicationHandlers.length);
|
||||
Assert.ok(protoInfo.alwaysAskBeforeHandling);
|
||||
if (AppConstants.MOZ_APP_NAME == "thunderbird") {
|
||||
Assert.equal(0, protoInfo.possibleApplicationHandlers.length);
|
||||
} else {
|
||||
Assert.equal(1, protoInfo.possibleApplicationHandlers.length);
|
||||
Assert.ok(protoInfo.alwaysAskBeforeHandling);
|
||||
}
|
||||
|
||||
//* *************************************************************************//
|
||||
// Test Round-Trip Data Integrity
|
||||
|
|
|
@ -595,43 +595,49 @@ function assertAllHandlerInfosMatchDefaultHandlers() {
|
|||
/**
|
||||
* Tests the default protocol handlers imported from the locale-specific data.
|
||||
*/
|
||||
add_task(async function test_default_protocol_handlers() {
|
||||
if (
|
||||
!Services.prefs.getPrefType("gecko.handlerService.defaultHandlersVersion")
|
||||
) {
|
||||
info("This platform or locale does not have default handlers.");
|
||||
return;
|
||||
add_task(
|
||||
{ skip_if: () => AppConstants.MOZ_APP_NAME == "thunderbird" },
|
||||
async function test_default_protocol_handlers() {
|
||||
if (
|
||||
!Services.prefs.getPrefType("gecko.handlerService.defaultHandlersVersion")
|
||||
) {
|
||||
info("This platform or locale does not have default handlers.");
|
||||
return;
|
||||
}
|
||||
|
||||
// This will inject the default protocol handlers for the current locale.
|
||||
await deleteHandlerStore();
|
||||
|
||||
await assertAllHandlerInfosMatchDefaultHandlers();
|
||||
}
|
||||
|
||||
// This will inject the default protocol handlers for the current locale.
|
||||
await deleteHandlerStore();
|
||||
|
||||
await assertAllHandlerInfosMatchDefaultHandlers();
|
||||
});
|
||||
);
|
||||
|
||||
/**
|
||||
* Tests that the default protocol handlers are not imported again from the
|
||||
* locale-specific data if they already exist.
|
||||
*/
|
||||
add_task(async function test_default_protocol_handlers_no_duplicates() {
|
||||
if (
|
||||
!Services.prefs.getPrefType("gecko.handlerService.defaultHandlersVersion")
|
||||
) {
|
||||
info("This platform or locale does not have default handlers.");
|
||||
return;
|
||||
add_task(
|
||||
{ skip_if: () => AppConstants.MOZ_APP_NAME == "thunderbird" },
|
||||
async function test_default_protocol_handlers_no_duplicates() {
|
||||
if (
|
||||
!Services.prefs.getPrefType("gecko.handlerService.defaultHandlersVersion")
|
||||
) {
|
||||
info("This platform or locale does not have default handlers.");
|
||||
return;
|
||||
}
|
||||
|
||||
// This will inject the default protocol handlers for the current locale.
|
||||
await deleteHandlerStore();
|
||||
|
||||
// Clear the preference to force injecting again.
|
||||
Services.prefs.clearUserPref("gecko.handlerService.defaultHandlersVersion");
|
||||
|
||||
await unloadHandlerStore();
|
||||
|
||||
// There should be no duplicate handlers in the protocols.
|
||||
assertAllHandlerInfosMatchDefaultHandlers();
|
||||
}
|
||||
|
||||
// This will inject the default protocol handlers for the current locale.
|
||||
await deleteHandlerStore();
|
||||
|
||||
// Clear the preference to force injecting again.
|
||||
Services.prefs.clearUserPref("gecko.handlerService.defaultHandlersVersion");
|
||||
|
||||
await unloadHandlerStore();
|
||||
|
||||
// There should be no duplicate handlers in the protocols.
|
||||
assertAllHandlerInfosMatchDefaultHandlers();
|
||||
});
|
||||
);
|
||||
|
||||
/**
|
||||
* Ensures forward compatibility by checking that the "store" method preserves
|
||||
|
|
Загрузка…
Ссылка в новой задаче