mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
b3dd358267
- Bug 1247362 - move mAnonymousGlobalScope tracing into nsMessageManagerScriptExecutor; r=mccr8 (9b33b54bc9)
- Bug 1195881 - Contextual Identity working under e10s. r=tanvi r=sicking r=baku (b3fd69bd92)
- Bug 1174624 - Add the Transferable parameter into SendAsyncMessage of nsFrameMessageManager. r=baku (33911dc6f7)
- Bug 1174624 - Add PortIdentifier copy code in order to communicate with same process. r=baku (d597f24e20)
- Bug 1234176 - Do not send memory pressure events to applications sent into the background. r=dhylands (687f154573)
- Bug 1201394 - Remove unused mLRUPoolSize member variable. r=gsvelto (a109934b8d)
- Bug 1144132 follow up to fix static check build bustage on a CLOSED TREE with r=me (050f49060e)
- Bug 1153394 - make HangMonitorChild::sInstance an atomic variable; r=billm (89e6905f3f)
- Bug 1202952 - Fix directory picking for e10s on Windows by making FilePickerParent use the correct nsIFilePicker API for directory picking. r=roc (a7e964d4fa)
- Bug 1227312 - Avoid calling FinalizeChildData twice in GenerateCompleteMinidump. r=ted (c29e6786ae)
- Bug 1222109 - Initialize mHasGamepadListener in InitializeMembers(); r=cleu (8057137e5d)
- Bug 1231498 - ContentParent::RecvCreateWindow() should fail in opt builds if passed bad chromeflags. r=billm (639fb93101)
- minor indentation (f5dbd8996c)
- fix misspatch (3b306e0084)
- Bug 1101264: Truncate long sourceName messages since they can be massive data: URLs. r=bent (c528048e58)
- Bug 1233497 - Update test_bug1086684.html to not access CPOWs unsafely inside SpecialPowers. r=mrbkap (d5d161eac2)
- align tests (24d98036dc)
- Bug 1232931 Return null instead of throwing if swm.getWorkerByID() cannot find the worker. r=ochameau IGNORE IDL for comment only change (17f293f323)
- Bug 1186812 (part 3) - Replace nsBaseHashtable::EnumerateRead() calls in dom/{ipc,plugins}/. r=jimm. (a944fa4480)
- Bug 1234656 - Add TouchEvent ctor, r=mbrubeck (842245df14)
- Bug 1246854 - Remove unnecessary warning. r=botond (7d0532e516)
- Bug 1245393 - Measure s{,Default}RootBranch in the Preferences memory reporter. r=froydnj. (be200f9ebe)
- Bug 1089232 - Updates nsContentPrefService to take an extra isPrivate argument. r=adw (9ea4fe075d)
- Bug 1229519: Fix toolkit/components/contentprefs to pass eslint checks. r=mconley (e48b64448b)
- Bug 663570 - MetaCSP Part 6: CSP preload changes (r=sicking) (65700820c1)
- Bug 1030936 - [CSP] remove fast-path for certified apps once the C++ backend is activated. r=ckerschb (e9527e9cfc)
- Bug 1228497 - initialize 3 members in class. r=christophkerschbaumer (44414e8429)
- Bug 1208946 - Strip URIs in CSP reports (r=dveditz) (dd6c18a8ff)
- Bug 1247464 - Run CSP report URIs through the URL classifier. r=ckerschb (ebb3570172)
- Bug 1242909, r=ckerschb (569de89b26)
- Bug 1119565: Ensure that a plugin listener's stream type is always set, even when it is STREAM_TYPE_UNKNOWN; r=jimm (43fb9ebdb9)
- Bug 1228116 - Relax Security checks for DTD loads. r=sicking (b77e2c4531)
- Bug 1195173 - Use channel->ascynOpen2 layout/style/Loader.cpp (r=bz) (97de97b864)
- let-var (fb35f8f50c)
- Bug 1226324 - Do not use NS_ENSURCE_SUCCESS(rv, NS_OK) within nsContentSecurityManager. r=tanvi (745ecaf562)
- Bug 1221365 - Tests for "Is origin potentially trustworthy?" logic. r=ckerschb,bkelly (1d520ebcc5)
- Bug 1132211 - Dispatch an event when <input type=password> is added to a document (including outside of a form). r=smaug (3e9acb8bf3)
- Bug 1217766 - All PDFs trigger the insecure password warning. r=MattN,bz (0ea7e35b96)
- Bug 1155471 - Mark some members of nsNodeInfoManager as MOZ_NON_OWNING_REF; r=baku (bd47bcea10)
- Tests for bug 1200856; r=sicking (454ff8048a)
- Bug 1243453 P1 Make nsCORSListenerProxy call UpdateChannel() for internal redirects. r=sicking (f2a45b1997)
- Bug 1243453 P2 Test XHR with a non-intercepting service worker. r=ehsan (d83b31ab3d)
- Bug 1169233 - Get grey (inactive) text color from menu labels. r=karlt (470155483b)
- Bug 1161056 - Gtk3 - use sMozWindowBackground colors for combobox background. r=karlt (4502f5583a)
- Bug 1169232 - [gtk3] Add background class to tooltip window to get correct background color. r=karlt (9421a23b1c)
- Bug 1219717 - Derive text color/background from GtkTextView. r=karlt (a39cd997ee)
- Bug 1241239 - Fix missing 'using mozilla::LogLevel' in nsIdleServiceGTK.cpp. r=karlt (16bacfc530)
- Bug 1209659 - Disable client-side decorations on broken Gtk3 versions (<3.20). r=karlt (d5cbd4c0fb)
- Bug 540078 - Remove assertion annotations that are no longer needed and add crashtest. (89f33bb00c)
- Bug 1168219 - Make nsIWidget::Configuration::mChild a smart pointer on widget/qt too. r=froydnj (0f2f97a31b)
- Bug 1234385: Add downloadable blocklist support for between comparison types, by recognizing driverVersionMax when parsing. r=benwa (87617d0fa1)
- Bug 1112712 - DOM key mapping for soft1 soft2 and call keys r=schien (3f4360e64b)
- Bug 1237691 - Implement Oculus Head Pose Prediction (3f6b0122e3)
- Bug 1041882 - Remove Froyo-specific OMX plugin support. r=snorp (eb2f6dd36a)
- Bug 1205930 - Tighten up warnings handling in media/omx-plugin/. r=gerald. (86845d720a)
- Bug 1153849 - Use MOZ_JPEG_CFLAGS when build libyuv with system jpeg. r=jesup (a38f53057d)
- Bug 1240635 - Interpret glyph x-offsets on SVG vertical text paths in the correct direction. r=longsonr (ce90452da1)
- Bug 1185266 - Look up painting properties on the SVGTextFrame when painting text frames that are direct children of <text>. r=jwatt (9c89ab71eb)
- Bug 1143096 - Init all WebMBufferedParser members - r=kinetik (7df2e4e0c3)
- Bug 1231855 - Avoid inserting out of (timecode) order entries in WebMBufferedParser. r=jya (f7806faec4)
468 lines
18 KiB
JavaScript
468 lines
18 KiB
JavaScript
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
function run_test() {
|
|
//**************************************************************************//
|
|
// Database Creation, Schema Migration, and Backup
|
|
|
|
// Note: in these tests we use createInstance instead of getService
|
|
// so we can instantiate the service multiple times and make it run
|
|
// its database initialization code each time.
|
|
|
|
// Create a new database.
|
|
{
|
|
ContentPrefTest.deleteDatabase();
|
|
|
|
// Get the service and make sure it has a ready database connection.
|
|
let cps = Cc["@mozilla.org/content-pref/service;1"].
|
|
createInstance(Ci.nsIContentPrefService);
|
|
do_check_true(cps.DBConnection.connectionReady);
|
|
cps.DBConnection.close();
|
|
}
|
|
|
|
// Open an existing database.
|
|
{
|
|
let dbFile = ContentPrefTest.deleteDatabase();
|
|
|
|
let cps = Cc["@mozilla.org/content-pref/service;1"].
|
|
createInstance(Ci.nsIContentPrefService);
|
|
cps.DBConnection.close();
|
|
do_check_true(dbFile.exists());
|
|
|
|
// Get the service and make sure it has a ready database connection.
|
|
cps = Cc["@mozilla.org/content-pref/service;1"].
|
|
createInstance(Ci.nsIContentPrefService);
|
|
do_check_true(cps.DBConnection.connectionReady);
|
|
cps.DBConnection.close();
|
|
}
|
|
|
|
// Open an empty database.
|
|
{
|
|
let dbFile = ContentPrefTest.deleteDatabase();
|
|
|
|
// Create an empty database.
|
|
let dbService = Cc["@mozilla.org/storage/service;1"].
|
|
getService(Ci.mozIStorageService);
|
|
let dbConnection = dbService.openDatabase(dbFile);
|
|
do_check_eq(dbConnection.schemaVersion, 0);
|
|
dbConnection.close();
|
|
do_check_true(dbFile.exists());
|
|
|
|
// Get the service and make sure it has created the schema.
|
|
let cps = Cc["@mozilla.org/content-pref/service;1"].
|
|
createInstance(Ci.nsIContentPrefService);
|
|
do_check_neq(cps.DBConnection.schemaVersion, 0);
|
|
cps.DBConnection.close();
|
|
}
|
|
|
|
// Open a corrupted database.
|
|
{
|
|
let dbFile = ContentPrefTest.deleteDatabase();
|
|
let backupDBFile = ContentPrefTest.deleteBackupDatabase();
|
|
|
|
// Create a corrupted database.
|
|
let foStream = Cc["@mozilla.org/network/file-output-stream;1"].
|
|
createInstance(Ci.nsIFileOutputStream);
|
|
foStream.init(dbFile, 0x02 | 0x08 | 0x20, 0666, 0);
|
|
let garbageData = "garbage that makes SQLite think the file is corrupted";
|
|
foStream.write(garbageData, garbageData.length);
|
|
foStream.close();
|
|
|
|
// Get the service and make sure it backs up and recreates the database.
|
|
let cps = Cc["@mozilla.org/content-pref/service;1"].
|
|
createInstance(Ci.nsIContentPrefService);
|
|
do_check_true(backupDBFile.exists());
|
|
do_check_true(cps.DBConnection.connectionReady);
|
|
|
|
cps.DBConnection.close();
|
|
}
|
|
|
|
// Open a database with a corrupted schema.
|
|
{
|
|
let dbFile = ContentPrefTest.deleteDatabase();
|
|
let backupDBFile = ContentPrefTest.deleteBackupDatabase();
|
|
|
|
// Create an empty database and set the schema version to a number
|
|
// that will trigger a schema migration that will fail.
|
|
let dbService = Cc["@mozilla.org/storage/service;1"].
|
|
getService(Ci.mozIStorageService);
|
|
let dbConnection = dbService.openDatabase(dbFile);
|
|
dbConnection.schemaVersion = -1;
|
|
dbConnection.close();
|
|
do_check_true(dbFile.exists());
|
|
|
|
// Get the service and make sure it backs up and recreates the database.
|
|
let cps = Cc["@mozilla.org/content-pref/service;1"].
|
|
createInstance(Ci.nsIContentPrefService);
|
|
do_check_true(backupDBFile.exists());
|
|
do_check_true(cps.DBConnection.connectionReady);
|
|
|
|
cps.DBConnection.close();
|
|
}
|
|
|
|
|
|
// Now get the content pref service for real for use by the rest of the tests.
|
|
let cps = new ContentPrefInstance(null);
|
|
|
|
var uri = ContentPrefTest.getURI("http://www.example.com/");
|
|
|
|
// Make sure disk synchronization checking is turned off by default.
|
|
var statement = cps.DBConnection.createStatement("PRAGMA synchronous");
|
|
statement.executeStep();
|
|
do_check_eq(0, statement.getInt32(0));
|
|
|
|
//**************************************************************************//
|
|
// Nonexistent Pref
|
|
|
|
do_check_eq(cps.getPref(uri, "test.nonexistent.getPref"), undefined);
|
|
do_check_eq(cps.setPref(uri, "test.nonexistent.setPref", 5), undefined);
|
|
do_check_false(cps.hasPref(uri, "test.nonexistent.hasPref"));
|
|
do_check_eq(cps.removePref(uri, "test.nonexistent.removePref"), undefined);
|
|
|
|
|
|
//**************************************************************************//
|
|
// Existing Pref
|
|
|
|
cps.setPref(uri, "test.existing", 5);
|
|
|
|
// getPref should return the pref value
|
|
do_check_eq(cps.getPref(uri, "test.existing"), 5);
|
|
|
|
// setPref should return undefined and change the value of the pref
|
|
do_check_eq(cps.setPref(uri, "test.existing", 6), undefined);
|
|
do_check_eq(cps.getPref(uri, "test.existing"), 6);
|
|
|
|
// hasPref should return true
|
|
do_check_true(cps.hasPref(uri, "test.existing"));
|
|
|
|
// removePref should return undefined and remove the pref
|
|
do_check_eq(cps.removePref(uri, "test.existing"), undefined);
|
|
do_check_false(cps.hasPref(uri, "test.existing"));
|
|
|
|
|
|
//**************************************************************************//
|
|
// Round-Trip Data Integrity
|
|
|
|
// Make sure pref values remain the same from setPref to getPref.
|
|
|
|
cps.setPref(uri, "test.data-integrity.integer", 5);
|
|
do_check_eq(cps.getPref(uri, "test.data-integrity.integer"), 5);
|
|
|
|
cps.setPref(uri, "test.data-integrity.float", 5.5);
|
|
do_check_eq(cps.getPref(uri, "test.data-integrity.float"), 5.5);
|
|
|
|
cps.setPref(uri, "test.data-integrity.boolean", true);
|
|
do_check_eq(cps.getPref(uri, "test.data-integrity.boolean"), true);
|
|
|
|
cps.setPref(uri, "test.data-integrity.string", "test");
|
|
do_check_eq(cps.getPref(uri, "test.data-integrity.string"), "test");
|
|
|
|
cps.setPref(uri, "test.data-integrity.null", null);
|
|
do_check_eq(cps.getPref(uri, "test.data-integrity.null"), null);
|
|
|
|
// XXX Test arbitrary binary data.
|
|
|
|
// Make sure hasPref and removePref work on all data types.
|
|
|
|
do_check_true(cps.hasPref(uri, "test.data-integrity.integer"));
|
|
do_check_true(cps.hasPref(uri, "test.data-integrity.float"));
|
|
do_check_true(cps.hasPref(uri, "test.data-integrity.boolean"));
|
|
do_check_true(cps.hasPref(uri, "test.data-integrity.string"));
|
|
do_check_true(cps.hasPref(uri, "test.data-integrity.null"));
|
|
|
|
do_check_eq(cps.removePref(uri, "test.data-integrity.integer"), undefined);
|
|
do_check_eq(cps.removePref(uri, "test.data-integrity.float"), undefined);
|
|
do_check_eq(cps.removePref(uri, "test.data-integrity.boolean"), undefined);
|
|
do_check_eq(cps.removePref(uri, "test.data-integrity.string"), undefined);
|
|
do_check_eq(cps.removePref(uri, "test.data-integrity.null"), undefined);
|
|
|
|
do_check_false(cps.hasPref(uri, "test.data-integrity.integer"));
|
|
do_check_false(cps.hasPref(uri, "test.data-integrity.float"));
|
|
do_check_false(cps.hasPref(uri, "test.data-integrity.boolean"));
|
|
do_check_false(cps.hasPref(uri, "test.data-integrity.string"));
|
|
do_check_false(cps.hasPref(uri, "test.data-integrity.null"));
|
|
|
|
|
|
//**************************************************************************//
|
|
// getPrefs
|
|
|
|
cps.setPref(uri, "test.getPrefs.a", 1);
|
|
cps.setPref(uri, "test.getPrefs.b", 2);
|
|
cps.setPref(uri, "test.getPrefs.c", 3);
|
|
|
|
var prefs = cps.getPrefs(uri);
|
|
do_check_true(prefs.hasKey("test.getPrefs.a"));
|
|
do_check_eq(prefs.get("test.getPrefs.a"), 1);
|
|
do_check_true(prefs.hasKey("test.getPrefs.b"));
|
|
do_check_eq(prefs.get("test.getPrefs.b"), 2);
|
|
do_check_true(prefs.hasKey("test.getPrefs.c"));
|
|
do_check_eq(prefs.get("test.getPrefs.c"), 3);
|
|
|
|
|
|
//**************************************************************************//
|
|
// Site-Specificity
|
|
|
|
// These are all different sites, and setting a pref for one of them
|
|
// shouldn't set it for the others.
|
|
var uri1 = ContentPrefTest.getURI("http://www.domain1.com/");
|
|
var uri2 = ContentPrefTest.getURI("http://foo.domain1.com/");
|
|
var uri3 = ContentPrefTest.getURI("http://domain1.com/");
|
|
var uri4 = ContentPrefTest.getURI("http://www.domain2.com/");
|
|
|
|
cps.setPref(uri1, "test.site-specificity.uri1", 5);
|
|
do_check_false(cps.hasPref(uri2, "test.site-specificity.uri1"));
|
|
do_check_false(cps.hasPref(uri3, "test.site-specificity.uri1"));
|
|
do_check_false(cps.hasPref(uri4, "test.site-specificity.uri1"));
|
|
|
|
cps.setPref(uri2, "test.site-specificity.uri2", 5);
|
|
do_check_false(cps.hasPref(uri1, "test.site-specificity.uri2"));
|
|
do_check_false(cps.hasPref(uri3, "test.site-specificity.uri2"));
|
|
do_check_false(cps.hasPref(uri4, "test.site-specificity.uri2"));
|
|
|
|
cps.setPref(uri3, "test.site-specificity.uri3", 5);
|
|
do_check_false(cps.hasPref(uri1, "test.site-specificity.uri3"));
|
|
do_check_false(cps.hasPref(uri2, "test.site-specificity.uri3"));
|
|
do_check_false(cps.hasPref(uri4, "test.site-specificity.uri3"));
|
|
|
|
cps.setPref(uri4, "test.site-specificity.uri4", 5);
|
|
do_check_false(cps.hasPref(uri1, "test.site-specificity.uri4"));
|
|
do_check_false(cps.hasPref(uri2, "test.site-specificity.uri4"));
|
|
do_check_false(cps.hasPref(uri3, "test.site-specificity.uri4"));
|
|
|
|
|
|
//**************************************************************************//
|
|
// Observers
|
|
|
|
var specificObserver = {
|
|
interfaces: [Ci.nsIContentPrefObserver, Ci.nsISupports],
|
|
|
|
QueryInterface: function ContentPrefTest_QueryInterface(iid) {
|
|
if (!this.interfaces.some( function(v) { return iid.equals(v) } ))
|
|
throw Cr.NS_ERROR_NO_INTERFACE;
|
|
return this;
|
|
},
|
|
|
|
numTimesSetCalled: 0,
|
|
onContentPrefSet: function specificObserver_onContentPrefSet(group, name, value) {
|
|
++this.numTimesSetCalled;
|
|
do_check_eq(group, "www.example.com");
|
|
do_check_eq(name, "test.observer.1");
|
|
do_check_eq(value, "test value");
|
|
},
|
|
|
|
numTimesRemovedCalled: 0,
|
|
onContentPrefRemoved: function specificObserver_onContentPrefRemoved(group, name) {
|
|
++this.numTimesRemovedCalled;
|
|
do_check_eq(group, "www.example.com");
|
|
do_check_eq(name, "test.observer.1");
|
|
}
|
|
|
|
};
|
|
|
|
var genericObserver = {
|
|
interfaces: [Ci.nsIContentPrefObserver, Ci.nsISupports],
|
|
|
|
QueryInterface: function ContentPrefTest_QueryInterface(iid) {
|
|
if (!this.interfaces.some( function(v) { return iid.equals(v) } ))
|
|
throw Cr.NS_ERROR_NO_INTERFACE;
|
|
return this;
|
|
},
|
|
|
|
numTimesSetCalled: 0,
|
|
onContentPrefSet: function genericObserver_onContentPrefSet(group, name, value, isPrivate) {
|
|
++this.numTimesSetCalled;
|
|
do_check_eq(group, "www.example.com");
|
|
if (name == "test.observer.private")
|
|
do_check_true(isPrivate);
|
|
else if (name == "test.observer.normal")
|
|
do_check_false(isPrivate);
|
|
else if (name != "test.observer.1" && name != "test.observer.2")
|
|
do_throw("genericObserver.onContentPrefSet: " +
|
|
"name not in (test.observer.(1|2|normal|private))");
|
|
do_check_eq(value, "test value");
|
|
},
|
|
|
|
numTimesRemovedCalled: 0,
|
|
onContentPrefRemoved: function genericObserver_onContentPrefRemoved(group, name) {
|
|
++this.numTimesRemovedCalled;
|
|
do_check_eq(group, "www.example.com");
|
|
if (name != "test.observer.1" && name != "test.observer.2" &&
|
|
name != "test.observer.normal" && name != "test.observer.private") {
|
|
do_throw("genericObserver.onContentPrefSet: " +
|
|
"name not in (test.observer.(1|2|normal|private))");
|
|
}
|
|
}
|
|
|
|
};
|
|
|
|
// Make sure we can add observers, observers get notified about changes,
|
|
// specific observers only get notified about changes to the specific setting,
|
|
// and generic observers get notified about changes to all settings.
|
|
cps.addObserver("test.observer.1", specificObserver);
|
|
cps.addObserver(null, genericObserver);
|
|
cps.setPref(uri, "test.observer.1", "test value");
|
|
cps.setPref(uri, "test.observer.2", "test value");
|
|
cps.removePref(uri, "test.observer.1");
|
|
cps.removePref(uri, "test.observer.2");
|
|
do_check_eq(specificObserver.numTimesSetCalled, 1);
|
|
do_check_eq(genericObserver.numTimesSetCalled, 2);
|
|
do_check_eq(specificObserver.numTimesRemovedCalled, 1);
|
|
do_check_eq(genericObserver.numTimesRemovedCalled, 2);
|
|
|
|
// // Make sure information about private context is properly
|
|
// // retrieved by the observer.
|
|
cps.setPref(uri, "test.observer.private", "test value", {usePrivateBrowsing: true});
|
|
cps.setPref(uri, "test.observer.normal", "test value", {usePrivateBrowsing: false});
|
|
cps.removePref(uri, "test.observer.private");
|
|
cps.removePref(uri, "test.observer.normal");
|
|
|
|
// Make sure we can remove observers and they don't get notified
|
|
// about changes anymore.
|
|
cps.removeObserver("test.observer.1", specificObserver);
|
|
cps.removeObserver(null, genericObserver);
|
|
cps.setPref(uri, "test.observer.1", "test value");
|
|
cps.removePref(uri, "test.observer.1", "test value");
|
|
do_check_eq(specificObserver.numTimesSetCalled, 1);
|
|
do_check_eq(genericObserver.numTimesSetCalled, 4);
|
|
do_check_eq(specificObserver.numTimesRemovedCalled, 1);
|
|
do_check_eq(genericObserver.numTimesRemovedCalled, 3);
|
|
|
|
|
|
//**************************************************************************//
|
|
// Get/Remove Prefs By Name
|
|
|
|
{
|
|
var anObserver = {
|
|
interfaces: [Ci.nsIContentPrefObserver, Ci.nsISupports],
|
|
|
|
QueryInterface: function ContentPrefTest_QueryInterface(iid) {
|
|
if (!this.interfaces.some( function(v) { return iid.equals(v) } ))
|
|
throw Cr.NS_ERROR_NO_INTERFACE;
|
|
return this;
|
|
},
|
|
|
|
onContentPrefSet: function anObserver_onContentPrefSet(group, name, value) {
|
|
},
|
|
|
|
expectedDomains: [],
|
|
numTimesRemovedCalled: 0,
|
|
onContentPrefRemoved: function anObserver_onContentPrefRemoved(group, name) {
|
|
++this.numTimesRemovedCalled;
|
|
|
|
// remove the domain from the list of expected domains
|
|
var index = this.expectedDomains.indexOf(group);
|
|
do_check_true(index >= 0);
|
|
this.expectedDomains.splice(index, 1);
|
|
}
|
|
};
|
|
|
|
let uri1 = ContentPrefTest.getURI("http://www.domain1.com/");
|
|
let uri2 = ContentPrefTest.getURI("http://foo.domain1.com/");
|
|
let uri3 = ContentPrefTest.getURI("http://domain1.com/");
|
|
let uri4 = ContentPrefTest.getURI("http://www.domain2.com/");
|
|
|
|
cps.setPref(uri1, "test.byname.1", 1);
|
|
cps.setPref(uri1, "test.byname.2", 2);
|
|
cps.setPref(uri2, "test.byname.1", 4);
|
|
cps.setPref(uri3, "test.byname.3", 8);
|
|
cps.setPref(uri4, "test.byname.1", 16);
|
|
cps.setPref(null, "test.byname.1", 32);
|
|
cps.setPref(null, "test.byname.2", false);
|
|
|
|
function enumerateAndCheck(testName, expectedSum, expectedDomains) {
|
|
var prefsByName = cps.getPrefsByName(testName);
|
|
var enumerator = prefsByName.enumerator;
|
|
var sum = 0;
|
|
while (enumerator.hasMoreElements()) {
|
|
var property = enumerator.getNext().QueryInterface(Components.interfaces.nsIProperty);
|
|
sum += parseInt(property.value);
|
|
|
|
// remove the domain from the list of expected domains
|
|
var index = expectedDomains.indexOf(property.name);
|
|
do_check_true(index >= 0);
|
|
expectedDomains.splice(index, 1);
|
|
}
|
|
do_check_eq(sum, expectedSum);
|
|
// check all domains have been removed from the array
|
|
do_check_eq(expectedDomains.length, 0);
|
|
}
|
|
|
|
enumerateAndCheck("test.byname.1", 53,
|
|
["foo.domain1.com", null, "www.domain1.com", "www.domain2.com"]);
|
|
enumerateAndCheck("test.byname.2", 2, ["www.domain1.com", null]);
|
|
enumerateAndCheck("test.byname.3", 8, ["domain1.com"]);
|
|
|
|
cps.addObserver("test.byname.1", anObserver);
|
|
anObserver.expectedDomains = ["foo.domain1.com", null, "www.domain1.com", "www.domain2.com"];
|
|
|
|
cps.removePrefsByName("test.byname.1");
|
|
do_check_false(cps.hasPref(uri1, "test.byname.1"));
|
|
do_check_false(cps.hasPref(uri2, "test.byname.1"));
|
|
do_check_false(cps.hasPref(uri3, "test.byname.1"));
|
|
do_check_false(cps.hasPref(uri4, "test.byname.1"));
|
|
do_check_false(cps.hasPref(null, "test.byname.1"));
|
|
do_check_true(cps.hasPref(uri1, "test.byname.2"));
|
|
do_check_true(cps.hasPref(uri3, "test.byname.3"));
|
|
|
|
do_check_eq(anObserver.numTimesRemovedCalled, 4);
|
|
do_check_eq(anObserver.expectedDomains.length, 0);
|
|
|
|
cps.removeObserver("test.byname.1", anObserver);
|
|
|
|
// Clean up after ourselves
|
|
cps.removePref(uri1, "test.byname.2");
|
|
cps.removePref(uri3, "test.byname.3");
|
|
cps.removePref(null, "test.byname.2");
|
|
}
|
|
|
|
|
|
//**************************************************************************//
|
|
// Clear Private Data Pref Removal
|
|
|
|
{
|
|
let uri1 = ContentPrefTest.getURI("http://www.domain1.com/");
|
|
let uri2 = ContentPrefTest.getURI("http://www.domain2.com/");
|
|
let uri3 = ContentPrefTest.getURI("http://www.domain3.com/");
|
|
|
|
let dbConnection = cps.DBConnection;
|
|
|
|
let prefCount = dbConnection.createStatement("SELECT COUNT(*) AS count FROM prefs");
|
|
|
|
let groupCount = dbConnection.createStatement("SELECT COUNT(*) AS count FROM groups");
|
|
|
|
// Add some prefs for multiple domains.
|
|
cps.setPref(uri1, "test.removeAllGroups", 1);
|
|
cps.setPref(uri2, "test.removeAllGroups", 2);
|
|
cps.setPref(uri3, "test.removeAllGroups", 3);
|
|
|
|
// Add a global pref.
|
|
cps.setPref(null, "test.removeAllGroups", 1);
|
|
|
|
// Make sure there are some prefs and groups in the database.
|
|
prefCount.executeStep();
|
|
do_check_true(prefCount.row.count > 0);
|
|
prefCount.reset();
|
|
groupCount.executeStep();
|
|
do_check_true(groupCount.row.count > 0);
|
|
groupCount.reset();
|
|
|
|
// Remove all prefs and groups from the database using the same routine
|
|
// the Clear Private Data dialog uses.
|
|
cps.removeGroupedPrefs();
|
|
|
|
// Make sure there are no longer any groups in the database and the only pref
|
|
// is the global one.
|
|
prefCount.executeStep();
|
|
do_check_true(prefCount.row.count == 1);
|
|
prefCount.reset();
|
|
groupCount.executeStep();
|
|
do_check_true(groupCount.row.count == 0);
|
|
groupCount.reset();
|
|
let globalPref = dbConnection.createStatement("SELECT groupID FROM prefs");
|
|
globalPref.executeStep();
|
|
do_check_true(globalPref.row.groupID == null);
|
|
globalPref.reset();
|
|
}
|
|
}
|