browser/base/content/test/general/head_plain.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/base/content/test/general/head_plain.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,27 @@
     1.4 +
     1.5 +function getTestPlugin(pluginName) {
     1.6 +  var ph = SpecialPowers.Cc["@mozilla.org/plugin/host;1"]
     1.7 +                                 .getService(SpecialPowers.Ci.nsIPluginHost);
     1.8 +  var tags = ph.getPluginTags();
     1.9 +  var name = pluginName || "Test Plug-in";
    1.10 +  for (var tag of tags) {
    1.11 +    if (tag.name == name) {
    1.12 +      return tag;
    1.13 +    }
    1.14 +  }
    1.15 +
    1.16 +  ok(false, "Could not find plugin tag with plugin name '" + name + "'");
    1.17 +  return null;
    1.18 +}
    1.19 +
    1.20 +// call this to set the test plugin(s) initially expected enabled state.
    1.21 +// it will automatically be reset to it's previous value after the test
    1.22 +// ends
    1.23 +function setTestPluginEnabledState(newEnabledState, pluginName) {
    1.24 +  var plugin = getTestPlugin(pluginName);
    1.25 +  var oldEnabledState = plugin.enabledState;
    1.26 +  plugin.enabledState = newEnabledState;
    1.27 +  SimpleTest.registerCleanupFunction(function() {
    1.28 +    getTestPlugin(pluginName).enabledState = oldEnabledState;
    1.29 +  });
    1.30 +}

mercurial