1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/plugins/test/unit/test_plugin_default_state.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,30 @@ 1.4 +Components.utils.import("resource://gre/modules/Services.jsm"); 1.5 + 1.6 +function run_test() { 1.7 + let pluginDefaultState = Services.prefs.getIntPref("plugin.default.state"); 1.8 + // if this fails, we just have to switch around the values we're testing 1.9 + do_check_neq(pluginDefaultState, Ci.nsIPluginTag.STATE_DISABLED); 1.10 + let nonDefaultState = (pluginDefaultState != Ci.nsIPluginTag.STATE_ENABLED ? 1.11 + Ci.nsIPluginTag.STATE_ENABLED : 1.12 + Ci.nsIPluginTag.STATE_CLICKTOPLAY); 1.13 + let ph = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost); 1.14 + let testPlugin = get_test_plugintag(); 1.15 + // the test plugin should have the default enabledState 1.16 + do_check_eq(testPlugin.enabledState, pluginDefaultState); 1.17 + 1.18 + let secondTestPlugin = get_test_plugintag("Second Test Plug-in"); 1.19 + // set an enabledState for the second test plugin 1.20 + secondTestPlugin.enabledState = Ci.nsIPluginTag.STATE_DISABLED; 1.21 + // change what the default enabledState is 1.22 + Services.prefs.setIntPref("plugin.default.state", nonDefaultState); 1.23 + // the test plugin should follow the default (it has no individual pref yet) 1.24 + do_check_eq(testPlugin.enabledState, nonDefaultState); 1.25 + // the second test plugin should retain its preferred state 1.26 + do_check_eq(secondTestPlugin.enabledState, Ci.nsIPluginTag.STATE_DISABLED); 1.27 + 1.28 + // clean up 1.29 + testPlugin.enabledState = pluginDefaultState; 1.30 + secondTestPlugin.enabledState = pluginDefaultState; 1.31 + Services.prefs.clearUserPref("plugin.default.state"); 1.32 + Services.prefs.clearUserPref("plugin.importedState"); 1.33 +}