Backed out changeset 9983874bfa63 (bug 854467) for bustage on a CLOSED TREE.

This commit is contained in:
Ryan VanderMeulen 2013-04-09 13:45:39 -04:00
parent 6b74493f4b
commit dcda86fbdf
13 changed files with 76 additions and 125 deletions

View File

@ -110,7 +110,7 @@ function test1() {
var plugin = getTestPlugin();
ok(plugin, "Should have a test plugin");
plugin.enabledState = Ci.nsIPluginTag.STATE_ENABLED;
plugin.disabled = false;
plugin.blocklisted = false;
prepareTest(test2, gTestRoot + "plugin_test.html");
}
@ -124,7 +124,7 @@ function test2() {
var plugin = getTestPlugin();
ok(plugin, "Should have a test plugin");
plugin.enabledState = Ci.nsIPluginTag.STATE_DISABLED;
plugin.disabled = true;
prepareTest(test3, gTestRoot + "plugin_test.html");
}
@ -154,7 +154,7 @@ function test4(tab, win) {
function prepareTest5() {
var plugin = getTestPlugin();
plugin.enabledState = Ci.nsIPluginTag.STATE_ENABLED;
plugin.disabled = false;
plugin.blocklisted = true;
prepareTest(test5, gTestRoot + "plugin_test.html");
}
@ -197,7 +197,7 @@ function test7() {
ok(gTestBrowser.missingPlugins.has("application/x-test"), "Test 7, Should know about application/x-test");
var plugin = getTestPlugin();
plugin.enabledState = Ci.nsIPluginTag.STATE_ENABLED;
plugin.disabled = false;
plugin.blocklisted = false;
Services.prefs.setBoolPref("plugins.click_to_play", true);
@ -523,7 +523,7 @@ function test14() {
ok(objLoadingContent.activated, "Test 14, Plugin should be activated");
var plugin = getTestPlugin();
plugin.enabledState = Ci.nsIPluginTag.STATE_ENABLED;
plugin.disabled = false;
plugin.blocklisted = false;
Services.prefs.setBoolPref("plugins.click_to_play", true);
prepareTest(test15, gTestRoot + "plugin_alternate_content.html");

View File

@ -71,7 +71,7 @@ function start_test(plugin) {
}
function finish_test(plugin) {
plugin.enabledState = Components.interfaces.nsIPluginTag.STATE_ENABLED;
plugin.disabled = false;
plugin.blocklisted = false;
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
@ -127,7 +127,7 @@ function test_normal(plugin) {
is(gDisabled.length, 0, "Should not have been any disabled plugins");
is(gBlocked.length, 0, "Should not have been any blocked plugins");
test_style("solid");
plugin.enabledState = Components.interfaces.nsIPluginTag.STATE_DISABLED;
plugin.disabled = true;
load_frame(test_disabled, "file_bug391728");
}
@ -138,7 +138,7 @@ function test_disabled(plugin) {
is(gBlocked.length, 0, "Should not have been any blocked plugins");
test_style("dotted");
ok(plugin.disabled, "Plugin lost its disabled status");
plugin.enabledState = Components.interfaces.nsIPluginTag.STATE_ENABLED;
plugin.disabled = false;
plugin.blocklisted = true;
load_frame(test_blocked, "file_bug391728");
}

View File

@ -6,25 +6,17 @@
#include "nsISupports.idl"
interface nsIDOMMimeType;
[scriptable, uuid(87b4fcfc-417b-47f6-9c79-dfeb5e5a4840)]
[scriptable, uuid(b8bf0a06-e395-4f44-af39-a51d3e7ef4b9)]
interface nsIPluginTag : nsISupports
{
// enabledState is stored as one of the following as an integer in prefs,
// so if new states are added, they must not renumber the existing states.
const unsigned long STATE_DISABLED = 0;
const unsigned long STATE_CLICKTOPLAY = 1;
const unsigned long STATE_ENABLED = 2;
readonly attribute AUTF8String description;
readonly attribute AUTF8String filename;
readonly attribute AUTF8String fullpath;
readonly attribute AUTF8String version;
readonly attribute AUTF8String name;
attribute boolean disabled;
attribute boolean blocklisted;
readonly attribute boolean disabled;
readonly attribute boolean clicktoplay;
attribute unsigned long enabledState;
attribute boolean clicktoplay;
void getMimeTypes([optional] out unsigned long aCount,
[retval, array, size_is(aCount)] out nsIDOMMimeType aResults);
};

View File

@ -2043,7 +2043,7 @@ nsresult nsPluginHost::ScanPluginsDirectory(nsIFile *pluginsDir,
pluginTag->SetBlocklisted(true);
}
if (state == nsIBlocklistService::STATE_SOFTBLOCKED && !seenBefore) {
pluginTag->SetEnabledState(nsIPluginTag::STATE_DISABLED);
pluginTag->SetDisabled(true);
}
if (state == nsIBlocklistService::STATE_OUTDATED && !seenBefore) {
warnOutdated = true;

View File

@ -321,6 +321,26 @@ nsPluginTag::IsEnabled()
return (state == ePluginState_Enabled) || (state == ePluginState_Clicktoplay);
}
void
nsPluginTag::SetEnabled(bool enabled)
{
if (enabled == IsEnabled()) {
return;
}
PluginState state = GetPluginState();
if (!enabled) {
SetPluginState(ePluginState_Disabled);
} else if (state != ePluginState_Clicktoplay) {
SetPluginState(ePluginState_Enabled);
}
if (nsRefPtr<nsPluginHost> host = nsPluginHost::GetInst()) {
host->UpdatePluginInfo(this);
}
}
NS_IMETHODIMP
nsPluginTag::GetDisabled(bool* aDisabled)
{
@ -328,6 +348,13 @@ nsPluginTag::GetDisabled(bool* aDisabled)
return NS_OK;
}
NS_IMETHODIMP
nsPluginTag::SetDisabled(bool aDisabled)
{
SetEnabled(!aDisabled);
return NS_OK;
}
bool
nsPluginTag::IsBlocklisted()
{
@ -376,23 +403,19 @@ nsPluginTag::GetClicktoplay(bool *aClicktoplay)
}
NS_IMETHODIMP
nsPluginTag::GetEnabledState(uint32_t *aEnabledState) {
*aEnabledState = Preferences::GetInt(GetStatePrefNameForPlugin(this).get(),
ePluginState_Enabled);
return NS_OK;
}
nsPluginTag::SetClicktoplay(bool clicktoplay)
{
if (clicktoplay == IsClicktoplay()) {
return NS_OK;
}
NS_IMETHODIMP
nsPluginTag::SetEnabledState(uint32_t aEnabledState) {
if (aEnabledState >= ePluginState_MaxValue)
return NS_ERROR_ILLEGAL_VALUE;
uint32_t oldState = nsIPluginTag::STATE_DISABLED;
GetEnabledState(&oldState);
if (oldState != aEnabledState) {
Preferences::SetInt(GetStatePrefNameForPlugin(this).get(), aEnabledState);
if (nsRefPtr<nsPluginHost> host = nsPluginHost::GetInst()) {
host->UpdatePluginInfo(this);
}
const PluginState state = GetPluginState();
if (state != ePluginState_Disabled) {
SetPluginState(ePluginState_Clicktoplay);
}
if (nsRefPtr<nsPluginHost> host = nsPluginHost::GetInst()) {
host->UpdatePluginInfo(this);
}
return NS_OK;
}
@ -400,18 +423,14 @@ nsPluginTag::SetEnabledState(uint32_t aEnabledState) {
nsPluginTag::PluginState
nsPluginTag::GetPluginState()
{
uint32_t enabledState = nsIPluginTag::STATE_DISABLED;
GetEnabledState(&enabledState);
return (PluginState)enabledState;
return (PluginState)Preferences::GetInt(GetStatePrefNameForPlugin(this).get(),
ePluginState_Enabled);
}
void
nsPluginTag::SetPluginState(PluginState state)
{
MOZ_STATIC_ASSERT(nsPluginTag::ePluginState_Disabled == nsIPluginTag::STATE_DISABLED, "nsPluginTag::ePluginState_Disabled must match nsIPluginTag::STATE_DISABLED");
MOZ_STATIC_ASSERT(nsPluginTag::ePluginState_Clicktoplay == nsIPluginTag::STATE_CLICKTOPLAY, "nsPluginTag::ePluginState_Clicktoplay must match nsIPluginTag::STATE_CLICKTOPLAY");
MOZ_STATIC_ASSERT(nsPluginTag::ePluginState_Enabled == nsIPluginTag::STATE_ENABLED, "nsPluginTag::ePluginState_Enabled must match nsIPluginTag::STATE_ENABLED");
SetEnabledState((uint32_t)state);
Preferences::SetInt(GetStatePrefNameForPlugin(this).get(), state);
}
NS_IMETHODIMP

View File

@ -27,12 +27,10 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSIPLUGINTAG
// These must match the STATE_* values in nsIPluginTag.idl
enum PluginState {
ePluginState_Disabled = 0,
ePluginState_Clicktoplay = 1,
ePluginState_Enabled = 2,
ePluginState_MaxValue = 3,
};
nsPluginTag(nsPluginTag* aPluginTag);

View File

@ -41,7 +41,7 @@
ok(!tagTestPlugin.disabled, "test plugin should not be disabled");
nextTest = testPart2;
tagTestPlugin.enabledState = Components.interfaces.nsIPluginTag.STATE_DISABLED;
tagTestPlugin.disabled = true;
function testPart2() {
var navTestPlugin = navigator.plugins.namedItem("Test Plug-in");
@ -49,7 +49,7 @@
ok(!navigator.mimeTypes[mimeType.type], "now navigator.mimeTypes should not have an entry for '" + mimeType.type + "'");
nextTest = testPart3;
tagTestPlugin.enabledState = Components.interfaces.nsIPluginTag.STATE_ENABLED;
tagTestPlugin.disabled = false;
}
function testPart3() {

View File

@ -1,38 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
function check_state(aTag, aExpectedClicktoplay, aExpectedDisabled) {
do_check_eq(aTag.clicktoplay, aExpectedClicktoplay);
do_check_eq(aTag.disabled, aExpectedDisabled);
}
function run_test() {
let tag = get_test_plugintag();
check_state(tag, false, false);
/* test going to click-to-play from always enabled and back */
tag.enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY;
check_state(tag, true, false);
tag.enabledState = Ci.nsIPluginTag.STATE_ENABLED;
check_state(tag, false, false);
/* test going to disabled from always enabled and back */
tag.enabledState = Ci.nsIPluginTag.STATE_DISABLED;
check_state(tag, false, true);
tag.enabledState = Ci.nsIPluginTag.STATE_ENABLED;
check_state(tag, false, false);
/* test going to click-to-play from disabled and back */
tag.enabledState = Ci.nsIPluginTag.STATE_DISABLED;
check_state(tag, false, true);
tag.enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY;
check_state(tag, true, false);
tag.enabledState = Ci.nsIPluginTag.STATE_DISABLED;
check_state(tag, false, true);
/* put everything back to normal and check that that succeeded */
tag.enabledState = Ci.nsIPluginTag.STATE_ENABLED;
check_state(tag, false, false);
}

View File

@ -15,4 +15,3 @@ fail-if = os == "android"
# Bug 676953: test fails consistently on Android
fail-if = os == "android"
[test_persist_in_prefs.js]
[test_bug854467.js]

View File

@ -300,12 +300,8 @@ function PluginWrapper(aId, aName, aDescription, aTags) {
if (aTags[0].disabled == aVal)
return;
for (let tag of aTags) {
if (aVal === true)
tag.enabledState = Ci.nsIPluginTag.STATE_DISABLED;
else
tag.enabledState = Ci.nsIPluginTag.STATE_ENABLED;
}
for (let tag of aTags)
tag.disabled = aVal;
AddonManagerPrivate.callAddonListeners(aVal ? "onDisabling" : "onEnabling", this, false);
AddonManagerPrivate.callAddonListeners(aVal ? "onDisabled" : "onEnabled", this);
return aVal;

View File

@ -959,7 +959,7 @@ Blocklist.prototype = {
if (plugin.blocklisted) {
if (state == Ci.nsIBlocklistService.STATE_SOFTBLOCKED)
plugin.enabledState = Ci.nsIPluginTag.STATE_DISABLED;
plugin.disabled = true;
}
else if (!plugin.disabled && state != Ci.nsIBlocklistService.STATE_NOT_BLOCKED) {
if (state == Ci.nsIBlocklistService.STATE_OUTDATED) {
@ -1015,7 +1015,7 @@ Blocklist.prototype = {
continue;
if (addon.item instanceof Ci.nsIPluginTag)
addon.item.enabledState = Ci.nsIPluginTag.STATE_DISABLED;
addon.item.disabled = true;
else
addon.item.softDisabled = true;
}

View File

@ -75,43 +75,37 @@ var PLUGINS = [{
// Tests how the blocklist affects a disabled plugin
name: "test_bug455906_1",
version: "5",
enabledState : Ci.nsIPluginTag.STATE_DISABLED,
get disabled() this.enabledState == Ci.nsIPluginTag.STATE_DISABLED,
disabled: true,
blocklisted: false
}, {
// Tests how the blocklist affects an enabled plugin
name: "test_bug455906_2",
version: "5",
enabledState: Ci.nsIPluginTag.STATE_ENABLED,
get disabled() this.enabledState == Ci.nsIPluginTag.STATE_DISABLED,
disabled: false,
blocklisted: false
}, {
// Tests how the blocklist affects an enabled plugin, to be disabled by the notification
name: "test_bug455906_3",
version: "5",
enabledState: Ci.nsIPluginTag.STATE_ENABLED,
get disabled() this.enabledState == Ci.nsIPluginTag.STATE_DISABLED,
disabled: false,
blocklisted: false
}, {
// Tests how the blocklist affects a disabled plugin that was already warned about
name: "test_bug455906_4",
version: "5",
enabledState: Ci.nsIPluginTag.STATE_DISABLED,
get disabled() this.enabledState == Ci.nsIPluginTag.STATE_DISABLED,
disabled: true,
blocklisted: false
}, {
// Tests how the blocklist affects an enabled plugin that was already warned about
name: "test_bug455906_5",
version: "5",
enabledState: Ci.nsIPluginTag.STATE_ENABLED,
get disabled() this.enabledState == Ci.nsIPluginTag.STATE_DISABLED,
disabled: false,
blocklisted: false
}, {
// Tests how the blocklist affects an already blocked plugin
name: "test_bug455906_6",
version: "5",
enabledState: Ci.nsIPluginTag.STATE_ENABLED,
get disabled() this.enabledState == Ci.nsIPluginTag.STATE_DISABLED,
disabled: false,
blocklisted: true
}];
@ -387,8 +381,8 @@ function check_test_pt2() {
// Back to starting state
addons[2].userDisabled = false;
addons[5].userDisabled = false;
PLUGINS[2].enabledState = Ci.nsIPluginTag.STATE_ENABLED;
PLUGINS[5].enabledState = Ci.nsIPluginTag.STATE_ENABLED;
PLUGINS[2].disabled = false;
PLUGINS[5].disabled = false;
restartManager();
gNotificationCheck = null;
gTestCheck = run_test_pt3;
@ -494,7 +488,7 @@ function check_test_pt3() {
function run_test_pt4() {
AddonManager.getAddonByID(ADDONS[4].id, function(addon) {
addon.userDisabled = false;
PLUGINS[4].enabledState = Ci.nsIPluginTag.STATE_ENABLED;
PLUGINS[4].disabled = false;
restartManager();
check_initial_state(function() {
gNotificationCheck = check_notification_pt4;

View File

@ -2,8 +2,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
const Ci = Components.interfaces;
// This verifies that duplicate plugins are coalesced and maintain their ID
// across restarts.
@ -12,16 +10,14 @@ var PLUGINS = [{
description: "A duplicate plugin",
version: "1",
blocklisted: false,
enabledState: Ci.nsIPluginTag.STATE_ENABLED,
get disabled() this.enabledState == Ci.nsIPluginTag.STATE_DISABLED,
disabled: false,
filename: "/home/mozilla/.plugins/dupplugin1.so"
}, {
name: "Duplicate Plugin 1",
description: "A duplicate plugin",
version: "1",
blocklisted: false,
enabledState: Ci.nsIPluginTag.STATE_ENABLED,
get disabled() this.enabledState == Ci.nsIPluginTag.STATE_DISABLED,
disabled: false,
filename: "",
filename: "/usr/lib/plugins/dupplugin1.so"
}, {
@ -29,16 +25,14 @@ var PLUGINS = [{
description: "Another duplicate plugin",
version: "1",
blocklisted: false,
enabledState: Ci.nsIPluginTag.STATE_ENABLED,
get disabled() this.enabledState == Ci.nsIPluginTag.STATE_DISABLED,
disabled: false,
filename: "/home/mozilla/.plugins/dupplugin2.so"
}, {
name: "Duplicate Plugin 2",
description: "Another duplicate plugin",
version: "1",
blocklisted: false,
enabledState: Ci.nsIPluginTag.STATE_ENABLED,
get disabled() this.enabledState == Ci.nsIPluginTag.STATE_DISABLED,
disabled: false,
filename: "",
filename: "/usr/lib/plugins/dupplugin2.so"
}, {
@ -46,16 +40,14 @@ var PLUGINS = [{
description: "Not a duplicate plugin",
version: "1",
blocklisted: false,
enabledState: Ci.nsIPluginTag.STATE_ENABLED,
get disabled() this.enabledState == Ci.nsIPluginTag.STATE_DISABLED,
disabled: false,
filename: "/home/mozilla/.plugins/dupplugin3.so"
}, {
name: "Non-duplicate Plugin", // 4
description: "Not a duplicate because the descriptions are different",
version: "1",
blocklisted: false,
enabledState: Ci.nsIPluginTag.STATE_ENABLED,
get disabled() this.enabledState == Ci.nsIPluginTag.STATE_DISABLED,
disabled: false,
filename: "",
filename: "/usr/lib/plugins/dupplugin4.so"
}, {
@ -63,8 +55,7 @@ var PLUGINS = [{
description: "Not a duplicate plugin",
version: "1",
blocklisted: false,
enabledState: Ci.nsIPluginTag.STATE_ENABLED,
get disabled() this.enabledState == Ci.nsIPluginTag.STATE_DISABLED,
disabled: false,
filename: "/home/mozilla/.plugins/dupplugin5.so"
}];