|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
|
4 */ |
|
5 |
|
6 // Disables security checking our updates which haven't been signed |
|
7 Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false); |
|
8 |
|
9 Components.utils.import("resource://testing-common/httpd.js"); |
|
10 var server; |
|
11 |
|
12 // nsIAddonUpdateCheckListener implementation |
|
13 var updateListener = { |
|
14 _count: 0, |
|
15 |
|
16 onUpdateAvailable: function onAddonUpdateEnded(aAddon, aInstall) { |
|
17 do_check_eq(aInstall.version, 10); |
|
18 }, |
|
19 |
|
20 onNoUpdateAvailable: function onNoUpdateAvailable(aAddon) { |
|
21 do_throw("Expected an available update for " + aAddon.id); |
|
22 }, |
|
23 |
|
24 onUpdateFinished: function onUpdateFinished() { |
|
25 if (++this._count == 2) |
|
26 server.stop(do_test_finished); |
|
27 }, |
|
28 } |
|
29 |
|
30 function run_test() |
|
31 { |
|
32 // Setup for test |
|
33 do_test_pending(); |
|
34 createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9"); |
|
35 startupManager(); |
|
36 |
|
37 installAllFiles([do_get_addon("test_bug394300_1"), |
|
38 do_get_addon("test_bug394300_2")], function() { |
|
39 |
|
40 restartManager(); |
|
41 |
|
42 AddonManager.getAddonsByIDs(["bug394300_1@tests.mozilla.org", |
|
43 "bug394300_2@tests.mozilla.org"], function(updates) { |
|
44 |
|
45 do_check_neq(updates[0], null); |
|
46 do_check_neq(updates[1], null); |
|
47 |
|
48 server = new HttpServer(); |
|
49 server.registerDirectory("/", do_get_file("data")); |
|
50 server.start(4444); |
|
51 |
|
52 updates[0].findUpdates(updateListener, AddonManager.UPDATE_WHEN_USER_REQUESTED); |
|
53 updates[1].findUpdates(updateListener, AddonManager.UPDATE_WHEN_USER_REQUESTED); |
|
54 }); |
|
55 }); |
|
56 } |