Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/
3 */
5 // Checks that we don't migrate data from SQLITE if
6 // the "extensions.databaseSchema" preference shows we've
7 // already upgraded to JSON
9 // Enable loading extensions from the user and system scopes
10 Services.prefs.setIntPref("extensions.enabledScopes",
11 AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_USER +
12 AddonManager.SCOPE_SYSTEM);
14 var addon1 = {
15 id: "addon1@tests.mozilla.org",
16 version: "1.0",
17 name: "Test 1",
18 targetApplications: [{
19 id: "xpcshell@tests.mozilla.org",
20 minVersion: "1",
21 maxVersion: "1"
22 }]
23 };
25 createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
26 const profileDir = gProfD.clone();
27 profileDir.append("extensions");
29 function run_test() {
30 writeInstallRDFForExtension(addon1, profileDir);
32 // Write out a minimal database
33 let dbfile = gProfD.clone();
34 dbfile.append("extensions.sqlite");
35 let db = AM_Cc["@mozilla.org/storage/service;1"].
36 getService(AM_Ci.mozIStorageService).
37 openDatabase(dbfile);
38 db.createTable("addon", "internal_id INTEGER PRIMARY KEY AUTOINCREMENT, " +
39 "id TEXT, location TEXT, version TEXT, active INTEGER, " +
40 "userDisabled INTEGER, installDate INTEGER");
41 db.createTable("targetApplication", "addon_internal_id INTEGER, " +
42 "id TEXT, minVersion TEXT, maxVersion TEXT");
43 let stmt = db.createStatement("INSERT INTO addon VALUES (NULL, :id, :location, " +
44 ":version, :active, :userDisabled, :installDate)");
46 let internal_ids = {};
48 let a = ["addon1@tests.mozilla.org", "app-profile", "1.0", "0", "1", "0"];
49 stmt.params.id = a[0];
50 stmt.params.location = a[1];
51 stmt.params.version = a[2];
52 stmt.params.active = a[3];
53 stmt.params.userDisabled = a[4];
54 stmt.params.installDate = a[5];
55 stmt.execute();
56 internal_ids[a[0]] = db.lastInsertRowID;
57 stmt.finalize();
59 db.schemaVersion = 14;
60 Services.prefs.setIntPref("extensions.databaseSchema", 14);
61 db.close();
63 startupManager();
64 run_next_test();
65 }
67 add_test(function before_rebuild() {
68 AddonManager.getAddonByID("addon1@tests.mozilla.org",
69 function check_before_rebuild (a1) {
70 // First check that it migrated OK once
71 // addon1 was disabled in the database
72 do_check_neq(a1, null);
73 do_check_true(a1.userDisabled);
74 do_check_false(a1.appDisabled);
75 do_check_false(a1.isActive);
76 do_check_false(a1.strictCompatibility);
77 do_check_false(a1.foreignInstall);
79 run_next_test();
80 });
81 });
83 // now shut down, remove the JSON database,
84 // start up again, and make sure the data didn't migrate this time
85 add_test(function rebuild_again() {
86 shutdownManager();
87 gExtensionsJSON.remove(true);
88 startupManager();
90 AddonManager.getAddonByID("addon1@tests.mozilla.org",
91 function check_after_rebuild(a1) {
92 // addon1 was rebuilt from extensions directory,
93 // so it appears enabled as a foreign install
94 do_check_neq(a1, null);
95 do_check_false(a1.userDisabled);
96 do_check_false(a1.appDisabled);
97 do_check_true(a1.isActive);
98 do_check_false(a1.strictCompatibility);
99 do_check_true(a1.foreignInstall);
101 run_next_test();
102 });
103 });