toolkit/mozapps/extensions/test/xpcshell/test_bug468528.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_bug468528.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,58 @@
     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 nsIBLS = Components.interfaces.nsIBlocklistService;
     1.9 +
    1.10 +var PLUGINS = [{
    1.11 +  // Normal blacklisted plugin, before an invalid regexp
    1.12 +  name: "test_bug468528_1",
    1.13 +  version: "5",
    1.14 +  disabled: false,
    1.15 +  blocklisted: false
    1.16 +},
    1.17 +{
    1.18 +  // Normal blacklisted plugin, with an invalid regexp
    1.19 +  name: "test_bug468528_2",
    1.20 +  version: "5",
    1.21 +  disabled: false,
    1.22 +  blocklisted: false
    1.23 +},
    1.24 +{
    1.25 +  // Normal blacklisted plugin, after an invalid regexp
    1.26 +  name: "test_bug468528_3",
    1.27 +  version: "5",
    1.28 +  disabled: false,
    1.29 +  blocklisted: false
    1.30 +},
    1.31 +{
    1.32 +  // Non-blocklisted plugin
    1.33 +  name: "test_bug468528_4",
    1.34 +  version: "5",
    1.35 +  disabled: false,
    1.36 +  blocklisted: false
    1.37 +}];
    1.38 +
    1.39 +
    1.40 +function run_test() {
    1.41 +  createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
    1.42 +
    1.43 +  // We cannot force the blocklist to update so just copy our test list to the profile
    1.44 +  copyBlocklistToProfile(do_get_file("data/test_bug468528.xml"));
    1.45 +
    1.46 +  var blocklist = Components.classes["@mozilla.org/extensions/blocklist;1"]
    1.47 +                            .getService(nsIBLS);
    1.48 +
    1.49 +  // blocked (sanity check)
    1.50 +  do_check_true(blocklist.getPluginBlocklistState(PLUGINS[0], "1", "1.9") == nsIBLS.STATE_BLOCKED);
    1.51 +
    1.52 +  // not blocked - won't match due to invalid regexp
    1.53 +  do_check_true(blocklist.getPluginBlocklistState(PLUGINS[1], "1", "1.9") == nsIBLS.STATE_NOT_BLOCKED);
    1.54 +  
    1.55 +  // blocked - the invalid regexp for the previous item shouldn't affect this one
    1.56 +  do_check_true(blocklist.getPluginBlocklistState(PLUGINS[2], "1", "1.9") == nsIBLS.STATE_BLOCKED);
    1.57 +
    1.58 +  // not blocked - the previous invalid regexp shouldn't act as a wildcard
    1.59 +  do_check_true(blocklist.getPluginBlocklistState(PLUGINS[3], "1", "1.9") == nsIBLS.STATE_NOT_BLOCKED);
    1.60 +
    1.61 +}

mercurial