toolkit/mozapps/extensions/test/xpcshell/test_bug514327_2.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_2.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,42 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +const Cc = Components.classes;
     1.9 +const Ci = Components.interfaces;
    1.10 +
    1.11 +const nsIBLS = Ci.nsIBlocklistService;
    1.12 +
    1.13 +// Finds the test nsIPluginTag
    1.14 +function get_test_plugintag() {
    1.15 +  var host = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
    1.16 +  var tags = host.getPluginTags();
    1.17 +  for (let tag of tags) {
    1.18 +    if (tag.name == "Test Plug-in")
    1.19 +      return tag;
    1.20 +  }
    1.21 +  return null;
    1.22 +}
    1.23 +
    1.24 +function run_test() {
    1.25 +  createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
    1.26 +
    1.27 +  copyBlocklistToProfile(do_get_file("data/test_bug514327_2.xml"));
    1.28 +
    1.29 +  var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].getService(nsIBLS);
    1.30 +  var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
    1.31 +
    1.32 +  var plugin = get_test_plugintag();
    1.33 +  if (!plugin)
    1.34 +    do_throw("Plugin tag not found");
    1.35 +
    1.36 +  //run the code after the blocklist is closed
    1.37 +  Services.obs.notifyObservers(null, "addon-blocklist-closed", null);
    1.38 +  do_execute_soon(function() {
    1.39 +    // should be marked as outdated by the blocklist
    1.40 +    do_check_true(blocklist.getPluginBlocklistState(plugin, "1", "1.9") == nsIBLS.STATE_OUTDATED);
    1.41 +
    1.42 +    // should indicate that a warning should be shown
    1.43 +    do_check_true(prefs.getBoolPref("plugins.update.notifyUser"));
    1.44 +  });
    1.45 +}

mercurial