michael@0: michael@0: function getTestPlugin(pluginName) { michael@0: var ph = SpecialPowers.Cc["@mozilla.org/plugin/host;1"] michael@0: .getService(SpecialPowers.Ci.nsIPluginHost); michael@0: var tags = ph.getPluginTags(); michael@0: var name = pluginName || "Test Plug-in"; michael@0: for (var tag of tags) { michael@0: if (tag.name == name) { michael@0: return tag; michael@0: } michael@0: } michael@0: michael@0: ok(false, "Could not find plugin tag with plugin name '" + name + "'"); michael@0: return null; michael@0: } michael@0: michael@0: // call this to set the test plugin(s) initially expected enabled state. michael@0: // it will automatically be reset to it's previous value after the test michael@0: // ends michael@0: function setTestPluginEnabledState(newEnabledState, pluginName) { michael@0: var plugin = getTestPlugin(pluginName); michael@0: var oldEnabledState = plugin.enabledState; michael@0: plugin.enabledState = newEnabledState; michael@0: SimpleTest.registerCleanupFunction(function() { michael@0: getTestPlugin(pluginName).enabledState = oldEnabledState; michael@0: }); michael@0: }