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
This commit is contained in:
Gijs Kruitbosch 2019-06-13 08:41:43 +00:00
parent a8bd1715ab
commit 7936fd6350
4 changed files with 19 additions and 10 deletions

View File

@ -58,6 +58,8 @@ interface nsIPluginTag : nsISupports
readonly attribute PRTime lastModifiedTime;
readonly attribute boolean isFlashPlugin;
Array<AUTF8String> getMimeTypes();
Array<AUTF8String> getMimeDescriptions();
Array<AUTF8String> getExtensions();

View File

@ -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;

View File

@ -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);
},
};

View File

@ -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");