gecko/testing/mochitest/tests/SimpleTest/PluginUtils.js

29 lines
705 B
JavaScript
Raw Normal View History

var PluginUtils =
{
withTestPlugin : function(callback)
{
if (typeof Components == "undefined")
{
todo(false, "Not a Mozilla-based browser");
return false;
}
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var ph = Components.classes["@mozilla.org/plugin/host;1"]
.getService(Components.interfaces.nsIPluginHost);
var tags = ph.getPluginTags();
// Find the test plugin
for (var i = 0; i < tags.length; i++)
{
if (tags[i].name == "Test Plug-in")
{
callback(tags[i]);
return true;
}
}
todo(false, "Need a test plugin on this platform");
return false;
}
};