|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ |
|
3 */ |
|
4 |
|
5 // This verifies that deleting the database from the profile doesn't break |
|
6 // anything |
|
7 |
|
8 const profileDir = gProfD.clone(); |
|
9 profileDir.append("extensions"); |
|
10 |
|
11 // getting an unused port |
|
12 Components.utils.import("resource://testing-common/httpd.js"); |
|
13 let gServer = new HttpServer(); |
|
14 gServer.start(-1); |
|
15 gPort = gServer.identity.primaryPort; |
|
16 |
|
17 function run_test() { |
|
18 createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); |
|
19 |
|
20 writeInstallRDFForExtension({ |
|
21 id: "addon1@tests.mozilla.org", |
|
22 version: "1.0", |
|
23 updateURL: "http://localhost:" + gPort + "/data/test_update.rdf", |
|
24 targetApplications: [{ |
|
25 id: "xpcshell@tests.mozilla.org", |
|
26 minVersion: "1", |
|
27 maxVersion: "1" |
|
28 }], |
|
29 name: "Test Addon 1", |
|
30 }, profileDir); |
|
31 |
|
32 startupManager(); |
|
33 |
|
34 do_test_pending(); |
|
35 |
|
36 run_test_1(); |
|
37 } |
|
38 |
|
39 function end_test() { |
|
40 gServer.stop(do_test_finished); |
|
41 } |
|
42 |
|
43 function run_test_1() { |
|
44 AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(function(a1) { |
|
45 do_check_neq(a1, null); |
|
46 do_check_eq(a1.version, "1.0"); |
|
47 |
|
48 shutdownManager(); |
|
49 |
|
50 gExtensionsJSON.remove(true); |
|
51 |
|
52 do_execute_soon(check_test_1); |
|
53 })); |
|
54 } |
|
55 |
|
56 function check_test_1() { |
|
57 startupManager(false); |
|
58 |
|
59 AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(function(a1) { |
|
60 do_check_neq(a1, null); |
|
61 do_check_eq(a1.version, "1.0"); |
|
62 |
|
63 // due to delayed write, the file may not exist until |
|
64 // after shutdown |
|
65 shutdownManager(); |
|
66 do_check_true(gExtensionsJSON.exists()); |
|
67 do_check_true(gExtensionsJSON.fileSize > 0); |
|
68 |
|
69 end_test(); |
|
70 })); |
|
71 } |