gecko/dom/tests/mochitest/localstorage/pbSwitch.js
Gijs Kruitbosch 41ba1acfa5 Back out bug 487059, fix tests and EM to cope, r=gavin,beltzner, bug 524995
--HG--
extra : rebase_source : d8414b8de165cf2fa534719c36416d82d21872c6
2009-10-29 14:44:10 +01:00

41 lines
1.0 KiB
JavaScript

var _PBSvc = null;
function get_PBSvc()
{
if (_PBSvc)
return _PBSvc;
try {
_PBSvc = Components.classes["@mozilla.org/privatebrowsing;1"].
getService(Components.interfaces.nsIPrivateBrowsingService);
return _PBSvc;
}
catch (ex) {
}
return null;
}
function enterPrivateBrowsing()
{
if (get_PBSvc()) {
var prefBranch = Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefBranch);
prefBranch.setBoolPref("browser.privatebrowsing.keep_current_session", true);
get_PBSvc().privateBrowsingEnabled = true;
}
}
function leavePrivateBrowsing()
{
if (get_PBSvc()) {
get_PBSvc().privateBrowsingEnabled = false;
var prefBranch = Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefBranch);
if (prefBranch.prefHasUserValue("browser.privatebrowsing.keep_current_session"))
prefBranch.clearUserPref("browser.privatebrowsing.keep_current_session");
}
}