Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | Components.utils.import("resource://gre/modules/Services.jsm"); |
michael@0 | 2 | |
michael@0 | 3 | function run_test() { |
michael@0 | 4 | let pluginDefaultState = Services.prefs.getIntPref("plugin.default.state"); |
michael@0 | 5 | // if this fails, we just have to switch around the values we're testing |
michael@0 | 6 | do_check_neq(pluginDefaultState, Ci.nsIPluginTag.STATE_DISABLED); |
michael@0 | 7 | let nonDefaultState = (pluginDefaultState != Ci.nsIPluginTag.STATE_ENABLED ? |
michael@0 | 8 | Ci.nsIPluginTag.STATE_ENABLED : |
michael@0 | 9 | Ci.nsIPluginTag.STATE_CLICKTOPLAY); |
michael@0 | 10 | let ph = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost); |
michael@0 | 11 | let testPlugin = get_test_plugintag(); |
michael@0 | 12 | // the test plugin should have the default enabledState |
michael@0 | 13 | do_check_eq(testPlugin.enabledState, pluginDefaultState); |
michael@0 | 14 | |
michael@0 | 15 | let secondTestPlugin = get_test_plugintag("Second Test Plug-in"); |
michael@0 | 16 | // set an enabledState for the second test plugin |
michael@0 | 17 | secondTestPlugin.enabledState = Ci.nsIPluginTag.STATE_DISABLED; |
michael@0 | 18 | // change what the default enabledState is |
michael@0 | 19 | Services.prefs.setIntPref("plugin.default.state", nonDefaultState); |
michael@0 | 20 | // the test plugin should follow the default (it has no individual pref yet) |
michael@0 | 21 | do_check_eq(testPlugin.enabledState, nonDefaultState); |
michael@0 | 22 | // the second test plugin should retain its preferred state |
michael@0 | 23 | do_check_eq(secondTestPlugin.enabledState, Ci.nsIPluginTag.STATE_DISABLED); |
michael@0 | 24 | |
michael@0 | 25 | // clean up |
michael@0 | 26 | testPlugin.enabledState = pluginDefaultState; |
michael@0 | 27 | secondTestPlugin.enabledState = pluginDefaultState; |
michael@0 | 28 | Services.prefs.clearUserPref("plugin.default.state"); |
michael@0 | 29 | Services.prefs.clearUserPref("plugin.importedState"); |
michael@0 | 30 | } |