mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 06:43:32 +00:00
Bug 1641389 - Remove image.webp.enabled pref, always on by default. r=necko-reviewers,tnikkel,valentin
Differential Revision: https://phabricator.services.mozilla.com/D188276
This commit is contained in:
parent
2b443482d0
commit
31921ad4d8
@ -126,16 +126,8 @@ export let DownloadsViewableInternally = {
|
||||
{
|
||||
extension: "webp",
|
||||
mimeTypes: ["image/webp"],
|
||||
initAvailable() {
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
this,
|
||||
"available",
|
||||
"image.webp.enabled",
|
||||
false,
|
||||
() => DownloadsViewableInternally._updateHandler(this)
|
||||
);
|
||||
},
|
||||
// available getter is set by initAvailable()
|
||||
available: true,
|
||||
managedElsewhere: false,
|
||||
},
|
||||
{
|
||||
extension: "avif",
|
||||
|
@ -2,14 +2,12 @@
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
const PREF_SVG_DISABLED = "svg.disabled";
|
||||
const PREF_WEBP_ENABLED = "image.webp.enabled";
|
||||
const PREF_AVIF_ENABLED = "image.avif.enabled";
|
||||
const PDF_MIME = "application/pdf";
|
||||
const OCTET_MIME = "application/octet-stream";
|
||||
const XML_MIME = "text/xml";
|
||||
const SVG_MIME = "image/svg+xml";
|
||||
const AVIF_MIME = "image/avif";
|
||||
const WEBP_MIME = "image/webp";
|
||||
|
||||
const { Integration } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/Integration.sys.mjs"
|
||||
@ -82,32 +80,25 @@ function checkAll(mime, ext, expected) {
|
||||
}
|
||||
|
||||
add_task(async function test_viewable_internally() {
|
||||
Services.prefs.setCharPref(PREF_ENABLED_TYPES, "xml , svg,avif,webp");
|
||||
Services.prefs.setCharPref(PREF_ENABLED_TYPES, "xml , svg,avif");
|
||||
Services.prefs.setBoolPref(PREF_SVG_DISABLED, false);
|
||||
Services.prefs.setBoolPref(PREF_WEBP_ENABLED, true);
|
||||
Services.prefs.setBoolPref(PREF_AVIF_ENABLED, true);
|
||||
|
||||
checkAll(XML_MIME, "xml", false);
|
||||
checkAll(SVG_MIME, "svg", false);
|
||||
checkAll(WEBP_MIME, "webp", false);
|
||||
checkAll(AVIF_MIME, "avif", false);
|
||||
|
||||
DownloadsViewableInternally.register();
|
||||
|
||||
checkAll(XML_MIME, "xml", true);
|
||||
checkAll(SVG_MIME, "svg", true);
|
||||
checkAll(WEBP_MIME, "webp", true);
|
||||
checkAll(AVIF_MIME, "avif", true);
|
||||
|
||||
// Remove webp so it won't be cleared
|
||||
Services.prefs.clearUserPref(PREF_BRANCH_WAS_REGISTERED + "webp");
|
||||
|
||||
// Disable xml, avif and webp, check that avif becomes disabled
|
||||
// Disable xml, and avif, check that avif becomes disabled
|
||||
Services.prefs.setCharPref(PREF_ENABLED_TYPES, "svg");
|
||||
|
||||
// (XML is externally managed, and we just cleared the webp pref)
|
||||
// (XML is externally managed)
|
||||
checkAll(XML_MIME, "xml", true);
|
||||
checkPreferInternal(WEBP_MIME, "webp", true);
|
||||
|
||||
// Avif should be disabled
|
||||
checkAll(AVIF_MIME, "avif", false);
|
||||
@ -129,15 +120,13 @@ add_task(async function test_viewable_internally() {
|
||||
);
|
||||
Assert.ok(!shouldView(OCTET_MIME, "exe"), ".exe shouldn't be accepted");
|
||||
|
||||
Assert.ok(!shouldView(WEBP_MIME), "imave/webp should be disabled by pref");
|
||||
Assert.ok(!shouldView(AVIF_MIME), "image/avif should be disabled by pref");
|
||||
|
||||
// Enable, check that everything is enabled again
|
||||
Services.prefs.setCharPref(PREF_ENABLED_TYPES, "xml,svg,webp,avif");
|
||||
Services.prefs.setCharPref(PREF_ENABLED_TYPES, "xml,svg,avif");
|
||||
|
||||
checkAll(XML_MIME, "xml", true);
|
||||
checkAll(SVG_MIME, "svg", true);
|
||||
checkPreferInternal(WEBP_MIME, "webp", true);
|
||||
checkPreferInternal(AVIF_MIME, "avif", true);
|
||||
|
||||
Assert.ok(
|
||||
@ -160,7 +149,6 @@ add_task(async function test_viewable_internally() {
|
||||
for (const [mime, ext, action, ask] of [
|
||||
[XML_MIME, "xml", Ci.nsIHandlerInfo.useSystemDefault, true],
|
||||
[SVG_MIME, "svg", Ci.nsIHandlerInfo.saveToDisk, true],
|
||||
[WEBP_MIME, "webp", Ci.nsIHandlerInfo.saveToDisk, false],
|
||||
]) {
|
||||
let handler = MIMEService.getFromTypeAndExtension(mime, ext);
|
||||
handler.preferredAction = action;
|
||||
@ -175,8 +163,8 @@ add_task(async function test_viewable_internally() {
|
||||
Assert.equal(handler.alwaysAskBeforeHandling, ask);
|
||||
}
|
||||
|
||||
// Enable viewable internally, SVG and XML should not be replaced, WebP should be saved.
|
||||
Services.prefs.setCharPref(PREF_ENABLED_TYPES, "svg,webp,xml");
|
||||
// Enable viewable internally, SVG and XML should not be replaced.
|
||||
Services.prefs.setCharPref(PREF_ENABLED_TYPES, "svg,xml");
|
||||
|
||||
Assert.equal(
|
||||
Services.prefs.prefHasUserValue(PREF_BRANCH_PREVIOUS_ACTION + "svg"),
|
||||
@ -188,16 +176,6 @@ add_task(async function test_viewable_internally() {
|
||||
false,
|
||||
"svg ask should not be stored"
|
||||
);
|
||||
Assert.equal(
|
||||
Services.prefs.getIntPref(PREF_BRANCH_PREVIOUS_ACTION + "webp"),
|
||||
Ci.nsIHandlerInfo.saveToDisk,
|
||||
"webp action should be saved"
|
||||
);
|
||||
Assert.equal(
|
||||
Services.prefs.getBoolPref(PREF_BRANCH_PREVIOUS_ASK + "webp"),
|
||||
false,
|
||||
"webp ask should be saved"
|
||||
);
|
||||
|
||||
{
|
||||
let handler = MIMEService.getFromTypeAndExtension(SVG_MIME, "svg");
|
||||
@ -231,7 +209,6 @@ add_task(async function test_viewable_internally() {
|
||||
checkShouldView(XML_MIME, "xml", true);
|
||||
|
||||
checkAll(SVG_MIME, "svg", true);
|
||||
checkAll(WEBP_MIME, "webp", true);
|
||||
|
||||
// Disable SVG to test SVG enabled check (depends on the pref)
|
||||
Services.prefs.setBoolPref(PREF_SVG_DISABLED, true);
|
||||
@ -246,21 +223,6 @@ add_task(async function test_viewable_internally() {
|
||||
|
||||
checkAll(SVG_MIME, "svg", true);
|
||||
|
||||
// Test WebP enabled check (depends on the pref)
|
||||
Services.prefs.setBoolPref(PREF_WEBP_ENABLED, false);
|
||||
// Should have restored the settings from above
|
||||
{
|
||||
let handler = MIMEService.getFromTypeAndExtension(WEBP_MIME, "webp");
|
||||
Assert.equal(handler.preferredAction, Ci.nsIHandlerInfo.saveToDisk);
|
||||
Assert.equal(!!handler.alwaysAskBeforeHandling, false);
|
||||
// Clean up
|
||||
HandlerService.remove(handler);
|
||||
}
|
||||
checkAll(WEBP_MIME, "webp", false);
|
||||
|
||||
Services.prefs.setBoolPref(PREF_WEBP_ENABLED, true);
|
||||
checkAll(WEBP_MIME, "webp", true);
|
||||
|
||||
Assert.ok(!shouldView(null, "pdf"), "missing MIME shouldn't be accepted");
|
||||
Assert.ok(!shouldView(null, "xml"), "missing MIME shouldn't be accepted");
|
||||
Assert.ok(!shouldView(OCTET_MIME), "unsupported MIME shouldn't be accepted");
|
||||
@ -273,5 +235,4 @@ registerCleanupFunction(() => {
|
||||
// Reset to the defaults
|
||||
Services.prefs.clearUserPref(PREF_ENABLED_TYPES);
|
||||
Services.prefs.clearUserPref(PREF_SVG_DISABLED);
|
||||
Services.prefs.clearUserPref(PREF_WEBP_ENABLED);
|
||||
});
|
||||
|
@ -51,8 +51,7 @@ function expectedImageAcceptHeader() {
|
||||
return (
|
||||
(Services.prefs.getBoolPref("image.avif.enabled") ? "image/avif," : "") +
|
||||
(Services.prefs.getBoolPref("image.jxl.enabled") ? "image/jxl," : "") +
|
||||
(Services.prefs.getBoolPref("image.webp.enabled") ? "image/webp," : "") +
|
||||
"*/*"
|
||||
"image/webp,*/*"
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -79,8 +79,7 @@ DecoderType DecoderFactory::GetDecoderType(const char* aMimeType) {
|
||||
type = DecoderType::ICON;
|
||||
|
||||
// WebP
|
||||
} else if (!strcmp(aMimeType, IMAGE_WEBP) &&
|
||||
StaticPrefs::image_webp_enabled()) {
|
||||
} else if (!strcmp(aMimeType, IMAGE_WEBP)) {
|
||||
type = DecoderType::WEBP;
|
||||
|
||||
// AVIF
|
||||
|
@ -60,14 +60,10 @@ nsresult mozilla::image::EnsureModuleInitialized() {
|
||||
mozilla::StaticPrefs::image_avif_enabled, "image/avif"_ns};
|
||||
static ImageEnablementCookie kJXLCookie = {
|
||||
mozilla::StaticPrefs::image_jxl_enabled, "image/jxl"_ns};
|
||||
static ImageEnablementCookie kWebPCookie = {
|
||||
mozilla::StaticPrefs::image_webp_enabled, "image/webp"_ns};
|
||||
Preferences::RegisterCallbackAndCall(UpdateContentViewerRegistration,
|
||||
"image.avif.enabled", &kAVIFCookie);
|
||||
Preferences::RegisterCallbackAndCall(UpdateContentViewerRegistration,
|
||||
"image.jxl.enabled", &kJXLCookie);
|
||||
Preferences::RegisterCallbackAndCall(UpdateContentViewerRegistration,
|
||||
"image.webp.enabled", &kWebPCookie);
|
||||
|
||||
mozilla::image::ShutdownTracker::Initialize();
|
||||
mozilla::image::ImageFactory::Initialize();
|
||||
|
@ -39,12 +39,8 @@ AutoInitializeImageLib::AutoInitializeImageLib() {
|
||||
EXPECT_TRUE(NS_IsMainThread());
|
||||
sImageLibInitialized = true;
|
||||
|
||||
// Ensure WebP is enabled to run decoder tests.
|
||||
nsresult rv = Preferences::SetBool("image.webp.enabled", true);
|
||||
EXPECT_TRUE(rv == NS_OK);
|
||||
|
||||
// Ensure AVIF is enabled to run decoder tests.
|
||||
rv = Preferences::SetBool("image.avif.enabled", true);
|
||||
nsresult rv = Preferences::SetBool("image.avif.enabled", true);
|
||||
EXPECT_TRUE(rv == NS_OK);
|
||||
rv = Preferences::SetBool("image.avif.sequence.enabled", true);
|
||||
EXPECT_TRUE(rv == NS_OK);
|
||||
|
@ -159,8 +159,7 @@ function runTests()
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SimpleTest.requestFlakyTimeout("untriaged");
|
||||
|
||||
SpecialPowers.pushPrefEnv({"set": [["image.webp.enabled", true]]}, runTests);
|
||||
runTests();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
@ -40,7 +40,6 @@ window.onload = function() {
|
||||
// Enable discarding for the test.
|
||||
SpecialPowers.pushPrefEnv({
|
||||
'set':[['image.mem.discardable',true],
|
||||
['image.webp.enabled',true],
|
||||
['image.avif.sequence.enabled',true]]
|
||||
}, runTest);
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ content_types = [
|
||||
'image/pjpeg',
|
||||
'image/png',
|
||||
'image/vnd.microsoft.icon',
|
||||
'image/webp',
|
||||
'image/x-icon',
|
||||
'image/x-ms-bmp',
|
||||
'image/x-png',
|
||||
|
@ -6981,12 +6981,6 @@
|
||||
value: false
|
||||
mirror: always
|
||||
|
||||
# Whether we attempt to decode WebP images or not.
|
||||
- name: image.webp.enabled
|
||||
type: RelaxedAtomicBool
|
||||
value: true
|
||||
mirror: always
|
||||
|
||||
# Whether we attempt to decode AVIF images or not.
|
||||
- name: image.avif.enabled
|
||||
type: RelaxedAtomicBool
|
||||
|
@ -216,11 +216,7 @@ static nsCString ImageAcceptHeader() {
|
||||
mimeTypes.Append("image/jxl,");
|
||||
}
|
||||
|
||||
if (mozilla::StaticPrefs::image_webp_enabled()) {
|
||||
mimeTypes.Append("image/webp,");
|
||||
}
|
||||
|
||||
mimeTypes.Append("*/*");
|
||||
mimeTypes.Append("image/webp,*/*");
|
||||
|
||||
return mimeTypes;
|
||||
}
|
||||
@ -296,7 +292,6 @@ static const char* gCallbackPrefs[] = {
|
||||
"image.http.accept",
|
||||
"image.avif.enabled",
|
||||
"image.jxl.enabled",
|
||||
"image.webp.enabled",
|
||||
nullptr,
|
||||
};
|
||||
|
||||
@ -1688,9 +1683,9 @@ void nsHttpHandler::PrefsChanged(const char* pref) {
|
||||
}
|
||||
}
|
||||
|
||||
const bool imageAcceptPrefChanged =
|
||||
PREF_CHANGED("image.http.accept") || PREF_CHANGED("image.avif.enabled") ||
|
||||
PREF_CHANGED("image.jxl.enabled") || PREF_CHANGED("image.webp.enabled");
|
||||
const bool imageAcceptPrefChanged = PREF_CHANGED("image.http.accept") ||
|
||||
PREF_CHANGED("image.avif.enabled") ||
|
||||
PREF_CHANGED("image.jxl.enabled");
|
||||
|
||||
if (imageAcceptPrefChanged) {
|
||||
nsAutoCString userSetImageAcceptHeader;
|
||||
|
@ -487,10 +487,6 @@ add_task(async function test_check_open_with_external_then_internal() {
|
||||
*/
|
||||
add_task(
|
||||
async function test_internal_handler_hidden_with_viewable_internally_type() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["image.webp.enabled", true]],
|
||||
});
|
||||
|
||||
const mimeInfosToRestore = alwaysAskForHandlingTypes({
|
||||
"binary/octet-stream": "xml",
|
||||
"image/webp": "webp",
|
||||
|
@ -13,7 +13,6 @@ add_task(async function skipDialogAndDownloadFile() {
|
||||
set: [
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
["browser.download.useDownloadDir", true],
|
||||
["image.webp.enabled", true],
|
||||
],
|
||||
});
|
||||
|
||||
|
@ -13,10 +13,7 @@ const TEST_PATH = getRootDirectory(gTestPath).replace(
|
||||
|
||||
add_setup(async function () {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
["image.webp.enabled", true],
|
||||
],
|
||||
set: [["browser.download.always_ask_before_handling_new_types", false]],
|
||||
});
|
||||
const allowDirectoriesVal = DownloadIntegration.allowDirectories;
|
||||
DownloadIntegration.allowDirectories = true;
|
||||
|
Loading…
Reference in New Issue
Block a user