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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/
     3  */
     5 // This verifies that the targetPlatform entries are checked when deciding
     6 // if an add-on is incompatible.
     8 // No targetPlatforms so should be compatible
     9 var addon1 = {
    10   id: "addon1@tests.mozilla.org",
    11   version: "1.0",
    12   name: "Test 1",
    13   targetApplications: [{
    14     id: "xpcshell@tests.mozilla.org",
    15     minVersion: "1",
    16     maxVersion: "1"
    17   }]
    18 };
    20 // Matches the OS
    21 var addon2 = {
    22   id: "addon2@tests.mozilla.org",
    23   version: "1.0",
    24   name: "Test 2",
    25   targetPlatforms: [
    26     "XPCShell",
    27     "WINNT_x86",
    28     "XPCShell"
    29   ],
    30   targetApplications: [{
    31     id: "xpcshell@tests.mozilla.org",
    32     minVersion: "1",
    33     maxVersion: "1"
    34   }]
    35 };
    37 // Matches the OS and ABI
    38 var addon3 = {
    39   id: "addon3@tests.mozilla.org",
    40   version: "1.0",
    41   name: "Test 3",
    42   targetPlatforms: [
    43     "WINNT",
    44     "XPCShell_noarch-spidermonkey"
    45   ],
    46   targetApplications: [{
    47     id: "xpcshell@tests.mozilla.org",
    48     minVersion: "1",
    49     maxVersion: "1"
    50   }]
    51 };
    53 // Doesn't match
    54 var addon4 = {
    55   id: "addon4@tests.mozilla.org",
    56   version: "1.0",
    57   name: "Test 4",
    58   targetPlatforms: [
    59     "WINNT_noarch-spidermonkey",
    60     "Darwin",
    61     "WINNT_noarch-spidermonkey"
    62   ],
    63   targetApplications: [{
    64     id: "xpcshell@tests.mozilla.org",
    65     minVersion: "1",
    66     maxVersion: "1"
    67   }]
    68 };
    70 // Matches the OS but since a different entry specifies ABI this doesn't match.
    71 var addon5 = {
    72   id: "addon5@tests.mozilla.org",
    73   version: "1.0",
    74   name: "Test 5",
    75   targetPlatforms: [
    76     "XPCShell",
    77     "XPCShell_foo"
    78   ],
    79   targetApplications: [{
    80     id: "xpcshell@tests.mozilla.org",
    81     minVersion: "1",
    82     maxVersion: "1"
    83   }]
    84 };
    86 createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
    88 const profileDir = gProfD.clone();
    89 profileDir.append("extensions");
    91 // Set up the profile
    92 function run_test() {
    93   do_test_pending();
    95   writeInstallRDFForExtension(addon1, profileDir);
    96   writeInstallRDFForExtension(addon2, profileDir);
    97   writeInstallRDFForExtension(addon3, profileDir);
    98   writeInstallRDFForExtension(addon4, profileDir);
    99   writeInstallRDFForExtension(addon5, profileDir);
   101   restartManager();
   102   AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
   103                                "addon2@tests.mozilla.org",
   104                                "addon3@tests.mozilla.org",
   105                                "addon4@tests.mozilla.org",
   106                                "addon5@tests.mozilla.org"],
   107                                function([a1, a2, a3, a4, a5]) {
   109     do_check_neq(a1, null);
   110     do_check_false(a1.appDisabled);
   111     do_check_true(a1.isPlatformCompatible);
   112     do_check_true(a1.isActive);
   113     do_check_true(isExtensionInAddonsList(profileDir, a1.id));
   114     do_check_in_crash_annotation(addon1.id, addon1.version);
   116     do_check_neq(a2, null);
   117     do_check_false(a2.appDisabled);
   118     do_check_true(a2.isPlatformCompatible);
   119     do_check_true(a2.isActive);
   120     do_check_true(isExtensionInAddonsList(profileDir, a2.id));
   121     do_check_in_crash_annotation(addon2.id, addon2.version);
   123     do_check_neq(a3, null);
   124     do_check_false(a3.appDisabled);
   125     do_check_true(a3.isPlatformCompatible);
   126     do_check_true(a3.isActive);
   127     do_check_true(isExtensionInAddonsList(profileDir, a3.id));
   128     do_check_in_crash_annotation(addon3.id, addon3.version);
   130     do_check_neq(a4, null);
   131     do_check_true(a4.appDisabled);
   132     do_check_false(a4.isPlatformCompatible);
   133     do_check_false(a4.isActive);
   134     do_check_false(isExtensionInAddonsList(profileDir, a4.id));
   135     do_check_not_in_crash_annotation(addon4.id, addon4.version);
   137     do_check_neq(a5, null);
   138     do_check_true(a5.appDisabled);
   139     do_check_false(a5.isPlatformCompatible);
   140     do_check_false(a5.isActive);
   141     do_check_false(isExtensionInAddonsList(profileDir, a5.id));
   142     do_check_not_in_crash_annotation(addon5.id, addon5.version);
   144     do_execute_soon(do_test_finished);
   145   });
   146 }

mercurial