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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | var cps = new ContentPrefInstance(null); |
michael@0 | 6 | |
michael@0 | 7 | function run_test() { |
michael@0 | 8 | var uri1 = ContentPrefTest.getURI("http://www.domain1.com/"); |
michael@0 | 9 | var uri2 = ContentPrefTest.getURI("http://foo.domain1.com/"); |
michael@0 | 10 | var uri3 = ContentPrefTest.getURI("http://domain1.com/"); |
michael@0 | 11 | var uri4 = ContentPrefTest.getURI("http://www.domain2.com/"); |
michael@0 | 12 | |
michael@0 | 13 | cps.setPref(uri1, "one", 1); |
michael@0 | 14 | cps.setPref(uri1, "two", 2); |
michael@0 | 15 | cps.setPref(uri2, "one", 4); |
michael@0 | 16 | cps.setPref(uri3, "three", 8); |
michael@0 | 17 | cps.setPref(uri4, "two", 16); |
michael@0 | 18 | |
michael@0 | 19 | cps.removePref(uri3, "three"); // uri3 should be removed now |
michael@0 | 20 | checkForUnusedGroups(); |
michael@0 | 21 | checkForUnusedSettings(); |
michael@0 | 22 | |
michael@0 | 23 | cps.removePrefsByName("two"); // uri4 should be removed now |
michael@0 | 24 | checkForUnusedGroups(); |
michael@0 | 25 | checkForUnusedSettings(); |
michael@0 | 26 | |
michael@0 | 27 | cps.removeGroupedPrefs(); |
michael@0 | 28 | checkForUnusedGroups(); |
michael@0 | 29 | checkForUnusedSettings(); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | function checkForUnusedGroups() { |
michael@0 | 33 | var stmt = cps.DBConnection.createStatement( |
michael@0 | 34 | "SELECT COUNT(*) AS count FROM groups " + |
michael@0 | 35 | "WHERE id NOT IN (SELECT DISTINCT groupID FROM prefs)" |
michael@0 | 36 | ); |
michael@0 | 37 | stmt.executeStep(); |
michael@0 | 38 | do_check_eq(0, stmt.row.count); |
michael@0 | 39 | stmt.reset(); |
michael@0 | 40 | stmt.finalize(); |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | function checkForUnusedSettings() { |
michael@0 | 44 | var stmt = cps.DBConnection.createStatement( |
michael@0 | 45 | "SELECT COUNT(*) AS count FROM settings " + |
michael@0 | 46 | "WHERE id NOT IN (SELECT DISTINCT settingID FROM prefs)" |
michael@0 | 47 | ); |
michael@0 | 48 | stmt.executeStep(); |
michael@0 | 49 | do_check_eq(0, stmt.row.count); |
michael@0 | 50 | stmt.reset(); |
michael@0 | 51 | stmt.finalize(); |
michael@0 | 52 | } |