Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | * http://creativecommons.org/publicdomain/zero/1.0/ |
michael@0 | 3 | */ |
michael@0 | 4 | |
michael@0 | 5 | // This verifies that multiple calls to the async API return fully formed |
michael@0 | 6 | // add-ons |
michael@0 | 7 | |
michael@0 | 8 | var addon1 = { |
michael@0 | 9 | id: "addon1@tests.mozilla.org", |
michael@0 | 10 | version: "1.0", |
michael@0 | 11 | name: "Test 1", |
michael@0 | 12 | targetApplications: [{ |
michael@0 | 13 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 14 | minVersion: "1", |
michael@0 | 15 | maxVersion: "1" |
michael@0 | 16 | }] |
michael@0 | 17 | }; |
michael@0 | 18 | |
michael@0 | 19 | const profileDir = gProfD.clone(); |
michael@0 | 20 | profileDir.append("extensions"); |
michael@0 | 21 | |
michael@0 | 22 | var gAddon; |
michael@0 | 23 | |
michael@0 | 24 | // Sets up the profile by installing an add-on. |
michael@0 | 25 | function run_test() { |
michael@0 | 26 | do_test_pending(); |
michael@0 | 27 | |
michael@0 | 28 | createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); |
michael@0 | 29 | |
michael@0 | 30 | writeInstallRDFForExtension(addon1, profileDir); |
michael@0 | 31 | |
michael@0 | 32 | startupManager(); |
michael@0 | 33 | |
michael@0 | 34 | run_test_1(); |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | // Verifies that multiple calls to get an add-on at various stages of execution |
michael@0 | 38 | // return an add-on with a valid name. |
michael@0 | 39 | function run_test_1() { |
michael@0 | 40 | var count = 0; |
michael@0 | 41 | |
michael@0 | 42 | AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) { |
michael@0 | 43 | do_check_neq(a1, null); |
michael@0 | 44 | do_check_eq(a1.name, "Test 1"); |
michael@0 | 45 | |
michael@0 | 46 | if (count == 0) |
michael@0 | 47 | gAddon = a1; |
michael@0 | 48 | else |
michael@0 | 49 | do_check_eq(a1, gAddon); |
michael@0 | 50 | count++; |
michael@0 | 51 | if (count == 4) |
michael@0 | 52 | run_test_2(); |
michael@0 | 53 | }); |
michael@0 | 54 | |
michael@0 | 55 | AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) { |
michael@0 | 56 | do_check_neq(a1, null); |
michael@0 | 57 | do_check_eq(a1.name, "Test 1"); |
michael@0 | 58 | |
michael@0 | 59 | if (count == 0) |
michael@0 | 60 | gAddon = a1; |
michael@0 | 61 | else |
michael@0 | 62 | do_check_eq(a1, gAddon); |
michael@0 | 63 | count++; |
michael@0 | 64 | if (count == 4) |
michael@0 | 65 | run_test_2(); |
michael@0 | 66 | }); |
michael@0 | 67 | |
michael@0 | 68 | do_execute_soon(function() { |
michael@0 | 69 | AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) { |
michael@0 | 70 | do_check_neq(a1, null); |
michael@0 | 71 | do_check_eq(a1.name, "Test 1"); |
michael@0 | 72 | |
michael@0 | 73 | if (count == 0) |
michael@0 | 74 | gAddon = a1; |
michael@0 | 75 | else |
michael@0 | 76 | do_check_eq(a1, gAddon); |
michael@0 | 77 | count++; |
michael@0 | 78 | if (count == 4) |
michael@0 | 79 | run_test_2(); |
michael@0 | 80 | }); |
michael@0 | 81 | }); |
michael@0 | 82 | |
michael@0 | 83 | do_execute_soon(function() { |
michael@0 | 84 | do_execute_soon(function() { |
michael@0 | 85 | AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) { |
michael@0 | 86 | do_check_neq(a1, null); |
michael@0 | 87 | do_check_eq(a1.name, "Test 1"); |
michael@0 | 88 | |
michael@0 | 89 | if (count == 0) |
michael@0 | 90 | gAddon = a1; |
michael@0 | 91 | else |
michael@0 | 92 | do_check_eq(a1, gAddon); |
michael@0 | 93 | count++; |
michael@0 | 94 | if (count == 4) |
michael@0 | 95 | run_test_2(); |
michael@0 | 96 | }); |
michael@0 | 97 | }); |
michael@0 | 98 | }); |
michael@0 | 99 | } |
michael@0 | 100 | |
michael@0 | 101 | // Verifies that a subsequent call gets the same add-on from the cache |
michael@0 | 102 | function run_test_2() { |
michael@0 | 103 | AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) { |
michael@0 | 104 | do_check_neq(a1, null); |
michael@0 | 105 | do_check_eq(a1.name, "Test 1"); |
michael@0 | 106 | |
michael@0 | 107 | do_check_eq(a1, gAddon); |
michael@0 | 108 | |
michael@0 | 109 | do_execute_soon(do_test_finished); |
michael@0 | 110 | }); |
michael@0 | 111 | |
michael@0 | 112 | } |