dom/plugins/test/unit/test_plugin_default_state.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial