mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 248970 - Private Browsing mode (global toggle for saving/caching everything) [unit test API changes]; r,sr=mconnor
This commit is contained in:
parent
99e40e800f
commit
4770654ff7
@ -55,24 +55,6 @@ function get_privatebrowsing_service() {
|
||||
try {
|
||||
_PBSvc = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
if (_PBSvc) {
|
||||
var observer = {
|
||||
QueryInterface: function (iid) {
|
||||
const interfaces = [Ci.nsIObserver,
|
||||
Ci.nsISupports];
|
||||
if (!interfaces.some(function(v) iid.equals(v)))
|
||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||
return this;
|
||||
},
|
||||
observe: function (subject, topic, data) {
|
||||
subject.QueryInterface(Ci.nsISupportsPRUint32);
|
||||
subject.data = 0;
|
||||
}
|
||||
};
|
||||
var os = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
os.addObserver(observer, "private-browsing-enter", false);
|
||||
}
|
||||
return _PBSvc;
|
||||
} catch (e) {}
|
||||
return null;
|
||||
@ -235,6 +217,10 @@ function retrieve_from_cache(aKey, aWhere) {
|
||||
function run_test() {
|
||||
var pb = get_privatebrowsing_service();
|
||||
if (pb) { // Private Browsing might not be available
|
||||
var prefBranch = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefBranch);
|
||||
prefBranch.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
||||
|
||||
const kCacheA = "cache-A",
|
||||
kCacheB = "cache-B",
|
||||
kCacheC = "cache-C",
|
||||
@ -285,5 +271,7 @@ function run_test() {
|
||||
do_check_eq(retrieve_from_cache(kCacheA, kMemoryDevice), null);
|
||||
do_check_eq(retrieve_from_cache(kCacheB, kDiskDevice), kTestContent);
|
||||
do_check_eq(retrieve_from_cache(kCacheC, kOfflineDevice), kTestContent);
|
||||
|
||||
prefBranch.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
}
|
||||
}
|
||||
|
@ -43,24 +43,6 @@ function get_PBSvc() {
|
||||
try {
|
||||
_PBSvc = Components.classes["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Components.interfaces.nsIPrivateBrowsingService);
|
||||
if (_PBSvc) {
|
||||
var observer = {
|
||||
QueryInterface: function (iid) {
|
||||
const interfaces = [Components.interfaces.nsIObserver,
|
||||
Components.interfaces.nsISupports];
|
||||
if (!interfaces.some(function(v) iid.equals(v)))
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
return this;
|
||||
},
|
||||
observe: function (subject, topic, data) {
|
||||
subject.QueryInterface(Components.interfaces.nsISupportsPRUint32);
|
||||
subject.data = 0;
|
||||
}
|
||||
};
|
||||
var os = Components.classes["@mozilla.org/observer-service;1"].
|
||||
getService(Components.interfaces.nsIObserverService);
|
||||
os.addObserver(observer, "private-browsing-enter", false);
|
||||
}
|
||||
return _PBSvc;
|
||||
} catch (e) {}
|
||||
return null;
|
||||
@ -126,7 +108,6 @@ function is_cookie_available2(domain, path, name, value,
|
||||
var cc_observer = null;
|
||||
function setup_cookie_changed_observer() {
|
||||
cc_observer = {
|
||||
gotCleared: false,
|
||||
gotReloaded: false,
|
||||
QueryInterface: function (iid) {
|
||||
const interfaces = [Components.interfaces.nsIObserver,
|
||||
@ -138,9 +119,7 @@ function setup_cookie_changed_observer() {
|
||||
observe: function (subject, topic, data) {
|
||||
if (topic == "cookie-changed") {
|
||||
if (!subject) {
|
||||
if (data == "cleared")
|
||||
this.gotCleared = true;
|
||||
else if (data == "reload")
|
||||
if (data == "reload")
|
||||
this.gotReloaded = true;
|
||||
}
|
||||
}
|
||||
@ -154,6 +133,10 @@ function setup_cookie_changed_observer() {
|
||||
function run_test() {
|
||||
var pb = get_PBSvc();
|
||||
if (pb) { // Private Browsing might not be available
|
||||
var prefBranch = Components.classes["@mozilla.org/preferences-service;1"].
|
||||
getService(Components.interfaces.nsIPrefBranch);
|
||||
prefBranch.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
||||
|
||||
var cm = get_CookieManager();
|
||||
do_check_neq(cm, null);
|
||||
|
||||
@ -170,7 +153,8 @@ function run_test() {
|
||||
// enter private browsing mode
|
||||
pb.privateBrowsingEnabled = true;
|
||||
// make sure the "cleared" notification was fired
|
||||
do_check_true(cc_observer.gotCleared);
|
||||
do_check_true(cc_observer.gotReloaded);
|
||||
cc_observer.gotReloaded = false;
|
||||
// make sure Cookie-A is not retrievable
|
||||
do_check_false(is_cookie_available1("pbtest.example.com", "/", "C1", "V1", false, true, false, time));
|
||||
do_check_false(is_cookie_available2("pbtest.example.com", "/", "C1", "V1", false, true, false, time));
|
||||
@ -193,6 +177,7 @@ function run_test() {
|
||||
} catch (e) {
|
||||
do_throw("Unexpected exception while testing cookies: " + e);
|
||||
}
|
||||
|
||||
prefBranch.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
}
|
||||
do_test_finished();
|
||||
}
|
||||
|
@ -43,24 +43,6 @@ function get_PBSvc() {
|
||||
try {
|
||||
_PBSvc = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
if (_PBSvc) {
|
||||
var observer = {
|
||||
QueryInterface: function (iid) {
|
||||
const interfaces = [Ci.nsIObserver,
|
||||
Ci.nsISupports];
|
||||
if (!interfaces.some(function(v) iid.equals(v)))
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
return this;
|
||||
},
|
||||
observe: function (subject, topic, data) {
|
||||
subject.QueryInterface(Ci.nsISupportsPRUint32);
|
||||
subject.data = 0;
|
||||
}
|
||||
};
|
||||
var os = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
os.addObserver(observer, "private-browsing-enter", false);
|
||||
}
|
||||
return _PBSvc;
|
||||
} catch (e) {}
|
||||
return null;
|
||||
@ -78,6 +60,10 @@ function get_ContentPrefs() {
|
||||
function run_test() {
|
||||
var pb = get_PBSvc();
|
||||
if (pb) { // Private Browsing might not be available
|
||||
var prefBranch = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefBranch);
|
||||
prefBranch.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
||||
|
||||
ContentPrefTest.deleteDatabase();
|
||||
var cp = get_ContentPrefs();
|
||||
do_check_neq(cp, null, "Retrieving the content prefs service failed");
|
||||
@ -110,6 +96,7 @@ function run_test() {
|
||||
} catch (e) {
|
||||
do_throw("Unexpected exception: " + e);
|
||||
}
|
||||
|
||||
prefBranch.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
}
|
||||
do_test_finished();
|
||||
}
|
||||
|
@ -189,34 +189,6 @@ function checkTest() {
|
||||
}
|
||||
|
||||
|
||||
// This observer prevents a prompt from showing up asking if the current
|
||||
// session should be kept or closed upon entering the private browsing mode.
|
||||
// It instructs the private browsing service to keep the current session open.
|
||||
var observer = {
|
||||
QueryInterface: function (iid) {
|
||||
const interfaces = [Ci.nsIObserver,
|
||||
Ci.nsISupports];
|
||||
if (!interfaces.some(function(v) iid.equals(v)))
|
||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||
return this;
|
||||
},
|
||||
observe: function (subject, topic, data) {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
subject.QueryInterface(Ci.nsISupportsPRUint32);
|
||||
subject.data = 0;
|
||||
},
|
||||
register: function () {
|
||||
var os = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
os.addObserver(this, "private-browsing-enter", false);
|
||||
},
|
||||
unregister: function () {
|
||||
var os = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
os.removeObserver(this, "private-browsing-enter");
|
||||
}
|
||||
};
|
||||
|
||||
var _PBSvc = null;
|
||||
function get_PBSvc() {
|
||||
if (_PBSvc)
|
||||
@ -258,7 +230,7 @@ function handleLoad(aEvent) {
|
||||
loadNextTest();
|
||||
} else {
|
||||
ok(true, "private browsing notification tests finished.");
|
||||
observer.unregister();
|
||||
prefBranch.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
@ -274,6 +246,10 @@ if (!pb) { // Private Browsing might not be available
|
||||
ok(Ci != null, "Access Ci");
|
||||
ok(Cc != null, "Access Cc");
|
||||
|
||||
var prefBranch = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefBranch);
|
||||
prefBranch.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
||||
|
||||
var pwmgr = Cc["@mozilla.org/login-manager;1"].
|
||||
getService(Ci.nsILoginManager);
|
||||
ok(pwmgr != null, "Access pwmgr");
|
||||
|
@ -87,24 +87,6 @@ function get_PBSvc() {
|
||||
try {
|
||||
_PBSvc = Components.classes["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Components.interfaces.nsIPrivateBrowsingService);
|
||||
if (_PBSvc) {
|
||||
var observer = {
|
||||
QueryInterface: function (iid) {
|
||||
const interfaces = [Components.interfaces.nsIObserver,
|
||||
Components.interfaces.nsISupports];
|
||||
if (!interfaces.some(function(v) iid.equals(v)))
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
return this;
|
||||
},
|
||||
observe: function (subject, topic, data) {
|
||||
subject.QueryInterface(Components.interfaces.nsISupportsPRUint32);
|
||||
subject.data = 0;
|
||||
}
|
||||
};
|
||||
var os = Components.classes["@mozilla.org/observer-service;1"].
|
||||
getService(Components.interfaces.nsIObserverService);
|
||||
os.addObserver(observer, "private-browsing-enter", false);
|
||||
}
|
||||
return _PBSvc;
|
||||
} catch (e) {}
|
||||
return null;
|
||||
@ -276,6 +258,9 @@ function run_test() {
|
||||
var pb = get_PBSvc();
|
||||
|
||||
if(pb){ // Private Browsing might not be available
|
||||
var prefBranch = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefBranch);
|
||||
prefBranch.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
||||
|
||||
// History database should be empty
|
||||
do_check_false(histsvc.hasHistoryEntries);
|
||||
@ -354,5 +339,7 @@ function run_test() {
|
||||
do_check_true(uri_in_db(uri(visited_uri)));
|
||||
do_check_true(bhist.isVisited(uri(visited_uri)));
|
||||
}
|
||||
|
||||
prefBranch.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
}
|
||||
}
|
||||
|
@ -43,24 +43,6 @@ function get_PBSvc() {
|
||||
try {
|
||||
_PBSvc = Components.classes["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Components.interfaces.nsIPrivateBrowsingService);
|
||||
if (_PBSvc) {
|
||||
var observer = {
|
||||
QueryInterface: function (iid) {
|
||||
const interfaces = [Components.interfaces.nsIObserver,
|
||||
Components.interfaces.nsISupports];
|
||||
if (!interfaces.some(function(v) iid.equals(v)))
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
return this;
|
||||
},
|
||||
observe: function (subject, topic, data) {
|
||||
subject.QueryInterface(Components.interfaces.nsISupportsPRUint32);
|
||||
subject.data = 0;
|
||||
}
|
||||
};
|
||||
var os = Components.classes["@mozilla.org/observer-service;1"].
|
||||
getService(Components.interfaces.nsIObserverService);
|
||||
os.addObserver(observer, "private-browsing-enter", false);
|
||||
}
|
||||
return _PBSvc;
|
||||
} catch (e) {}
|
||||
return null;
|
||||
@ -78,6 +60,10 @@ function get_FormHistory() {
|
||||
function run_test() {
|
||||
var pb = get_PBSvc();
|
||||
if (pb) { // Private Browsing might not be available
|
||||
var prefBranch = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefBranch);
|
||||
prefBranch.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
||||
|
||||
var fh = get_FormHistory();
|
||||
do_check_neq(fh, null);
|
||||
|
||||
@ -103,5 +89,7 @@ function run_test() {
|
||||
do_check_true(fh.entryExists("pair-A", "value-A"));
|
||||
// make sure that Pair-B does not exist
|
||||
do_check_false(fh.entryExists("pair-B", "value-B"));
|
||||
|
||||
prefBranch.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user