Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | |
michael@0 | 2 | function getTestPlugin(pluginName) { |
michael@0 | 3 | var ph = SpecialPowers.Cc["@mozilla.org/plugin/host;1"] |
michael@0 | 4 | .getService(SpecialPowers.Ci.nsIPluginHost); |
michael@0 | 5 | var tags = ph.getPluginTags(); |
michael@0 | 6 | var name = pluginName || "Test Plug-in"; |
michael@0 | 7 | for (var tag of tags) { |
michael@0 | 8 | if (tag.name == name) { |
michael@0 | 9 | return tag; |
michael@0 | 10 | } |
michael@0 | 11 | } |
michael@0 | 12 | |
michael@0 | 13 | ok(false, "Could not find plugin tag with plugin name '" + name + "'"); |
michael@0 | 14 | return null; |
michael@0 | 15 | } |
michael@0 | 16 | |
michael@0 | 17 | // call this to set the test plugin(s) initially expected enabled state. |
michael@0 | 18 | // it will automatically be reset to it's previous value after the test |
michael@0 | 19 | // ends |
michael@0 | 20 | function setTestPluginEnabledState(newEnabledState, pluginName) { |
michael@0 | 21 | var plugin = getTestPlugin(pluginName); |
michael@0 | 22 | var oldEnabledState = plugin.enabledState; |
michael@0 | 23 | plugin.enabledState = newEnabledState; |
michael@0 | 24 | SimpleTest.registerCleanupFunction(function() { |
michael@0 | 25 | getTestPlugin(pluginName).enabledState = oldEnabledState; |
michael@0 | 26 | }); |
michael@0 | 27 | } |