From 7936fd635056236d90080cd98f5befc99c4cab9d Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Thu, 13 Jun 2019 08:41:43 +0000 Subject: [PATCH] Bug 1519434 - make nsPluginTag and the addon manager agree about what is and isn't flash, r=jmathies,aswan Differential Revision: https://phabricator.services.mozilla.com/D34214 --HG-- extra : moz-landing-system : lando --- dom/plugins/base/nsIPluginTag.idl | 2 ++ dom/plugins/base/nsPluginTags.cpp | 12 ++++++++++++ .../mozapps/extensions/internal/PluginProvider.jsm | 8 +------- .../mozapps/extensions/test/xpcshell/test_plugins.js | 7 ++++--- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/dom/plugins/base/nsIPluginTag.idl b/dom/plugins/base/nsIPluginTag.idl index f66aad4975b7..a988bfdf0643 100644 --- a/dom/plugins/base/nsIPluginTag.idl +++ b/dom/plugins/base/nsIPluginTag.idl @@ -58,6 +58,8 @@ interface nsIPluginTag : nsISupports readonly attribute PRTime lastModifiedTime; + readonly attribute boolean isFlashPlugin; + Array getMimeTypes(); Array getMimeDescriptions(); Array getExtensions(); diff --git a/dom/plugins/base/nsPluginTags.cpp b/dom/plugins/base/nsPluginTags.cpp index ad50ed22e82c..1370f27f88f8 100644 --- a/dom/plugins/base/nsPluginTags.cpp +++ b/dom/plugins/base/nsPluginTags.cpp @@ -442,6 +442,12 @@ nsPluginTag::GetDescription(nsACString& aDescription) { return NS_OK; } +NS_IMETHODIMP +nsPluginTag::GetIsFlashPlugin(bool* aIsFlash) { + *aIsFlash = mIsFlashPlugin; + return NS_OK; +} + NS_IMETHODIMP nsPluginTag::GetFilename(nsACString& aFileName) { aFileName = mFileName; @@ -765,6 +771,12 @@ nsFakePluginTag::GetDescription(/* utf-8 */ nsACString& aResult) { return NS_OK; } +NS_IMETHODIMP +nsFakePluginTag::GetIsFlashPlugin(bool* aIsFlash) { + *aIsFlash = false; + return NS_OK; +} + NS_IMETHODIMP nsFakePluginTag::GetFilename(/* utf-8 */ nsACString& aResult) { aResult = mFileName; diff --git a/toolkit/mozapps/extensions/internal/PluginProvider.jsm b/toolkit/mozapps/extensions/internal/PluginProvider.jsm index 16c1ca5430ea..2c6b5b449ae6 100644 --- a/toolkit/mozapps/extensions/internal/PluginProvider.jsm +++ b/toolkit/mozapps/extensions/internal/PluginProvider.jsm @@ -17,7 +17,6 @@ ChromeUtils.defineModuleGetter(this, "Blocklist", const URI_EXTENSION_STRINGS = "chrome://mozapps/locale/extensions/extensions.properties"; const LIST_UPDATED_TOPIC = "plugins-list-updated"; -const FLASH_MIME_TYPE = "application/x-shockwave-flash"; const {Log} = ChromeUtils.import("resource://gre/modules/Log.jsm"); const LOGGER_ID = "addons.plugins"; @@ -515,12 +514,7 @@ PluginWrapper.prototype = { }, get isFlashPlugin() { - for (let type of this.pluginMimeTypes) { - if (type.type == FLASH_MIME_TYPE) { - return true; - } - } - return false; + return pluginFor(this).tags.some(t => t.isFlashPlugin); }, }; diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_plugins.js b/toolkit/mozapps/extensions/test/xpcshell/test_plugins.js index 1c12589742d3..607c76158faa 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_plugins.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_plugins.js @@ -103,7 +103,7 @@ async function run_test_1() { Assert.ok(p.isCompatible); Assert.ok(p.providesUpdatesSecurely); Assert.equal(p.blocklistState, 0); - Assert.equal(p.permissions, AddonManager.PERM_CAN_DISABLE | AddonManager.PERM_CAN_ENABLE); + Assert.equal(p.permissions, AddonManager.PERM_CAN_DISABLE); Assert.equal(p.pendingOperations, 0); Assert.ok(p.updateDate > 0); Assert.ok("isCompatibleWith" in p); @@ -132,6 +132,7 @@ async function run_test_2(p) { () => p.disable()); Assert.ok(p.userDisabled); + Assert.equal(p.permissions, AddonManager.PERM_CAN_ASK_TO_ACTIVATE); Assert.ok(!p.appDisabled); Assert.ok(!p.isActive); @@ -158,13 +159,13 @@ async function run_test_3(p) { }, () => p.enable()); - Assert.ok(!p.userDisabled); + Assert.equal(p.userDisabled, "askToActivate"); Assert.ok(!p.appDisabled); Assert.ok(p.isActive); let p2 = await AddonManager.getAddonByID(gID); Assert.notEqual(p2, null); - Assert.ok(!p2.userDisabled); + Assert.equal(p2.userDisabled, "askToActivate"); Assert.ok(!p2.appDisabled); Assert.ok(p2.isActive); Assert.equal(p2.name, "Shockwave Flash");