Bug 926830 - Test cleanup for plugin enabledState usage, toolkit. r=bsmedberg

This commit is contained in:
Georg Fritzsche 2014-02-17 15:57:54 +01:00
parent b9f40a548b
commit 83af0fd5df
2 changed files with 15 additions and 4 deletions

View File

@ -35,8 +35,7 @@ function test() {
waitForExplicitFinish();
Services.prefs.setBoolPref("plugins.click_to_play", true);
Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
let pluginTag = getTestPluginTag();
pluginTag.enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY;
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
open_manager("addons://list/plugin", part1);
}
@ -219,8 +218,6 @@ function part13() {
function end_test() {
Services.prefs.clearUserPref("plugins.click_to_play");
Services.prefs.clearUserPref("extensions.blocklist.suppressUI");
let pluginTag = getTestPluginTag();
pluginTag.enabledState = Ci.nsIPluginTag.STATE_ENABLED;
resetBlocklist();
close_manager(gManagerWindow, function() {
finish();

View File

@ -1268,3 +1268,17 @@ function getTestPluginTag() {
ok(false, "Unable to find plugin");
return null;
}
// Call this to set the test plugin(s) initially expected enabled state.
// It will automatically be reset to it's previous value after the test
// ends
function setTestPluginEnabledState(newEnabledState, pluginTag) {
if (!pluginTag) {
pluginTag = getTestPluginTag();
}
var oldEnabledState = pluginTag.enabledState;
pluginTag.enabledState = newEnabledState;
SimpleTest.registerCleanupFunction(function() {
pluginTag.enabledState = oldEnabledState;
});
}