|
1 |
|
2 function getTestPlugin(pluginName) { |
|
3 var ph = SpecialPowers.Cc["@mozilla.org/plugin/host;1"] |
|
4 .getService(SpecialPowers.Ci.nsIPluginHost); |
|
5 var tags = ph.getPluginTags(); |
|
6 var name = pluginName || "Test Plug-in"; |
|
7 for (var tag of tags) { |
|
8 if (tag.name == name) { |
|
9 return tag; |
|
10 } |
|
11 } |
|
12 |
|
13 ok(false, "Could not find plugin tag with plugin name '" + name + "'"); |
|
14 return null; |
|
15 } |
|
16 |
|
17 // call this to set the test plugin(s) initially expected enabled state. |
|
18 // it will automatically be reset to it's previous value after the test |
|
19 // ends |
|
20 function setTestPluginEnabledState(newEnabledState, pluginName) { |
|
21 var plugin = getTestPlugin(pluginName); |
|
22 var oldEnabledState = plugin.enabledState; |
|
23 plugin.enabledState = newEnabledState; |
|
24 SimpleTest.registerCleanupFunction(function() { |
|
25 getTestPlugin(pluginName).enabledState = oldEnabledState; |
|
26 }); |
|
27 } |