layout/base/tests/enableTestPlugin.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/base/tests/enableTestPlugin.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,25 @@
     1.4 +// this automatically sets the test plugin to be enabled (not e.g. click-to-play)
     1.5 +// and resets this afterwards
     1.6 +
     1.7 +(function() {
     1.8 +  function getTestPlugin(aPluginName) {
     1.9 +    var ph = SpecialPowers.Cc["@mozilla.org/plugin/host;1"]
    1.10 +                          .getService(SpecialPowers.Ci.nsIPluginHost);
    1.11 +    var tags = ph.getPluginTags();
    1.12 +    for (var tag of tags) {
    1.13 +      if (tag.name == aPluginName) {
    1.14 +       return tag;
    1.15 +      }
    1.16 +    }
    1.17 +
    1.18 +    ok(false, "Could not find plugin tag with plugin name '" + name + "'");
    1.19 +    return null;
    1.20 +  }
    1.21 +
    1.22 +  var plugin = getTestPlugin("Test Plug-in");
    1.23 +  var oldEnabledState = plugin.enabledState;
    1.24 +  plugin.enabledState = SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED;
    1.25 +  SimpleTest.registerCleanupFunction(function() {
    1.26 +    getTestPlugin("Test Plug-in").enabledState = oldEnabledState;
    1.27 +  });
    1.28 +})();

mercurial