mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Merge the removal of global private browsing support
This commit is contained in:
commit
4613c4dee9
@ -172,10 +172,6 @@ let TestPilotSetup = {
|
||||
"testpilot:task:dataAutoSubmitted", this._onTaskDataAutoSubmitted, self);
|
||||
// Set up observation for application shutdown.
|
||||
this._obs.add("quit-application", this.globalShutdown, self);
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
// Set up observation for enter/exit private browsing:
|
||||
this._obs.add("private-browsing", this.onPrivateBrowsingMode, self);
|
||||
#endif
|
||||
|
||||
// Set up timers to remind user x minutes after startup
|
||||
// and once per day thereafter. Use nsITimer so it doesn't belong to
|
||||
@ -245,9 +241,6 @@ let TestPilotSetup = {
|
||||
this._obs.remove(
|
||||
"testpilot:task:dataAutoSubmitted", this._onTaskDataAutoSubmitted, self);
|
||||
this._obs.remove("quit-application", this.globalShutdown, self);
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
this._obs.remove("private-browsing", this.onPrivateBrowsingMode, self);
|
||||
#endif
|
||||
this._loader.unload();
|
||||
this._shortTimer.cancel();
|
||||
this._longTimer.cancel();
|
||||
@ -261,18 +254,6 @@ let TestPilotSetup = {
|
||||
return wm.getMostRecentWindow("navigator:browser");
|
||||
},
|
||||
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
onPrivateBrowsingMode: function TPS_onPrivateBrowsingMode(topic, data) {
|
||||
for (let i = 0; i < this.taskList.length; i++) {
|
||||
if (data == "enter") {
|
||||
this.taskList[i].onEnterPrivateBrowsing();
|
||||
} else if (data == "exit") {
|
||||
this.taskList[i].onExitPrivateBrowsing();
|
||||
}
|
||||
}
|
||||
},
|
||||
#endif
|
||||
|
||||
onWindowUnload: function TPS__onWindowRegistered(window) {
|
||||
this._logger.trace("Called TestPilotSetup.onWindow unload!");
|
||||
for (let i = 0; i < this.taskList.length; i++) {
|
@ -162,14 +162,6 @@ var TestPilotTask = {
|
||||
// Called by extension core when Firefox is shutting down.
|
||||
},
|
||||
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
onEnterPrivateBrowsing: function TestPilotTask_onEnterPrivate() {
|
||||
},
|
||||
|
||||
onExitPrivateBrowsing: function TestPilotTask_onExitPrivate() {
|
||||
},
|
||||
#endif
|
||||
|
||||
onNewWindow: function TestPilotTask_onNewWindow(window) {
|
||||
},
|
||||
|
||||
@ -534,30 +526,6 @@ TestPilotExperiment.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
onEnterPrivateBrowsing: function TestPilotExperiment_onEnterPrivate() {
|
||||
this._logger.trace("Task is entering private browsing.");
|
||||
if (this.experimentIsRunning()) {
|
||||
try {
|
||||
this._handlers.onEnterPrivateBrowsing();
|
||||
} catch(e) {
|
||||
this._dataStore.logException("onEnterPrivateBrowsing: " + e);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onExitPrivateBrowsing: function TestPilotExperiment_onExitPrivate() {
|
||||
this._logger.trace("Task is exiting private browsing.");
|
||||
if (this.experimentIsRunning()) {
|
||||
try {
|
||||
this._handlers.onExitPrivateBrowsing();
|
||||
} catch(e) {
|
||||
this._dataStore.logException("onExitPrivateBrowsing: " + e);
|
||||
}
|
||||
}
|
||||
},
|
||||
#endif
|
||||
|
||||
getStudyMetadata: function TestPilotExperiment_getStudyMetadata() {
|
||||
try {
|
||||
if (this._handlers.getStudyMetadata) {
|
@ -878,11 +878,6 @@ pref("security.alternate_certificate_error_page", "certerror");
|
||||
// Whether to start the private browsing mode at application startup
|
||||
pref("browser.privatebrowsing.autostart", false);
|
||||
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
// Whether we should skip prompting before starting the private browsing mode
|
||||
pref("browser.privatebrowsing.dont_prompt_on_enter", false);
|
||||
#endif
|
||||
|
||||
// Don't try to alter this pref, it'll be reset the next time you use the
|
||||
// bookmarking dialog
|
||||
pref("browser.bookmarks.editDialog.firstEditField", "namePicker");
|
||||
|
@ -34,21 +34,11 @@
|
||||
key="openFileKb"/>
|
||||
</menupopup>
|
||||
</splitmenu>
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
<menuitem id="appmenu_newPrivateWindow"
|
||||
class="menuitem-iconic menuitem-iconic-tooltip"
|
||||
label="&newPrivateWindow.label;"
|
||||
command="Tools:PrivateBrowsing"
|
||||
key="key_privatebrowsing"/>
|
||||
#else
|
||||
<menuitem id="appmenu_privateBrowsing"
|
||||
class="menuitem-iconic menuitem-iconic-tooltip"
|
||||
label="&privateBrowsingCmd.start.label;"
|
||||
startlabel="&privateBrowsingCmd.start.label;"
|
||||
stoplabel="&privateBrowsingCmd.stop.label;"
|
||||
command="Tools:PrivateBrowsing"
|
||||
key="key_privatebrowsing"/>
|
||||
#endif
|
||||
<menuitem label="&goOfflineCmd.label;"
|
||||
id="appmenu_offlineModeRecovery"
|
||||
type="checkbox"
|
||||
|
@ -28,12 +28,10 @@
|
||||
label="&openLinkCmd.label;"
|
||||
accesskey="&openLinkCmd.accesskey;"
|
||||
oncommand="gContextMenu.openLink();"/>
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
<menuitem id="context-openlinkprivate"
|
||||
label="&openLinkInPrivateWindowCmd.label;"
|
||||
accesskey="&openLinkInPrivateWindowCmd.accesskey;"
|
||||
oncommand="gContextMenu.openLinkInPrivateWindow();"/>
|
||||
#endif
|
||||
<menuseparator id="context-sep-open"/>
|
||||
<menuitem id="context-bookmarklink"
|
||||
label="&bookmarkThisLinkCmd.label;"
|
||||
|
@ -22,13 +22,11 @@
|
||||
accesskey="&newNavigatorCmd.accesskey;"
|
||||
key="key_newNavigator"
|
||||
command="cmd_newNavigator"/>
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
<menuitem id="menu_newPrivateWindow"
|
||||
label="&newPrivateWindow.label;"
|
||||
accesskey="&newPrivateWindow.accesskey;"
|
||||
command="Tools:PrivateBrowsing"
|
||||
key="key_privatebrowsing"/>
|
||||
#endif
|
||||
<menuitem id="menu_openLocation"
|
||||
class="show-only-for-keyboard"
|
||||
label="&openLocationCmd.label;"
|
||||
@ -600,17 +598,6 @@
|
||||
#endif
|
||||
command="View:PageInfo"/>
|
||||
<menuseparator id="sanitizeSeparator"/>
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
<menuitem id="privateBrowsingItem"
|
||||
label="&privateBrowsingCmd.start.label;"
|
||||
accesskey="&privateBrowsingCmd.start.accesskey;"
|
||||
startlabel="&privateBrowsingCmd.start.label;"
|
||||
startaccesskey="&privateBrowsingCmd.start.accesskey;"
|
||||
stoplabel="&privateBrowsingCmd.stop.label;"
|
||||
stopaccesskey="&privateBrowsingCmd.stop.accesskey;"
|
||||
key="key_privatebrowsing"
|
||||
command="Tools:PrivateBrowsing"/>
|
||||
#endif
|
||||
<menuitem id="sanitizeItem"
|
||||
accesskey="&clearRecentHistory.accesskey;"
|
||||
label="&clearRecentHistory.label;"
|
||||
|
@ -101,11 +101,7 @@
|
||||
<command id="Tools:Sanitize"
|
||||
oncommand="Cc['@mozilla.org/browser/browserglue;1'].getService(Ci.nsIBrowserGlue).sanitize(window);"/>
|
||||
<command id="Tools:PrivateBrowsing"
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
oncommand="OpenBrowserWindow({private: true});"/>
|
||||
#else
|
||||
oncommand="gPrivateBrowsingUI.toggleMode();"/>
|
||||
#endif
|
||||
<command id="History:UndoCloseTab" oncommand="undoCloseTab();"/>
|
||||
<command id="History:UndoCloseWindow" oncommand="undoCloseWindow();"/>
|
||||
<command id="Browser:ToggleAddonBar" oncommand="toggleAddonBar();"/>
|
||||
|
@ -18,11 +18,6 @@ let SocialUI = {
|
||||
Services.obs.addObserver(this, "social:recommend-info-changed", false);
|
||||
Services.obs.addObserver(this, "social:frameworker-error", false);
|
||||
Services.obs.addObserver(this, "social:provider-set", false);
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
// this observer is necessary so things are also correctly updated
|
||||
// when per-window PB isn't active
|
||||
Services.obs.addObserver(this, "private-browsing", false);
|
||||
#endif
|
||||
|
||||
Services.prefs.addObserver("social.sidebar.open", this, false);
|
||||
Services.prefs.addObserver("social.toast-notifications.enabled", this, false);
|
||||
@ -46,9 +41,6 @@ let SocialUI = {
|
||||
Services.obs.removeObserver(this, "social:recommend-info-changed");
|
||||
Services.obs.removeObserver(this, "social:frameworker-error");
|
||||
Services.obs.removeObserver(this, "social:provider-set");
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
Services.obs.removeObserver(this, "private-browsing");
|
||||
#endif
|
||||
|
||||
Services.prefs.removeObserver("social.sidebar.open", this);
|
||||
Services.prefs.removeObserver("social.toast-notifications.enabled", this);
|
||||
@ -140,14 +132,6 @@ let SocialUI = {
|
||||
SocialToolbar.updateButton();
|
||||
}
|
||||
break;
|
||||
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
case "private-browsing":
|
||||
this._updateEnabledState();
|
||||
this._updateActiveUI();
|
||||
SocialToolbar.init();
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
} catch (e) {
|
||||
Components.utils.reportError(e + "\n" + e.stack);
|
||||
@ -173,11 +157,8 @@ let SocialUI = {
|
||||
_updateActiveUI: function SocialUI_updateActiveUI() {
|
||||
// The "active" UI isn't dependent on there being a provider, just on
|
||||
// social being "active" (but also chromeless/PB)
|
||||
let enabled = Social.active && !this._chromeless
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
&& !PrivateBrowsingUtils.isWindowPrivate(window)
|
||||
#endif
|
||||
;
|
||||
let enabled = Social.active && !this._chromeless &&
|
||||
!PrivateBrowsingUtils.isWindowPrivate(window);
|
||||
let broadcaster = document.getElementById("socialActiveBroadcaster");
|
||||
broadcaster.hidden = !enabled;
|
||||
|
||||
@ -328,11 +309,7 @@ let SocialUI = {
|
||||
|
||||
get enabled() {
|
||||
// Returns whether social is enabled *for this window*.
|
||||
if (this._chromeless
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
|| PrivateBrowsingUtils.isWindowPrivate(window)
|
||||
#endif
|
||||
)
|
||||
if (this._chromeless || PrivateBrowsingUtils.isWindowPrivate(window))
|
||||
return false;
|
||||
return !!(Social.active && Social.provider && Social.provider.enabled);
|
||||
},
|
||||
|
@ -1330,11 +1330,8 @@ var gBrowserInit = {
|
||||
ss.init(window);
|
||||
|
||||
// Enable the Restore Last Session command if needed
|
||||
if (ss.canRestoreLastSession
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
&& !PrivateBrowsingUtils.isWindowPrivate(window)
|
||||
#endif
|
||||
)
|
||||
if (ss.canRestoreLastSession &&
|
||||
!PrivateBrowsingUtils.isWindowPrivate(window))
|
||||
goSetCommandEnabled("Browser:RestoreLastSession", true);
|
||||
|
||||
PlacesToolbarHelper.init();
|
||||
@ -1551,10 +1548,6 @@ var gBrowserInit = {
|
||||
|
||||
PlacesStarButton.uninit();
|
||||
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
gPrivateBrowsingUI.uninit();
|
||||
#endif
|
||||
|
||||
TabsOnTop.uninit();
|
||||
|
||||
TabsInTitlebar.uninit();
|
||||
@ -1700,10 +1693,6 @@ var gBrowserInit = {
|
||||
}
|
||||
|
||||
BrowserOffline.uninit();
|
||||
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
gPrivateBrowsingUI.uninit();
|
||||
#endif
|
||||
},
|
||||
#endif
|
||||
|
||||
@ -2510,11 +2499,8 @@ function BrowserOnAboutPageLoad(document) {
|
||||
|
||||
let ss = Components.classes["@mozilla.org/browser/sessionstore;1"].
|
||||
getService(Components.interfaces.nsISessionStore);
|
||||
if (ss.canRestoreLastSession
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
&& !PrivateBrowsingUtils.isWindowPrivate(window)
|
||||
#endif
|
||||
)
|
||||
if (ss.canRestoreLastSession &&
|
||||
!PrivateBrowsingUtils.isWindowPrivate(window))
|
||||
document.getElementById("launcher").setAttribute("session", "true");
|
||||
|
||||
// Inject search engine and snippets URL.
|
||||
@ -3535,11 +3521,7 @@ function OpenBrowserWindow(options)
|
||||
var wintype = document.documentElement.getAttribute('windowtype');
|
||||
|
||||
var extraFeatures = "";
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
if (options && options.private) {
|
||||
#else
|
||||
if (gPrivateBrowsingUI.privateBrowsingEnabled) {
|
||||
#endif
|
||||
extraFeatures = ",private";
|
||||
// Force the new window to load about:privatebrowsing instead of the default home page
|
||||
defaultArgs = "about:privatebrowsing";
|
||||
@ -6920,15 +6902,6 @@ function getTabModalPromptBox(aWindow) {
|
||||
function getBrowser() gBrowser;
|
||||
function getNavToolbox() gNavToolbox;
|
||||
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
|
||||
# We define a new gPrivateBrowsingUI object, as the per-window PB implementation
|
||||
# is completely different to the global PB one. Specifically, the per-window
|
||||
# PB implementation does not expose many APIs on the gPrivateBrowsingUI object,
|
||||
# and only uses it as a way to initialize and uninitialize private browsing
|
||||
# windows. While we could use #ifdefs all around the global PB mode code to
|
||||
# make it work in both modes, the amount of duplicated code is small and the
|
||||
# code is much more readable this way.
|
||||
let gPrivateBrowsingUI = {
|
||||
init: function PBUI_init() {
|
||||
// Do nothing for normal windows
|
||||
@ -6965,243 +6938,6 @@ let gPrivateBrowsingUI = {
|
||||
}
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
let gPrivateBrowsingUI = {
|
||||
_privateBrowsingService: null,
|
||||
_searchBarValue: null,
|
||||
_findBarValue: null,
|
||||
_inited: false,
|
||||
|
||||
init: function PBUI_init() {
|
||||
Services.obs.addObserver(this, "private-browsing", false);
|
||||
Services.obs.addObserver(this, "private-browsing-transition-complete", false);
|
||||
|
||||
this._privateBrowsingService = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
|
||||
if (this.privateBrowsingEnabled)
|
||||
this.onEnterPrivateBrowsing(true);
|
||||
|
||||
this._inited = true;
|
||||
},
|
||||
|
||||
uninit: function PBUI_unint() {
|
||||
if (!this._inited)
|
||||
return;
|
||||
|
||||
Services.obs.removeObserver(this, "private-browsing");
|
||||
Services.obs.removeObserver(this, "private-browsing-transition-complete");
|
||||
},
|
||||
|
||||
get _disableUIOnToggle() {
|
||||
if (PrivateBrowsingUtils.permanentPrivateBrowsing)
|
||||
return false;
|
||||
|
||||
try {
|
||||
return !gPrefService.getBoolPref("browser.privatebrowsing.keep_current_session");
|
||||
}
|
||||
catch (e) {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
observe: function PBUI_observe(aSubject, aTopic, aData) {
|
||||
if (aTopic == "private-browsing") {
|
||||
if (aData == "enter")
|
||||
this.onEnterPrivateBrowsing();
|
||||
else if (aData == "exit")
|
||||
this.onExitPrivateBrowsing();
|
||||
}
|
||||
else if (aTopic == "private-browsing-transition-complete") {
|
||||
if (this._disableUIOnToggle) {
|
||||
document.getElementById("Tools:PrivateBrowsing")
|
||||
.removeAttribute("disabled");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_shouldEnter: function PBUI__shouldEnter() {
|
||||
try {
|
||||
// Never prompt if the session is not going to be closed, or if user has
|
||||
// already requested not to be prompted.
|
||||
if (gPrefService.getBoolPref("browser.privatebrowsing.dont_prompt_on_enter") ||
|
||||
gPrefService.getBoolPref("browser.privatebrowsing.keep_current_session"))
|
||||
return true;
|
||||
}
|
||||
catch (ex) { }
|
||||
|
||||
var bundleService = Services.strings;
|
||||
var pbBundle = bundleService.createBundle("chrome://browser/locale/browser.properties");
|
||||
var brandBundle = bundleService.createBundle("chrome://branding/locale/brand.properties");
|
||||
|
||||
var appName = brandBundle.GetStringFromName("brandShortName");
|
||||
# On Mac, use the header as the title.
|
||||
#ifdef XP_MACOSX
|
||||
var dialogTitle = pbBundle.GetStringFromName("privateBrowsingMessageHeader");
|
||||
var header = "";
|
||||
#else
|
||||
var dialogTitle = pbBundle.GetStringFromName("privateBrowsingDialogTitle");
|
||||
var header = pbBundle.GetStringFromName("privateBrowsingMessageHeader") + "\n\n";
|
||||
#endif
|
||||
var message = pbBundle.formatStringFromName("privateBrowsingMessage", [appName], 1);
|
||||
|
||||
var ps = Services.prompt;
|
||||
|
||||
var flags = ps.BUTTON_TITLE_IS_STRING * ps.BUTTON_POS_0 +
|
||||
ps.BUTTON_TITLE_IS_STRING * ps.BUTTON_POS_1 +
|
||||
ps.BUTTON_POS_0_DEFAULT;
|
||||
|
||||
var neverAsk = {value:false};
|
||||
var button0Title = pbBundle.GetStringFromName("privateBrowsingYesTitle");
|
||||
var button1Title = pbBundle.GetStringFromName("privateBrowsingNoTitle");
|
||||
var neverAskText = pbBundle.GetStringFromName("privateBrowsingNeverAsk");
|
||||
|
||||
var result;
|
||||
var choice = ps.confirmEx(null, dialogTitle, header + message,
|
||||
flags, button0Title, button1Title, null,
|
||||
neverAskText, neverAsk);
|
||||
|
||||
switch (choice) {
|
||||
case 0: // Start Private Browsing
|
||||
result = true;
|
||||
if (neverAsk.value)
|
||||
gPrefService.setBoolPref("browser.privatebrowsing.dont_prompt_on_enter", true);
|
||||
break;
|
||||
case 1: // Keep
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
onEnterPrivateBrowsing: function PBUI_onEnterPrivateBrowsing(aOnWindowOpen) {
|
||||
if (BrowserSearch.searchBar)
|
||||
this._searchBarValue = BrowserSearch.searchBar.textbox.value;
|
||||
|
||||
if (gFindBarInitialized)
|
||||
this._findBarValue = gFindBar.getElement("findbar-textbox").value;
|
||||
|
||||
this._setPBMenuTitle("stop");
|
||||
|
||||
// Disable the Clear Recent History... menu item when in PB mode
|
||||
// temporary fix until bug 463607 is fixed
|
||||
document.getElementById("Tools:Sanitize").setAttribute("disabled", "true");
|
||||
|
||||
let docElement = document.documentElement;
|
||||
if (PrivateBrowsingUtils.permanentPrivateBrowsing) {
|
||||
// Disable the menu item in auto-start mode
|
||||
document.getElementById("privateBrowsingItem")
|
||||
.setAttribute("disabled", "true");
|
||||
#ifdef MENUBAR_CAN_AUTOHIDE
|
||||
document.getElementById("appmenu_privateBrowsing")
|
||||
.setAttribute("disabled", "true");
|
||||
#endif
|
||||
document.getElementById("Tools:PrivateBrowsing")
|
||||
.setAttribute("disabled", "true");
|
||||
if (window.location.href == getBrowserURL())
|
||||
docElement.setAttribute("privatebrowsingmode", "permanent");
|
||||
}
|
||||
else if (window.location.href == getBrowserURL()) {
|
||||
// Adjust the window's title
|
||||
docElement.setAttribute("title",
|
||||
docElement.getAttribute("title_privatebrowsing"));
|
||||
docElement.setAttribute("titlemodifier",
|
||||
docElement.getAttribute("titlemodifier_privatebrowsing"));
|
||||
docElement.setAttribute("privatebrowsingmode", "temporary");
|
||||
gBrowser.updateTitlebar();
|
||||
}
|
||||
|
||||
if (!aOnWindowOpen && this._disableUIOnToggle)
|
||||
document.getElementById("Tools:PrivateBrowsing")
|
||||
.setAttribute("disabled", "true");
|
||||
},
|
||||
|
||||
onExitPrivateBrowsing: function PBUI_onExitPrivateBrowsing() {
|
||||
if (BrowserSearch.searchBar) {
|
||||
let searchBox = BrowserSearch.searchBar.textbox;
|
||||
searchBox.reset();
|
||||
if (this._searchBarValue) {
|
||||
searchBox.value = this._searchBarValue;
|
||||
this._searchBarValue = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (gURLBar) {
|
||||
gURLBar.editor.transactionManager.clear();
|
||||
}
|
||||
|
||||
// Re-enable the Clear Recent History... menu item on exit of PB mode
|
||||
// temporary fix until bug 463607 is fixed
|
||||
document.getElementById("Tools:Sanitize").removeAttribute("disabled");
|
||||
|
||||
if (gFindBarInitialized) {
|
||||
let findbox = gFindBar.getElement("findbar-textbox");
|
||||
findbox.reset();
|
||||
if (this._findBarValue) {
|
||||
findbox.value = this._findBarValue;
|
||||
this._findBarValue = null;
|
||||
}
|
||||
}
|
||||
|
||||
this._setPBMenuTitle("start");
|
||||
|
||||
if (window.location.href == getBrowserURL()) {
|
||||
// Adjust the window's title
|
||||
let docElement = document.documentElement;
|
||||
docElement.setAttribute("title",
|
||||
docElement.getAttribute("title_normal"));
|
||||
docElement.setAttribute("titlemodifier",
|
||||
docElement.getAttribute("titlemodifier_normal"));
|
||||
docElement.removeAttribute("privatebrowsingmode");
|
||||
}
|
||||
|
||||
// Enable the menu item in after exiting the auto-start mode
|
||||
document.getElementById("privateBrowsingItem")
|
||||
.removeAttribute("disabled");
|
||||
#ifdef MENUBAR_CAN_AUTOHIDE
|
||||
document.getElementById("appmenu_privateBrowsing")
|
||||
.removeAttribute("disabled");
|
||||
#endif
|
||||
document.getElementById("Tools:PrivateBrowsing")
|
||||
.removeAttribute("disabled");
|
||||
|
||||
gLastOpenDirectory.reset();
|
||||
|
||||
if (this._disableUIOnToggle)
|
||||
document.getElementById("Tools:PrivateBrowsing")
|
||||
.setAttribute("disabled", "true");
|
||||
},
|
||||
|
||||
_setPBMenuTitle: function PBUI__setPBMenuTitle(aMode) {
|
||||
let pbMenuItem = document.getElementById("privateBrowsingItem");
|
||||
pbMenuItem.setAttribute("label", pbMenuItem.getAttribute(aMode + "label"));
|
||||
pbMenuItem.setAttribute("accesskey", pbMenuItem.getAttribute(aMode + "accesskey"));
|
||||
#ifdef MENUBAR_CAN_AUTOHIDE
|
||||
let appmenupbMenuItem = document.getElementById("appmenu_privateBrowsing");
|
||||
appmenupbMenuItem.setAttribute("label", appmenupbMenuItem.getAttribute(aMode + "label"));
|
||||
appmenupbMenuItem.setAttribute("accesskey", appmenupbMenuItem.getAttribute(aMode + "accesskey"));
|
||||
#endif
|
||||
},
|
||||
|
||||
toggleMode: function PBUI_toggleMode() {
|
||||
// prompt the users on entering the private mode, if needed
|
||||
if (!this.privateBrowsingEnabled)
|
||||
if (!this._shouldEnter())
|
||||
return;
|
||||
|
||||
this._privateBrowsingService.privateBrowsingEnabled =
|
||||
!this.privateBrowsingEnabled;
|
||||
},
|
||||
|
||||
get privateBrowsingEnabled() {
|
||||
return this._privateBrowsingService.privateBrowsingEnabled;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Switch to a tab that has a given URI, and focusses its browser window.
|
||||
@ -7218,14 +6954,12 @@ let gPrivateBrowsingUI = {
|
||||
function switchToTabHavingURI(aURI, aOpenNew) {
|
||||
// This will switch to the tab in aWindow having aURI, if present.
|
||||
function switchIfURIInWindow(aWindow) {
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
// Only switch to the tab if neither the source and desination window are
|
||||
// private.
|
||||
if (PrivateBrowsingUtils.isWindowPrivate(window) ||
|
||||
PrivateBrowsingUtils.isWindowPrivate(aWindow)) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
let browsers = aWindow.gBrowser.browsers;
|
||||
for (let i = 0; i < browsers.length; i++) {
|
||||
|
@ -56,9 +56,7 @@
|
||||
<!-- The command cannot be cmd_newNavigator because we need to activate
|
||||
the application. -->
|
||||
<menuitem label="&newNavigatorCmd.label;" oncommand="OpenBrowserWindowFromDockMenu();" />
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
<menuitem label="&newPrivateWindow.label;" oncommand="OpenBrowserWindowFromDockMenu({private: true});" />
|
||||
#endif
|
||||
</menupopup>
|
||||
</popupset>
|
||||
|
||||
|
@ -137,13 +137,9 @@ nsContextMenu.prototype = {
|
||||
}
|
||||
|
||||
var shouldShow = this.onSaveableLink || isMailtoInternal || this.onPlainTextLink;
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
var isWindowPrivate = PrivateBrowsingUtils.isWindowPrivate(window);
|
||||
this.showItem("context-openlink", shouldShow && !isWindowPrivate);
|
||||
this.showItem("context-openlinkprivate", shouldShow);
|
||||
#else
|
||||
this.showItem("context-openlink", shouldShow);
|
||||
#endif
|
||||
this.showItem("context-openlinkintab", shouldShow);
|
||||
this.showItem("context-openlinkincurrent", this.onPlainTextLink);
|
||||
this.showItem("context-sep-open", shouldShow);
|
||||
|
@ -624,13 +624,10 @@
|
||||
autocomplete.unregisterOpenPage(this.mBrowser.registeredOpenURI);
|
||||
delete this.mBrowser.registeredOpenURI;
|
||||
}
|
||||
if (!isBlankPageURL(aLocation.spec)
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
// Tabs in private windows aren't registered as "Open" so
|
||||
// that they don't appear as switch-to-tab candidates.
|
||||
&& !PrivateBrowsingUtils.isWindowPrivate(window)
|
||||
#endif
|
||||
) {
|
||||
// Tabs in private windows aren't registered as "Open" so
|
||||
// that they don't appear as switch-to-tab candidates.
|
||||
if (!isBlankPageURL(aLocation.spec) &&
|
||||
!PrivateBrowsingUtils.isWindowPrivate(window)) {
|
||||
autocomplete.registerOpenPage(aLocation);
|
||||
this.mBrowser.registeredOpenURI = aLocation;
|
||||
}
|
||||
@ -1905,13 +1902,11 @@
|
||||
<parameter name="aOtherTab"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
// Do not allow transfering a private tab to a non-private window
|
||||
// and vice versa.
|
||||
if (PrivateBrowsingUtils.isWindowPrivate(window) !=
|
||||
PrivateBrowsingUtils.isWindowPrivate(aOtherTab.ownerDocument.defaultView))
|
||||
return;
|
||||
#endif
|
||||
|
||||
// That's gBrowser for the other window, not the tab's browser!
|
||||
var remoteBrowser = aOtherTab.ownerDocument.defaultView.gBrowser;
|
||||
@ -3463,13 +3458,11 @@
|
||||
sourceNode.ownerDocument.defaultView instanceof ChromeWindow &&
|
||||
sourceNode.ownerDocument.documentElement.getAttribute("windowtype") == "navigator:browser" &&
|
||||
sourceNode.ownerDocument.defaultView.gBrowser.tabContainer == sourceNode.parentNode) {
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
// Do not allow transfering a private tab to a non-private window
|
||||
// and vice versa.
|
||||
if (PrivateBrowsingUtils.isWindowPrivate(window) !=
|
||||
PrivateBrowsingUtils.isWindowPrivate(sourceNode.ownerDocument.defaultView))
|
||||
return dt.effectAllowed = "none";
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
return dt.effectAllowed = event.altKey ? "copy" : "move";
|
||||
|
@ -50,13 +50,9 @@ MOCHITEST_FILES += \
|
||||
audio.ogg \
|
||||
test_contextmenu.html \
|
||||
subtst_contextmenu.html \
|
||||
$(NULL)
|
||||
ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
MOCHITEST_FILES += \
|
||||
privateBrowsingMode.js \
|
||||
$(NULL)
|
||||
endif
|
||||
endif
|
||||
|
||||
# The following tests are disabled because they are unreliable:
|
||||
# browser_bug423833.js is bug 428712
|
||||
@ -163,8 +159,11 @@ _BROWSER_FILES = \
|
||||
browser_bug735471.js \
|
||||
browser_bug743421.js \
|
||||
browser_bug749738.js \
|
||||
browser_bug763468_perwindowpb.js \
|
||||
browser_bug767836_perwindowpb.js \
|
||||
browser_bug783614.js \
|
||||
browser_bug797677.js \
|
||||
browser_bug816527.js \
|
||||
browser_bug832435.js \
|
||||
browser_canonizeURL.js \
|
||||
browser_customize.js \
|
||||
@ -190,6 +189,7 @@ _BROWSER_FILES = \
|
||||
browser_plugins_added_dynamically.js \
|
||||
browser_CTPScriptPlugin.js \
|
||||
browser_pluginplaypreview.js \
|
||||
browser_private_browsing_window.js \
|
||||
browser_relatedTabs.js \
|
||||
browser_sanitize-passwordDisabledHosts.js \
|
||||
browser_sanitize-sitepermissions.js \
|
||||
@ -199,7 +199,11 @@ _BROWSER_FILES = \
|
||||
browser_clearplugindata_noage.html \
|
||||
browser_popupUI.js \
|
||||
browser_sanitizeDialog.js \
|
||||
browser_save_link-perwindowpb.js \
|
||||
browser_save_private_link_perwindowpb.js \
|
||||
browser_save_video.js \
|
||||
browser_tabMatchesInAwesomebar_perwindowpb.js \
|
||||
browser_tab_drag_drop_perwindow.js \
|
||||
bug564387.html \
|
||||
bug564387_video1.ogv \
|
||||
bug564387_video1.ogv^headers^ \
|
||||
@ -318,27 +322,6 @@ _BROWSER_FILES += \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
_BROWSER_FILES += \
|
||||
browser_bug763468_perwindowpb.js \
|
||||
browser_bug767836_perwindowpb.js \
|
||||
browser_bug816527.js \
|
||||
browser_private_browsing_window.js \
|
||||
browser_save_link-perwindowpb.js \
|
||||
browser_save_private_link_perwindowpb.js \
|
||||
browser_tabMatchesInAwesomebar_perwindowpb.js \
|
||||
browser_tab_drag_drop_perwindow.js \
|
||||
$(NULL)
|
||||
else
|
||||
_BROWSER_FILES += \
|
||||
browser_bug763468.js \
|
||||
browser_bug767836.js \
|
||||
browser_save_link.js \
|
||||
browser_save_private_link.js \
|
||||
browser_tabMatchesInAwesomebar.js \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
libs:: $(_BROWSER_FILES)
|
||||
|
@ -1,81 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
// This test makes sure that opening a new tab in private browsing mode opens about:privatebrowsing
|
||||
|
||||
// initialization
|
||||
const pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
|
||||
const PREF = "browser.newtab.url";
|
||||
|
||||
function test() {
|
||||
let newTabUrl = Services.prefs.getCharPref(PREF) || "about:blank";
|
||||
|
||||
waitForExplicitFinish();
|
||||
// check whether the mode that we start off with is normal or not
|
||||
ok(!pb.privateBrowsingEnabled, "private browsing is disabled");
|
||||
|
||||
// Open a new tab page in normal mode
|
||||
openNewTab(function () {
|
||||
// Check the new tab opened while in normal mode
|
||||
is(gBrowser.selectedBrowser.currentURI.spec, newTabUrl,
|
||||
"URL of NewTab should be browser.newtab.url in Normal mode");
|
||||
|
||||
// enter private browsing mode
|
||||
togglePrivateBrowsing(function () {
|
||||
ok(pb.privateBrowsingEnabled, "private browsing is enabled");
|
||||
|
||||
// Open a new tab page in private browsing mode
|
||||
openNewTab(function () {
|
||||
// Check the new tab opened while in private browsing mode
|
||||
is(gBrowser.selectedBrowser.currentURI.spec, "about:privatebrowsing",
|
||||
"URL of NewTab should be about:privatebrowsing in PB mode");
|
||||
|
||||
// exit private browsing mode
|
||||
togglePrivateBrowsing(function () {
|
||||
ok(!pb.privateBrowsingEnabled, "private browsing is disabled");
|
||||
|
||||
// Open a new tab page in normal mode to check if
|
||||
// returning from pb mode restores everything as it should
|
||||
openNewTab(function () {
|
||||
// Check the new tab opened while in normal mode
|
||||
is(gBrowser.selectedBrowser.currentURI.spec, newTabUrl,
|
||||
"URL of NewTab should be browser.newtab.url in Normal mode");
|
||||
gBrowser.removeTab(gBrowser.selectedTab);
|
||||
gBrowser.removeTab(gBrowser.selectedTab);
|
||||
finish();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function togglePrivateBrowsing(aCallback) {
|
||||
let topic = "private-browsing-transition-complete";
|
||||
|
||||
Services.obs.addObserver(function observe() {
|
||||
Services.obs.removeObserver(observe, topic);
|
||||
executeSoon(aCallback);
|
||||
}, topic, false);
|
||||
|
||||
pb.privateBrowsingEnabled = !pb.privateBrowsingEnabled;
|
||||
}
|
||||
|
||||
function openNewTab(aCallback) {
|
||||
// Open a new tab
|
||||
BrowserOpenTab();
|
||||
|
||||
let browser = gBrowser.selectedBrowser;
|
||||
if (browser.contentDocument.readyState == "complete") {
|
||||
executeSoon(aCallback);
|
||||
return;
|
||||
}
|
||||
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
executeSoon(aCallback);
|
||||
}, true);
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
// initialization
|
||||
const pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
const PREF = "browser.newtab.url";
|
||||
const NEWTABURL = Services.prefs.getCharPref(PREF) || "about:blank";
|
||||
const TESTURL = "http://example.com/";
|
||||
|
||||
function test() {
|
||||
|
||||
waitForExplicitFinish();
|
||||
// check whether the mode that we start off with is normal or not
|
||||
ok(!pb.privateBrowsingEnabled, "private browsing is disabled");
|
||||
// check whether any custom new tab url has been configured
|
||||
ok(!Services.prefs.prefHasUserValue(PREF), "No custom newtab url is set");
|
||||
|
||||
openNewTab(function () {
|
||||
// Check the new tab opened while in normal mode
|
||||
is(gBrowser.selectedBrowser.currentURI.spec, NEWTABURL,
|
||||
"URL of NewTab should be browser.newtab.url in Normal mode");
|
||||
// Set the custom newtab url
|
||||
Services.prefs.setCharPref(PREF, TESTURL);
|
||||
ok(Services.prefs.prefHasUserValue(PREF), "Custom newtab url is set");
|
||||
|
||||
// Open a newtab after setting the custom newtab url
|
||||
openNewTab(function () {
|
||||
is(gBrowser.selectedBrowser.currentURI.spec, TESTURL,
|
||||
"URL of NewTab should be the custom url");
|
||||
|
||||
// clear the custom url preference
|
||||
Services.prefs.clearUserPref(PREF);
|
||||
ok(!Services.prefs.prefHasUserValue(PREF), "No custom newtab url is set");
|
||||
|
||||
// enter private browsing mode
|
||||
togglePrivateBrowsing(function () {
|
||||
ok(pb.privateBrowsingEnabled, "private browsing is enabled");
|
||||
|
||||
// Open a new tab page in private browsing mode
|
||||
openNewTab(function () {
|
||||
// Check the new tab opened while in private browsing mode
|
||||
is(gBrowser.selectedBrowser.currentURI.spec, "about:privatebrowsing",
|
||||
"URL of NewTab should be about:privatebrowsing in PB mode");
|
||||
|
||||
Services.prefs.setCharPref(PREF, TESTURL);
|
||||
ok(Services.prefs.prefHasUserValue(PREF), "Custom newtab url is set");
|
||||
|
||||
// Open a newtab after setting the custom newtab url
|
||||
openNewTab(function () {
|
||||
is(gBrowser.selectedBrowser.currentURI.spec, TESTURL,
|
||||
"URL of NewTab should be the custom url");
|
||||
|
||||
Services.prefs.clearUserPref(PREF);
|
||||
ok(!Services.prefs.prefHasUserValue(PREF), "No custom newtab url is set");
|
||||
|
||||
// exit private browsing mode
|
||||
togglePrivateBrowsing(function () {
|
||||
ok(!pb.privateBrowsingEnabled, "private browsing is disabled");
|
||||
|
||||
gBrowser.removeTab(gBrowser.selectedTab);
|
||||
gBrowser.removeTab(gBrowser.selectedTab);
|
||||
finish();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function togglePrivateBrowsing(aCallback) {
|
||||
let topic = "private-browsing-transition-complete";
|
||||
|
||||
Services.obs.addObserver(function observe() {
|
||||
Services.obs.removeObserver(observe, topic);
|
||||
executeSoon(aCallback);
|
||||
}, topic, false);
|
||||
|
||||
pb.privateBrowsingEnabled = !pb.privateBrowsingEnabled;
|
||||
}
|
||||
|
||||
function openNewTab(aCallback) {
|
||||
// Open a new tab
|
||||
BrowserOpenTab();
|
||||
|
||||
let browser = gBrowser.selectedBrowser;
|
||||
if (browser.contentDocument.readyState == "complete") {
|
||||
executeSoon(aCallback);
|
||||
return;
|
||||
}
|
||||
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
executeSoon(aCallback);
|
||||
}, true);
|
||||
}
|
@ -1,128 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
var MockFilePicker = SpecialPowers.MockFilePicker;
|
||||
MockFilePicker.init(window);
|
||||
|
||||
let tempScope = {};
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm", tempScope);
|
||||
let NetUtil = tempScope.NetUtil;
|
||||
|
||||
// Trigger a save of a link in public mode, then trigger an identical save
|
||||
// in private mode and ensure that the second request is differentiated from
|
||||
// the first by checking the cookies that are sent.
|
||||
|
||||
function triggerSave(aCallback) {
|
||||
var fileName;
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
let testBrowser = gBrowser.selectedBrowser;
|
||||
testBrowser.loadURI("http://mochi.test:8888/browser/browser/base/content/test/bug792517-2.html");
|
||||
testBrowser.addEventListener("pageshow", function pageShown(event) {
|
||||
if (event.target.location == "about:blank")
|
||||
return;
|
||||
testBrowser.removeEventListener("pageshow", pageShown, false);
|
||||
|
||||
executeSoon(function () {
|
||||
document.addEventListener("popupshown", contextMenuOpened, false);
|
||||
|
||||
var link = testBrowser.contentDocument.getElementById("fff");
|
||||
EventUtils.synthesizeMouseAtCenter(link,
|
||||
{ type: "contextmenu", button: 2 },
|
||||
testBrowser.contentWindow);
|
||||
});
|
||||
}, false);
|
||||
|
||||
function contextMenuOpened(event) {
|
||||
event.currentTarget.removeEventListener("popupshown", contextMenuOpened, false);
|
||||
|
||||
// Create the folder the link will be saved into.
|
||||
var destDir = createTemporarySaveDirectory();
|
||||
var destFile = destDir.clone();
|
||||
|
||||
MockFilePicker.displayDirectory = destDir;
|
||||
MockFilePicker.showCallback = function(fp) {
|
||||
fileName = fp.defaultString;
|
||||
destFile.append (fileName);
|
||||
MockFilePicker.returnFiles = [destFile];
|
||||
MockFilePicker.filterIndex = 1; // kSaveAsType_URL
|
||||
};
|
||||
|
||||
mockTransferCallback = function(a) onTransferComplete(a, destFile, destDir);
|
||||
|
||||
// Select "Save Link As" option from context menu
|
||||
var saveLinkCommand = document.getElementById("context-savelink");
|
||||
saveLinkCommand.doCommand();
|
||||
|
||||
event.target.hidePopup();
|
||||
}
|
||||
|
||||
function onTransferComplete(downloadSuccess, destFile, destDir) {
|
||||
ok(downloadSuccess, "Link should have been downloaded successfully");
|
||||
gBrowser.removeCurrentTab();
|
||||
|
||||
// Give the request a chance to finish
|
||||
executeSoon(function() aCallback(destFile, destDir));
|
||||
}
|
||||
}
|
||||
|
||||
function readFile(file, callback) {
|
||||
let channel = NetUtil.newChannel(file);
|
||||
channel.contentType = "application/javascript";
|
||||
|
||||
NetUtil.asyncFetch(channel, function(inputStream, status) {
|
||||
ok(Components.isSuccessCode(status),
|
||||
"file was read successfully");
|
||||
|
||||
let content = NetUtil.readInputStreamToString(inputStream,
|
||||
inputStream.available());
|
||||
executeSoon(function() callback(content));
|
||||
});
|
||||
}
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"]
|
||||
.getService(Ci.nsIPrivateBrowsingService);
|
||||
|
||||
mockTransferRegisterer.register();
|
||||
|
||||
registerCleanupFunction(function () {
|
||||
mockTransferRegisterer.unregister();
|
||||
MockFilePicker.cleanup();
|
||||
pb.privateBrowsingEnabled = false;
|
||||
Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
});
|
||||
|
||||
triggerSave(function(destFile, destDir) {
|
||||
readFile(destFile, function(content) {
|
||||
is(content, "cookie-not-present", "no cookie should be sent");
|
||||
destDir.remove(true);
|
||||
|
||||
Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
||||
pb.privateBrowsingEnabled = true;
|
||||
triggerSave(function(destFile, destDir) {
|
||||
readFile(destFile, function(content) {
|
||||
is(content, "cookie-not-present", "no cookie should be sent");
|
||||
destDir.remove(true);
|
||||
finish();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
||||
.getService(Ci.mozIJSSubScriptLoader)
|
||||
.loadSubScript("chrome://mochitests/content/browser/toolkit/content/tests/browser/common/mockTransfer.js",
|
||||
this);
|
||||
|
||||
function createTemporarySaveDirectory() {
|
||||
var saveDir = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties)
|
||||
.get("TmpD", Ci.nsIFile);
|
||||
saveDir.append("testsavedir");
|
||||
if (!saveDir.exists())
|
||||
saveDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0755);
|
||||
return saveDir;
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
var MockFilePicker = SpecialPowers.MockFilePicker;
|
||||
MockFilePicker.init(window);
|
||||
|
||||
function checkDiskCacheFor(filename) {
|
||||
let visitor = {
|
||||
visitDevice: function(deviceID, deviceInfo) {
|
||||
if (deviceID == "disk")
|
||||
info(deviceID + " device contains " + deviceInfo.entryCount + " entries");
|
||||
return deviceID == "disk";
|
||||
},
|
||||
|
||||
visitEntry: function(deviceID, entryInfo) {
|
||||
info(entryInfo.key);
|
||||
is(entryInfo.key.contains(filename), false, "web content present in disk cache");
|
||||
}
|
||||
};
|
||||
cache.visitEntries(visitor);
|
||||
}
|
||||
|
||||
var cache = Cc["@mozilla.org/network/cache-service;1"]
|
||||
.getService(Ci.nsICacheService);
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
var fileName;
|
||||
|
||||
gPrefService.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
pb.privateBrowsingEnabled = true;
|
||||
|
||||
gBrowser.loadURI("http://mochi.test:8888/browser/browser/base/content/test/bug792517.html");
|
||||
|
||||
registerCleanupFunction(function () {
|
||||
pb.privateBrowsingEnabled = false;
|
||||
gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
gBrowser.addTab();
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
gBrowser.addEventListener("pageshow", function pageShown(event) {
|
||||
if (event.target.location == "about:blank")
|
||||
return;
|
||||
gBrowser.removeEventListener("pageshow", pageShown);
|
||||
|
||||
executeSoon(function () {
|
||||
document.addEventListener("popupshown", contextMenuOpened);
|
||||
|
||||
var img = gBrowser.contentDocument.getElementById("img");
|
||||
EventUtils.synthesizeMouseAtCenter(img,
|
||||
{ type: "contextmenu", button: 2 },
|
||||
gBrowser.contentWindow);
|
||||
});
|
||||
});
|
||||
|
||||
function contextMenuOpened(event) {
|
||||
cache.evictEntries(Ci.nsICache.STORE_ANYWHERE);
|
||||
|
||||
event.currentTarget.removeEventListener("popupshown", contextMenuOpened);
|
||||
|
||||
// Create the folder the image will be saved into.
|
||||
var destDir = createTemporarySaveDirectory();
|
||||
var destFile = destDir.clone();
|
||||
|
||||
MockFilePicker.displayDirectory = destDir;
|
||||
MockFilePicker.showCallback = function(fp) {
|
||||
fileName = fp.defaultString;
|
||||
destFile.append (fileName);
|
||||
MockFilePicker.returnFiles = [destFile];
|
||||
MockFilePicker.filterIndex = 1; // kSaveAsType_URL
|
||||
};
|
||||
|
||||
mockTransferCallback = onTransferComplete;
|
||||
mockTransferRegisterer.register();
|
||||
|
||||
registerCleanupFunction(function () {
|
||||
mockTransferRegisterer.unregister();
|
||||
MockFilePicker.cleanup();
|
||||
destDir.remove(true);
|
||||
});
|
||||
|
||||
// Select "Save Image As" option from context menu
|
||||
var saveVideoCommand = document.getElementById("context-saveimage");
|
||||
saveVideoCommand.doCommand();
|
||||
|
||||
event.target.hidePopup();
|
||||
}
|
||||
|
||||
function onTransferComplete(downloadSuccess) {
|
||||
ok(downloadSuccess, "Image file should have been downloaded successfully");
|
||||
|
||||
// Give the request a chance to finish and create a cache entry
|
||||
executeSoon(function() {
|
||||
checkDiskCacheFor(fileName);
|
||||
finish();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
||||
.getService(Ci.mozIJSSubScriptLoader)
|
||||
.loadSubScript("chrome://mochitests/content/browser/toolkit/content/tests/browser/common/mockTransfer.js",
|
||||
this);
|
||||
|
||||
function createTemporarySaveDirectory() {
|
||||
var saveDir = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties)
|
||||
.get("TmpD", Ci.nsIFile);
|
||||
saveDir.append("testsavedir");
|
||||
if (!saveDir.exists())
|
||||
saveDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0755);
|
||||
return saveDir;
|
||||
}
|
@ -1,323 +0,0 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim:set ts=2 sw=2 sts=2 et:
|
||||
* 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/. */
|
||||
|
||||
const TEST_URL_BASES = [
|
||||
"http://example.org/browser/browser/base/content/test/dummy_page.html#tabmatch",
|
||||
"http://example.org/browser/browser/base/content/test/moz.png#tabmatch"
|
||||
];
|
||||
|
||||
var gPrivateBrowsing = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
var gController = Cc["@mozilla.org/autocomplete/controller;1"].
|
||||
getService(Ci.nsIAutoCompleteController);
|
||||
|
||||
var gTabWaitCount = 0;
|
||||
var gTabCounter = 0;
|
||||
|
||||
var gTestSteps = [
|
||||
function() {
|
||||
info("Running step 1");
|
||||
for (let i = 0; i < 10; i++) {
|
||||
let tab = gBrowser.addTab();
|
||||
loadTab(tab, TEST_URL_BASES[0] + (++gTabCounter));
|
||||
}
|
||||
},
|
||||
function() {
|
||||
info("Running step 2");
|
||||
gBrowser.selectTabAtIndex(1);
|
||||
gBrowser.removeCurrentTab();
|
||||
gBrowser.selectTabAtIndex(1);
|
||||
gBrowser.removeCurrentTab();
|
||||
for (let i = 1; i < gBrowser.tabs.length; i++)
|
||||
loadTab(gBrowser.tabs[i], TEST_URL_BASES[1] + (++gTabCounter));
|
||||
},
|
||||
function() {
|
||||
info("Running step 3");
|
||||
for (let i = 1; i < gBrowser.tabs.length; i++)
|
||||
loadTab(gBrowser.tabs[i], TEST_URL_BASES[0] + gTabCounter);
|
||||
},
|
||||
function() {
|
||||
info("Running step 4");
|
||||
let ps = Services.prefs;
|
||||
ps.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
||||
ps.setBoolPref("browser.tabs.warnOnClose", false);
|
||||
|
||||
// Make sure that all restored tabs are loaded without waiting for the user
|
||||
// to bring them to the foreground. We ensure this by resetting the
|
||||
// related preference (see the "firefox.js" defaults file for details).
|
||||
ps.setBoolPref("browser.sessionstore.restore_on_demand", false);
|
||||
|
||||
gPrivateBrowsing.privateBrowsingEnabled = true;
|
||||
|
||||
executeSoon(function() {
|
||||
ensure_opentabs_match_db(nextStep);
|
||||
});
|
||||
},
|
||||
function() {
|
||||
info("Running step 5");
|
||||
gPrivateBrowsing.privateBrowsingEnabled = false;
|
||||
|
||||
executeSoon(function() {
|
||||
let ps = Services.prefs;
|
||||
ps.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
ps.clearUserPref("browser.tabs.warnOnClose");
|
||||
|
||||
ensure_opentabs_match_db(nextStep);
|
||||
});
|
||||
},
|
||||
function() {
|
||||
info("Running step 6 - ensure we don't register subframes as open pages");
|
||||
let tab = gBrowser.addTab();
|
||||
tab.linkedBrowser.addEventListener("load", function () {
|
||||
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
// Start the sub-document load.
|
||||
executeSoon(function () {
|
||||
tab.linkedBrowser.addEventListener("load", function (e) {
|
||||
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
ensure_opentabs_match_db(nextStep);
|
||||
}, true);
|
||||
tab.linkedBrowser.contentDocument.querySelector("iframe").src = "http://test2.example.org/";
|
||||
});
|
||||
}, true);
|
||||
tab.linkedBrowser.loadURI('data:text/html,<body><iframe src=""></iframe></body>');
|
||||
},
|
||||
function() {
|
||||
info("Running step 7 - remove tab immediately");
|
||||
let tab = gBrowser.addTab("about:logo");
|
||||
gBrowser.removeTab(tab);
|
||||
ensure_opentabs_match_db(nextStep);
|
||||
},
|
||||
function() {
|
||||
info("Running step 8 - check swapBrowsersAndCloseOther preserves registered switch-to-tab result");
|
||||
let tabToKeep = gBrowser.addTab();
|
||||
let tab = gBrowser.addTab();
|
||||
tab.linkedBrowser.addEventListener("load", function () {
|
||||
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
gBrowser.swapBrowsersAndCloseOther(tabToKeep, tab);
|
||||
ensure_opentabs_match_db(function () {
|
||||
gBrowser.removeTab(tabToKeep);
|
||||
ensure_opentabs_match_db(nextStep);
|
||||
});
|
||||
}, true);
|
||||
tab.linkedBrowser.loadURI("about:mozilla");
|
||||
},
|
||||
function() {
|
||||
info("Running step 9 - enter private browsing mode, without keeping session");
|
||||
let ps = Services.prefs;
|
||||
ps.setBoolPref("browser.privatebrowsing.keep_current_session", false);
|
||||
ps.setBoolPref("browser.tabs.warnOnClose", false);
|
||||
|
||||
Services.obs.addObserver(function(aSubject, aTopic, aData) {
|
||||
Services.obs.removeObserver(arguments.callee, "private-browsing-transition-complete");
|
||||
|
||||
for (let i = 0; i < gBrowser.tabs.length; i++)
|
||||
waitForRestoredTab(gBrowser.tabs[i]);
|
||||
}, "private-browsing-transition-complete", false);
|
||||
|
||||
gPrivateBrowsing.privateBrowsingEnabled = true;
|
||||
},
|
||||
function() {
|
||||
info("Running step 10 - open tabs in private browsing mode");
|
||||
for (let i = 0; i < 3; i++) {
|
||||
let tab = gBrowser.addTab();
|
||||
loadTab(tab, TEST_URL_BASES[0] + (++gTabCounter));
|
||||
}
|
||||
},
|
||||
function() {
|
||||
info("Running step 11 - close tabs in private browsing mode");
|
||||
gBrowser.removeCurrentTab();
|
||||
ensure_opentabs_match_db(nextStep);
|
||||
},
|
||||
function() {
|
||||
info("Running step 12 - leave private browsing mode");
|
||||
|
||||
Services.obs.addObserver(function(aSubject, aTopic, aData) {
|
||||
Services.obs.removeObserver(arguments.callee, "private-browsing-transition-complete");
|
||||
|
||||
let ps = Services.prefs;
|
||||
ps.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
ps.clearUserPref("browser.tabs.warnOnClose");
|
||||
|
||||
for (let i = 1; i < gBrowser.tabs.length; i++)
|
||||
waitForRestoredTab(gBrowser.tabs[i]);
|
||||
|
||||
}, "private-browsing-transition-complete", false);
|
||||
|
||||
gPrivateBrowsing.privateBrowsingEnabled = false;
|
||||
},
|
||||
function() {
|
||||
info("Running step 13 - close all tabs");
|
||||
|
||||
Services.prefs.clearUserPref("browser.sessionstore.restore_on_demand");
|
||||
|
||||
gBrowser.addTab("about:blank", {skipAnimation: true});
|
||||
while (gBrowser.tabs.length > 1) {
|
||||
info("Removing tab: " + gBrowser.tabs[0].linkedBrowser.currentURI.spec);
|
||||
gBrowser.selectTabAtIndex(0);
|
||||
gBrowser.removeCurrentTab();
|
||||
}
|
||||
ensure_opentabs_match_db(nextStep);
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
nextStep();
|
||||
}
|
||||
|
||||
function loadTab(tab, url) {
|
||||
// Because adding visits is async, we will not be notified immediately.
|
||||
let visited = gPrivateBrowsing.privateBrowsingEnabled;
|
||||
let loaded = false;
|
||||
|
||||
function maybeCheckResults() {
|
||||
if (visited && loaded && --gTabWaitCount == 0) {
|
||||
ensure_opentabs_match_db(nextStep);
|
||||
}
|
||||
}
|
||||
|
||||
tab.linkedBrowser.addEventListener("load", function () {
|
||||
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
loaded = true;
|
||||
maybeCheckResults();
|
||||
}, true);
|
||||
|
||||
if (!visited) {
|
||||
Services.obs.addObserver(
|
||||
function (aSubject, aTopic, aData) {
|
||||
if (url != aSubject.QueryInterface(Ci.nsIURI).spec)
|
||||
return;
|
||||
Services.obs.removeObserver(arguments.callee, aTopic);
|
||||
visited = true;
|
||||
maybeCheckResults();
|
||||
},
|
||||
"uri-visit-saved",
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
gTabWaitCount++;
|
||||
info("Loading page: " + url);
|
||||
tab.linkedBrowser.loadURI(url);
|
||||
}
|
||||
|
||||
function waitForRestoredTab(tab) {
|
||||
gTabWaitCount++;
|
||||
|
||||
tab.linkedBrowser.addEventListener("load", function () {
|
||||
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
if (--gTabWaitCount == 0) {
|
||||
ensure_opentabs_match_db(nextStep);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
|
||||
function nextStep() {
|
||||
if (gTestSteps.length == 0) {
|
||||
while (gBrowser.tabs.length > 1) {
|
||||
gBrowser.selectTabAtIndex(1);
|
||||
gBrowser.removeCurrentTab();
|
||||
}
|
||||
|
||||
waitForClearHistory(finish);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var stepFunc = gTestSteps.shift();
|
||||
stepFunc();
|
||||
}
|
||||
|
||||
function ensure_opentabs_match_db(aCallback) {
|
||||
var tabs = {};
|
||||
|
||||
var winEnum = Services.wm.getEnumerator("navigator:browser");
|
||||
while (winEnum.hasMoreElements()) {
|
||||
let browserWin = winEnum.getNext();
|
||||
// skip closed-but-not-destroyed windows
|
||||
if (browserWin.closed)
|
||||
continue;
|
||||
|
||||
for (let i = 0; i < browserWin.gBrowser.tabContainer.childElementCount; i++) {
|
||||
let browser = browserWin.gBrowser.getBrowserAtIndex(i);
|
||||
let url = browser.currentURI.spec;
|
||||
if (browserWin.isBlankPageURL(url))
|
||||
continue;
|
||||
if (!(url in tabs))
|
||||
tabs[url] = 1;
|
||||
else
|
||||
tabs[url]++;
|
||||
}
|
||||
}
|
||||
|
||||
checkAutocompleteResults(tabs, aCallback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears history invoking callback when done.
|
||||
*/
|
||||
function waitForClearHistory(aCallback) {
|
||||
const TOPIC_EXPIRATION_FINISHED = "places-expiration-finished";
|
||||
let observer = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
Services.obs.removeObserver(this, TOPIC_EXPIRATION_FINISHED);
|
||||
aCallback();
|
||||
}
|
||||
};
|
||||
Services.obs.addObserver(observer, TOPIC_EXPIRATION_FINISHED, false);
|
||||
|
||||
PlacesUtils.bhistory.removeAllPages();
|
||||
}
|
||||
|
||||
function checkAutocompleteResults(aExpected, aCallback)
|
||||
{
|
||||
gController.input = {
|
||||
timeout: 10,
|
||||
textValue: "",
|
||||
searches: ["history"],
|
||||
searchParam: "enable-actions",
|
||||
popupOpen: false,
|
||||
minResultsForPopup: 0,
|
||||
invalidate: function() {},
|
||||
disableAutoComplete: false,
|
||||
completeDefaultIndex: false,
|
||||
get popup() { return this; },
|
||||
onSearchBegin: function() {},
|
||||
onSearchComplete: function ()
|
||||
{
|
||||
info("Found " + gController.matchCount + " matches.");
|
||||
// Check to see the expected uris and titles match up (in any order)
|
||||
for (let i = 0; i < gController.matchCount; i++) {
|
||||
let uri = gController.getValueAt(i).replace(/^moz-action:[^,]+,/i, "");
|
||||
|
||||
info("Search for '" + uri + "' in open tabs.");
|
||||
ok(uri in aExpected, "Registered open page found in autocomplete.");
|
||||
// Remove the found entry from expected results.
|
||||
delete aExpected[uri];
|
||||
}
|
||||
|
||||
// Make sure there is no reported open page that is not open.
|
||||
for (let entry in aExpected) {
|
||||
ok(false, "'" + entry + "' not found in autocomplete.");
|
||||
}
|
||||
|
||||
executeSoon(aCallback);
|
||||
},
|
||||
setSelectedIndex: function() {},
|
||||
get searchCount() { return this.searches.length; },
|
||||
getSearchAt: function(aIndex) this.searches[aIndex],
|
||||
QueryInterface: XPCOMUtils.generateQI([
|
||||
Ci.nsIAutoCompleteInput,
|
||||
Ci.nsIAutoCompletePopup,
|
||||
])
|
||||
};
|
||||
|
||||
info("Searching open pages.");
|
||||
gController.startSearch(Services.prefs.getCharPref("browser.urlbar.restrict.openpage"));
|
||||
}
|
@ -30,18 +30,9 @@ _BROWSER_FILES = \
|
||||
browser_newtab_bug735987.js \
|
||||
browser_newtab_bug752841.js \
|
||||
browser_newtab_bug765628.js \
|
||||
browser_newtab_perwindow_private_browsing.js \
|
||||
head.js \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
_BROWSER_FILES += \
|
||||
browser_newtab_perwindow_private_browsing.js \
|
||||
$(NULL)
|
||||
else
|
||||
_BROWSER_FILES += \
|
||||
browser_newtab_private_browsing.js \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
libs:: $(_BROWSER_FILES)
|
||||
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)
|
||||
|
@ -1,54 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/*
|
||||
* These tests ensure that all changes made to the new tab page in private
|
||||
* browsing mode are discarded after switching back to normal mode again.
|
||||
* The private browsing mode should start with the current grid shown in normal
|
||||
* mode.
|
||||
*/
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"]
|
||||
.getService(Ci.nsIPrivateBrowsingService);
|
||||
|
||||
function runTests() {
|
||||
// prepare the grid
|
||||
yield setLinks("0,1,2,3,4,5,6,7,8,9");
|
||||
ok(!pb.privateBrowsingEnabled, "private browsing is disabled");
|
||||
|
||||
yield addNewTabPageTab();
|
||||
pinCell(0);
|
||||
checkGrid("0p,1,2,3,4,5,6,7,8");
|
||||
|
||||
// enter private browsing mode
|
||||
yield togglePrivateBrowsing();
|
||||
ok(pb.privateBrowsingEnabled, "private browsing is enabled");
|
||||
|
||||
yield addNewTabPageTab();
|
||||
checkGrid("0p,1,2,3,4,5,6,7,8");
|
||||
|
||||
// modify the grid while we're in pb mode
|
||||
yield blockCell(1);
|
||||
checkGrid("0p,2,3,4,5,6,7,8");
|
||||
|
||||
yield unpinCell(0);
|
||||
checkGrid("0,2,3,4,5,6,7,8");
|
||||
|
||||
// exit private browsing mode
|
||||
yield togglePrivateBrowsing();
|
||||
ok(!pb.privateBrowsingEnabled, "private browsing is disabled");
|
||||
|
||||
// check that the grid is the same as before entering pb mode
|
||||
yield addNewTabPageTab();
|
||||
checkGrid("0,2,3,4,5,6,7,8")
|
||||
}
|
||||
|
||||
function togglePrivateBrowsing() {
|
||||
let topic = "private-browsing-transition-complete";
|
||||
|
||||
Services.obs.addObserver(function observe() {
|
||||
Services.obs.removeObserver(observe, topic);
|
||||
executeSoon(TestRunner.next);
|
||||
}, topic, false);
|
||||
|
||||
pb.privateBrowsingEnabled = !pb.privateBrowsingEnabled;
|
||||
}
|
@ -12,6 +12,7 @@ include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
_BROWSER_FILES = \
|
||||
head.js \
|
||||
browser_social_perwindowPB.js \
|
||||
browser_social_toolbar.js \
|
||||
browser_social_shareButton.js \
|
||||
browser_social_sidebar.js \
|
||||
@ -30,16 +31,6 @@ _BROWSER_FILES = \
|
||||
social_worker.js \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
_BROWSER_FILES += \
|
||||
browser_social_perwindowPB.js \
|
||||
$(NULL)
|
||||
else
|
||||
_BROWSER_FILES += \
|
||||
browser_social_globalPB.js \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
libs:: $(_BROWSER_FILES)
|
||||
|
@ -1,147 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
// a place for miscellaneous social tests
|
||||
|
||||
|
||||
const pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
|
||||
function waitForPortMessage(port, topic, callback) {
|
||||
port.onmessage = function(evt) {
|
||||
if (evt.data.topic == topic)
|
||||
callback(evt.data);
|
||||
}
|
||||
}
|
||||
|
||||
function portClosed(port) {
|
||||
try {
|
||||
port.postMessage({topic: "ping"});
|
||||
return false; // worked - port can't be closed!
|
||||
} catch (ex) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
let manifest = { // normal provider
|
||||
name: "provider 1",
|
||||
origin: "https://example.com",
|
||||
sidebarURL: "https://example.com/browser/browser/base/content/test/social/social_sidebar.html",
|
||||
workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js",
|
||||
iconURL: "https://example.com/browser/browser/base/content/test/moz.png"
|
||||
};
|
||||
runSocialTestWithProvider(manifest, function (finishcb) {
|
||||
runSocialTests(tests, undefined, undefined, finishcb);
|
||||
});
|
||||
}
|
||||
|
||||
var tests = {
|
||||
testPrivateBrowsing: function(next) {
|
||||
let port = Social.provider.getWorkerPort();
|
||||
ok(port, "provider has a port");
|
||||
port.postMessage({topic: "test-init"});
|
||||
port.onmessage = function (e) {
|
||||
let topic = e.data.topic;
|
||||
switch (topic) {
|
||||
case "got-sidebar-message":
|
||||
ok(true, "got sidebar message");
|
||||
port.close();
|
||||
togglePrivateBrowsing(function () {
|
||||
ok(!Social.enabled, "Social shuts down during private browsing");
|
||||
togglePrivateBrowsing(function () {
|
||||
ok(Social.provider.getWorkerPort(), "port still obtainable after PB")
|
||||
ok(Social.enabled, "Social enabled after private browsing");
|
||||
next();
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
testPrivateBrowsingSocialDisabled: function(next) {
|
||||
// test PB from the perspective of entering PB without social enabled
|
||||
// we expect social to be enabled at the start of the test, we need
|
||||
// to disable it before testing PB transitions.
|
||||
ok(Social.enabled, "social is still enabled");
|
||||
let port = Social.provider.getWorkerPort();
|
||||
ok(port, "provider has a port");
|
||||
port.postMessage({topic: "test-init"});
|
||||
port.onmessage = function (e) {
|
||||
let topic = e.data.topic;
|
||||
switch (topic) {
|
||||
case "got-sidebar-message":
|
||||
ok(true, "got sidebar message");
|
||||
port.close();
|
||||
Social.enabled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// wait for disable, then do some pb toggling. We expect social to remain
|
||||
// disabled through these tests
|
||||
Services.obs.addObserver(function observer(aSubject, aTopic) {
|
||||
Services.obs.removeObserver(observer, aTopic);
|
||||
ok(!Social.enabled, "Social is not enabled");
|
||||
togglePrivateBrowsing(function () {
|
||||
ok(!Social.enabled, "Social not available during private browsing");
|
||||
togglePrivateBrowsing(function () {
|
||||
ok(!Social.enabled, "Social is not enabled after private browsing");
|
||||
// reenable social for next social test
|
||||
Social.enabled = true;
|
||||
next();
|
||||
});
|
||||
});
|
||||
}, "social:pref-changed", false);
|
||||
},
|
||||
|
||||
testPrivateBrowsingExitReloads: function(next) {
|
||||
let port = Social.provider.getWorkerPort();
|
||||
waitForPortMessage(port, "got-sidebar-message", function(data) {
|
||||
ok(!portClosed(port), "port not closed before PB transition");
|
||||
togglePrivateBrowsing(function () {
|
||||
ok(!Social.enabled, "Social shuts down during private browsing");
|
||||
// check the port we had before is dead.
|
||||
ok(portClosed(port), "port closed after PB transition");
|
||||
// enable it and stick a value in the window object.
|
||||
Social.enabled = true;
|
||||
port = Social.provider.getWorkerPort();
|
||||
waitForPortMessage(port, "got-sidebar-message", function(data) {
|
||||
// now just stuff a value in the sidebar - it should end
|
||||
// up being removed when we leave PB mode via the sidebar
|
||||
// being reloaded.
|
||||
let sbw = document.getElementById("social-sidebar-browser").contentWindow;
|
||||
sbw.wrappedJSObject.foo = "bar";
|
||||
// Now toggle PB mode back to off.
|
||||
togglePrivateBrowsing(function () {
|
||||
ok(Social.enabled, "Social still enabled after leaving private browsing");
|
||||
ok(portClosed(port), "port closed after PB transition");
|
||||
port = Social.provider.getWorkerPort();
|
||||
waitForPortMessage(port, "got-sidebar-message", function() {
|
||||
sbw = document.getElementById("social-sidebar-browser").contentWindow;
|
||||
is(sbw.wrappedJSObject.foo, undefined, "should have lost window variable when exiting")
|
||||
next();
|
||||
});
|
||||
port.postMessage({topic: "test-init"});
|
||||
});
|
||||
});
|
||||
port.postMessage({topic: "test-init"});
|
||||
});
|
||||
});
|
||||
port.postMessage({topic: "test-init"});
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
function togglePrivateBrowsing(aCallback) {
|
||||
Services.obs.addObserver(function observe(subject, topic, data) {
|
||||
Services.obs.removeObserver(observe, topic);
|
||||
executeSoon(aCallback);
|
||||
}, "private-browsing-transition-complete", false);
|
||||
|
||||
pb.privateBrowsingEnabled = !pb.privateBrowsingEnabled;
|
||||
}
|
@ -10,9 +10,6 @@ Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "BROWSER_NEW_TAB_URL", function () {
|
||||
const PREF = "browser.newtab.url";
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
const TOPIC = "private-browsing-transition-complete";
|
||||
#endif
|
||||
|
||||
function getNewTabPageURL() {
|
||||
if (!Services.prefs.prefHasUserValue(PREF)) {
|
||||
@ -28,16 +25,10 @@ XPCOMUtils.defineLazyGetter(this, "BROWSER_NEW_TAB_URL", function () {
|
||||
}
|
||||
|
||||
Services.prefs.addObserver(PREF, update, false);
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
Services.obs.addObserver(update, TOPIC, false);
|
||||
#endif
|
||||
|
||||
addEventListener("unload", function onUnload() {
|
||||
removeEventListener("unload", onUnload);
|
||||
Services.prefs.removeObserver(PREF, update);
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
Services.obs.removeObserver(update, TOPIC);
|
||||
#endif
|
||||
});
|
||||
|
||||
return getNewTabPageURL();
|
||||
@ -275,11 +266,9 @@ function openLinkIn(url, where, params) {
|
||||
sa.AppendElement(allowThirdPartyFixupSupports);
|
||||
|
||||
let features = "chrome,dialog=no,all";
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
if (aIsPrivate) {
|
||||
features += ",private";
|
||||
}
|
||||
#endif
|
||||
|
||||
Services.ww.openWindow(w || window, getBrowserURL(), null, features, sa);
|
||||
return;
|
||||
|
@ -44,11 +44,6 @@ SHARED_LIBRARY_LIBS = \
|
||||
../dirprovider/$(LIB_PREFIX)browserdir_s.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
|
||||
ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
LOCAL_INCLUDES += -I$(srcdir)/../privatebrowsing/src
|
||||
SHARED_LIBRARY_LIBS += ../privatebrowsing/src/$(LIB_PREFIX)privatebrowsing_s.$(LIB_SUFFIX)
|
||||
endif
|
||||
|
||||
ifneq (,$(filter windows cocoa gtk2, $(MOZ_WIDGET_TOOLKIT)))
|
||||
SHARED_LIBRARY_LIBS += ../shell/src/$(LIB_PREFIX)shellservice_s.$(LIB_SUFFIX)
|
||||
endif
|
||||
|
@ -25,9 +25,6 @@
|
||||
#include "AboutRedirector.h"
|
||||
#include "nsIAboutModule.h"
|
||||
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
#include "nsPrivateBrowsingServiceWrapper.h"
|
||||
#endif
|
||||
#include "nsNetCID.h"
|
||||
|
||||
using namespace mozilla::browser;
|
||||
@ -49,10 +46,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsIEHistoryEnumerator)
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFeedSniffer)
|
||||
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrivateBrowsingServiceWrapper, Init)
|
||||
#endif
|
||||
|
||||
NS_DEFINE_NAMED_CID(NS_BROWSERDIRECTORYPROVIDER_CID);
|
||||
#if defined(XP_WIN)
|
||||
NS_DEFINE_NAMED_CID(NS_SHELLSERVICE_CID);
|
||||
@ -66,9 +59,6 @@ NS_DEFINE_NAMED_CID(NS_WINIEHISTORYENUMERATOR_CID);
|
||||
#elif defined(XP_MACOSX)
|
||||
NS_DEFINE_NAMED_CID(NS_SHELLSERVICE_CID);
|
||||
#endif
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
NS_DEFINE_NAMED_CID(NS_PRIVATE_BROWSING_SERVICE_WRAPPER_CID);
|
||||
#endif
|
||||
|
||||
static const mozilla::Module::CIDEntry kBrowserCIDs[] = {
|
||||
{ &kNS_BROWSERDIRECTORYPROVIDER_CID, false, NULL, DirectoryProviderConstructor },
|
||||
@ -83,9 +73,6 @@ static const mozilla::Module::CIDEntry kBrowserCIDs[] = {
|
||||
{ &kNS_WINIEHISTORYENUMERATOR_CID, false, NULL, nsIEHistoryEnumeratorConstructor },
|
||||
#elif defined(XP_MACOSX)
|
||||
{ &kNS_SHELLSERVICE_CID, false, NULL, nsMacShellServiceConstructor },
|
||||
#endif
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
{ &kNS_PRIVATE_BROWSING_SERVICE_WRAPPER_CID, false, NULL, nsPrivateBrowsingServiceWrapperConstructor },
|
||||
#endif
|
||||
{ NULL }
|
||||
};
|
||||
@ -124,9 +111,6 @@ static const mozilla::Module::ContractIDEntry kBrowserContracts[] = {
|
||||
{ NS_IEHISTORYENUMERATOR_CONTRACTID, &kNS_WINIEHISTORYENUMERATOR_CID },
|
||||
#elif defined(XP_MACOSX)
|
||||
{ NS_SHELLSERVICE_CONTRACTID, &kNS_SHELLSERVICE_CID },
|
||||
#endif
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
{ NS_PRIVATE_BROWSING_SERVICE_CONTRACTID, &kNS_PRIVATE_BROWSING_SERVICE_WRAPPER_CID },
|
||||
#endif
|
||||
{ NULL }
|
||||
};
|
||||
|
@ -186,15 +186,11 @@ this.DownloadsCommon = {
|
||||
* The browser window which owns the download button.
|
||||
*/
|
||||
getData: function DC_getData(aWindow) {
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
if (PrivateBrowsingUtils.isWindowPrivate(aWindow)) {
|
||||
return PrivateDownloadsData;
|
||||
} else {
|
||||
return DownloadsData;
|
||||
}
|
||||
#else
|
||||
return DownloadsData;
|
||||
#endif
|
||||
},
|
||||
|
||||
/**
|
||||
@ -239,15 +235,11 @@ this.DownloadsCommon = {
|
||||
* the window in question.
|
||||
*/
|
||||
getIndicatorData: function DC_getIndicatorData(aWindow) {
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
if (PrivateBrowsingUtils.isWindowPrivate(aWindow)) {
|
||||
return PrivateDownloadsIndicatorData;
|
||||
} else {
|
||||
return DownloadsIndicatorData;
|
||||
}
|
||||
#else
|
||||
return DownloadsIndicatorData;
|
||||
#endif
|
||||
},
|
||||
|
||||
/**
|
||||
@ -262,7 +254,6 @@ this.DownloadsCommon = {
|
||||
*/
|
||||
getSummary: function DC_getSummary(aWindow, aNumToExclude)
|
||||
{
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
if (PrivateBrowsingUtils.isWindowPrivate(aWindow)) {
|
||||
if (this._privateSummary) {
|
||||
return this._privateSummary;
|
||||
@ -274,12 +265,6 @@ this.DownloadsCommon = {
|
||||
}
|
||||
return this._summary = new DownloadsSummaryData(false, aNumToExclude);
|
||||
}
|
||||
#else
|
||||
if (this._summary) {
|
||||
return this._summary;
|
||||
}
|
||||
return this._summary = new DownloadsSummaryData(false, aNumToExclude);
|
||||
#endif
|
||||
},
|
||||
_summary: null,
|
||||
_privateSummary: null,
|
||||
@ -559,12 +544,6 @@ function DownloadsDataCtor(aPrivate) {
|
||||
// prevent race conditions when populating the list asynchronously.
|
||||
this.dataItems = {};
|
||||
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
// While operating in Private Browsing Mode, persistent data items are parked
|
||||
// here until we return to the normal mode.
|
||||
this._persistentDataItems = {};
|
||||
#endif
|
||||
|
||||
// Array of view objects that should be notified when the available download
|
||||
// data changes.
|
||||
this._views = [];
|
||||
@ -585,10 +564,6 @@ DownloadsDataCtor.prototype = {
|
||||
// Start receiving real-time events.
|
||||
aDownloadManagerService.addPrivacyAwareListener(this);
|
||||
Services.obs.addObserver(this, "download-manager-remove-download-guid", false);
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
Services.obs.addObserver(this, "download-manager-database-type-changed",
|
||||
false);
|
||||
#endif
|
||||
},
|
||||
|
||||
/**
|
||||
@ -599,9 +574,6 @@ DownloadsDataCtor.prototype = {
|
||||
this._terminateDataAccess();
|
||||
|
||||
// Stop receiving real-time events.
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
Services.obs.removeObserver(this, "download-manager-database-type-changed");
|
||||
#endif
|
||||
Services.obs.removeObserver(this, "download-manager-remove-download-guid");
|
||||
Services.downloads.removeListener(this);
|
||||
},
|
||||
@ -917,26 +889,6 @@ DownloadsDataCtor.prototype = {
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
case "download-manager-database-type-changed":
|
||||
let pbs = Cc["@mozilla.org/privatebrowsing;1"]
|
||||
.getService(Ci.nsIPrivateBrowsingService);
|
||||
if (pbs.privateBrowsingEnabled) {
|
||||
// Save a reference to the persistent store before terminating access.
|
||||
this._persistentDataItems = this.dataItems;
|
||||
this.clear();
|
||||
} else {
|
||||
// Terminate data access, then restore the persistent store.
|
||||
this.clear();
|
||||
this.dataItems = this._persistentDataItems;
|
||||
this._persistentDataItems = null;
|
||||
}
|
||||
// Reinitialize the views with the current items. View data has been
|
||||
// already invalidated by the previous calls.
|
||||
this._views.forEach(this._updateView, this);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
},
|
||||
|
||||
@ -945,13 +897,11 @@ DownloadsDataCtor.prototype = {
|
||||
|
||||
onDownloadStateChange: function DD_onDownloadStateChange(aOldState, aDownload)
|
||||
{
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
if (aDownload.isPrivate != this._isPrivate) {
|
||||
// Ignore the downloads with a privacy status other than what we are
|
||||
// tracking.
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// When a new download is added, it may have the same identifier of a
|
||||
// download that we previously deleted during this session, and we also
|
||||
@ -1031,13 +981,11 @@ DownloadsDataCtor.prototype = {
|
||||
aCurTotalProgress,
|
||||
aMaxTotalProgress, aDownload)
|
||||
{
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
if (aDownload.isPrivate != this._isPrivate) {
|
||||
// Ignore the downloads with a privacy status other than what we are
|
||||
// tracking.
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
let dataItem = this._getOrAddDataItem(aDownload, false);
|
||||
if (!dataItem) {
|
||||
|
@ -31,22 +31,13 @@ XPCOMUtils.defineLazyModuleGetter(this, "DownloadsCommon",
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "gSessionStartup",
|
||||
"@mozilla.org/browser/sessionstartup;1",
|
||||
"nsISessionStartup");
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "gPrivateBrowsingService",
|
||||
"@mozilla.org/privatebrowsing;1",
|
||||
"nsIPrivateBrowsingService");
|
||||
#endif
|
||||
|
||||
const kObservedTopics = [
|
||||
"sessionstore-windows-restored",
|
||||
"sessionstore-browser-state-restored",
|
||||
"download-manager-initialized",
|
||||
"download-manager-change-retention",
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
"last-pb-context-exited",
|
||||
#else
|
||||
"private-browsing-transition-complete",
|
||||
#endif
|
||||
"browser-lastwindow-close-granted",
|
||||
"quit-application",
|
||||
"profile-change-teardown",
|
||||
@ -145,14 +136,6 @@ DownloadsStartup.prototype = {
|
||||
}
|
||||
break;
|
||||
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
case "private-browsing-transition-complete":
|
||||
// Ensure that persistent data is reloaded only when the database
|
||||
// connection is available again.
|
||||
this._ensureDataLoaded();
|
||||
break;
|
||||
#endif
|
||||
|
||||
case "browser-lastwindow-close-granted":
|
||||
// When using the panel interface, downloads that are already completed
|
||||
// should be removed when the last full browser window is closed. This
|
||||
@ -166,7 +149,6 @@ DownloadsStartup.prototype = {
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
case "last-pb-context-exited":
|
||||
// Similar to the above notification, but for private downloads.
|
||||
if (this._downloadsServiceInitialized &&
|
||||
@ -174,7 +156,6 @@ DownloadsStartup.prototype = {
|
||||
Services.downloads.cleanUpPrivate();
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
case "quit-application":
|
||||
// When the application is shutting down, we must free all resources in
|
||||
@ -276,11 +257,7 @@ DownloadsStartup.prototype = {
|
||||
*/
|
||||
_ensureDataLoaded: function DS_ensureDataLoaded()
|
||||
{
|
||||
if (!this._downloadsServiceInitialized
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
|| gPrivateBrowsingService.privateBrowsingEnabled
|
||||
#endif
|
||||
) {
|
||||
if (!this._downloadsServiceInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -511,17 +511,12 @@ nsBrowserContentHandler.prototype = {
|
||||
}
|
||||
if (cmdLine.handleFlag("silent", false))
|
||||
cmdLine.preventDefault = true;
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
if (cmdLine.handleFlag("private-window", false)) {
|
||||
openWindow(null, this.chromeURL, "_blank",
|
||||
"chrome,dialog=no,private,all" + this.getFeatures(cmdLine),
|
||||
"about:privatebrowsing");
|
||||
cmdLine.preventDefault = true;
|
||||
}
|
||||
#else
|
||||
if (cmdLine.findFlag("private-toggle", false) >= 0)
|
||||
cmdLine.preventDefault = true;
|
||||
#endif
|
||||
|
||||
var searchParam = cmdLine.handleFlagWithParam("search", false);
|
||||
if (searchParam) {
|
||||
@ -531,11 +526,7 @@ nsBrowserContentHandler.prototype = {
|
||||
|
||||
// The global PB Service consumes this flag, so only eat it in per-window
|
||||
// PB builds.
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
if (cmdLine.handleFlag("private", false)) {
|
||||
#else
|
||||
if (cmdLine.findFlag("private", false) >= 0) {
|
||||
#endif
|
||||
PrivateBrowsingUtils.enterTemporaryAutoStartMode();
|
||||
}
|
||||
|
||||
|
@ -139,13 +139,8 @@ PlacesController.prototype = {
|
||||
// Otherwise fallback to cmd_delete check.
|
||||
case "cmd_delete":
|
||||
case "placesCmd_delete":
|
||||
return this._hasRemovableSelection(false);
|
||||
case "placesCmd_deleteDataHost":
|
||||
return this._hasRemovableSelection(false)
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
&& !PlacesUIUtils.privateBrowsing.privateBrowsingEnabled
|
||||
#endif
|
||||
;
|
||||
return this._hasRemovableSelection(false);
|
||||
case "placesCmd_moveBookmarks":
|
||||
return this._hasRemovableSelection(true);
|
||||
case "cmd_copy":
|
||||
@ -604,14 +599,7 @@ PlacesController.prototype = {
|
||||
// We allow pasting into tag containers, so special case that.
|
||||
var hideIfNoIP = item.getAttribute("hideifnoinsertionpoint") == "true" &&
|
||||
noIp && !(ip && ip.isTag && item.id == "placesContext_paste");
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
var hideIfPB = false;
|
||||
#else
|
||||
var hideIfPB = item.getAttribute("hideifprivatebrowsing") == "true" &&
|
||||
PlacesUIUtils.privateBrowsing.privateBrowsingEnabled;
|
||||
#endif
|
||||
item.hidden = hideIfNoIP || hideIfPB ||
|
||||
!this._shouldShowMenuItem(item, metadata);
|
||||
item.hidden = hideIfNoIP || !this._shouldShowMenuItem(item, metadata);
|
||||
|
||||
if (!item.hidden) {
|
||||
visibleItemsBeforeSep = true;
|
||||
|
@ -75,10 +75,6 @@ var PlacesOrganizer = {
|
||||
document.getElementById("placesContext")
|
||||
.removeChild(document.getElementById("placesContext_show:info"));
|
||||
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
gPrivateBrowsingListener.init();
|
||||
#endif
|
||||
|
||||
ContentArea.focus();
|
||||
},
|
||||
|
||||
@ -111,9 +107,6 @@ var PlacesOrganizer = {
|
||||
},
|
||||
|
||||
destroy: function PO_destroy() {
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
gPrivateBrowsingListener.uninit();
|
||||
#endif
|
||||
},
|
||||
|
||||
_location: null,
|
||||
@ -1198,45 +1191,6 @@ var ViewMenu = {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
/**
|
||||
* Disables the "Import and Backup->Import From Another Browser" menu item
|
||||
* in private browsing mode.
|
||||
*/
|
||||
let gPrivateBrowsingListener = {
|
||||
_cmd_import: null,
|
||||
|
||||
init: function PO_PB_init() {
|
||||
this._cmd_import = document.getElementById("OrganizerCommand_browserImport");
|
||||
|
||||
let pbs = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
if (pbs.privateBrowsingEnabled)
|
||||
this.updateUI(true);
|
||||
|
||||
Services.obs.addObserver(this, "private-browsing", false);
|
||||
},
|
||||
|
||||
uninit: function PO_PB_uninit() {
|
||||
Services.obs.removeObserver(this, "private-browsing");
|
||||
},
|
||||
|
||||
observe: function PO_PB_observe(aSubject, aTopic, aData) {
|
||||
if (aData == "enter")
|
||||
this.updateUI(true);
|
||||
else if (aData == "exit")
|
||||
this.updateUI(false);
|
||||
},
|
||||
|
||||
updateUI: function PO_PB_updateUI(PBmode) {
|
||||
if (PBmode)
|
||||
this._cmd_import.setAttribute("disabled", "true");
|
||||
else
|
||||
this._cmd_import.removeAttribute("disabled");
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
let ContentArea = {
|
||||
_specialViews: new Map(),
|
||||
|
||||
|
@ -1009,12 +1009,6 @@ XPCOMUtils.defineLazyGetter(PlacesUIUtils, "ellipsis", function() {
|
||||
Ci.nsIPrefLocalizedString).data;
|
||||
});
|
||||
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
XPCOMUtils.defineLazyServiceGetter(PlacesUIUtils, "privateBrowsing",
|
||||
"@mozilla.org/privatebrowsing;1",
|
||||
"nsIPrivateBrowsingService");
|
||||
#endif
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "URIFixup",
|
||||
"@mozilla.org/docshell/urifixup;1",
|
||||
"nsIURIFixup");
|
||||
|
@ -10,8 +10,8 @@ browser.jar:
|
||||
content/browser/preferences/in-content/main.js
|
||||
* content/browser/preferences/in-content/tabs.xul
|
||||
* content/browser/preferences/in-content/tabs.js
|
||||
* content/browser/preferences/in-content/privacy.xul
|
||||
* content/browser/preferences/in-content/privacy.js
|
||||
content/browser/preferences/in-content/privacy.xul
|
||||
content/browser/preferences/in-content/privacy.js
|
||||
* content/browser/preferences/in-content/advanced.xul
|
||||
* content/browser/preferences/in-content/advanced.js
|
||||
content/browser/preferences/in-content/applications.xul
|
||||
|
@ -276,7 +276,6 @@ var gPrivacyPane = {
|
||||
|
||||
observe: function PPP_observe(aSubject, aTopic, aData)
|
||||
{
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
if (!gPrivacyPane._shouldPromptForRestart) {
|
||||
// We're performing a revert. Just let it happen.
|
||||
gPrivacyPane._shouldPromptForRestart = true;
|
||||
@ -318,23 +317,6 @@ var gPrivacyPane = {
|
||||
let rememberHistoryCheckbox = document.getElementById("rememberHistory");
|
||||
rememberHistory.checked = pref.value;
|
||||
}
|
||||
#else
|
||||
// Toggle the private browsing mode without switching the session
|
||||
let prefValue = document.getElementById("browser.privatebrowsing.autostart").value;
|
||||
let keepCurrentSession = document.getElementById("browser.privatebrowsing.keep_current_session");
|
||||
keepCurrentSession.value = true;
|
||||
|
||||
let privateBrowsingService = Components.classes["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Components.interfaces.nsIPrivateBrowsingService);
|
||||
|
||||
// If activating from within the private browsing mode, reset the
|
||||
// private session
|
||||
if (prefValue && privateBrowsingService.privateBrowsingEnabled)
|
||||
privateBrowsingService.privateBrowsingEnabled = false;
|
||||
privateBrowsingService.privateBrowsingEnabled = prefValue;
|
||||
|
||||
keepCurrentSession.reset();
|
||||
#endif
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -61,16 +61,8 @@
|
||||
<preference id="browser.privatebrowsing.autostart"
|
||||
name="browser.privatebrowsing.autostart"
|
||||
onchange="gPrivacyPane.updatePrivacyMicroControls();"
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
instantApply="true"
|
||||
#endif
|
||||
type="bool"/>
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
<preference id="browser.privatebrowsing.keep_current_session"
|
||||
name="browser.privatebrowsing.keep_current_session"
|
||||
instantApply="true"
|
||||
type="bool"/>
|
||||
#endif
|
||||
|
||||
</preferences>
|
||||
|
||||
|
@ -17,31 +17,13 @@ _BROWSER_FILES = \
|
||||
browser_bug410900.js \
|
||||
browser_bug731866.js \
|
||||
browser_connection.js \
|
||||
$(NULL)
|
||||
|
||||
ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
_BROWSER_FILES += \
|
||||
privacypane_tests.js \
|
||||
browser_bug567487.js \
|
||||
browser_privacypane_1.js \
|
||||
browser_privacypane_2.js \
|
||||
browser_privacypane_3.js \
|
||||
browser_privacypane_4.js \
|
||||
browser_privacypane_5.js \
|
||||
browser_privacypane_6.js \
|
||||
browser_privacypane_7.js \
|
||||
browser_privacypane_8.js \
|
||||
$(NULL)
|
||||
else
|
||||
_BROWSER_FILES += \
|
||||
privacypane_tests_perwindow.js \
|
||||
browser_privacypane_1.js \
|
||||
browser_privacypane_3.js \
|
||||
browser_privacypane_4.js \
|
||||
browser_privacypane_5.js \
|
||||
browser_privacypane_8.js \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
ifdef MOZ_SERVICES_HEALTHREPORT
|
||||
_BROWSER_FILES += browser_healthreport.js
|
||||
|
@ -1,73 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
resetPreferences();
|
||||
|
||||
function observer(win, topic, data) {
|
||||
if (topic != "main-pane-loaded")
|
||||
return;
|
||||
|
||||
Services.obs.removeObserver(observer, "main-pane-loaded");
|
||||
runTest(win);
|
||||
}
|
||||
Services.obs.addObserver(observer, "main-pane-loaded", false);
|
||||
|
||||
gBrowser.selectedTab = gBrowser.addTab("about:preferences");
|
||||
}
|
||||
|
||||
function runTest(win) {
|
||||
win.gotoPref("general");
|
||||
let doc = win.document;
|
||||
let pbAutoStartPref = doc.getElementById("browser.privatebrowsing.autostart");
|
||||
let startupPref = doc.getElementById("browser.startup.page");
|
||||
let menu = doc.getElementById("browserStartupPage");
|
||||
let option = doc.getElementById("browserStartupLastSession");
|
||||
let defOption = doc.getElementById("browserStartupHomePage");
|
||||
let otherOption = doc.getElementById("browserStartupBlank");
|
||||
|
||||
ok(!pbAutoStartPref.value, "Sanity check");
|
||||
is(startupPref.value, startupPref.defaultValue, "Sanity check");
|
||||
|
||||
// First, check to make sure that setting pbAutoStartPref disables the menu item
|
||||
pbAutoStartPref.value = true;
|
||||
is(option.getAttribute("disabled"), "true", "Setting private browsing to autostart " +
|
||||
"should disable the 'Show my tabs and windows from last time' option");
|
||||
pbAutoStartPref.value = false;
|
||||
|
||||
// Now ensure the correct behavior when pbAutoStartPref is set with option enabled
|
||||
startupPref.value = option.getAttribute("value");
|
||||
is(menu.selectedItem, option, "Sanity check");
|
||||
pbAutoStartPref.value = true;
|
||||
is(option.getAttribute("disabled"), "true", "Setting private browsing to autostart " +
|
||||
"should disable the 'Show my tabs and windows from last time' option");
|
||||
is(menu.selectedItem, defOption, "The 'Show home page' option should be selected");
|
||||
is(startupPref.value, option.getAttribute("value"), "But the value of the startup " +
|
||||
"pref itself shouldn't change");
|
||||
menu.selectedItem = otherOption;
|
||||
menu.doCommand();
|
||||
is(startupPref.value, otherOption.getAttribute("value"), "And we should be able to " +
|
||||
"chnage it!");
|
||||
pbAutoStartPref.value = false;
|
||||
|
||||
// Now, ensure that with 'Show my windows and tabs from last time' enabled, toggling
|
||||
// pbAutoStartPref would restore that value in the menulist.
|
||||
startupPref.value = option.getAttribute("value");
|
||||
is(menu.selectedItem, option, "Sanity check");
|
||||
pbAutoStartPref.value = true;
|
||||
is(menu.selectedItem, defOption, "The 'Show home page' option should be selected");
|
||||
pbAutoStartPref.value = false;
|
||||
is(menu.selectedItem, option, "The correct value should be restored");
|
||||
|
||||
// cleanup
|
||||
resetPreferences();
|
||||
gBrowser.removeCurrentTab();
|
||||
win.close();
|
||||
finish();
|
||||
}
|
||||
|
||||
function resetPreferences() {
|
||||
Services.prefs.clearUserPref("browser.startup.page");
|
||||
Services.prefs.clearUserPref("browser.privatebrowsing.autostart");
|
||||
}
|
@ -11,11 +11,7 @@ function test() {
|
||||
let tmpdir = extractJarToTmp(jar);
|
||||
rootDir = "file://" + tmpdir.path + '/';
|
||||
}
|
||||
try {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
} catch(x) {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests.js", this);
|
||||
}
|
||||
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
|
||||
run_test_subset([
|
||||
test_pane_visibility,
|
||||
|
@ -1,33 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
function test() {
|
||||
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
|
||||
getService(Ci.mozIJSSubScriptLoader);
|
||||
|
||||
let rootDir = getRootDirectory(gTestPath);
|
||||
let jar = getJar(rootDir);
|
||||
if (jar) {
|
||||
let tmpdir = extractJarToTmp(jar);
|
||||
rootDir = "file://" + tmpdir.path + '/';
|
||||
}
|
||||
try {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
} catch(x) {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests.js", this);
|
||||
}
|
||||
|
||||
run_test_subset([
|
||||
test_historymode_retention("remember", undefined),
|
||||
test_historymode_retention("dontremember", "remember"),
|
||||
test_historymode_retention("custom", "dontremember"),
|
||||
// custom without any micro-prefs changed won't retain
|
||||
test_historymode_retention("remember", "dontremember"),
|
||||
test_historymode_retention("custom", "remember"),
|
||||
// custom without any micro-prefs changed won't retain
|
||||
test_historymode_retention("remember", "remember"),
|
||||
|
||||
// reset all preferences to their default values once we're done
|
||||
reset_preferences
|
||||
]);
|
||||
}
|
@ -10,11 +10,7 @@ function test() {
|
||||
let tmpdir = extractJarToTmp(jar);
|
||||
rootDir = "file://" + tmpdir.path + '/';
|
||||
}
|
||||
try {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
} catch(x) {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests.js", this);
|
||||
}
|
||||
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
|
||||
run_test_subset([
|
||||
test_custom_retention("rememberHistory", "remember"),
|
||||
|
@ -10,11 +10,7 @@ function test() {
|
||||
let tmpdir = extractJarToTmp(jar);
|
||||
rootDir = "file://" + tmpdir.path + '/';
|
||||
}
|
||||
try {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
} catch(x) {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests.js", this);
|
||||
}
|
||||
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
|
||||
run_test_subset([
|
||||
test_custom_retention("acceptCookies", "remember"),
|
||||
|
@ -10,11 +10,7 @@ function test() {
|
||||
let tmpdir = extractJarToTmp(jar);
|
||||
rootDir = "file://" + tmpdir.path + '/';
|
||||
}
|
||||
try {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
} catch(x) {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests.js", this);
|
||||
}
|
||||
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
|
||||
run_test_subset([
|
||||
test_locbar_suggestion_retention(-1, undefined),
|
||||
|
@ -1,26 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
function test() {
|
||||
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
|
||||
getService(Ci.mozIJSSubScriptLoader);
|
||||
let rootDir = getRootDirectory(gTestPath);
|
||||
let jar = getJar(rootDir);
|
||||
if (jar) {
|
||||
let tmpdir = extractJarToTmp(jar);
|
||||
rootDir = "file://" + tmpdir.path + '/';
|
||||
}
|
||||
try {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
} catch(x) {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests.js", this);
|
||||
}
|
||||
|
||||
run_test_subset([
|
||||
test_privatebrowsing_toggle,
|
||||
enter_private_browsing, // once again, test with PB initially enabled
|
||||
test_privatebrowsing_toggle,
|
||||
|
||||
// don't reset preferences, will pick up where we left off in browser_privacypane_7.js
|
||||
]);
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
function test() {
|
||||
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
|
||||
getService(Ci.mozIJSSubScriptLoader);
|
||||
let rootDir = getRootDirectory(gTestPath);
|
||||
let jar = getJar(rootDir);
|
||||
if (jar) {
|
||||
let tmpdir = extractJarToTmp(jar);
|
||||
rootDir = "file://" + tmpdir.path + '/';
|
||||
}
|
||||
try {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
} catch(x) {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests.js", this);
|
||||
}
|
||||
|
||||
run_test_subset([
|
||||
test_privatebrowsing_ui,
|
||||
enter_private_browsing, // once again, test with PB initially enabled
|
||||
test_privatebrowsing_ui,
|
||||
|
||||
// reset all preferences to their default values once we're done
|
||||
reset_preferences
|
||||
]);
|
||||
}
|
@ -10,11 +10,7 @@ function test() {
|
||||
let tmpdir = extractJarToTmp(jar);
|
||||
rootDir = "file://" + tmpdir.path + '/';
|
||||
}
|
||||
try {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
} catch(x) {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests.js", this);
|
||||
}
|
||||
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
|
||||
run_test_subset([
|
||||
// history mode should be initialized to remember
|
||||
|
@ -1,491 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
function runTestOnPrivacyPrefPane(testFunc) {
|
||||
|
||||
gBrowser.tabContainer.addEventListener("TabOpen", function(aEvent) {
|
||||
gBrowser.tabContainer.removeEventListener("TabOpen", arguments.callee, true);
|
||||
let browser = aEvent.originalTarget.linkedBrowser;
|
||||
browser.addEventListener("Initialized", function(aEvent) {
|
||||
browser.removeEventListener("Initialized", arguments.callee, true);
|
||||
is(browser.contentWindow.location.href, "about:preferences", "Checking if the preferences tab was opened");
|
||||
testFunc(browser.contentWindow);
|
||||
gBrowser.removeCurrentTab();
|
||||
testRunner.runNext();
|
||||
}, true);
|
||||
}, true);
|
||||
|
||||
gBrowser.selectedTab = gBrowser.addTab("about:preferences");
|
||||
}
|
||||
|
||||
function controlChanged(element) {
|
||||
element.doCommand();
|
||||
}
|
||||
|
||||
function test_pane_visibility(win) {
|
||||
let modes = {
|
||||
"remember": "historyRememberPane",
|
||||
"dontremember": "historyDontRememberPane",
|
||||
"custom": "historyCustomPane"
|
||||
};
|
||||
|
||||
let historymode = win.document.getElementById("historyMode");
|
||||
ok(historymode, "history mode menulist should exist");
|
||||
let historypane = win.document.getElementById("historyPane");
|
||||
ok(historypane, "history mode pane should exist");
|
||||
|
||||
for (let mode in modes) {
|
||||
historymode.value = mode;
|
||||
controlChanged(historymode);
|
||||
is(historypane.selectedPanel, win.document.getElementById(modes[mode]),
|
||||
"The correct pane should be selected for the " + mode + " mode");
|
||||
}
|
||||
}
|
||||
|
||||
function test_dependent_elements(win) {
|
||||
let historymode = win.document.getElementById("historyMode");
|
||||
ok(historymode, "history mode menulist should exist");
|
||||
let pbautostart = win.document.getElementById("privateBrowsingAutoStart");
|
||||
ok(pbautostart, "the private browsing auto-start checkbox should exist");
|
||||
let controls = [
|
||||
win.document.getElementById("rememberHistory"),
|
||||
win.document.getElementById("rememberForms"),
|
||||
win.document.getElementById("keepUntil"),
|
||||
win.document.getElementById("keepCookiesUntil"),
|
||||
win.document.getElementById("alwaysClear"),
|
||||
];
|
||||
controls.forEach(function(control) {
|
||||
ok(control, "the dependent controls should exist");
|
||||
});
|
||||
let independents = [
|
||||
win.document.getElementById("acceptCookies"),
|
||||
win.document.getElementById("acceptThirdParty"),
|
||||
];
|
||||
independents.forEach(function(control) {
|
||||
ok(control, "the independent controls should exist");
|
||||
});
|
||||
let cookieexceptions = win.document.getElementById("cookieExceptions");
|
||||
ok(cookieexceptions, "the cookie exceptions button should exist");
|
||||
let keepuntil = win.document.getElementById("keepCookiesUntil");
|
||||
ok(keepuntil, "the keep cookies until menulist should exist");
|
||||
let alwaysclear = win.document.getElementById("alwaysClear");
|
||||
ok(alwaysclear, "the clear data on close checkbox should exist");
|
||||
let rememberhistory = win.document.getElementById("rememberHistory");
|
||||
ok(rememberhistory, "the remember history checkbox should exist");
|
||||
let rememberforms = win.document.getElementById("rememberForms");
|
||||
ok(rememberforms, "the remember forms checkbox should exist");
|
||||
let alwaysclearsettings = win.document.getElementById("clearDataSettings");
|
||||
ok(alwaysclearsettings, "the clear data settings button should exist");
|
||||
|
||||
function expect_disabled(disabled) {
|
||||
controls.forEach(function(control) {
|
||||
is(control.disabled, disabled,
|
||||
control.getAttribute("id") + " should " + (disabled ? "" : "not ") + "be disabled");
|
||||
});
|
||||
is(keepuntil.value, disabled ? 2 : 0,
|
||||
"the keep cookies until menulist value should be as expected");
|
||||
if (disabled) {
|
||||
ok(!alwaysclear.checked,
|
||||
"the clear data on close checkbox value should be as expected");
|
||||
ok(!rememberhistory.checked,
|
||||
"the remember history checkbox value should be as expected");
|
||||
ok(!rememberforms.checked,
|
||||
"the remember forms checkbox value should be as expected");
|
||||
}
|
||||
}
|
||||
function check_independents(expected) {
|
||||
independents.forEach(function(control) {
|
||||
is(control.disabled, expected,
|
||||
control.getAttribute("id") + " should " + (expected ? "" : "not ") + "be disabled");
|
||||
});
|
||||
|
||||
ok(!cookieexceptions.disabled,
|
||||
"the cookie exceptions button should never be disabled");
|
||||
ok(alwaysclearsettings.disabled,
|
||||
"the clear data settings button should always be disabled");
|
||||
}
|
||||
|
||||
// controls should only change in custom mode
|
||||
historymode.value = "remember";
|
||||
controlChanged(historymode);
|
||||
expect_disabled(false);
|
||||
check_independents(false);
|
||||
|
||||
// setting the mode to custom shouldn't change anything
|
||||
historymode.value = "custom";
|
||||
controlChanged(historymode);
|
||||
expect_disabled(false);
|
||||
check_independents(false);
|
||||
|
||||
// controls should only change in custom mode
|
||||
historymode.value = "dontremember";
|
||||
controlChanged(historymode);
|
||||
expect_disabled(false);
|
||||
check_independents(false);
|
||||
|
||||
// controls should only change in custom mode
|
||||
historymode.value = "custom";
|
||||
controlChanged(historymode);
|
||||
expect_disabled(true);
|
||||
check_independents(false);
|
||||
|
||||
// dependent controls should follow pbautostart
|
||||
pbautostart.checked = false;
|
||||
controlChanged(pbautostart);
|
||||
expect_disabled(false);
|
||||
check_independents(false);
|
||||
|
||||
// dependent controls should follow pbautostart
|
||||
pbautostart.checked = true;
|
||||
controlChanged(pbautostart);
|
||||
expect_disabled(true);
|
||||
check_independents(false);
|
||||
}
|
||||
|
||||
function test_dependent_cookie_elements(win) {
|
||||
let historymode = win.document.getElementById("historyMode");
|
||||
ok(historymode, "history mode menulist should exist");
|
||||
let pbautostart = win.document.getElementById("privateBrowsingAutoStart");
|
||||
ok(pbautostart, "the private browsing auto-start checkbox should exist");
|
||||
let controls = [
|
||||
win.document.getElementById("acceptThirdParty"),
|
||||
win.document.getElementById("keepUntil"),
|
||||
win.document.getElementById("keepCookiesUntil"),
|
||||
];
|
||||
controls.forEach(function(control) {
|
||||
ok(control, "the dependent cookie controls should exist");
|
||||
});
|
||||
let acceptcookies = win.document.getElementById("acceptCookies");
|
||||
ok(acceptcookies, "the accept cookies checkbox should exist");
|
||||
|
||||
function expect_disabled(disabled) {
|
||||
controls.forEach(function(control) {
|
||||
is(control.disabled, disabled,
|
||||
control.getAttribute("id") + " should " + (disabled ? "" : "not ") + "be disabled");
|
||||
});
|
||||
}
|
||||
|
||||
historymode.value = "custom";
|
||||
controlChanged(historymode);
|
||||
pbautostart.checked = false;
|
||||
controlChanged(pbautostart);
|
||||
expect_disabled(false);
|
||||
|
||||
acceptcookies.checked = false;
|
||||
controlChanged(acceptcookies);
|
||||
expect_disabled(true);
|
||||
|
||||
// pbautostart shouldn't change anything now
|
||||
pbautostart.checked = true;
|
||||
controlChanged(pbautostart);
|
||||
expect_disabled(true);
|
||||
|
||||
pbautostart.checked = false;
|
||||
controlChanged(pbautostart);
|
||||
expect_disabled(true);
|
||||
|
||||
acceptcookies.checked = true;
|
||||
controlChanged(acceptcookies);
|
||||
expect_disabled(false);
|
||||
|
||||
let accessthirdparty = controls.shift();
|
||||
pbautostart.checked = true;
|
||||
controlChanged(pbautostart);
|
||||
expect_disabled(true);
|
||||
ok(!accessthirdparty.disabled, "access third party button should be enabled");
|
||||
|
||||
acceptcookies.checked = false;
|
||||
controlChanged(acceptcookies);
|
||||
expect_disabled(true);
|
||||
ok(accessthirdparty.disabled, "access third party button should be disabled");
|
||||
|
||||
pbautostart.checked = false;
|
||||
controlChanged(pbautostart);
|
||||
expect_disabled(true);
|
||||
ok(accessthirdparty.disabled, "access third party button should be disabled");
|
||||
|
||||
acceptcookies.checked = true;
|
||||
controlChanged(acceptcookies);
|
||||
expect_disabled(false);
|
||||
ok(!accessthirdparty.disabled, "access third party button should be enabled");
|
||||
}
|
||||
|
||||
function test_dependent_clearonclose_elements(win) {
|
||||
let historymode = win.document.getElementById("historyMode");
|
||||
ok(historymode, "history mode menulist should exist");
|
||||
let pbautostart = win.document.getElementById("privateBrowsingAutoStart");
|
||||
ok(pbautostart, "the private browsing auto-start checkbox should exist");
|
||||
let alwaysclear = win.document.getElementById("alwaysClear");
|
||||
ok(alwaysclear, "the clear data on close checkbox should exist");
|
||||
let alwaysclearsettings = win.document.getElementById("clearDataSettings");
|
||||
ok(alwaysclearsettings, "the clear data settings button should exist");
|
||||
|
||||
function expect_disabled(disabled) {
|
||||
is(alwaysclearsettings.disabled, disabled,
|
||||
"the clear data settings should " + (disabled ? "" : "not ") + "be disabled");
|
||||
}
|
||||
|
||||
historymode.value = "custom";
|
||||
controlChanged(historymode);
|
||||
pbautostart.checked = false;
|
||||
controlChanged(pbautostart);
|
||||
alwaysclear.checked = false;
|
||||
controlChanged(alwaysclear);
|
||||
expect_disabled(true);
|
||||
|
||||
alwaysclear.checked = true;
|
||||
controlChanged(alwaysclear);
|
||||
expect_disabled(false);
|
||||
|
||||
pbautostart.checked = true;
|
||||
controlChanged(pbautostart);
|
||||
expect_disabled(true);
|
||||
|
||||
pbautostart.checked = false;
|
||||
controlChanged(pbautostart);
|
||||
expect_disabled(false);
|
||||
|
||||
alwaysclear.checked = false;
|
||||
controlChanged(alwaysclear);
|
||||
expect_disabled(true);
|
||||
}
|
||||
|
||||
function test_dependent_prefs(win) {
|
||||
let historymode = win.document.getElementById("historyMode");
|
||||
ok(historymode, "history mode menulist should exist");
|
||||
let controls = [
|
||||
win.document.getElementById("rememberHistory"),
|
||||
win.document.getElementById("rememberForms"),
|
||||
win.document.getElementById("acceptCookies"),
|
||||
win.document.getElementById("acceptThirdParty"),
|
||||
];
|
||||
controls.forEach(function(control) {
|
||||
ok(control, "the micro-management controls should exist");
|
||||
});
|
||||
|
||||
function expect_checked(checked) {
|
||||
controls.forEach(function(control) {
|
||||
is(control.checked, checked,
|
||||
control.getAttribute("id") + " should " + (checked ? "not " : "") + "be checked");
|
||||
});
|
||||
}
|
||||
|
||||
// controls should be checked in remember mode
|
||||
historymode.value = "remember";
|
||||
controlChanged(historymode);
|
||||
expect_checked(true);
|
||||
|
||||
// even if they're unchecked in custom mode
|
||||
historymode.value = "custom";
|
||||
controlChanged(historymode);
|
||||
controls.forEach(function(control) {
|
||||
control.checked = false;
|
||||
controlChanged(control);
|
||||
});
|
||||
expect_checked(false);
|
||||
historymode.value = "remember";
|
||||
controlChanged(historymode);
|
||||
expect_checked(true);
|
||||
}
|
||||
|
||||
function test_historymode_retention(mode, expect) {
|
||||
return function(win) {
|
||||
let historymode = win.document.getElementById("historyMode");
|
||||
ok(historymode, "history mode menulist should exist");
|
||||
|
||||
if (expect !== undefined) {
|
||||
is(historymode.value, expect,
|
||||
"history mode is expected to remain " + expect);
|
||||
}
|
||||
|
||||
historymode.value = mode;
|
||||
controlChanged(historymode);
|
||||
};
|
||||
}
|
||||
|
||||
function test_custom_retention(controlToChange, expect, valueIncrement) {
|
||||
return function(win) {
|
||||
let historymode = win.document.getElementById("historyMode");
|
||||
ok(historymode, "history mode menulist should exist");
|
||||
|
||||
if (expect !== undefined) {
|
||||
is(historymode.value, expect,
|
||||
"history mode is expected to remain " + expect);
|
||||
}
|
||||
|
||||
historymode.value = "custom";
|
||||
controlChanged(historymode);
|
||||
|
||||
controlToChange = win.document.getElementById(controlToChange);
|
||||
ok(controlToChange, "the control to change should exist");
|
||||
switch (controlToChange.localName) {
|
||||
case "checkbox":
|
||||
controlToChange.checked = !controlToChange.checked;
|
||||
break;
|
||||
case "textbox":
|
||||
controlToChange.value = parseInt(controlToChange.value) + valueIncrement;
|
||||
break;
|
||||
case "menulist":
|
||||
controlToChange.value = valueIncrement;
|
||||
break;
|
||||
}
|
||||
controlChanged(controlToChange);
|
||||
};
|
||||
}
|
||||
|
||||
function test_locbar_suggestion_retention(mode, expect) {
|
||||
return function(win) {
|
||||
let locbarsuggest = win.document.getElementById("locationBarSuggestion");
|
||||
ok(locbarsuggest, "location bar suggestion menulist should exist");
|
||||
|
||||
if (expect !== undefined) {
|
||||
is(locbarsuggest.value, expect,
|
||||
"location bar suggestion is expected to remain " + expect);
|
||||
}
|
||||
|
||||
locbarsuggest.value = mode;
|
||||
controlChanged(locbarsuggest);
|
||||
};
|
||||
}
|
||||
|
||||
function test_privatebrowsing_toggle(win) {
|
||||
let historymode = win.document.getElementById("historyMode");
|
||||
ok(historymode, "history mode menulist should exist");
|
||||
let pbautostart = win.document.getElementById("privateBrowsingAutoStart");
|
||||
ok(pbautostart, "the private browsing auto-start checkbox should exist");
|
||||
|
||||
let pbService = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
|
||||
// initial state
|
||||
historymode.value = "remember";
|
||||
controlChanged(historymode);
|
||||
|
||||
// switch to dontremember mode
|
||||
historymode.value = "dontremember";
|
||||
controlChanged(historymode);
|
||||
ok(pbService.privateBrowsingEnabled, "private browsing should be activated");
|
||||
|
||||
// switch to remember mode
|
||||
historymode.value = "remember";
|
||||
controlChanged(historymode);
|
||||
ok(!pbService.privateBrowsingEnabled, "private browsing should be deactivated");
|
||||
|
||||
// switch to custom mode
|
||||
historymode.value = "custom";
|
||||
controlChanged(historymode);
|
||||
ok(!pbService.privateBrowsingEnabled, "private browsing should remain deactivated");
|
||||
|
||||
// check the autostart checkbox
|
||||
pbautostart.checked = true;
|
||||
controlChanged(pbautostart);
|
||||
ok(pbService.privateBrowsingEnabled, "private browsing should be activated");
|
||||
|
||||
// uncheck the autostart checkbox
|
||||
pbautostart.checked = false;
|
||||
controlChanged(pbautostart);
|
||||
ok(!pbService.privateBrowsingEnabled, "private browsing should be deactivated");
|
||||
}
|
||||
|
||||
function test_privatebrowsing_ui(win) {
|
||||
let historymode = win.document.getElementById("historyMode");
|
||||
ok(historymode, "history mode menulist should exist");
|
||||
let pbautostart = win.document.getElementById("privateBrowsingAutoStart");
|
||||
ok(pbautostart, "the private browsing auto-start checkbox should exist");
|
||||
|
||||
let pbmenuitem = document.getElementById("privateBrowsingItem");
|
||||
ok(pbmenuitem, "the private browsing menu item should exist");
|
||||
let pbcommand = document.getElementById("Tools:PrivateBrowsing");
|
||||
ok(pbcommand, "the private browsing command should exist");
|
||||
|
||||
// initial state
|
||||
historymode.value = "remember";
|
||||
controlChanged(historymode);
|
||||
ok(!pbmenuitem.hasAttribute("disabled"),
|
||||
"private browsing menu item should not be initially disabled");
|
||||
ok(!pbcommand.hasAttribute("disabled"),
|
||||
"private browsing command should not be initially disabled");
|
||||
|
||||
// switch to dontremember mode
|
||||
historymode.value = "dontremember";
|
||||
controlChanged(historymode);
|
||||
ok(pbmenuitem.hasAttribute("disabled"),
|
||||
"private browsing menu item should be disabled");
|
||||
ok(pbcommand.hasAttribute("disabled"),
|
||||
"private browsing command should be disabled");
|
||||
|
||||
// switch to remember mode
|
||||
historymode.value = "remember";
|
||||
controlChanged(historymode);
|
||||
ok(!pbmenuitem.hasAttribute("disabled"),
|
||||
"private browsing menu item should be enabled");
|
||||
ok(!pbcommand.hasAttribute("disabled"),
|
||||
"private browsing command should be enabled");
|
||||
|
||||
// switch to custom mode
|
||||
historymode.value = "custom";
|
||||
controlChanged(historymode);
|
||||
ok(!pbmenuitem.hasAttribute("disabled"),
|
||||
"private browsing menu item should remain enabled");
|
||||
ok(!pbcommand.hasAttribute("disabled"),
|
||||
"private browsing command should remain enabled");
|
||||
|
||||
// check the autostart checkbox
|
||||
pbautostart.checked = true;
|
||||
controlChanged(pbautostart);
|
||||
ok(pbmenuitem.hasAttribute("disabled"),
|
||||
"private browsing menu item should be disabled");
|
||||
ok(pbcommand.hasAttribute("disabled"),
|
||||
"private browsing command should be disabled");
|
||||
|
||||
// uncheck the autostart checkbox
|
||||
pbautostart.checked = false;
|
||||
controlChanged(pbautostart);
|
||||
ok(!pbmenuitem.hasAttribute("disabled"),
|
||||
"private browsing menu item should be enabled");
|
||||
ok(!pbcommand.hasAttribute("disabled"),
|
||||
"private browsing command should be enabled");
|
||||
}
|
||||
|
||||
function enter_private_browsing(win) {
|
||||
let pbService = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
win.document.getElementById("browser.privatebrowsing.keep_current_session")
|
||||
.value = true;
|
||||
pbService.privateBrowsingEnabled = true;
|
||||
}
|
||||
|
||||
function reset_preferences(win) {
|
||||
let prefs = win.document.querySelectorAll("#privacyPreferences > preference");
|
||||
for (let i = 0; i < prefs.length; ++i)
|
||||
if (prefs[i].hasUserValue)
|
||||
prefs[i].reset();
|
||||
}
|
||||
|
||||
let testRunner;
|
||||
function run_test_subset(subset) {
|
||||
Services.prefs.setBoolPref("browser.preferences.instantApply", true);
|
||||
|
||||
waitForExplicitFinish();
|
||||
registerCleanupFunction(function() {
|
||||
// Reset pref to its default
|
||||
Services.prefs.clearUserPref("browser.preferences.instantApply");
|
||||
});
|
||||
|
||||
testRunner = {
|
||||
tests: subset,
|
||||
counter: 0,
|
||||
runNext: function() {
|
||||
if (this.counter == this.tests.length) {
|
||||
finish();
|
||||
} else {
|
||||
let self = this;
|
||||
setTimeout(function() {
|
||||
runTestOnPrivacyPrefPane(self.tests[self.counter++]);
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
testRunner.runNext();
|
||||
}
|
@ -32,8 +32,8 @@ browser.jar:
|
||||
* content/browser/preferences/permissions.xul
|
||||
content/browser/preferences/permissions.js
|
||||
* content/browser/preferences/preferences.xul
|
||||
* content/browser/preferences/privacy.xul
|
||||
* content/browser/preferences/privacy.js
|
||||
content/browser/preferences/privacy.xul
|
||||
content/browser/preferences/privacy.js
|
||||
content/browser/preferences/sanitize.xul
|
||||
content/browser/preferences/security.xul
|
||||
content/browser/preferences/security.js
|
||||
|
@ -279,7 +279,6 @@ var gPrivacyPane = {
|
||||
|
||||
observe: function PPP_observe(aSubject, aTopic, aData)
|
||||
{
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
if (!gPrivacyPane._shouldPromptForRestart) {
|
||||
// We're performing a revert. Just let it happen.
|
||||
gPrivacyPane._shouldPromptForRestart = true;
|
||||
@ -321,23 +320,6 @@ var gPrivacyPane = {
|
||||
let rememberHistoryCheckbox = document.getElementById("rememberHistory");
|
||||
rememberHistory.checked = pref.value;
|
||||
}
|
||||
#else
|
||||
// Toggle the private browsing mode without switching the session
|
||||
let prefValue = document.getElementById("browser.privatebrowsing.autostart").value;
|
||||
let keepCurrentSession = document.getElementById("browser.privatebrowsing.keep_current_session");
|
||||
keepCurrentSession.value = true;
|
||||
|
||||
let privateBrowsingService = Components.classes["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Components.interfaces.nsIPrivateBrowsingService);
|
||||
|
||||
// If activating from within the private browsing mode, reset the
|
||||
// private session
|
||||
if (prefValue && privateBrowsingService.privateBrowsingEnabled)
|
||||
privateBrowsingService.privateBrowsingEnabled = false;
|
||||
privateBrowsingService.privateBrowsingEnabled = prefValue;
|
||||
|
||||
keepCurrentSession.reset();
|
||||
#endif
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -73,16 +73,8 @@
|
||||
<preference id="browser.privatebrowsing.autostart"
|
||||
name="browser.privatebrowsing.autostart"
|
||||
onchange="gPrivacyPane.updatePrivacyMicroControls();"
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
instantApply="true"
|
||||
#endif
|
||||
type="bool"/>
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
<preference id="browser.privatebrowsing.keep_current_session"
|
||||
name="browser.privatebrowsing.keep_current_session"
|
||||
instantApply="true"
|
||||
type="bool"/>
|
||||
#endif
|
||||
|
||||
</preferences>
|
||||
|
||||
|
@ -18,31 +18,13 @@ _BROWSER_FILES = \
|
||||
browser_bug705422.js \
|
||||
browser_permissions.js \
|
||||
browser_chunk_permissions.js \
|
||||
$(NULL)
|
||||
|
||||
ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
_BROWSER_FILES += \
|
||||
privacypane_tests.js \
|
||||
browser_bug567487.js \
|
||||
browser_privacypane_1.js \
|
||||
browser_privacypane_2.js \
|
||||
browser_privacypane_3.js \
|
||||
browser_privacypane_4.js \
|
||||
browser_privacypane_5.js \
|
||||
browser_privacypane_6.js \
|
||||
browser_privacypane_7.js \
|
||||
browser_privacypane_8.js \
|
||||
$(NULL)
|
||||
else
|
||||
_BROWSER_FILES += \
|
||||
privacypane_tests_perwindow.js \
|
||||
browser_privacypane_1.js \
|
||||
browser_privacypane_3.js \
|
||||
browser_privacypane_4.js \
|
||||
browser_privacypane_5.js \
|
||||
browser_privacypane_8.js \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
ifdef MOZ_SERVICES_HEALTHREPORT
|
||||
_BROWSER_FILES += browser_healthreport.js
|
||||
|
@ -1,70 +0,0 @@
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
resetPreferences();
|
||||
|
||||
function observer(win, topic, data) {
|
||||
if (topic != "main-pane-loaded")
|
||||
return;
|
||||
|
||||
Services.obs.removeObserver(observer, "main-pane-loaded");
|
||||
runTest(win);
|
||||
}
|
||||
Services.obs.addObserver(observer, "main-pane-loaded", false);
|
||||
|
||||
openDialog("chrome://browser/content/preferences/preferences.xul", "Preferences",
|
||||
"chrome,titlebar,toolbar,centerscreen,dialog=no", "paneMain");
|
||||
}
|
||||
|
||||
function runTest(win) {
|
||||
let doc = win.document;
|
||||
let pbAutoStartPref = doc.getElementById("browser.privatebrowsing.autostart");
|
||||
let startupPref = doc.getElementById("browser.startup.page");
|
||||
let menu = doc.getElementById("browserStartupPage");
|
||||
let option = doc.getElementById("browserStartupLastSession");
|
||||
let defOption = doc.getElementById("browserStartupHomePage");
|
||||
let otherOption = doc.getElementById("browserStartupBlank");
|
||||
|
||||
ok(!pbAutoStartPref.value, "Sanity check");
|
||||
is(startupPref.value, startupPref.defaultValue, "Sanity check");
|
||||
|
||||
// First, check to make sure that setting pbAutoStartPref disables the menu item
|
||||
pbAutoStartPref.value = true;
|
||||
is(option.getAttribute("disabled"), "true", "Setting private browsing to autostart " +
|
||||
"should disable the 'Show my tabs and windows from last time' option");
|
||||
pbAutoStartPref.value = false;
|
||||
|
||||
// Now ensure the correct behavior when pbAutoStartPref is set with option enabled
|
||||
startupPref.value = option.getAttribute("value");
|
||||
is(menu.selectedItem, option, "Sanity check");
|
||||
pbAutoStartPref.value = true;
|
||||
is(option.getAttribute("disabled"), "true", "Setting private browsing to autostart " +
|
||||
"should disable the 'Show my tabs and windows from last time' option");
|
||||
is(menu.selectedItem, defOption, "The 'Show home page' option should be selected");
|
||||
is(startupPref.value, option.getAttribute("value"), "But the value of the startup " +
|
||||
"pref itself shouldn't change");
|
||||
menu.selectedItem = otherOption;
|
||||
menu.doCommand();
|
||||
is(startupPref.value, otherOption.getAttribute("value"), "And we should be able to " +
|
||||
"chnage it!");
|
||||
pbAutoStartPref.value = false;
|
||||
|
||||
// Now, ensure that with 'Show my windows and tabs from last time' enabled, toggling
|
||||
// pbAutoStartPref would restore that value in the menulist.
|
||||
startupPref.value = option.getAttribute("value");
|
||||
is(menu.selectedItem, option, "Sanity check");
|
||||
pbAutoStartPref.value = true;
|
||||
is(menu.selectedItem, defOption, "The 'Show home page' option should be selected");
|
||||
pbAutoStartPref.value = false;
|
||||
is(menu.selectedItem, option, "The correct value should be restored");
|
||||
|
||||
// cleanup
|
||||
resetPreferences();
|
||||
|
||||
win.close();
|
||||
finish();
|
||||
}
|
||||
|
||||
function resetPreferences() {
|
||||
Services.prefs.clearUserPref("browser.startup.page");
|
||||
Services.prefs.clearUserPref("browser.privatebrowsing.autostart");
|
||||
}
|
@ -12,11 +12,7 @@ function test() {
|
||||
let tmpdir = extractJarToTmp(jar);
|
||||
rootDir = "file://" + tmpdir.path + '/';
|
||||
}
|
||||
try {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
} catch(x) {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests.js", this);
|
||||
}
|
||||
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
|
||||
run_test_subset([
|
||||
test_pane_visibility,
|
||||
|
@ -1,34 +0,0 @@
|
||||
/* 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 test() {
|
||||
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
|
||||
getService(Ci.mozIJSSubScriptLoader);
|
||||
|
||||
let rootDir = getRootDirectory(gTestPath);
|
||||
let jar = getJar(rootDir);
|
||||
if (jar) {
|
||||
let tmpdir = extractJarToTmp(jar);
|
||||
rootDir = "file://" + tmpdir.path + '/';
|
||||
}
|
||||
try {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
} catch(x) {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests.js", this);
|
||||
}
|
||||
|
||||
run_test_subset([
|
||||
test_historymode_retention("remember", undefined),
|
||||
test_historymode_retention("dontremember", "remember"),
|
||||
test_historymode_retention("custom", "dontremember"),
|
||||
// custom without any micro-prefs changed won't retain
|
||||
test_historymode_retention("remember", "dontremember"),
|
||||
test_historymode_retention("custom", "remember"),
|
||||
// custom without any micro-prefs changed won't retain
|
||||
test_historymode_retention("remember", "remember"),
|
||||
|
||||
// reset all preferences to their default values once we're done
|
||||
reset_preferences
|
||||
]);
|
||||
}
|
@ -11,11 +11,7 @@ function test() {
|
||||
let tmpdir = extractJarToTmp(jar);
|
||||
rootDir = "file://" + tmpdir.path + '/';
|
||||
}
|
||||
try {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
} catch(x) {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests.js", this);
|
||||
}
|
||||
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
|
||||
run_test_subset([
|
||||
test_custom_retention("rememberHistory", "remember"),
|
||||
|
@ -11,11 +11,7 @@ function test() {
|
||||
let tmpdir = extractJarToTmp(jar);
|
||||
rootDir = "file://" + tmpdir.path + '/';
|
||||
}
|
||||
try {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
} catch(x) {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests.js", this);
|
||||
}
|
||||
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
|
||||
run_test_subset([
|
||||
test_custom_retention("acceptCookies", "remember"),
|
||||
|
@ -11,11 +11,7 @@ function test() {
|
||||
let tmpdir = extractJarToTmp(jar);
|
||||
rootDir = "file://" + tmpdir.path + '/';
|
||||
}
|
||||
try {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
} catch(x) {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests.js", this);
|
||||
}
|
||||
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
|
||||
run_test_subset([
|
||||
test_locbar_suggestion_retention(-1, undefined),
|
||||
|
@ -1,27 +0,0 @@
|
||||
/* 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 test() {
|
||||
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
|
||||
getService(Ci.mozIJSSubScriptLoader);
|
||||
let rootDir = getRootDirectory(gTestPath);
|
||||
let jar = getJar(rootDir);
|
||||
if (jar) {
|
||||
let tmpdir = extractJarToTmp(jar);
|
||||
rootDir = "file://" + tmpdir.path + '/';
|
||||
}
|
||||
try {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
} catch(x) {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests.js", this);
|
||||
}
|
||||
|
||||
run_test_subset([
|
||||
test_privatebrowsing_toggle,
|
||||
enter_private_browsing, // once again, test with PB initially enabled
|
||||
test_privatebrowsing_toggle,
|
||||
|
||||
// don't reset preferences, will pick up where we left off in browser_privacypane_7.js
|
||||
]);
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
/* 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 test() {
|
||||
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
|
||||
getService(Ci.mozIJSSubScriptLoader);
|
||||
let rootDir = getRootDirectory(gTestPath);
|
||||
let jar = getJar(rootDir);
|
||||
if (jar) {
|
||||
let tmpdir = extractJarToTmp(jar);
|
||||
rootDir = "file://" + tmpdir.path + '/';
|
||||
}
|
||||
try {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
} catch(x) {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests.js", this);
|
||||
}
|
||||
|
||||
run_test_subset([
|
||||
test_privatebrowsing_ui,
|
||||
enter_private_browsing, // once again, test with PB initially enabled
|
||||
test_privatebrowsing_ui,
|
||||
|
||||
// reset all preferences to their default values once we're done
|
||||
reset_preferences
|
||||
]);
|
||||
}
|
@ -11,11 +11,7 @@ function test() {
|
||||
let tmpdir = extractJarToTmp(jar);
|
||||
rootDir = "file://" + tmpdir.path + '/';
|
||||
}
|
||||
try {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
} catch(x) {
|
||||
loader.loadSubScript(rootDir + "privacypane_tests.js", this);
|
||||
}
|
||||
loader.loadSubScript(rootDir + "privacypane_tests_perwindow.js", this);
|
||||
|
||||
run_test_subset([
|
||||
// history mode should be initialized to remember
|
||||
|
@ -1,499 +0,0 @@
|
||||
/* 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 runTestOnPrivacyPrefPane(testFunc) {
|
||||
let observer = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic == "domwindowopened") {
|
||||
Services.ww.unregisterNotification(this);
|
||||
|
||||
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget);
|
||||
win.addEventListener("load", function() {
|
||||
win.removeEventListener("load", arguments.callee, false);
|
||||
testFunc(dialog.document.defaultView);
|
||||
|
||||
Services.ww.registerNotification(observer);
|
||||
dialog.close();
|
||||
}, false);
|
||||
} else if (aTopic == "domwindowclosed") {
|
||||
Services.ww.unregisterNotification(this);
|
||||
testRunner.runNext();
|
||||
}
|
||||
}
|
||||
};
|
||||
Services.ww.registerNotification(observer);
|
||||
|
||||
let dialog = openDialog("chrome://browser/content/preferences/preferences.xul", "Preferences",
|
||||
"chrome,titlebar,toolbar,centerscreen,dialog=no", "panePrivacy");
|
||||
}
|
||||
|
||||
function controlChanged(element) {
|
||||
element.doCommand();
|
||||
}
|
||||
|
||||
function test_pane_visibility(win) {
|
||||
let modes = {
|
||||
"remember": "historyRememberPane",
|
||||
"dontremember": "historyDontRememberPane",
|
||||
"custom": "historyCustomPane"
|
||||
};
|
||||
|
||||
let historymode = win.document.getElementById("historyMode");
|
||||
ok(historymode, "history mode menulist should exist");
|
||||
let historypane = win.document.getElementById("historyPane");
|
||||
ok(historypane, "history mode pane should exist");
|
||||
|
||||
for (let mode in modes) {
|
||||
historymode.value = mode;
|
||||
controlChanged(historymode);
|
||||
is(historypane.selectedPanel, win.document.getElementById(modes[mode]),
|
||||
"The correct pane should be selected for the " + mode + " mode");
|
||||
}
|
||||
}
|
||||
|
||||
function test_dependent_elements(win) {
|
||||
let historymode = win.document.getElementById("historyMode");
|
||||
ok(historymode, "history mode menulist should exist");
|
||||
let pbautostart = win.document.getElementById("privateBrowsingAutoStart");
|
||||
ok(pbautostart, "the private browsing auto-start checkbox should exist");
|
||||
let controls = [
|
||||
win.document.getElementById("rememberHistory"),
|
||||
win.document.getElementById("rememberForms"),
|
||||
win.document.getElementById("keepUntil"),
|
||||
win.document.getElementById("keepCookiesUntil"),
|
||||
win.document.getElementById("alwaysClear"),
|
||||
];
|
||||
controls.forEach(function(control) {
|
||||
ok(control, "the dependent controls should exist");
|
||||
});
|
||||
let independents = [
|
||||
win.document.getElementById("acceptCookies"),
|
||||
win.document.getElementById("acceptThirdParty"),
|
||||
];
|
||||
independents.forEach(function(control) {
|
||||
ok(control, "the independent controls should exist");
|
||||
});
|
||||
let cookieexceptions = win.document.getElementById("cookieExceptions");
|
||||
ok(cookieexceptions, "the cookie exceptions button should exist");
|
||||
let keepuntil = win.document.getElementById("keepCookiesUntil");
|
||||
ok(keepuntil, "the keep cookies until menulist should exist");
|
||||
let alwaysclear = win.document.getElementById("alwaysClear");
|
||||
ok(alwaysclear, "the clear data on close checkbox should exist");
|
||||
let rememberhistory = win.document.getElementById("rememberHistory");
|
||||
ok(rememberhistory, "the remember history checkbox should exist");
|
||||
let rememberforms = win.document.getElementById("rememberForms");
|
||||
ok(rememberforms, "the remember forms checkbox should exist");
|
||||
let alwaysclearsettings = win.document.getElementById("clearDataSettings");
|
||||
ok(alwaysclearsettings, "the clear data settings button should exist");
|
||||
|
||||
function expect_disabled(disabled) {
|
||||
controls.forEach(function(control) {
|
||||
is(control.disabled, disabled,
|
||||
control.getAttribute("id") + " should " + (disabled ? "" : "not ") + "be disabled");
|
||||
});
|
||||
is(keepuntil.value, disabled ? 2 : 0,
|
||||
"the keep cookies until menulist value should be as expected");
|
||||
if (disabled) {
|
||||
ok(!alwaysclear.checked,
|
||||
"the clear data on close checkbox value should be as expected");
|
||||
ok(!rememberhistory.checked,
|
||||
"the remember history checkbox value should be as expected");
|
||||
ok(!rememberforms.checked,
|
||||
"the remember forms checkbox value should be as expected");
|
||||
}
|
||||
}
|
||||
function check_independents(expected) {
|
||||
independents.forEach(function(control) {
|
||||
is(control.disabled, expected,
|
||||
control.getAttribute("id") + " should " + (expected ? "" : "not ") + "be disabled");
|
||||
});
|
||||
ok(!cookieexceptions.disabled,
|
||||
"the cookie exceptions button should never be disabled");
|
||||
ok(alwaysclearsettings.disabled,
|
||||
"the clear data settings button should always be disabled");
|
||||
}
|
||||
|
||||
// controls should only change in custom mode
|
||||
historymode.value = "remember";
|
||||
controlChanged(historymode);
|
||||
expect_disabled(false);
|
||||
check_independents(false);
|
||||
|
||||
// setting the mode to custom shouldn't change anything
|
||||
historymode.value = "custom";
|
||||
controlChanged(historymode);
|
||||
expect_disabled(false);
|
||||
check_independents(false);
|
||||
|
||||
// controls should only change in custom mode
|
||||
historymode.value = "dontremember";
|
||||
controlChanged(historymode);
|
||||
expect_disabled(false);
|
||||
check_independents(false);
|
||||
|
||||
// controls should only change in custom mode
|
||||
historymode.value = "custom";
|
||||
controlChanged(historymode);
|
||||
expect_disabled(true);
|
||||
check_independents(false);
|
||||
|
||||
// dependent controls should follow pbautostart
|
||||
pbautostart.checked = false;
|
||||
controlChanged(pbautostart);
|
||||
expect_disabled(false);
|
||||
check_independents(false);
|
||||
|
||||
// dependent controls should follow pbautostart
|
||||
pbautostart.checked = true;
|
||||
controlChanged(pbautostart);
|
||||
expect_disabled(true);
|
||||
check_independents(false);
|
||||
}
|
||||
|
||||
function test_dependent_cookie_elements(win) {
|
||||
let historymode = win.document.getElementById("historyMode");
|
||||
ok(historymode, "history mode menulist should exist");
|
||||
let pbautostart = win.document.getElementById("privateBrowsingAutoStart");
|
||||
ok(pbautostart, "the private browsing auto-start checkbox should exist");
|
||||
let controls = [
|
||||
win.document.getElementById("acceptThirdParty"),
|
||||
win.document.getElementById("keepUntil"),
|
||||
win.document.getElementById("keepCookiesUntil"),
|
||||
];
|
||||
controls.forEach(function(control) {
|
||||
ok(control, "the dependent cookie controls should exist");
|
||||
});
|
||||
let acceptcookies = win.document.getElementById("acceptCookies");
|
||||
ok(acceptcookies, "the accept cookies checkbox should exist");
|
||||
|
||||
function expect_disabled(disabled) {
|
||||
controls.forEach(function(control) {
|
||||
is(control.disabled, disabled,
|
||||
control.getAttribute("id") + " should " + (disabled ? "" : "not ") + "be disabled");
|
||||
});
|
||||
}
|
||||
|
||||
historymode.value = "custom";
|
||||
controlChanged(historymode);
|
||||
pbautostart.checked = false;
|
||||
controlChanged(pbautostart);
|
||||
expect_disabled(false);
|
||||
|
||||
acceptcookies.checked = false;
|
||||
controlChanged(acceptcookies);
|
||||
expect_disabled(true);
|
||||
|
||||
// pbautostart shouldn't change anything now
|
||||
pbautostart.checked = true;
|
||||
controlChanged(pbautostart);
|
||||
expect_disabled(true);
|
||||
|
||||
pbautostart.checked = false;
|
||||
controlChanged(pbautostart);
|
||||
expect_disabled(true);
|
||||
|
||||
acceptcookies.checked = true;
|
||||
controlChanged(acceptcookies);
|
||||
expect_disabled(false);
|
||||
|
||||
let accessthirdparty = controls.shift();
|
||||
pbautostart.checked = true;
|
||||
controlChanged(pbautostart);
|
||||
expect_disabled(true);
|
||||
ok(!accessthirdparty.disabled, "access third party button should be enabled");
|
||||
|
||||
acceptcookies.checked = false;
|
||||
controlChanged(acceptcookies);
|
||||
expect_disabled(true);
|
||||
ok(accessthirdparty.disabled, "access third party button should be disabled");
|
||||
|
||||
pbautostart.checked = false;
|
||||
controlChanged(pbautostart);
|
||||
expect_disabled(true);
|
||||
ok(accessthirdparty.disabled, "access third party button should be disabled");
|
||||
|
||||
acceptcookies.checked = true;
|
||||
controlChanged(acceptcookies);
|
||||
expect_disabled(false);
|
||||
ok(!accessthirdparty.disabled, "access third party button should be enabled");
|
||||
}
|
||||
|
||||
function test_dependent_clearonclose_elements(win) {
|
||||
let historymode = win.document.getElementById("historyMode");
|
||||
ok(historymode, "history mode menulist should exist");
|
||||
let pbautostart = win.document.getElementById("privateBrowsingAutoStart");
|
||||
ok(pbautostart, "the private browsing auto-start checkbox should exist");
|
||||
let alwaysclear = win.document.getElementById("alwaysClear");
|
||||
ok(alwaysclear, "the clear data on close checkbox should exist");
|
||||
let alwaysclearsettings = win.document.getElementById("clearDataSettings");
|
||||
ok(alwaysclearsettings, "the clear data settings button should exist");
|
||||
|
||||
function expect_disabled(disabled) {
|
||||
is(alwaysclearsettings.disabled, disabled,
|
||||
"the clear data settings should " + (disabled ? "" : "not ") + "be disabled");
|
||||
}
|
||||
|
||||
historymode.value = "custom";
|
||||
controlChanged(historymode);
|
||||
pbautostart.checked = false;
|
||||
controlChanged(pbautostart);
|
||||
alwaysclear.checked = false;
|
||||
controlChanged(alwaysclear);
|
||||
expect_disabled(true);
|
||||
|
||||
alwaysclear.checked = true;
|
||||
controlChanged(alwaysclear);
|
||||
expect_disabled(false);
|
||||
|
||||
pbautostart.checked = true;
|
||||
controlChanged(pbautostart);
|
||||
expect_disabled(true);
|
||||
|
||||
pbautostart.checked = false;
|
||||
controlChanged(pbautostart);
|
||||
expect_disabled(false);
|
||||
|
||||
alwaysclear.checked = false;
|
||||
controlChanged(alwaysclear);
|
||||
expect_disabled(true);
|
||||
}
|
||||
|
||||
function test_dependent_prefs(win) {
|
||||
let historymode = win.document.getElementById("historyMode");
|
||||
ok(historymode, "history mode menulist should exist");
|
||||
let controls = [
|
||||
win.document.getElementById("rememberHistory"),
|
||||
win.document.getElementById("rememberForms"),
|
||||
win.document.getElementById("acceptCookies"),
|
||||
win.document.getElementById("acceptThirdParty"),
|
||||
];
|
||||
controls.forEach(function(control) {
|
||||
ok(control, "the micro-management controls should exist");
|
||||
});
|
||||
|
||||
function expect_checked(checked) {
|
||||
controls.forEach(function(control) {
|
||||
is(control.checked, checked,
|
||||
control.getAttribute("id") + " should " + (checked ? "not " : "") + "be checked");
|
||||
});
|
||||
}
|
||||
|
||||
// controls should be checked in remember mode
|
||||
historymode.value = "remember";
|
||||
controlChanged(historymode);
|
||||
expect_checked(true);
|
||||
|
||||
// even if they're unchecked in custom mode
|
||||
historymode.value = "custom";
|
||||
controlChanged(historymode);
|
||||
controls.forEach(function(control) {
|
||||
control.checked = false;
|
||||
controlChanged(control);
|
||||
});
|
||||
expect_checked(false);
|
||||
historymode.value = "remember";
|
||||
controlChanged(historymode);
|
||||
expect_checked(true);
|
||||
}
|
||||
|
||||
function test_historymode_retention(mode, expect) {
|
||||
return function(win) {
|
||||
let historymode = win.document.getElementById("historyMode");
|
||||
ok(historymode, "history mode menulist should exist");
|
||||
|
||||
if (expect !== undefined) {
|
||||
is(historymode.value, expect,
|
||||
"history mode is expected to remain " + expect);
|
||||
}
|
||||
|
||||
historymode.value = mode;
|
||||
controlChanged(historymode);
|
||||
};
|
||||
}
|
||||
|
||||
function test_custom_retention(controlToChange, expect, valueIncrement) {
|
||||
return function(win) {
|
||||
let historymode = win.document.getElementById("historyMode");
|
||||
ok(historymode, "history mode menulist should exist");
|
||||
|
||||
if (expect !== undefined) {
|
||||
is(historymode.value, expect,
|
||||
"history mode is expected to remain " + expect);
|
||||
}
|
||||
|
||||
historymode.value = "custom";
|
||||
controlChanged(historymode);
|
||||
|
||||
controlToChange = win.document.getElementById(controlToChange);
|
||||
ok(controlToChange, "the control to change should exist");
|
||||
switch (controlToChange.localName) {
|
||||
case "checkbox":
|
||||
controlToChange.checked = !controlToChange.checked;
|
||||
break;
|
||||
case "textbox":
|
||||
controlToChange.value = parseInt(controlToChange.value) + valueIncrement;
|
||||
break;
|
||||
case "menulist":
|
||||
controlToChange.value = valueIncrement;
|
||||
break;
|
||||
}
|
||||
controlChanged(controlToChange);
|
||||
};
|
||||
}
|
||||
|
||||
function test_locbar_suggestion_retention(mode, expect) {
|
||||
return function(win) {
|
||||
let locbarsuggest = win.document.getElementById("locationBarSuggestion");
|
||||
ok(locbarsuggest, "location bar suggestion menulist should exist");
|
||||
|
||||
if (expect !== undefined) {
|
||||
is(locbarsuggest.value, expect,
|
||||
"location bar suggestion is expected to remain " + expect);
|
||||
}
|
||||
|
||||
locbarsuggest.value = mode;
|
||||
controlChanged(locbarsuggest);
|
||||
};
|
||||
}
|
||||
|
||||
function test_privatebrowsing_toggle(win) {
|
||||
let historymode = win.document.getElementById("historyMode");
|
||||
ok(historymode, "history mode menulist should exist");
|
||||
let pbautostart = win.document.getElementById("privateBrowsingAutoStart");
|
||||
ok(pbautostart, "the private browsing auto-start checkbox should exist");
|
||||
|
||||
let pbService = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
|
||||
// initial state
|
||||
historymode.value = "remember";
|
||||
controlChanged(historymode);
|
||||
|
||||
// switch to dontremember mode
|
||||
historymode.value = "dontremember";
|
||||
controlChanged(historymode);
|
||||
ok(pbService.privateBrowsingEnabled, "private browsing should be activated");
|
||||
|
||||
// switch to remember mode
|
||||
historymode.value = "remember";
|
||||
controlChanged(historymode);
|
||||
ok(!pbService.privateBrowsingEnabled, "private browsing should be deactivated");
|
||||
|
||||
// switch to custom mode
|
||||
historymode.value = "custom";
|
||||
controlChanged(historymode);
|
||||
ok(!pbService.privateBrowsingEnabled, "private browsing should remain deactivated");
|
||||
|
||||
// check the autostart checkbox
|
||||
pbautostart.checked = true;
|
||||
controlChanged(pbautostart);
|
||||
ok(pbService.privateBrowsingEnabled, "private browsing should be activated");
|
||||
|
||||
// uncheck the autostart checkbox
|
||||
pbautostart.checked = false;
|
||||
controlChanged(pbautostart);
|
||||
ok(!pbService.privateBrowsingEnabled, "private browsing should be deactivated");
|
||||
}
|
||||
|
||||
function test_privatebrowsing_ui(win) {
|
||||
let historymode = win.document.getElementById("historyMode");
|
||||
ok(historymode, "history mode menulist should exist");
|
||||
let pbautostart = win.document.getElementById("privateBrowsingAutoStart");
|
||||
ok(pbautostart, "the private browsing auto-start checkbox should exist");
|
||||
|
||||
let pbmenuitem = document.getElementById("privateBrowsingItem");
|
||||
ok(pbmenuitem, "the private browsing menu item should exist");
|
||||
let pbcommand = document.getElementById("Tools:PrivateBrowsing");
|
||||
ok(pbcommand, "the private browsing command should exist");
|
||||
|
||||
// initial state
|
||||
historymode.value = "remember";
|
||||
controlChanged(historymode);
|
||||
ok(!pbmenuitem.hasAttribute("disabled"),
|
||||
"private browsing menu item should not be initially disabled");
|
||||
ok(!pbcommand.hasAttribute("disabled"),
|
||||
"private browsing command should not be initially disabled");
|
||||
|
||||
// switch to dontremember mode
|
||||
historymode.value = "dontremember";
|
||||
controlChanged(historymode);
|
||||
ok(pbmenuitem.hasAttribute("disabled"),
|
||||
"private browsing menu item should be disabled");
|
||||
ok(pbcommand.hasAttribute("disabled"),
|
||||
"private browsing command should be disabled");
|
||||
|
||||
// switch to remember mode
|
||||
historymode.value = "remember";
|
||||
controlChanged(historymode);
|
||||
ok(!pbmenuitem.hasAttribute("disabled"),
|
||||
"private browsing menu item should be enabled");
|
||||
ok(!pbcommand.hasAttribute("disabled"),
|
||||
"private browsing command should be enabled");
|
||||
|
||||
// switch to custom mode
|
||||
historymode.value = "custom";
|
||||
controlChanged(historymode);
|
||||
ok(!pbmenuitem.hasAttribute("disabled"),
|
||||
"private browsing menu item should remain enabled");
|
||||
ok(!pbcommand.hasAttribute("disabled"),
|
||||
"private browsing command should remain enabled");
|
||||
|
||||
// check the autostart checkbox
|
||||
pbautostart.checked = true;
|
||||
controlChanged(pbautostart);
|
||||
ok(pbmenuitem.hasAttribute("disabled"),
|
||||
"private browsing menu item should be disabled");
|
||||
ok(pbcommand.hasAttribute("disabled"),
|
||||
"private browsing command should be disabled");
|
||||
|
||||
// uncheck the autostart checkbox
|
||||
pbautostart.checked = false;
|
||||
controlChanged(pbautostart);
|
||||
ok(!pbmenuitem.hasAttribute("disabled"),
|
||||
"private browsing menu item should be enabled");
|
||||
ok(!pbcommand.hasAttribute("disabled"),
|
||||
"private browsing command should be enabled");
|
||||
}
|
||||
|
||||
function enter_private_browsing(win) {
|
||||
let pbService = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
win.document.getElementById("browser.privatebrowsing.keep_current_session")
|
||||
.value = true;
|
||||
pbService.privateBrowsingEnabled = true;
|
||||
}
|
||||
|
||||
function reset_preferences(win) {
|
||||
let prefs = win.document.getElementsByTagName("preference");
|
||||
for (let i = 0; i < prefs.length; ++i)
|
||||
if (prefs[i].hasUserValue)
|
||||
prefs[i].reset();
|
||||
}
|
||||
|
||||
let testRunner;
|
||||
function run_test_subset(subset) {
|
||||
let instantApplyOrig = Services.prefs.getBoolPref("browser.preferences.instantApply");
|
||||
Services.prefs.setBoolPref("browser.preferences.instantApply", true);
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
testRunner = {
|
||||
tests: subset,
|
||||
counter: 0,
|
||||
runNext: function() {
|
||||
if (this.counter == this.tests.length) {
|
||||
// cleanup
|
||||
Services.prefs.setBoolPref("browser.preferences.instantApply", instantApplyOrig);
|
||||
finish();
|
||||
} else {
|
||||
let self = this;
|
||||
setTimeout(function() {
|
||||
runTestOnPrivacyPrefPane(self.tests[self.counter++]);
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
testRunner.runNext();
|
||||
}
|
@ -13,18 +13,10 @@
|
||||
%globalDTD;
|
||||
<!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd">
|
||||
%browserDTD;
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
#ifdef XP_MACOSX
|
||||
<!ENTITY basePBMenu.label "&fileMenu.label;">
|
||||
#else
|
||||
<!ENTITY basePBMenu.label "<span class='appMenuButton'>&brandShortName;</span><span class='fileMenu'>&fileMenu.label;</span>">
|
||||
#endif
|
||||
#else
|
||||
#ifdef XP_MACOSX
|
||||
<!ENTITY basePBMenu.label "&toolsMenu.label;">
|
||||
#else
|
||||
<!ENTITY basePBMenu.label "<span class='appMenuButton'>&brandShortName;</span><span class='toolsMenu'>&toolsMenu.label;</span>">
|
||||
#endif
|
||||
#endif
|
||||
<!ENTITY % privatebrowsingpageDTD SYSTEM "chrome://browser/locale/aboutPrivateBrowsing.dtd">
|
||||
%privatebrowsingpageDTD;
|
||||
@ -39,15 +31,9 @@
|
||||
body.private .showNormal {
|
||||
display: none;
|
||||
}
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
body.appMenuButtonVisible .fileMenu {
|
||||
display: none;
|
||||
}
|
||||
#else
|
||||
body.appMenuButtonVisible .toolsMenu {
|
||||
display: none;
|
||||
}
|
||||
#endif
|
||||
body.appMenuButtonInvisible .appMenuButton {
|
||||
display: none;
|
||||
}
|
||||
@ -108,15 +94,9 @@
|
||||
"appMenuButtonInvisible");
|
||||
}, false);
|
||||
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
function openPrivateWindow() {
|
||||
mainWindow.OpenBrowserWindow({private: true});
|
||||
}
|
||||
#else
|
||||
function togglePrivateBrowsing() {
|
||||
mainWindow.gPrivateBrowsingUI.toggleMode();
|
||||
}
|
||||
#endif
|
||||
]]></script>
|
||||
</head>
|
||||
|
||||
@ -137,48 +117,27 @@
|
||||
|
||||
<!-- Short Description -->
|
||||
<div id="errorShortDesc">
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
<p id="errorShortDescText" class="showPrivate">&privatebrowsingpage.perwindow.issueDesc;</p>
|
||||
<p id="errorShortDescTextNormal" class="showNormal">&privatebrowsingpage.perwindow.issueDesc.normal;</p>
|
||||
#else
|
||||
<p id="errorShortDescText" class="showPrivate">&privatebrowsingpage.issueDesc;</p>
|
||||
<p id="errorShortDescTextNormal" class="showNormal">&privatebrowsingpage.issueDesc.normal;</p>
|
||||
#endif
|
||||
</div>
|
||||
|
||||
<!-- Long Description -->
|
||||
<div id="errorLongDesc">
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
<p id="errorLongDescText">&privatebrowsingpage.perwindow.description;</p>
|
||||
#else
|
||||
<p id="errorLongDescText">&privatebrowsingpage.description;</p>
|
||||
#endif
|
||||
</div>
|
||||
|
||||
<!-- Start Private Browsing -->
|
||||
<div id="startPrivateBrowsingDesc" class="showNormal">
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
<button xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
id="startPrivateBrowsing" label="&privatebrowsingpage.openPrivateWindow.label;"
|
||||
accesskey="&privatebrowsingpage.openPrivateWindow.accesskey;"
|
||||
oncommand="openPrivateWindow();"/>
|
||||
#else
|
||||
<button xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
id="startPrivateBrowsing" label="&privatebrowsingpage.startPrivateBrowsing.label;"
|
||||
accesskey="&privatebrowsingpage.startPrivateBrowsing.accesskey;"
|
||||
oncommand="togglePrivateBrowsing();"/>
|
||||
#endif
|
||||
</div>
|
||||
|
||||
<!-- Footer -->
|
||||
<div id="footerDesc">
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
<p id="footerText" class="showPrivate">&privatebrowsingpage.howToStop3;</p>
|
||||
<p id="footerTextNormal" class="showNormal">&privatebrowsingpage.howToStart3;</p>
|
||||
#else
|
||||
<p id="footerText" class="showPrivate">&privatebrowsingpage.howToStop2;</p>
|
||||
<p id="footerTextNormal" class="showNormal">&privatebrowsingpage.howToStart2;</p>
|
||||
#endif
|
||||
</div>
|
||||
|
||||
<!-- More Info -->
|
||||
|
@ -15,29 +15,9 @@ LIBRARY_NAME = privatebrowsing_s
|
||||
FORCE_STATIC_LIB = 1
|
||||
USE_STATIC_LIBS = 1
|
||||
|
||||
ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
|
||||
EXTRA_COMPONENTS = \
|
||||
nsPrivateBrowsingServiceObsolete.manifest \
|
||||
nsPrivateBrowsingServiceObsolete.js \
|
||||
$(NULL)
|
||||
|
||||
else
|
||||
|
||||
CPPSRCS = \
|
||||
nsPrivateBrowsingServiceWrapper.cpp \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES = -I$(srcdir)/../../build
|
||||
|
||||
EXTRA_COMPONENTS = \
|
||||
nsPrivateBrowsingService.manifest \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_PP_COMPONENTS = \
|
||||
nsPrivateBrowsingService.js \
|
||||
$(NULL)
|
||||
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -1,593 +0,0 @@
|
||||
# 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/.
|
||||
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
#ifndef XP_WIN
|
||||
#define BROKEN_WM_Z_ORDER
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//// Constants
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
const Cr = Components.results;
|
||||
|
||||
const STATE_IDLE = 0;
|
||||
const STATE_TRANSITION_STARTED = 1;
|
||||
const STATE_WAITING_FOR_RESTORE = 2;
|
||||
const STATE_RESTORE_FINISHED = 3;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//// PrivateBrowsingService
|
||||
|
||||
function PrivateBrowsingService() {
|
||||
this._obs = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
this._obs.addObserver(this, "profile-after-change", true);
|
||||
this._obs.addObserver(this, "quit-application-granted", true);
|
||||
this._obs.addObserver(this, "private-browsing", true);
|
||||
this._obs.addObserver(this, "command-line-startup", true);
|
||||
this._obs.addObserver(this, "sessionstore-browser-state-restored", true);
|
||||
|
||||
// List of nsIXULWindows we are going to be closing during the transition
|
||||
this._windowsToClose = [];
|
||||
}
|
||||
|
||||
PrivateBrowsingService.prototype = {
|
||||
// Preferences Service
|
||||
get _prefs() {
|
||||
let prefs = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefBranch);
|
||||
this.__defineGetter__("_prefs", function() prefs);
|
||||
return this._prefs;
|
||||
},
|
||||
|
||||
// Whether the private browsing mode is currently active or not.
|
||||
_inPrivateBrowsing: false,
|
||||
|
||||
// Saved browser state before entering the private mode.
|
||||
_savedBrowserState: null,
|
||||
|
||||
// Whether we're in the process of shutting down
|
||||
_quitting: false,
|
||||
|
||||
// How to treat the non-private session
|
||||
_saveSession: true,
|
||||
|
||||
// The current status of the private browsing service
|
||||
_currentStatus: STATE_IDLE,
|
||||
|
||||
// Whether the private browsing mode has been started automatically (ie. always-on)
|
||||
_autoStarted: false,
|
||||
|
||||
// List of view source window URIs for restoring later
|
||||
_viewSrcURLs: [],
|
||||
|
||||
// Whether private browsing has been turned on from the command line
|
||||
_lastChangedByCommandLine: false,
|
||||
|
||||
// Telemetry measurements
|
||||
_enterTimestamps: {},
|
||||
_exitTimestamps: {},
|
||||
|
||||
// XPCOM registration
|
||||
classID: Components.ID("{c31f4883-839b-45f6-82ad-a6a9bc5ad599}"),
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPrivateBrowsingService,
|
||||
Ci.nsIObserver,
|
||||
Ci.nsISupportsWeakReference,
|
||||
Ci.nsICommandLineHandler]),
|
||||
|
||||
_unload: function PBS__destroy() {
|
||||
// Force an exit from the private browsing mode on shutdown
|
||||
this._quitting = true;
|
||||
if (this._inPrivateBrowsing)
|
||||
this.privateBrowsingEnabled = false;
|
||||
},
|
||||
|
||||
_setPerWindowPBFlag: function PBS__setPerWindowPBFlag(aWindow, aFlag) {
|
||||
aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShellTreeItem)
|
||||
.treeOwner
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIXULWindow)
|
||||
.docShell.QueryInterface(Ci.nsILoadContext)
|
||||
.usePrivateBrowsing = aFlag;
|
||||
},
|
||||
|
||||
_adjustPBFlagOnExistingWindows: function PBS__adjustPBFlagOnExistingWindows() {
|
||||
var windowsEnum = Services.wm.getEnumerator(null);
|
||||
while (windowsEnum.hasMoreElements()) {
|
||||
var window = windowsEnum.getNext();
|
||||
this._setPerWindowPBFlag(window, this._inPrivateBrowsing);
|
||||
}
|
||||
},
|
||||
|
||||
_onBeforePrivateBrowsingModeChange: function PBS__onBeforePrivateBrowsingModeChange() {
|
||||
// If we're about to enter PB mode, adjust the flags now
|
||||
if (this._inPrivateBrowsing) {
|
||||
this._adjustPBFlagOnExistingWindows();
|
||||
}
|
||||
|
||||
// nothing needs to be done here if we're enabling at startup
|
||||
if (!this._autoStarted) {
|
||||
let ss = Cc["@mozilla.org/browser/sessionstore;1"].
|
||||
getService(Ci.nsISessionStore);
|
||||
let blankState = JSON.stringify({
|
||||
"windows": [{
|
||||
"tabs": [{
|
||||
"entries": [{
|
||||
"url": "about:blank"
|
||||
}]
|
||||
}],
|
||||
"_closedTabs": []
|
||||
}]
|
||||
});
|
||||
|
||||
if (this._inPrivateBrowsing) {
|
||||
// save the whole browser state in order to restore all windows/tabs later
|
||||
if (this._saveSession && !this._savedBrowserState) {
|
||||
if (this._getBrowserWindow())
|
||||
this._savedBrowserState = ss.getBrowserState();
|
||||
else // no open browser windows, just restore a blank state on exit
|
||||
this._savedBrowserState = blankState;
|
||||
}
|
||||
}
|
||||
|
||||
this._closePageInfoWindows();
|
||||
|
||||
// save view-source windows URIs and close them
|
||||
let viewSrcWindowsEnum = Services.wm.getEnumerator("navigator:view-source");
|
||||
while (viewSrcWindowsEnum.hasMoreElements()) {
|
||||
let win = viewSrcWindowsEnum.getNext();
|
||||
if (this._inPrivateBrowsing) {
|
||||
let plainURL = win.gBrowser.currentURI.spec;
|
||||
if (plainURL.indexOf("view-source:") == 0) {
|
||||
plainURL = plainURL.substr(12);
|
||||
this._viewSrcURLs.push(plainURL);
|
||||
}
|
||||
}
|
||||
win.close();
|
||||
}
|
||||
|
||||
if (!this._quitting && this._saveSession) {
|
||||
let browserWindow = this._getBrowserWindow();
|
||||
|
||||
// if there are open browser windows, load a dummy session to get a distinct
|
||||
// separation between private and non-private sessions
|
||||
if (browserWindow) {
|
||||
// set an empty session to transition from/to pb mode, see bug 476463
|
||||
ss.setBrowserState(blankState);
|
||||
|
||||
// just in case the only remaining window after setBrowserState is different.
|
||||
// it probably shouldn't be with the current sessionstore impl, but we shouldn't
|
||||
// rely on behaviour the API doesn't guarantee
|
||||
browserWindow = this._getBrowserWindow();
|
||||
let browser = browserWindow.gBrowser;
|
||||
|
||||
// this ensures a clean slate from which to transition into or out of
|
||||
// private browsing
|
||||
browser.addTab();
|
||||
browser.getBrowserForTab(browser.tabContainer.firstChild).stop();
|
||||
browser.removeTab(browser.tabContainer.firstChild);
|
||||
browserWindow.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShellTreeItem)
|
||||
.treeOwner
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIXULWindow)
|
||||
.docShell.contentViewer.resetCloseWindow();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
this._saveSession = false;
|
||||
|
||||
// If we're about to leave PB mode, adjust the flags now
|
||||
if (!this._inPrivateBrowsing) {
|
||||
this._adjustPBFlagOnExistingWindows();
|
||||
}
|
||||
},
|
||||
|
||||
_onAfterPrivateBrowsingModeChange: function PBS__onAfterPrivateBrowsingModeChange() {
|
||||
// nothing to do here if we're enabling at startup or the current session is being
|
||||
// used
|
||||
if (!this._autoStarted && this._saveSession) {
|
||||
let ss = Cc["@mozilla.org/browser/sessionstore;1"].
|
||||
getService(Ci.nsISessionStore);
|
||||
// if we have transitioned out of private browsing mode and the session is
|
||||
// to be restored, do it now
|
||||
if (!this._inPrivateBrowsing) {
|
||||
this._currentStatus = STATE_WAITING_FOR_RESTORE;
|
||||
if (!this._getBrowserWindow()) {
|
||||
ss.init(null);
|
||||
}
|
||||
ss.setBrowserState(this._savedBrowserState);
|
||||
this._savedBrowserState = null;
|
||||
|
||||
this._closePageInfoWindows();
|
||||
|
||||
// re-open all view-source windows
|
||||
let windowWatcher = Cc["@mozilla.org/embedcomp/window-watcher;1"].
|
||||
getService(Ci.nsIWindowWatcher);
|
||||
this._viewSrcURLs.forEach(function(uri) {
|
||||
let args = Cc["@mozilla.org/supports-array;1"].
|
||||
createInstance(Ci.nsISupportsArray);
|
||||
let str = Cc["@mozilla.org/supports-string;1"].
|
||||
createInstance(Ci.nsISupportsString);
|
||||
str.data = uri;
|
||||
args.AppendElement(str);
|
||||
args.AppendElement(null); // charset
|
||||
args.AppendElement(null); // page descriptor
|
||||
args.AppendElement(null); // line number
|
||||
let forcedCharset = Cc["@mozilla.org/supports-PRBool;1"].
|
||||
createInstance(Ci.nsISupportsPRBool);
|
||||
forcedCharset.data = false;
|
||||
args.AppendElement(forcedCharset);
|
||||
windowWatcher.openWindow(null, "chrome://global/content/viewSource.xul",
|
||||
"_blank", "all,dialog=no", args);
|
||||
});
|
||||
this._viewSrcURLs = [];
|
||||
}
|
||||
else {
|
||||
// otherwise, if we have transitioned into private browsing mode, load
|
||||
// about:privatebrowsing
|
||||
let privateBrowsingState = {
|
||||
"windows": [{
|
||||
"tabs": [{
|
||||
"entries": [{
|
||||
"url": "about:privatebrowsing"
|
||||
}]
|
||||
}],
|
||||
"_closedTabs": []
|
||||
}]
|
||||
};
|
||||
// Transition into private browsing mode
|
||||
this._currentStatus = STATE_WAITING_FOR_RESTORE;
|
||||
if (!this._getBrowserWindow()) {
|
||||
ss.init(null);
|
||||
}
|
||||
ss.setBrowserState(JSON.stringify(privateBrowsingState));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_notifyIfTransitionComplete: function PBS__notifyIfTransitionComplete() {
|
||||
switch (this._currentStatus) {
|
||||
case STATE_TRANSITION_STARTED:
|
||||
// no session store operation was needed, so just notify of transition completion
|
||||
case STATE_RESTORE_FINISHED:
|
||||
// restore has been completed
|
||||
this._currentStatus = STATE_IDLE;
|
||||
this._obs.notifyObservers(null, "private-browsing-transition-complete", "");
|
||||
this._recordTransitionTime("completed");
|
||||
break;
|
||||
case STATE_WAITING_FOR_RESTORE:
|
||||
// too soon to notify...
|
||||
break;
|
||||
case STATE_IDLE:
|
||||
// no need to notify
|
||||
break;
|
||||
default:
|
||||
// unexpected state observed
|
||||
Cu.reportError("Unexpected private browsing status reached: " +
|
||||
this._currentStatus);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
_recordTransitionTime: function PBS__recordTransitionTime(aPhase) {
|
||||
// To record the time spent in private browsing transitions, note that we
|
||||
// cannot use the TelemetryStopwatch module, because it reports its results
|
||||
// immediately when the timer is stopped. In this case, we need to delay
|
||||
// the actual histogram update after we are out of private browsing mode.
|
||||
if (this._inPrivateBrowsing) {
|
||||
this._enterTimestamps[aPhase] = Date.now();
|
||||
} else {
|
||||
if (this._quitting) {
|
||||
// If we are quitting the browser, we don't care collecting the data,
|
||||
// because we wouldn't be able to record it with telemetry.
|
||||
return;
|
||||
}
|
||||
this._exitTimestamps[aPhase] = Date.now();
|
||||
if (aPhase == "completed") {
|
||||
// After we finished exiting the private browsing mode, we can finally
|
||||
// record the telemetry data, for the enter and the exit processes.
|
||||
this._reportTelemetry();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_reportTelemetry: function PBS__reportTelemetry() {
|
||||
function reportTelemetryEntry(aHistogramId, aValue) {
|
||||
try {
|
||||
Services.telemetry.getHistogramById(aHistogramId).add(aValue);
|
||||
} catch (ex) {
|
||||
Cu.reportError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
reportTelemetryEntry(
|
||||
"PRIVATE_BROWSING_TRANSITION_ENTER_PREPARATION_MS",
|
||||
this._enterTimestamps.prepared - this._enterTimestamps.started);
|
||||
reportTelemetryEntry(
|
||||
"PRIVATE_BROWSING_TRANSITION_ENTER_TOTAL_MS",
|
||||
this._enterTimestamps.completed - this._enterTimestamps.started);
|
||||
reportTelemetryEntry(
|
||||
"PRIVATE_BROWSING_TRANSITION_EXIT_PREPARATION_MS",
|
||||
this._exitTimestamps.prepared - this._exitTimestamps.started);
|
||||
reportTelemetryEntry(
|
||||
"PRIVATE_BROWSING_TRANSITION_EXIT_TOTAL_MS",
|
||||
this._exitTimestamps.completed - this._exitTimestamps.started);
|
||||
},
|
||||
|
||||
_canEnterPrivateBrowsingMode: function PBS__canEnterPrivateBrowsingMode() {
|
||||
let cancelEnter = Cc["@mozilla.org/supports-PRBool;1"].
|
||||
createInstance(Ci.nsISupportsPRBool);
|
||||
cancelEnter.data = false;
|
||||
this._obs.notifyObservers(cancelEnter, "private-browsing-cancel-vote", "enter");
|
||||
return !cancelEnter.data;
|
||||
},
|
||||
|
||||
_canLeavePrivateBrowsingMode: function PBS__canLeavePrivateBrowsingMode() {
|
||||
let cancelLeave = Cc["@mozilla.org/supports-PRBool;1"].
|
||||
createInstance(Ci.nsISupportsPRBool);
|
||||
cancelLeave.data = false;
|
||||
this._obs.notifyObservers(cancelLeave, "private-browsing-cancel-vote", "exit");
|
||||
if (!cancelLeave.data) {
|
||||
this._obs.notifyObservers(cancelLeave, "last-pb-context-exiting", null);
|
||||
}
|
||||
return !cancelLeave.data;
|
||||
},
|
||||
|
||||
_getBrowserWindow: function PBS__getBrowserWindow() {
|
||||
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
|
||||
getService(Ci.nsIWindowMediator);
|
||||
|
||||
var win = wm.getMostRecentWindow("navigator:browser");
|
||||
|
||||
// We don't just return |win| now because of bug 528706.
|
||||
|
||||
if (!win)
|
||||
return null;
|
||||
if (!win.closed)
|
||||
return win;
|
||||
|
||||
#ifdef BROKEN_WM_Z_ORDER
|
||||
win = null;
|
||||
var windowsEnum = wm.getEnumerator("navigator:browser");
|
||||
// this is oldest to newest, so this gets a bit ugly
|
||||
while (windowsEnum.hasMoreElements()) {
|
||||
let nextWin = windowsEnum.getNext();
|
||||
if (!nextWin.closed)
|
||||
win = nextWin;
|
||||
}
|
||||
return win;
|
||||
#else
|
||||
var windowsEnum = wm.getZOrderDOMWindowEnumerator("navigator:browser", true);
|
||||
while (windowsEnum.hasMoreElements()) {
|
||||
win = windowsEnum.getNext();
|
||||
if (!win.closed)
|
||||
return win;
|
||||
}
|
||||
return null;
|
||||
#endif
|
||||
},
|
||||
|
||||
_ensureCanCloseWindows: function PBS__ensureCanCloseWindows() {
|
||||
// whether we should save and close the current session
|
||||
this._saveSession = true;
|
||||
try {
|
||||
if (this._prefs.getBoolPref("browser.privatebrowsing.keep_current_session")) {
|
||||
this._saveSession = false;
|
||||
return;
|
||||
}
|
||||
} catch (ex) {}
|
||||
|
||||
let windowMediator = Cc["@mozilla.org/appshell/window-mediator;1"].
|
||||
getService(Ci.nsIWindowMediator);
|
||||
let windowsEnum = windowMediator.getEnumerator("navigator:browser");
|
||||
|
||||
while (windowsEnum.hasMoreElements()) {
|
||||
let win = windowsEnum.getNext();
|
||||
if (win.closed)
|
||||
continue;
|
||||
let xulWin = win.QueryInterface(Ci.nsIInterfaceRequestor).
|
||||
getInterface(Ci.nsIWebNavigation).
|
||||
QueryInterface(Ci.nsIDocShellTreeItem).
|
||||
treeOwner.QueryInterface(Ci.nsIInterfaceRequestor).
|
||||
getInterface(Ci.nsIXULWindow);
|
||||
if (xulWin.docShell.contentViewer.permitUnload(true))
|
||||
this._windowsToClose.push(xulWin);
|
||||
else
|
||||
throw Cr.NS_ERROR_ABORT;
|
||||
}
|
||||
},
|
||||
|
||||
_closePageInfoWindows: function PBS__closePageInfoWindows() {
|
||||
let pageInfoEnum = Cc["@mozilla.org/appshell/window-mediator;1"].
|
||||
getService(Ci.nsIWindowMediator).
|
||||
getEnumerator("Browser:page-info");
|
||||
while (pageInfoEnum.hasMoreElements()) {
|
||||
let win = pageInfoEnum.getNext();
|
||||
win.close();
|
||||
}
|
||||
},
|
||||
|
||||
// nsIObserver
|
||||
|
||||
observe: function PBS_observe(aSubject, aTopic, aData) {
|
||||
switch (aTopic) {
|
||||
case "profile-after-change":
|
||||
// If the autostart prefs has been set, simulate entering the
|
||||
// private browsing mode upon startup.
|
||||
// This won't interfere with the session store component, because
|
||||
// that component will be initialized on final-ui-startup.
|
||||
if (!this._autoStarted) {
|
||||
this._autoStarted = this._prefs.getBoolPref("browser.privatebrowsing.autostart");
|
||||
if (this._autoStarted)
|
||||
this.privateBrowsingEnabled = true;
|
||||
}
|
||||
this._obs.removeObserver(this, "profile-after-change");
|
||||
break;
|
||||
case "quit-application-granted":
|
||||
this._unload();
|
||||
break;
|
||||
case "private-browsing":
|
||||
if (!this._inPrivateBrowsing) {
|
||||
// Clear the error console
|
||||
let consoleService = Cc["@mozilla.org/consoleservice;1"].
|
||||
getService(Ci.nsIConsoleService);
|
||||
consoleService.logStringMessage(null); // trigger the listeners
|
||||
consoleService.reset();
|
||||
}
|
||||
break;
|
||||
case "command-line-startup":
|
||||
this._obs.removeObserver(this, "command-line-startup");
|
||||
aSubject.QueryInterface(Ci.nsICommandLine);
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
if (aSubject.findFlag("private", false) >= 0) {
|
||||
// Don't need to go into PB mode if it's already set to autostart
|
||||
if (this._autoStarted)
|
||||
aSubject.handleFlag("private", false);
|
||||
|
||||
this.privateBrowsingEnabled = true;
|
||||
this._autoStarted = true;
|
||||
this._lastChangedByCommandLine = true;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (aSubject.findFlag("private-toggle", false) >= 0) {
|
||||
this._lastChangedByCommandLine = true;
|
||||
}
|
||||
break;
|
||||
case "sessionstore-browser-state-restored":
|
||||
if (this._currentStatus == STATE_WAITING_FOR_RESTORE) {
|
||||
this._currentStatus = STATE_RESTORE_FINISHED;
|
||||
this._notifyIfTransitionComplete();
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
// nsICommandLineHandler
|
||||
|
||||
handle: function PBS_handle(aCmdLine) {
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
if (aCmdLine.handleFlag("private", false))
|
||||
aCmdLine.preventDefault = true; // It has already been handled
|
||||
else
|
||||
#endif
|
||||
if (aCmdLine.handleFlag("private-toggle", false)) {
|
||||
if (this._autoStarted) {
|
||||
throw Cr.NS_ERROR_ABORT;
|
||||
}
|
||||
this.privateBrowsingEnabled = !this.privateBrowsingEnabled;
|
||||
this._lastChangedByCommandLine = true;
|
||||
}
|
||||
},
|
||||
|
||||
get helpInfo() {
|
||||
return " -private Enable private browsing mode.\n" +
|
||||
" -private-toggle Toggle private browsing mode.\n";
|
||||
},
|
||||
|
||||
// nsIPrivateBrowsingService
|
||||
|
||||
/**
|
||||
* Return the current status of private browsing.
|
||||
*/
|
||||
get privateBrowsingEnabled() {
|
||||
return this._inPrivateBrowsing;
|
||||
},
|
||||
|
||||
/**
|
||||
* Enter or leave private browsing mode.
|
||||
*/
|
||||
set privateBrowsingEnabled(val) {
|
||||
// Allowing observers to set the private browsing status from their
|
||||
// notification handlers is not desired, because it will change the
|
||||
// status of the service while it's in the process of another transition.
|
||||
// So, we detect a reentrant call here and throw an error.
|
||||
// This is documented in nsIPrivateBrowsingService.idl.
|
||||
if (this._currentStatus != STATE_IDLE)
|
||||
throw Cr.NS_ERROR_FAILURE;
|
||||
|
||||
if (val == this._inPrivateBrowsing)
|
||||
return;
|
||||
|
||||
try {
|
||||
if (val) {
|
||||
if (!this._canEnterPrivateBrowsingMode())
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (!this._canLeavePrivateBrowsingMode())
|
||||
return;
|
||||
}
|
||||
|
||||
this._ensureCanCloseWindows();
|
||||
|
||||
// start the transition now that we know that we can
|
||||
this._currentStatus = STATE_TRANSITION_STARTED;
|
||||
|
||||
this._autoStarted = this._prefs.getBoolPref("browser.privatebrowsing.autostart");
|
||||
this._inPrivateBrowsing = val != false;
|
||||
|
||||
this._recordTransitionTime("started");
|
||||
|
||||
let data = val ? "enter" : "exit";
|
||||
|
||||
let quitting = Cc["@mozilla.org/supports-PRBool;1"].
|
||||
createInstance(Ci.nsISupportsPRBool);
|
||||
quitting.data = this._quitting;
|
||||
|
||||
// notify observers of the pending private browsing mode change
|
||||
this._obs.notifyObservers(quitting, "private-browsing-change-granted", data);
|
||||
|
||||
// destroy the current session and start initial cleanup
|
||||
this._onBeforePrivateBrowsingModeChange();
|
||||
|
||||
this._obs.notifyObservers(quitting, "private-browsing", data);
|
||||
|
||||
this._recordTransitionTime("prepared");
|
||||
|
||||
// load the appropriate session
|
||||
this._onAfterPrivateBrowsingModeChange();
|
||||
} catch (ex) {
|
||||
// We aborted the transition to/from private browsing, we must restore the
|
||||
// beforeunload handling on all the windows for which we switched it off.
|
||||
for (let i = 0; i < this._windowsToClose.length; i++)
|
||||
this._windowsToClose[i].docShell.contentViewer.resetCloseWindow();
|
||||
// We don't log an error when the transition is canceled from beforeunload
|
||||
if (ex != Cr.NS_ERROR_ABORT)
|
||||
Cu.reportError("Exception thrown while processing the " +
|
||||
"private browsing mode change request: " + ex.toString());
|
||||
} finally {
|
||||
this._windowsToClose = [];
|
||||
this._notifyIfTransitionComplete();
|
||||
this._lastChangedByCommandLine = false;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Whether private browsing has been started automatically.
|
||||
*/
|
||||
get autoStarted() {
|
||||
return this._inPrivateBrowsing && this._autoStarted;
|
||||
},
|
||||
|
||||
/**
|
||||
* Whether the latest transition was initiated from the command line.
|
||||
*/
|
||||
get lastChangedByCommandLine() {
|
||||
return this._lastChangedByCommandLine;
|
||||
}
|
||||
};
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([PrivateBrowsingService]);
|
@ -1,17 +0,0 @@
|
||||
# WebappRT doesn't need these instructions, and they don't necessarily work
|
||||
# with it, but it does use a GRE directory that the GRE shares with Firefox,
|
||||
# so in order to prevent the instructions from being processed for WebappRT,
|
||||
# we need to restrict them to the applications that depend on them, i.e.:
|
||||
#
|
||||
# b2g: {3c2e2abc-06d4-11e1-ac3b-374f68613e61}
|
||||
# browser: {ec8030f7-c20a-464f-9b0e-13a3a9e97384}
|
||||
# mobile/android: {aa3c5121-dab2-40e2-81ca-7ea25febc110}
|
||||
# mobile/xul: {a23983c0-fd0e-11dc-95ff-0800200c9a66}
|
||||
#
|
||||
# In theory we should do this for all these instructions, but in practice it is
|
||||
# sufficient to do it for the app-startup one, and the file is simpler that way.
|
||||
|
||||
component {c31f4883-839b-45f6-82ad-a6a9bc5ad599} nsPrivateBrowsingService.js
|
||||
contract @mozilla.org/privatebrowsing;1 {c31f4883-839b-45f6-82ad-a6a9bc5ad599}
|
||||
category command-line-handler m-privatebrowsing @mozilla.org/privatebrowsing;1
|
||||
category app-startup nsPrivateBrowsingService service,@mozilla.org/privatebrowsing;1 application={3c2e2abc-06d4-11e1-ac3b-374f68613e61} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} application={aa3c5121-dab2-40e2-81ca-7ea25febc110} application={a23983c0-fd0e-11dc-95ff-0800200c9a66}
|
@ -1,93 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
#include "nsPrivateBrowsingServiceWrapper.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "jsapi.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
|
||||
class JSStackGuard
|
||||
{
|
||||
public:
|
||||
JSStackGuard();
|
||||
~JSStackGuard();
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIJSContextStack> mJSStack;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsPrivateBrowsingServiceWrapper, nsIPrivateBrowsingService, nsIObserver)
|
||||
|
||||
nsresult
|
||||
nsPrivateBrowsingServiceWrapper::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
mPBService = do_GetService("@mozilla.org/privatebrowsing;1", &rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
JSStackGuard::JSStackGuard()
|
||||
: mJSStack(nullptr)
|
||||
{
|
||||
nsresult rv;
|
||||
mJSStack = do_GetService("@mozilla.org/js/xpc/ContextStack;1", &rv);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && mJSStack) {
|
||||
rv = mJSStack->Push(nullptr);
|
||||
if (NS_FAILED(rv))
|
||||
mJSStack = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
JSStackGuard::~JSStackGuard()
|
||||
{
|
||||
if (mJSStack) {
|
||||
JSContext *cx;
|
||||
mJSStack->Pop(&cx);
|
||||
NS_ASSERTION(cx == nullptr, "JSContextStack mismatch");
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrivateBrowsingServiceWrapper::GetPrivateBrowsingEnabled(bool *aPrivateBrowsingEnabled)
|
||||
{
|
||||
if (!aPrivateBrowsingEnabled)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
JSStackGuard guard;
|
||||
return mPBService->GetPrivateBrowsingEnabled(aPrivateBrowsingEnabled);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrivateBrowsingServiceWrapper::SetPrivateBrowsingEnabled(bool aPrivateBrowsingEnabled)
|
||||
{
|
||||
JSStackGuard guard;
|
||||
return mPBService->SetPrivateBrowsingEnabled(aPrivateBrowsingEnabled);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrivateBrowsingServiceWrapper::GetAutoStarted(bool *aAutoStarted)
|
||||
{
|
||||
if (!aAutoStarted)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
JSStackGuard guard;
|
||||
return mPBService->GetAutoStarted(aAutoStarted);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrivateBrowsingServiceWrapper::GetLastChangedByCommandLine(bool *aReason)
|
||||
{
|
||||
if (!aReason)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
JSStackGuard guard;
|
||||
return mPBService->GetLastChangedByCommandLine(aReason);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrivateBrowsingServiceWrapper::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData)
|
||||
{
|
||||
JSStackGuard guard;
|
||||
nsCOMPtr<nsIObserver> observer(do_QueryInterface(mPBService));
|
||||
NS_ENSURE_TRUE(observer, NS_ERROR_FAILURE);
|
||||
return observer->Observe(aSubject, aTopic, aData);
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIPrivateBrowsingService.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
class nsIJSContextStack;
|
||||
|
||||
class nsPrivateBrowsingServiceWrapper MOZ_FINAL : public nsIPrivateBrowsingService,
|
||||
public nsIObserver
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPRIVATEBROWSINGSERVICE
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
nsresult Init();
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIPrivateBrowsingService> mPBService;
|
||||
};
|
@ -12,15 +12,6 @@ include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = test_privatebrowsing
|
||||
|
||||
# Most xpcshell PB tests use the global PB service, which means that we should
|
||||
# not attempt to run them in regular builds. We should look at the list and
|
||||
# decide which ones of them should be ported to the browser/perwindow suite
|
||||
# in the future.
|
||||
|
||||
ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
XPCSHELL_TESTS = unit
|
||||
endif
|
||||
|
||||
DIRS += browser \
|
||||
$(NULL)
|
||||
|
||||
|
@ -12,21 +12,6 @@ include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = test_privatebrowsing
|
||||
|
||||
# We have three category of browser-chrome tests:
|
||||
# global: these tests focus on the global PB service implementation.
|
||||
# perwindow: these tests focus on the per-window PB implementation.
|
||||
# obsolete: these tests focus on the global mode, but the functionality
|
||||
# that they are testing is specific to the global mode, and
|
||||
# will never have a per-window counterpart.
|
||||
#
|
||||
# As a transition plan, we have divided the existing tests into the
|
||||
# global and obsolete categories, and we'll then focus on rewriting the
|
||||
# global tests to test the per-window mode.
|
||||
|
||||
ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
DIRS += perwindow
|
||||
else
|
||||
DIRS += global obsolete
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -1,56 +0,0 @@
|
||||
# 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/.
|
||||
|
||||
DEPTH = @DEPTH@
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
relativesrcdir = @relativesrcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MOCHITEST_BROWSER_FILES = \
|
||||
head.js \
|
||||
browser_privatebrowsing_certexceptionsui.js \
|
||||
browser_privatebrowsing_crh.js \
|
||||
browser_privatebrowsing_downloadLastDir.js \
|
||||
browser_privatebrowsing_downloadLastDir_c.js \
|
||||
browser_privatebrowsing_downloadLastDir_toggle.js \
|
||||
browser_privatebrowsing_DownloadLastDirWithCPS.js \
|
||||
browser_privatebrowsing_geoprompt.js \
|
||||
browser_privatebrowsing_geoprompt_page.html \
|
||||
browser_privatebrowsing_localStorage.js \
|
||||
browser_privatebrowsing_localStorage_before_after.js \
|
||||
browser_privatebrowsing_localStorage_before_after_page.html \
|
||||
browser_privatebrowsing_localStorage_before_after_page2.html \
|
||||
browser_privatebrowsing_localStorage_page1.html \
|
||||
browser_privatebrowsing_localStorage_page2.html \
|
||||
browser_privatebrowsing_opendir.js \
|
||||
browser_privatebrowsing_openlocation.js \
|
||||
browser_privatebrowsing_openLocationLastURL.js \
|
||||
browser_privatebrowsing_placestitle.js \
|
||||
browser_privatebrowsing_popupblocker.js \
|
||||
browser_privatebrowsing_protocolhandler.js \
|
||||
browser_privatebrowsing_protocolhandler_page.html \
|
||||
browser_privatebrowsing_theming.js \
|
||||
browser_privatebrowsing_ui.js \
|
||||
browser_privatebrowsing_urlbarfocus.js \
|
||||
browser_privatebrowsing_windowtitle.js \
|
||||
browser_privatebrowsing_windowtitle_page.html \
|
||||
browser_privatebrowsing_zoom.js \
|
||||
browser_privatebrowsing_zoomrestore.js \
|
||||
ctxmenu.html \
|
||||
ctxmenu-image.png \
|
||||
popup.html \
|
||||
title.sjs \
|
||||
$(NULL)
|
||||
|
||||
# Turn off private browsing tests that perma-timeout on Linux.
|
||||
ifneq (Linux,$(OS_ARCH))
|
||||
MOCHITEST_BROWSER_FILES += \
|
||||
browser_privatebrowsing_cookieacceptdialog.js \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
@ -1,259 +0,0 @@
|
||||
/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
let gTests;
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
gTests = runTest();
|
||||
moveAlong();
|
||||
}
|
||||
|
||||
function moveAlong() {
|
||||
try {
|
||||
gTests.next();
|
||||
} catch (x if x instanceof StopIteration) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
function waitForPB() {
|
||||
function observer(aSubject, aTopic, aData) {
|
||||
Services.obs.removeObserver(observer, "last-pb-context-exited", false);
|
||||
executeSoon(moveAlong);
|
||||
}
|
||||
Services.obs.addObserver(observer, "last-pb-context-exited", false);
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
let tmpScope = {};
|
||||
Cu.import("resource://gre/modules/DownloadLastDir.jsm", tmpScope);
|
||||
let gDownloadLastDir = new tmpScope.DownloadLastDir(window);
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/FileUtils.jsm", tmpScope);
|
||||
let FileUtils = tmpScope.FileUtils;
|
||||
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
|
||||
function clearHistory() {
|
||||
// simulate clearing the private data
|
||||
Services.obs.notifyObservers(null, "browser:purge-session-history", "");
|
||||
}
|
||||
|
||||
is(typeof gDownloadLastDir, "object", "gDownloadLastDir should be a valid object");
|
||||
is(gDownloadLastDir.file, null, "LastDir pref should be null to start with");
|
||||
|
||||
let tmpDir = FileUtils.getDir("TmpD", [], true);
|
||||
|
||||
let uri1 = Services.io.newURI("http://test1.com/", null, null);
|
||||
let uri2 = Services.io.newURI("http://test2.com/", null, null);
|
||||
let uri3 = Services.io.newURI("http://test3.com/", null, null);
|
||||
let uri4 = Services.io.newURI("http://test4.com/", null, null);
|
||||
|
||||
function newDir() {
|
||||
let dir = tmpDir.clone();
|
||||
dir.append("testdir");
|
||||
dir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0700);
|
||||
return dir;
|
||||
}
|
||||
|
||||
let dir1 = newDir();
|
||||
let dir2 = newDir();
|
||||
let dir3 = newDir();
|
||||
try {
|
||||
{ // set up last dir
|
||||
gDownloadLastDir.setFile(null, tmpDir);
|
||||
is(gDownloadLastDir.file.path, tmpDir.path, "LastDir should point to the tmpDir");
|
||||
isnot(gDownloadLastDir.file, tmpDir, "gDownloadLastDir.file should not be pointing to tmpDir");
|
||||
}
|
||||
|
||||
{ // set uri1 to dir1, all should now return dir1
|
||||
// also check that a new object is returned
|
||||
gDownloadLastDir.setFile(uri1, dir1);
|
||||
is(gDownloadLastDir.file.path, dir1.path, "gDownloadLastDir should return dir1");
|
||||
isnot(gDownloadLastDir.file, dir1, "gDownloadLastDir.file should not return dir1");
|
||||
is(gDownloadLastDir.getFile(uri1).path, dir1.path, "uri1 should return dir1"); // set in CPS
|
||||
isnot(gDownloadLastDir.getFile(uri1), dir1, "getFile on uri1 should not return dir1");
|
||||
is(gDownloadLastDir.getFile(uri2).path, dir1.path, "uri2 should return dir1"); // fallback
|
||||
isnot(gDownloadLastDir.getFile(uri2), dir1, "getFile on uri2 should not return dir1");
|
||||
is(gDownloadLastDir.getFile(uri3).path, dir1.path, "uri3 should return dir1"); // fallback
|
||||
isnot(gDownloadLastDir.getFile(uri3), dir1, "getFile on uri3 should not return dir1");
|
||||
is(gDownloadLastDir.getFile(uri4).path, dir1.path, "uri4 should return dir1"); // fallback
|
||||
isnot(gDownloadLastDir.getFile(uri4), dir1, "getFile on uri4 should not return dir1");
|
||||
}
|
||||
|
||||
{ // set uri2 to dir2, all except uri1 should now return dir2
|
||||
gDownloadLastDir.setFile(uri2, dir2);
|
||||
is(gDownloadLastDir.file.path, dir2.path, "gDownloadLastDir should point to dir2");
|
||||
is(gDownloadLastDir.getFile(uri1).path, dir1.path, "uri1 should return dir1"); // set in CPS
|
||||
is(gDownloadLastDir.getFile(uri2).path, dir2.path, "uri2 should return dir2"); // set in CPS
|
||||
is(gDownloadLastDir.getFile(uri3).path, dir2.path, "uri3 should return dir2"); // fallback
|
||||
is(gDownloadLastDir.getFile(uri4).path, dir2.path, "uri4 should return dir2"); // fallback
|
||||
}
|
||||
|
||||
{ // set uri3 to dir3, all except uri1 and uri2 should now return dir3
|
||||
gDownloadLastDir.setFile(uri3, dir3);
|
||||
is(gDownloadLastDir.file.path, dir3.path, "gDownloadLastDir should point to dir3");
|
||||
is(gDownloadLastDir.getFile(uri1).path, dir1.path, "uri1 should return dir1"); // set in CPS
|
||||
is(gDownloadLastDir.getFile(uri2).path, dir2.path, "uri2 should return dir2"); // set in CPS
|
||||
is(gDownloadLastDir.getFile(uri3).path, dir3.path, "uri3 should return dir3"); // set in CPS
|
||||
is(gDownloadLastDir.getFile(uri4).path, dir3.path, "uri4 should return dir4"); // fallback
|
||||
}
|
||||
|
||||
{ // set uri1 to dir2, all except uri3 should now return dir2
|
||||
gDownloadLastDir.setFile(uri1, dir2);
|
||||
is(gDownloadLastDir.file.path, dir2.path, "gDownloadLastDir should point to dir2");
|
||||
is(gDownloadLastDir.getFile(uri1).path, dir2.path, "uri1 should return dir2"); // set in CPS
|
||||
is(gDownloadLastDir.getFile(uri2).path, dir2.path, "uri2 should return dir2"); // set in CPS
|
||||
is(gDownloadLastDir.getFile(uri3).path, dir3.path, "uri3 should return dir3"); // set in CPS
|
||||
is(gDownloadLastDir.getFile(uri4).path, dir2.path, "uri4 should return dir2"); // fallback
|
||||
}
|
||||
|
||||
{ // check clearHistory removes all data
|
||||
clearHistory();
|
||||
is(gDownloadLastDir.file, null, "clearHistory removes all data");
|
||||
is(Services.contentPrefs.hasPref(uri1, "browser.download.lastDir", null), false, "LastDir preference should be absent");
|
||||
is(gDownloadLastDir.getFile(uri1), null, "uri1 should point to null");
|
||||
is(gDownloadLastDir.getFile(uri2), null, "uri2 should point to null");
|
||||
is(gDownloadLastDir.getFile(uri3), null, "uri3 should point to null");
|
||||
is(gDownloadLastDir.getFile(uri4), null, "uri4 should point to null");
|
||||
}
|
||||
|
||||
Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
||||
|
||||
{ // check data set outside PB mode is remembered
|
||||
gDownloadLastDir.setFile(null, tmpDir);
|
||||
pb.privateBrowsingEnabled = true;
|
||||
is(gDownloadLastDir.file.path, tmpDir.path, "LastDir should point to tmpDir inside PB mode");
|
||||
is(gDownloadLastDir.getFile(uri1).path, tmpDir.path, "uri1 should return tmpDir inside PB mode");
|
||||
|
||||
waitForPB();
|
||||
pb.privateBrowsingEnabled = false;
|
||||
yield;
|
||||
is(gDownloadLastDir.file.path, tmpDir.path, "LastDir should point to tmpDir outside PB mode");
|
||||
is(gDownloadLastDir.getFile(uri1).path, tmpDir.path, "uri1 should return tmpDir outside PB mode");
|
||||
|
||||
clearHistory();
|
||||
}
|
||||
|
||||
{ // check data set using CPS outside PB mode is remembered
|
||||
gDownloadLastDir.setFile(uri1, dir1);
|
||||
pb.privateBrowsingEnabled = true;
|
||||
is(gDownloadLastDir.file.path, dir1.path, "LastDir should point to dir1 inside PB mode");
|
||||
is(gDownloadLastDir.getFile(uri1).path, dir1.path, "uri1 should return dir1 inside PB mode");
|
||||
|
||||
waitForPB();
|
||||
pb.privateBrowsingEnabled = false;
|
||||
yield;
|
||||
is(gDownloadLastDir.file.path, dir1.path, "LastDir should point to dir1 outside PB mode");
|
||||
is(gDownloadLastDir.getFile(uri1).path, dir1.path, "uri1 should return dir1 outside PB mode");
|
||||
|
||||
clearHistory();
|
||||
}
|
||||
|
||||
{ // check data set inside PB mode is forgotten
|
||||
pb.privateBrowsingEnabled = true;
|
||||
gDownloadLastDir.setFile(null, tmpDir);
|
||||
is(gDownloadLastDir.file.path, tmpDir.path, "LastDir should return tmpDir inside PB mode");
|
||||
is(gDownloadLastDir.getFile(uri1).path, tmpDir.path, "uri1 should return tmpDir inside PB mode");
|
||||
|
||||
waitForPB();
|
||||
pb.privateBrowsingEnabled = false;
|
||||
yield;
|
||||
is(gDownloadLastDir.file, null, "LastDir should be null outside PB mode");
|
||||
is(gDownloadLastDir.getFile(uri1), null, "uri1 should return null outside PB mode");
|
||||
|
||||
clearHistory();
|
||||
}
|
||||
|
||||
{ // check data set using CPS inside PB mode is forgotten
|
||||
pb.privateBrowsingEnabled = true;
|
||||
gDownloadLastDir.setFile(uri1, dir1);
|
||||
is(gDownloadLastDir.file.path, dir1.path, "LastDir should point to dir1 inside PB mode");
|
||||
is(gDownloadLastDir.getFile(uri1).path, dir1.path, "uri1 should return dir1 inside PB mode");
|
||||
|
||||
waitForPB();
|
||||
pb.privateBrowsingEnabled = false;
|
||||
yield;
|
||||
is(gDownloadLastDir.file, null, "LastDir should point to null outside PB mode");
|
||||
is(gDownloadLastDir.getFile(uri1), null, "uri1 should return null outside PB mode");
|
||||
|
||||
clearHistory();
|
||||
}
|
||||
|
||||
{ // check data set outside PB mode but changed inside is remembered correctly
|
||||
gDownloadLastDir.setFile(uri1, dir1);
|
||||
pb.privateBrowsingEnabled = true;
|
||||
gDownloadLastDir.setFile(uri1, dir2);
|
||||
is(gDownloadLastDir.file.path, dir2.path, "LastDir should point to dir2 inside PB mode");
|
||||
is(gDownloadLastDir.getFile(uri1).path, dir2.path, "uri1 should return dir2 inside PB mode");
|
||||
|
||||
waitForPB();
|
||||
pb.privateBrowsingEnabled = false;
|
||||
yield;
|
||||
is(gDownloadLastDir.file.path, dir1.path, "LastDir should point to dir1 outside PB mode");
|
||||
is(gDownloadLastDir.getFile(uri1).path, dir1.path, "uri1 should return dir1 outside PB mode");
|
||||
|
||||
// check that the last dir store got cleared
|
||||
pb.privateBrowsingEnabled = true;
|
||||
is(gDownloadLastDir.file.path, dir1.path, "LastDir should be cleared");
|
||||
is(gDownloadLastDir.getFile(uri1).path, dir1.path, "uri1 should return dir1");
|
||||
|
||||
waitForPB();
|
||||
pb.privateBrowsingEnabled = false;
|
||||
yield;
|
||||
clearHistory();
|
||||
}
|
||||
|
||||
{ // check clearHistory inside PB mode clears data outside PB mode
|
||||
pb.privateBrowsingEnabled = true;
|
||||
gDownloadLastDir.setFile(uri1, dir2);
|
||||
|
||||
clearHistory();
|
||||
is(gDownloadLastDir.file, null, "LastDir should be null afer clearing history");
|
||||
is(gDownloadLastDir.getFile(uri1), null, "uri1 should return null");
|
||||
|
||||
waitForPB();
|
||||
pb.privateBrowsingEnabled = false;
|
||||
yield;
|
||||
is(gDownloadLastDir.file, null, "LastDir should be null");
|
||||
is(gDownloadLastDir.getFile(uri1), null, "uri1 should return null");
|
||||
}
|
||||
|
||||
{ // check that disabling CPS works
|
||||
Services.prefs.setBoolPref("browser.download.lastDir.savePerSite", false);
|
||||
|
||||
gDownloadLastDir.setFile(uri1, dir1);
|
||||
is(gDownloadLastDir.file.path, dir1.path, "LastDir should be set to dir1");
|
||||
is(gDownloadLastDir.getFile(uri1).path, dir1.path, "uri1 should return dir1");
|
||||
is(gDownloadLastDir.getFile(uri2).path, dir1.path, "uri2 should return dir1");
|
||||
is(gDownloadLastDir.getFile(uri3).path, dir1.path, "uri3 should return dir1");
|
||||
is(gDownloadLastDir.getFile(uri4).path, dir1.path, "uri4 should return dir1");
|
||||
|
||||
gDownloadLastDir.setFile(uri2, dir2);
|
||||
is(gDownloadLastDir.file.path, dir2.path, "LastDir should be set to dir2");
|
||||
is(gDownloadLastDir.getFile(uri1).path, dir2.path, "uri1 should return dir2");
|
||||
is(gDownloadLastDir.getFile(uri2).path, dir2.path, "uri2 should return dir2");
|
||||
is(gDownloadLastDir.getFile(uri3).path, dir2.path, "uri3 should return dir2");
|
||||
is(gDownloadLastDir.getFile(uri4).path, dir2.path, "uri4 should return dir2");
|
||||
|
||||
Services.prefs.clearUserPref("browser.download.lastDir.savePerSite");
|
||||
}
|
||||
|
||||
{ // check that passing null to setFile clears the stored value
|
||||
gDownloadLastDir.setFile(uri3, dir3);
|
||||
is(gDownloadLastDir.getFile(uri3).path, dir3.path, "LastDir should be set to dir3");
|
||||
gDownloadLastDir.setFile(uri3, null);
|
||||
is(gDownloadLastDir.getFile(uri3), null, "uri3 should return null");
|
||||
}
|
||||
} finally {
|
||||
dir1.remove(true);
|
||||
dir2.remove(true);
|
||||
dir3.remove(true);
|
||||
Services.prefs.clearUserPref("browser.download.lastDir.savePerSite");
|
||||
Services.prefs.clearUserPref("browser.download.lastDir");
|
||||
gDownloadLastDir.cleanupPrivateFile();
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
// This test makes sure that certificate exceptions UI behaves correctly
|
||||
// inside the private browsing mode, based on whether it's opened from the prefs
|
||||
// window or from the SSL error page (see bug 461627).
|
||||
|
||||
function test() {
|
||||
// initialization
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
|
||||
const EXCEPTIONS_DLG_URL = 'chrome://pippki/content/exceptionDialog.xul';
|
||||
const EXCEPTIONS_DLG_FEATURES = 'chrome,centerscreen';
|
||||
const INVALID_CERT_LOCATION = 'https://nocert.example.com/';
|
||||
waitForExplicitFinish();
|
||||
|
||||
// enter private browsing mode
|
||||
pb.privateBrowsingEnabled = true;
|
||||
|
||||
doTest();
|
||||
|
||||
// Test the certificate exceptions dialog
|
||||
function doTest() {
|
||||
let params = {
|
||||
exceptionAdded : false,
|
||||
location: INVALID_CERT_LOCATION,
|
||||
prefetchCert: true,
|
||||
};
|
||||
function testCheckbox() {
|
||||
win.removeEventListener("load", testCheckbox, false);
|
||||
Services.obs.addObserver(function (aSubject, aTopic, aData) {
|
||||
Services.obs.removeObserver(arguments.callee, "cert-exception-ui-ready", false);
|
||||
ok(win.gCert, "The certificate information should be available now");
|
||||
|
||||
let checkbox = win.document.getElementById("permanent");
|
||||
ok(checkbox.hasAttribute("disabled"),
|
||||
"the permanent checkbox should be disabled when handling the private browsing mode");
|
||||
ok(!checkbox.hasAttribute("checked"),
|
||||
"the permanent checkbox should not be checked when handling the private browsing mode");
|
||||
win.close();
|
||||
cleanup();
|
||||
}, "cert-exception-ui-ready", false);
|
||||
}
|
||||
var win = openDialog(EXCEPTIONS_DLG_URL, "", EXCEPTIONS_DLG_FEATURES, params);
|
||||
win.addEventListener("load", testCheckbox, false);
|
||||
}
|
||||
|
||||
function cleanup() {
|
||||
// leave the private browsing mode
|
||||
pb.privateBrowsingEnabled = false;
|
||||
finish();
|
||||
}
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
// This test makes sure that private browsing mode disables the "remember"
|
||||
// option in the cookie accept dialog.
|
||||
|
||||
function test() {
|
||||
// initialization
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
let cp = Cc["@mozilla.org/embedcomp/cookieprompt-service;1"].
|
||||
getService(Ci.nsICookiePromptService);
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
function checkRememberOption(expectedDisabled, callback) {
|
||||
function observer(aSubject, aTopic, aData) {
|
||||
if (aTopic != "domwindowopened")
|
||||
return;
|
||||
|
||||
Services.ww.unregisterNotification(observer);
|
||||
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
win.addEventListener("load", function onLoad(event) {
|
||||
win.removeEventListener("load", onLoad, false);
|
||||
|
||||
executeSoon(function () {
|
||||
let doc = win.document;
|
||||
let remember = doc.getElementById("persistDomainAcceptance");
|
||||
ok(remember, "The remember checkbox should exist");
|
||||
|
||||
if (expectedDisabled)
|
||||
is(remember.getAttribute("disabled"), "true",
|
||||
"The checkbox should be disabled");
|
||||
else
|
||||
ok(!remember.hasAttribute("disabled"),
|
||||
"The checkbox should not be disabled");
|
||||
|
||||
win.close();
|
||||
callback();
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
Services.ww.registerNotification(observer);
|
||||
|
||||
let remember = {};
|
||||
const time = (new Date("Jan 1, 2030")).getTime() / 1000;
|
||||
let cookie = {
|
||||
name: "foo",
|
||||
value: "bar",
|
||||
isDomain: true,
|
||||
host: "mozilla.org",
|
||||
path: "/baz",
|
||||
isSecure: false,
|
||||
expires: time,
|
||||
status: 0,
|
||||
policy: 0,
|
||||
isSession: false,
|
||||
expiry: time,
|
||||
isHttpOnly: true,
|
||||
QueryInterface: function(iid) {
|
||||
const validIIDs = [Ci.nsISupports,
|
||||
Ci.nsICookie,
|
||||
Ci.nsICookie2];
|
||||
for (var i = 0; i < validIIDs.length; ++i)
|
||||
if (iid == validIIDs[i])
|
||||
return this;
|
||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
};
|
||||
cp.cookieDialog(window, cookie, "mozilla.org", 10, false, remember);
|
||||
}
|
||||
|
||||
checkRememberOption(false, function() {
|
||||
pb.privateBrowsingEnabled = true;
|
||||
checkRememberOption(true, function() {
|
||||
pb.privateBrowsingEnabled = false;
|
||||
checkRememberOption(false, finish);
|
||||
});
|
||||
});
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
// This test makes sure that the Clear Recent History menu item and command
|
||||
// is disabled inside the private browsing mode.
|
||||
|
||||
function test() {
|
||||
// initialization
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
|
||||
let crhCommand = document.getElementById("Tools:Sanitize");
|
||||
|
||||
// make sure the command is not disabled to begin with
|
||||
ok(!crhCommand.hasAttribute("disabled"),
|
||||
"Clear Recent History command should not be disabled outside of the private browsing mode");
|
||||
|
||||
// enter private browsing mode
|
||||
pb.privateBrowsingEnabled = true;
|
||||
|
||||
ok(crhCommand.hasAttribute("disabled"),
|
||||
"Clear Recent History command should be disabled inside of the private browsing mode");
|
||||
|
||||
// leave private browsing mode
|
||||
pb.privateBrowsingEnabled = false;
|
||||
|
||||
ok(!crhCommand.hasAttribute("disabled"),
|
||||
"Clear Recent History command should not be disabled after leaving the private browsing mode");
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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 test() {
|
||||
let tempScope = {};
|
||||
let downloadModule = {};
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/DownloadLastDir.jsm", downloadModule);
|
||||
Cu.import("resource://gre/modules/FileUtils.jsm", tempScope);
|
||||
let FileUtils = tempScope.FileUtils;
|
||||
let MockFilePicker = SpecialPowers.MockFilePicker;
|
||||
let gDownloadLastDir = new downloadModule.DownloadLastDir(window);
|
||||
|
||||
let launcher = {
|
||||
source: Services.io.newURI("http://test1.com/file", null, null)
|
||||
};
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
|
||||
MockFilePicker.init(window);
|
||||
MockFilePicker.returnValue = Ci.nsIFilePicker.returnOK;
|
||||
|
||||
Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
||||
let prefs = Services.prefs.getBranch("browser.download.");
|
||||
let launcherDialog = Cc["@mozilla.org/helperapplauncherdialog;1"].
|
||||
getService(Ci.nsIHelperAppLauncherDialog);
|
||||
let tmpDir = FileUtils.getDir("TmpD", [], true);
|
||||
function newDirectory() {
|
||||
let dir = tmpDir.clone();
|
||||
dir.append("testdir");
|
||||
dir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0700);
|
||||
return dir;
|
||||
}
|
||||
function newFileInDirectory(dir) {
|
||||
let file = dir.clone();
|
||||
file.append("testfile");
|
||||
file.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0600);
|
||||
return file;
|
||||
}
|
||||
|
||||
let dir1 = newDirectory();
|
||||
let dir2 = newDirectory();
|
||||
let dir3 = newDirectory();
|
||||
let file1 = newFileInDirectory(dir1);
|
||||
let file2 = newFileInDirectory(dir2);
|
||||
let file3 = newFileInDirectory(dir3);
|
||||
|
||||
// cleanup functions registration
|
||||
registerCleanupFunction(function () {
|
||||
Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
Services.prefs.clearUserPref("browser.download.lastDir");
|
||||
[dir1, dir2, dir3].forEach(function(dir) dir.remove(true));
|
||||
MockFilePicker.cleanup();
|
||||
gDownloadLastDir.cleanupPrivateFile();
|
||||
delete FileUtils;
|
||||
});
|
||||
|
||||
let context = gBrowser.selectedBrowser.contentWindow;
|
||||
|
||||
prefs.setComplexValue("lastDir", Ci.nsIFile, tmpDir);
|
||||
MockFilePicker.returnFiles = [file1];
|
||||
let file = launcherDialog.promptForSaveToFile(launcher, context, null, null, null);
|
||||
ok(!!file, "promptForSaveToFile correctly returned a file");
|
||||
// file picker should start with browser.download.lastDir
|
||||
is(MockFilePicker.displayDirectory.path, tmpDir.path, "File picker should start with browser.download.lastDir");
|
||||
// browser.download.lastDir should be modified before entering the private browsing mode
|
||||
is(prefs.getComplexValue("lastDir", Ci.nsIFile).path, dir1.path, "LastDir should be modified before entering the PB mode");
|
||||
// gDownloadLastDir should be usable outside of the private browsing mode
|
||||
is(gDownloadLastDir.file.path, dir1.path, "gDownloadLastDir should be usable outside of the PB mode");
|
||||
|
||||
pb.privateBrowsingEnabled = true;
|
||||
is(prefs.getComplexValue("lastDir", Ci.nsIFile).path, dir1.path, "LastDir should be that set before entering PB mode");
|
||||
MockFilePicker.returnFiles = [file2];
|
||||
MockFilePicker.displayDirectory = null;
|
||||
file = launcherDialog.promptForSaveToFile(launcher, context, null, null, null);
|
||||
ok(!!file, "promptForSaveToFile correctly returned a file");
|
||||
// file picker should start with browser.download.lastDir as set before entering the private browsing mode
|
||||
is(MockFilePicker.displayDirectory.path, dir1.path, "Start with LastDir as set before entering the PB mode");
|
||||
// browser.download.lastDir should not be modified inside the private browsing mode
|
||||
is(prefs.getComplexValue("lastDir", Ci.nsIFile).path, dir1.path, "LastDir should not be modified inside the PB mode");
|
||||
// but gDownloadLastDir should be modified
|
||||
is(gDownloadLastDir.file.path, dir2.path, "gDownloadLastDir should be modified inside PB mode");
|
||||
|
||||
pb.privateBrowsingEnabled = false;
|
||||
// gDownloadLastDir should be cleared after leaving the private browsing mode
|
||||
is(gDownloadLastDir.file.path, dir1.path, "gDownloadLastDir should be cleared after leaving the PB mode");
|
||||
MockFilePicker.returnFiles = [file3];
|
||||
MockFilePicker.displayDirectory = null;
|
||||
file = launcherDialog.promptForSaveToFile(launcher, context, null, null, null);
|
||||
ok(!!file, "promptForSaveToFile correctly returned a file");
|
||||
// file picker should start with browser.download.lastDir as set before entering the private browsing mode
|
||||
is(MockFilePicker.displayDirectory.path, dir1.path, "Start with LastDir as set before entering the PB mode");
|
||||
// browser.download.lastDir should be modified after leaving the private browsing mode
|
||||
is(prefs.getComplexValue("lastDir", Ci.nsIFile).path, dir3.path, "LastDir should be modified after leaving the PB mode");
|
||||
// gDownloadLastDir should be usable after leaving the private browsing mode
|
||||
is(gDownloadLastDir.file.path, dir3.path, "gDownloadLastDir should be usable after leaving the PB mode");
|
||||
}
|
@ -1,114 +0,0 @@
|
||||
/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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 test() {
|
||||
let tmpScope = {};
|
||||
let downloadModule = {};
|
||||
Cu.import("resource://gre/modules/DownloadLastDir.jsm", downloadModule);
|
||||
Cu.import("resource://gre/modules/FileUtils.jsm", tmpScope);
|
||||
let FileUtils = tmpScope.FileUtils;
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
let MockFilePicker = SpecialPowers.MockFilePicker;
|
||||
let gDownloadLastDir = new downloadModule.DownloadLastDir(window);
|
||||
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
|
||||
MockFilePicker.init(window);
|
||||
MockFilePicker.returnValue = Ci.nsIFilePicker.returnOK;
|
||||
|
||||
//let stringBundleToRestore = ContentAreaUtils.stringBundle;
|
||||
let validateFileNameToRestore = validateFileName;
|
||||
|
||||
Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
||||
let prefs = Services.prefs.getBranch("browser.download.");
|
||||
let tmpDir = FileUtils.getDir("TmpD", [], true);
|
||||
function newDirectory() {
|
||||
let dir = tmpDir.clone();
|
||||
dir.append("testdir");
|
||||
dir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0700);
|
||||
return dir;
|
||||
}
|
||||
|
||||
function newFileInDirectory(dir) {
|
||||
let file = dir.clone();
|
||||
file.append("testfile");
|
||||
file.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0600);
|
||||
return file;
|
||||
}
|
||||
|
||||
let dir1 = newDirectory();
|
||||
let dir2 = newDirectory();
|
||||
let dir3 = newDirectory();
|
||||
let file1 = newFileInDirectory(dir1);
|
||||
let file2 = newFileInDirectory(dir2);
|
||||
let file3 = newFileInDirectory(dir3);
|
||||
|
||||
// cleanup function registration
|
||||
registerCleanupFunction(function () {
|
||||
Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
Services.prefs.clearUserPref("browser.download.lastDir");
|
||||
[dir1, dir2, dir3].forEach(function(dir) dir.remove(true));
|
||||
MockFilePicker.cleanup();
|
||||
//ContentAreaUtils.stringBundle = stringBundleToRestore;
|
||||
validateFileName = validateFileNameToRestore;
|
||||
gDownloadLastDir.cleanupPrivateFile();
|
||||
delete FileUtils;
|
||||
});
|
||||
|
||||
// Overwrite stringBundle to return an object masquerading as a string bundle
|
||||
/*delete ContentAreaUtils.stringBundle;
|
||||
ContentAreaUtils.stringBundle = {
|
||||
GetStringFromName: function() ""
|
||||
};*/
|
||||
|
||||
// Overwrite validateFileName to validate everything
|
||||
validateFileName = function(foo) foo;
|
||||
|
||||
let params = {
|
||||
//fpTitleKey: "test",
|
||||
fileInfo: new FileInfo("test.txt", "test.txt", "test", "txt", "http://mozilla.org/test.txt"),
|
||||
contentType: "text/plain",
|
||||
saveMode: SAVEMODE_FILEONLY,
|
||||
saveAsType: kSaveAsType_Complete,
|
||||
file: null
|
||||
};
|
||||
|
||||
prefs.setComplexValue("lastDir", Ci.nsIFile, tmpDir);
|
||||
MockFilePicker.returnFiles = [file1];
|
||||
MockFilePicker.displayDirectory = null;
|
||||
ok(getTargetFile(params), "Show the file picker dialog with given params");
|
||||
// file picker should start with browser.download.lastDir
|
||||
is(MockFilePicker.displayDirectory.path, tmpDir.path, "file picker should start with browser.download.lastDir");
|
||||
// browser.download.lastDir should be modified before entering the private browsing mode
|
||||
is(prefs.getComplexValue("lastDir", Ci.nsIFile).path, dir1.path, "LastDir should be modified before entering PB mode");
|
||||
// gDownloadLastDir should be usable outside of the private browsing mode
|
||||
is(gDownloadLastDir.file.path, dir1.path, "gDownloadLastDir should be usable outside of the PB mode");
|
||||
|
||||
pb.privateBrowsingEnabled = true;
|
||||
is(prefs.getComplexValue("lastDir", Ci.nsIFile).path, dir1.path, "LastDir should be that set before PB mode");
|
||||
MockFilePicker.returnFiles = [file2];
|
||||
MockFilePicker.displayDirectory = null;
|
||||
ok(getTargetFile(params), "Show the file picker dialog with the given params");
|
||||
// file picker should start with browser.download.lastDir as set before entering the private browsing mode
|
||||
is(MockFilePicker.displayDirectory.path, dir1.path, "File picker should start with LastDir set before entering PB mode");
|
||||
// browser.download.lastDir should not be modified inside the private browsing mode
|
||||
is(prefs.getComplexValue("lastDir", Ci.nsIFile).path, dir1.path, "LastDir should not be modified inside PB mode");
|
||||
// but gDownloadLastDir should be modified
|
||||
is(gDownloadLastDir.file.path, dir2.path, "gDownloadLastDir should be modified");
|
||||
|
||||
pb.privateBrowsingEnabled = false;
|
||||
// gDownloadLastDir should be cleared after leaving the private browsing mode
|
||||
is(gDownloadLastDir.file.path, dir1.path, "gDownloadLastDir should be cleared after leaving PB mode");
|
||||
MockFilePicker.returnFiles = [file3];
|
||||
MockFilePicker.displayDirectory = null;
|
||||
ok(getTargetFile(params), "Show the file picker dialog with the given params");
|
||||
// file picker should start with browser.download.lastDir as set before entering the private browsing mode
|
||||
is(MockFilePicker.displayDirectory.path, dir1.path, "File picker should start with LastDir set before PB mode");
|
||||
// browser.download.lastDir should be modified after leaving the private browsing mode
|
||||
is(prefs.getComplexValue("lastDir", Ci.nsIFile).path, dir3.path, "LastDir should be modified after leaving PB mode");
|
||||
// gDownloadLastDir should be usable after leaving the private browsing mode
|
||||
is(gDownloadLastDir.file.path, dir3.path, "gDownloadLastDir should be usable after leaving PB mode");
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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 test() {
|
||||
var tmpScope = {};
|
||||
let downloadModule = {};
|
||||
Cu.import("resource://gre/modules/DownloadLastDir.jsm", downloadModule);
|
||||
Cu.import("resource://gre/modules/FileUtils.jsm", tmpScope);
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
let FileUtils = tmpScope.FileUtils;
|
||||
let gDownloadLastDir = new downloadModule.DownloadLastDir(window);
|
||||
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
|
||||
function clearHistory() {
|
||||
// simulate clearing the private data
|
||||
Services.obs.notifyObservers(null, "browser:purge-session-history", "");
|
||||
}
|
||||
|
||||
is(typeof gDownloadLastDir, "object", "gDownloadLastDir should be a valid object");
|
||||
is(gDownloadLastDir.file, null, "gDownloadLastDir.file should be null to start with");
|
||||
let tmpDir = FileUtils.getDir("TmpD", [], true);
|
||||
let newDir = tmpDir.clone();
|
||||
|
||||
registerCleanupFunction(function () {
|
||||
Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
Services.prefs.clearUserPref("browser.download.lastDir");
|
||||
newDir.remove(true);
|
||||
gDownloadLastDir.cleanupPrivateFile();
|
||||
delete FileUtils;
|
||||
});
|
||||
|
||||
newDir.append("testdir");
|
||||
newDir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0700);
|
||||
|
||||
gDownloadLastDir.file = tmpDir;
|
||||
is(gDownloadLastDir.file.path, tmpDir.path, "LastDir should point to the temporary directory");
|
||||
isnot(gDownloadLastDir.file, tmpDir, "gDownloadLastDir.file should not be pointing to the tmpDir");
|
||||
|
||||
gDownloadLastDir.file = 1; // not an nsIFile
|
||||
is(gDownloadLastDir.file, null, "gDownloadLastDir.file should be null");
|
||||
gDownloadLastDir.file = tmpDir;
|
||||
|
||||
clearHistory();
|
||||
is(gDownloadLastDir.file, null, "gDownloadLastDir.file should be null");
|
||||
gDownloadLastDir.file = tmpDir;
|
||||
|
||||
Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
||||
|
||||
pb.privateBrowsingEnabled = true;
|
||||
is(gDownloadLastDir.file.path, tmpDir.path, "LastDir should point to the temporary directory");
|
||||
isnot(gDownloadLastDir.file, tmpDir, "gDownloadLastDir.file should not be pointing to the tmpDir");
|
||||
|
||||
pb.privateBrowsingEnabled = false;
|
||||
is(gDownloadLastDir.file.path, tmpDir.path, "LastDir should point to the tmpDir");
|
||||
pb.privateBrowsingEnabled = true;
|
||||
|
||||
gDownloadLastDir.file = newDir;
|
||||
is(gDownloadLastDir.file.path, newDir.path, "gDownloadLastDir should be modified in PB mode");
|
||||
isnot(gDownloadLastDir.file, newDir, "gDownloadLastDir should not point to the newDir");
|
||||
|
||||
pb.privateBrowsingEnabled = false;
|
||||
is(gDownloadLastDir.file.path, tmpDir.path, "gDownloadLastDir should point to the earlier directory outside PB mode");
|
||||
isnot(gDownloadLastDir.file, tmpDir, "gDownloadLastDir should not be modifief outside PB mode");
|
||||
|
||||
pb.privateBrowsingEnabled = true;
|
||||
isnot(gDownloadLastDir.file, null, "gDownloadLastDir should not be null inside PB mode");
|
||||
clearHistory();
|
||||
is(gDownloadLastDir.file, null, "gDownloadLastDir should be null after clearing history");
|
||||
|
||||
pb.privateBrowsingEnabled = false;
|
||||
is(gDownloadLastDir.file, null, "gDownloadLastDir should be null outside PB mode");
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
// This test makes sure that the geolocation prompt does not show a remember
|
||||
// control inside the private browsing mode.
|
||||
|
||||
function test() {
|
||||
// initialization
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
|
||||
const testPageURL = "http://mochi.test:8888/browser/" +
|
||||
"browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_geoprompt_page.html";
|
||||
waitForExplicitFinish();
|
||||
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
let notification = PopupNotifications.getNotification("geolocation");
|
||||
ok(notification, "Notification should exist");
|
||||
ok(notification.secondaryActions.length > 1, "Secondary actions should exist (always/never remember)");
|
||||
notification.remove();
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
|
||||
// enter the private browsing mode
|
||||
pb.privateBrowsingEnabled = true;
|
||||
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
// Make sure the notification is correctly displayed without a remember control
|
||||
let notification = PopupNotifications.getNotification("geolocation");
|
||||
ok(notification, "Notification should exist");
|
||||
is(notification.secondaryActions.length, 0, "Secondary actions shouldn't exist (always/never remember)");
|
||||
notification.remove();
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
|
||||
// cleanup
|
||||
pb.privateBrowsingEnabled = false;
|
||||
finish();
|
||||
}, true);
|
||||
content.location = testPageURL;
|
||||
}, true);
|
||||
content.location = testPageURL;
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Geolocation invoker</title>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
navigator.geolocation.getCurrentPosition(function (pos) {
|
||||
// ignore
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,26 +0,0 @@
|
||||
/* 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 test() {
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
waitForExplicitFinish();
|
||||
pb.privateBrowsingEnabled = true;
|
||||
let tab = gBrowser.selectedTab = gBrowser.addTab();
|
||||
let browser = gBrowser.selectedBrowser;
|
||||
browser.addEventListener('load', function() {
|
||||
browser.removeEventListener('load', arguments.callee, true);
|
||||
let tab2 = gBrowser.selectedTab = gBrowser.addTab();
|
||||
browser.contentWindow.location = 'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/global/' +
|
||||
'browser_privatebrowsing_localStorage_page2.html';
|
||||
browser.addEventListener('load', function() {
|
||||
browser.removeEventListener('load', arguments.callee, true);
|
||||
is(browser.contentWindow.document.title, '2', "localStorage should contain 2 items");
|
||||
pb.privateBrowsingEnabled = false;
|
||||
finish();
|
||||
}, true);
|
||||
}, true);
|
||||
browser.loadURI('http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/global/' +
|
||||
'browser_privatebrowsing_localStorage_page1.html');
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
// Ensure that a storage instance used by both private and public sessions at different times does not
|
||||
// allow any data to leak due to cached values.
|
||||
|
||||
// Step 1: Load browser_privatebrowsing_localStorage_before_after_page.html in a private tab, causing a storage
|
||||
// item to exist. Close the tab.
|
||||
// Step 2: Load the same page in a non-private tab, ensuring that the storage instance reports only one item
|
||||
// existing.
|
||||
|
||||
function test() {
|
||||
let prefix = 'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/global/';
|
||||
waitForExplicitFinish();
|
||||
|
||||
// We wait for a GC to ensure that all previous PB docshells in this test suite are destroyed
|
||||
// so that the PB localStorage instance is clean.
|
||||
Components.utils.schedulePreciseGC(function() {
|
||||
let tab = gBrowser.selectedTab = gBrowser.addTab();
|
||||
let browser = gBrowser.selectedBrowser;
|
||||
browser.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = true;
|
||||
browser.addEventListener('load', function() {
|
||||
browser.removeEventListener('load', arguments.callee, true);
|
||||
is(browser.contentWindow.document.title, '1', "localStorage should contain 1 item");
|
||||
browser.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = false;
|
||||
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
let browser2 = gBrowser.selectedBrowser;
|
||||
gBrowser.removeTab(tab);
|
||||
browser2.addEventListener('load', function() {
|
||||
browser2.removeEventListener('load', arguments.callee, true);
|
||||
is(browser2.contentWindow.document.title, 'null|0', 'localStorage should contain 0 items');
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
}, true);
|
||||
browser2.loadURI(prefix + 'browser_privatebrowsing_localStorage_before_after_page2.html');
|
||||
}, true);
|
||||
browser.loadURI(prefix + 'browser_privatebrowsing_localStorage_before_after_page.html');
|
||||
});
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<script type="text/javascript">
|
||||
localStorage.clear();
|
||||
localStorage.setItem('zzztest', 'zzzvalue');
|
||||
document.title = localStorage.length;
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@ -1,10 +0,0 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<script type="text/javascript">
|
||||
document.title = localStorage.getItem('zzztest', 'zzzvalue') + '|' + localStorage.length;
|
||||
localStorage.clear();
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@ -1,10 +0,0 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<script type="text/javascript">
|
||||
localStorage.clear();
|
||||
localStorage.setItem('test1', 'value1');
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@ -1,10 +0,0 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<script type="text/javascript">
|
||||
localStorage.setItem('test2', 'value2');
|
||||
document.title = localStorage.length;
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@ -1,63 +0,0 @@
|
||||
/* 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 test() {
|
||||
const URL_1 = "mozilla.org";
|
||||
const URL_2 = "mozilla.com";
|
||||
|
||||
let openLocationLastURL = getLocationModule();
|
||||
let privateBrowsingService =
|
||||
Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
|
||||
function clearHistory() {
|
||||
Services.obs.notifyObservers(null, "browser:purge-session-history", "");
|
||||
}
|
||||
function testURL(aTestNumber, aValue) {
|
||||
is(openLocationLastURL.value, aValue,
|
||||
"Test: " + aTestNumber + ": Validate last url value.");
|
||||
}
|
||||
|
||||
// Clean to start testing.
|
||||
is(typeof openLocationLastURL, "object", "Validate type of last url.");
|
||||
openLocationLastURL.reset();
|
||||
testURL(1, "");
|
||||
|
||||
// Test without private browsing.
|
||||
openLocationLastURL.value = URL_1;
|
||||
testURL(2, URL_1);
|
||||
openLocationLastURL.value = "";
|
||||
testURL(3, "");
|
||||
openLocationLastURL.value = URL_2;
|
||||
testURL(4, URL_2);
|
||||
clearHistory();
|
||||
testURL(5, "");
|
||||
|
||||
// Test changing private browsing.
|
||||
openLocationLastURL.value = URL_2;
|
||||
privateBrowsingService.privateBrowsingEnabled = true;
|
||||
testURL(6, "");
|
||||
privateBrowsingService.privateBrowsingEnabled = false;
|
||||
testURL(7, URL_2);
|
||||
privateBrowsingService.privateBrowsingEnabled = true;
|
||||
openLocationLastURL.value = URL_1;
|
||||
testURL(8, URL_1);
|
||||
privateBrowsingService.privateBrowsingEnabled = false;
|
||||
testURL(9, URL_2);
|
||||
privateBrowsingService.privateBrowsingEnabled = true;
|
||||
openLocationLastURL.value = URL_1;
|
||||
testURL(10, URL_1);
|
||||
|
||||
// Test cleaning history.
|
||||
clearHistory();
|
||||
testURL(11, "");
|
||||
privateBrowsingService.privateBrowsingEnabled = false;
|
||||
testURL(12, "");
|
||||
}
|
||||
|
||||
function getLocationModule() {
|
||||
let openLocationModule = {};
|
||||
Cu.import("resource:///modules/openLocationLastURL.jsm", openLocationModule);
|
||||
return new openLocationModule.OpenLocationLastURL(window);
|
||||
}
|
@ -1,109 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
// This test makes sure that the last open directory used inside the private
|
||||
// browsing mode is not remembered after leaving that mode.
|
||||
|
||||
function test() {
|
||||
// initialization
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
let ds = Cc["@mozilla.org/file/directory_service;1"].
|
||||
getService(Ci.nsIProperties);
|
||||
let dir1 = ds.get("ProfD", Ci.nsIFile);
|
||||
let dir2 = ds.get("TmpD", Ci.nsIFile);
|
||||
let file = dir2.clone();
|
||||
file.append("pbtest.file");
|
||||
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0600);
|
||||
|
||||
const kPrefName = "browser.open.lastDir";
|
||||
|
||||
function setupCleanSlate() {
|
||||
gLastOpenDirectory.reset();
|
||||
gPrefService.clearUserPref(kPrefName);
|
||||
}
|
||||
|
||||
setupCleanSlate();
|
||||
|
||||
// Test 1: general workflow test
|
||||
|
||||
// initial checks
|
||||
ok(!gLastOpenDirectory.path,
|
||||
"Last open directory path should be initially empty");
|
||||
gLastOpenDirectory.path = dir2;
|
||||
is(gLastOpenDirectory.path.path, dir2.path,
|
||||
"The path should be successfully set");
|
||||
gLastOpenDirectory.path = null;
|
||||
is(gLastOpenDirectory.path.path, dir2.path,
|
||||
"The path should be not change when assigning it to null");
|
||||
gLastOpenDirectory.path = dir1;
|
||||
is(gLastOpenDirectory.path.path, dir1.path,
|
||||
"The path should be successfully outside of the private browsing mode");
|
||||
|
||||
// enter private browsing mode
|
||||
pb.privateBrowsingEnabled = true;
|
||||
|
||||
is(gLastOpenDirectory.path.path, dir1.path,
|
||||
"The path should not change when entering the private browsing mode");
|
||||
gLastOpenDirectory.path = dir2;
|
||||
is(gLastOpenDirectory.path.path, dir2.path,
|
||||
"The path should successfully change inside the private browsing mode");
|
||||
|
||||
// leave private browsing mode
|
||||
pb.privateBrowsingEnabled = false;
|
||||
|
||||
is(gLastOpenDirectory.path.path, dir1.path,
|
||||
"The path should be reset to the same path as before entering the private browsing mode");
|
||||
|
||||
setupCleanSlate();
|
||||
|
||||
// Test 2: the user first tries to open a file inside the private browsing mode
|
||||
|
||||
pb.privateBrowsingEnabled = true;
|
||||
ok(!gLastOpenDirectory.path,
|
||||
"No original path should exist inside the private browsing mode");
|
||||
gLastOpenDirectory.path = dir1;
|
||||
is(gLastOpenDirectory.path.path, dir1.path,
|
||||
"The path should be successfully set inside the private browsing mode");
|
||||
pb.privateBrowsingEnabled = false;
|
||||
ok(!gLastOpenDirectory.path,
|
||||
"The path set inside the private browsing mode should not leak when leaving that mode");
|
||||
|
||||
setupCleanSlate();
|
||||
|
||||
// Test 3: the last open directory is set from a previous session, it should be used
|
||||
// in normal mode
|
||||
|
||||
gPrefService.setComplexValue(kPrefName, Ci.nsILocalFile, dir1);
|
||||
is(gLastOpenDirectory.path.path, dir1.path,
|
||||
"The pref set from last session should take effect outside the private browsing mode");
|
||||
|
||||
setupCleanSlate();
|
||||
|
||||
// Test 4: the last open directory is set from a previous session, it should be used
|
||||
// in private browsing mode mode
|
||||
|
||||
gPrefService.setComplexValue(kPrefName, Ci.nsILocalFile, dir1);
|
||||
pb.privateBrowsingEnabled = true;
|
||||
is(gLastOpenDirectory.path.path, dir1.path,
|
||||
"The pref set from last session should take effect inside the private browsing mode");
|
||||
pb.privateBrowsingEnabled = false;
|
||||
is(gLastOpenDirectory.path.path, dir1.path,
|
||||
"The pref set from last session should remain in effect after leaving the private browsing mode");
|
||||
|
||||
setupCleanSlate();
|
||||
|
||||
// Test 5: setting the path to a file shouldn't work
|
||||
|
||||
gLastOpenDirectory.path = file;
|
||||
ok(!gLastOpenDirectory.path,
|
||||
"Setting the path to a file shouldn't work when it's originally null");
|
||||
gLastOpenDirectory.path = dir1;
|
||||
gLastOpenDirectory.path = file;
|
||||
is(gLastOpenDirectory.path.path, dir1.path,
|
||||
"Setting the path to a file shouldn't work when it's not originally null");
|
||||
|
||||
// cleanup
|
||||
file.remove(false);
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
// This test makes sure that Open Location dialog is usable inside the private browsing
|
||||
// mode without leaving any trace of the URLs visited.
|
||||
|
||||
function test() {
|
||||
// initialization
|
||||
gPrefService.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
waitForExplicitFinish();
|
||||
|
||||
function openLocation(url, autofilled, callback) {
|
||||
function observer(aSubject, aTopic, aData) {
|
||||
switch (aTopic) {
|
||||
case "domwindowopened":
|
||||
let dialog = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
dialog.addEventListener("load", function () {
|
||||
dialog.removeEventListener("load", arguments.callee, false);
|
||||
|
||||
let browser = gBrowser.selectedBrowser;
|
||||
browser.addEventListener("load", function() {
|
||||
browser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
is(browser.currentURI.spec, url,
|
||||
"The correct URL should be loaded via the open location dialog");
|
||||
executeSoon(callback);
|
||||
}, true);
|
||||
|
||||
SimpleTest.waitForFocus(function() {
|
||||
let input = dialog.document.getElementById("dialog.input");
|
||||
is(input.value, autofilled, "The input field should be correctly auto-filled");
|
||||
input.focus();
|
||||
for (let i = 0; i < url.length; ++i)
|
||||
EventUtils.synthesizeKey(url[i], {}, dialog);
|
||||
EventUtils.synthesizeKey("VK_RETURN", {}, dialog);
|
||||
}, dialog);
|
||||
}, false);
|
||||
break;
|
||||
|
||||
case "domwindowclosed":
|
||||
Services.ww.unregisterNotification(arguments.callee);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Services.ww.registerNotification(observer);
|
||||
gPrefService.setIntPref("general.open_location.last_window_choice", 0);
|
||||
openDialog("chrome://browser/content/openLocation.xul", "_blank",
|
||||
"chrome,titlebar", window);
|
||||
}
|
||||
|
||||
|
||||
if (gPrefService.prefHasUserValue("general.open_location.last_url"))
|
||||
gPrefService.clearUserPref("general.open_location.last_url");
|
||||
|
||||
openLocation("http://example.com/", "", function() {
|
||||
openLocation("http://example.org/", "http://example.com/", function() {
|
||||
// enter private browsing mode
|
||||
pb.privateBrowsingEnabled = true;
|
||||
openLocation("about:logo", "", function() {
|
||||
openLocation("about:buildconfig", "about:logo", function() {
|
||||
// exit private browsing mode
|
||||
pb.privateBrowsingEnabled = false;
|
||||
openLocation("about:blank", "http://example.org/", function() {
|
||||
gPrefService.clearUserPref("general.open_location.last_url");
|
||||
if (gPrefService.prefHasUserValue("general.open_location.last_window_choice"))
|
||||
gPrefService.clearUserPref("general.open_location.last_window_choice");
|
||||
gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
finish();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
// This test makes sure that the title of existing history entries does not
|
||||
// change inside the private browsing mode.
|
||||
|
||||
function test() {
|
||||
// initialization
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
let cm = Cc["@mozilla.org/cookiemanager;1"].
|
||||
getService(Ci.nsICookieManager);
|
||||
waitForExplicitFinish();
|
||||
ignoreAllUncaughtExceptions();
|
||||
|
||||
const TEST_URL = "http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/global/title.sjs";
|
||||
|
||||
function waitForCleanup(aCallback) {
|
||||
// delete all cookies
|
||||
cm.removeAll();
|
||||
// delete all history items
|
||||
waitForClearHistory(aCallback);
|
||||
}
|
||||
|
||||
let observer = {
|
||||
pass: 1,
|
||||
onTitleChanged: function(aURI, aPageTitle) {
|
||||
if (aURI.spec != TEST_URL)
|
||||
return;
|
||||
switch (this.pass++) {
|
||||
case 1: // the first time that the page is loaded
|
||||
is(aPageTitle, "No Cookie", "The page should be loaded without any cookie for the first time");
|
||||
gBrowser.selectedTab = gBrowser.addTab(TEST_URL);
|
||||
break;
|
||||
case 2: // the second time that the page is loaded
|
||||
is(aPageTitle, "Cookie", "The page should be loaded with a cookie for the second time");
|
||||
waitForCleanup(function () {
|
||||
gBrowser.selectedTab = gBrowser.addTab(TEST_URL);
|
||||
});
|
||||
break;
|
||||
case 3: // before entering the private browsing mode
|
||||
is(aPageTitle, "No Cookie", "The page should be loaded without any cookie again");
|
||||
// enter private browsing mode
|
||||
pb.privateBrowsingEnabled = true;
|
||||
gBrowser.selectedTab = gBrowser.addTab(TEST_URL);
|
||||
executeSoon(function() {
|
||||
PlacesUtils.history.removeObserver(observer);
|
||||
pb.privateBrowsingEnabled = false;
|
||||
while (gBrowser.browsers.length > 1) {
|
||||
gBrowser.removeCurrentTab();
|
||||
}
|
||||
waitForCleanup(finish);
|
||||
});
|
||||
break;
|
||||
default:
|
||||
ok(false, "Unexpected pass: " + (this.pass - 1));
|
||||
}
|
||||
},
|
||||
|
||||
onBeginUpdateBatch: function () {},
|
||||
onEndUpdateBatch: function () {},
|
||||
onVisit: function () {},
|
||||
onBeforeDeleteURI: function () {},
|
||||
onDeleteURI: function () {},
|
||||
onClearHistory: function () {},
|
||||
onPageChanged: function () {},
|
||||
onDeleteVisits: function() {},
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsINavHistoryObserver])
|
||||
};
|
||||
PlacesUtils.history.addObserver(observer, false);
|
||||
|
||||
waitForCleanup(function () {
|
||||
gBrowser.selectedTab = gBrowser.addTab(TEST_URL);
|
||||
});
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
// This test makes sure that private browsing mode disables the remember option
|
||||
// for the popup blocker menu.
|
||||
|
||||
function test() {
|
||||
// initialization
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
|
||||
let oldPopupPolicy = gPrefService.getBoolPref("dom.disable_open_during_load");
|
||||
gPrefService.setBoolPref("dom.disable_open_during_load", true);
|
||||
|
||||
const TEST_URI = "http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/global/popup.html";
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
function testPopupBlockerMenuItem(expectedDisabled, callback) {
|
||||
gBrowser.addEventListener("DOMUpdatePageReport", function() {
|
||||
gBrowser.removeEventListener("DOMUpdatePageReport", arguments.callee, false);
|
||||
executeSoon(function() {
|
||||
let notification = gBrowser.getNotificationBox().getNotificationWithValue("popup-blocked");
|
||||
|
||||
ok(notification, "The notification box should be displayed");
|
||||
|
||||
function checkMenuItem(callback) {
|
||||
dump("CMI: in\n");
|
||||
document.addEventListener("popupshown", function(event) {
|
||||
dump("CMI: popupshown\n");
|
||||
document.removeEventListener("popupshown", arguments.callee, false);
|
||||
|
||||
if (expectedDisabled)
|
||||
is(document.getElementById("blockedPopupAllowSite").getAttribute("disabled"), "true",
|
||||
"The allow popups menu item should be disabled");
|
||||
|
||||
event.originalTarget.hidePopup();
|
||||
dump("CMI: calling back\n");
|
||||
callback();
|
||||
dump("CMI: called back\n");
|
||||
}, false);
|
||||
dump("CMI: out\n");
|
||||
}
|
||||
|
||||
checkMenuItem(function() {
|
||||
gBrowser.removeTab(tab);
|
||||
callback();
|
||||
});
|
||||
notification.querySelector("button").doCommand();
|
||||
});
|
||||
}, false);
|
||||
|
||||
let tab = gBrowser.addTab(TEST_URI);
|
||||
gBrowser.selectedTab = tab;
|
||||
}
|
||||
|
||||
testPopupBlockerMenuItem(false, function() {
|
||||
pb.privateBrowsingEnabled = true;
|
||||
testPopupBlockerMenuItem(true, function() {
|
||||
pb.privateBrowsingEnabled = false;
|
||||
testPopupBlockerMenuItem(false, function() {
|
||||
gPrefService.setBoolPref("dom.disable_open_during_load", oldPopupPolicy);
|
||||
finish();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
// This test makes sure that the web pages can't register protocol handlers
|
||||
// inside the private browsing mode.
|
||||
|
||||
function test() {
|
||||
// initialization
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
|
||||
const testPageURL = "http://example.com/browser/" +
|
||||
"browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_protocolhandler_page.html";
|
||||
waitForExplicitFinish();
|
||||
|
||||
const notificationValue = "Protocol Registration: testprotocol";
|
||||
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
setTimeout(function() {
|
||||
// Make sure the notification is correctly displayed with a remember control
|
||||
let notificationBox = gBrowser.getNotificationBox();
|
||||
let notification = notificationBox.getNotificationWithValue(notificationValue);
|
||||
ok(notification, "Notification box should be displaying outside of private browsing mode");
|
||||
gBrowser.removeCurrentTab();
|
||||
|
||||
// enter the private browsing mode
|
||||
pb.privateBrowsingEnabled = true;
|
||||
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
gBrowser.selectedBrowser.addEventListener("load", function () {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
setTimeout(function () {
|
||||
// Make sure the notification is correctly displayed without a remember control
|
||||
let notificationBox = gBrowser.getNotificationBox();
|
||||
let notification = notificationBox.getNotificationWithValue(notificationValue);
|
||||
ok(!notification, "Notification box should not be displayed inside of private browsing mode");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
|
||||
// cleanup
|
||||
pb.privateBrowsingEnabled = false;
|
||||
finish();
|
||||
}, 100); // remember control is added in a setTimeout(0) call
|
||||
}, true);
|
||||
content.location = testPageURL;
|
||||
}, 100); // remember control is added in a setTimeout(0) call
|
||||
}, true);
|
||||
content.location = testPageURL;
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Protocol registrar page</title>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
navigator.registerProtocolHandler("testprotocol",
|
||||
"https://example.com/foobar?uri=%s",
|
||||
"Test Protocol");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,32 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
// This test makes sure that privatebrowsingmode attribute of the window is correctly
|
||||
// switched with private browsing mode changes.
|
||||
|
||||
function test() {
|
||||
// initialization
|
||||
gPrefService.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
let docRoot = document.documentElement;
|
||||
|
||||
ok(!docRoot.hasAttribute("privatebrowsingmode"),
|
||||
"privatebrowsingmode should not be present in normal mode");
|
||||
|
||||
// enter private browsing mode
|
||||
pb.privateBrowsingEnabled = true;
|
||||
|
||||
is(docRoot.getAttribute("privatebrowsingmode"), "temporary",
|
||||
"privatebrowsingmode should be \"temporary\" inside the private browsing mode");
|
||||
|
||||
// leave private browsing mode
|
||||
pb.privateBrowsingEnabled = false;
|
||||
|
||||
ok(!docRoot.hasAttribute("privatebrowsingmode"),
|
||||
"privatebrowsingmode should not be present in normal mode");
|
||||
|
||||
// cleanup
|
||||
gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
}
|
@ -1,102 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
// This test makes sure that the gPrivateBrowsingUI object, the Private Browsing
|
||||
// menu item and its XUL <command> element work correctly.
|
||||
|
||||
function test() {
|
||||
// initialization
|
||||
waitForExplicitFinish();
|
||||
gPrefService.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
let observerData;
|
||||
function observer(aSubject, aTopic, aData) {
|
||||
if (aTopic == "private-browsing")
|
||||
observerData = aData;
|
||||
}
|
||||
Services.obs.addObserver(observer, "private-browsing", false);
|
||||
let pbMenuItem = document.getElementById("privateBrowsingItem");
|
||||
// add a new blank tab to ensure the title can be meaningfully compared later
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
let originalTitle = document.title;
|
||||
|
||||
function testNewWindow(aCallback, expected) {
|
||||
Services.obs.addObserver(function observer1(aSubject, aTopic, aData) {
|
||||
aSubject.addEventListener("load", function() {
|
||||
aSubject.removeEventListener("load", arguments.callee);
|
||||
executeSoon(function() {
|
||||
let ui = aSubject.gPrivateBrowsingUI;
|
||||
is(ui.privateBrowsingEnabled, expected, "The privateBrowsingEnabled property on the new window is set correctly");
|
||||
is(PrivateBrowsingUtils.isWindowPrivate(aSubject), expected, "The private bit on the new window is set correctly");
|
||||
|
||||
Services.obs.addObserver(function observer2(aSubject, aTopic, aData) {
|
||||
aCallback();
|
||||
Services.obs.removeObserver(observer2, "domwindowclosed");
|
||||
}, "domwindowclosed", false);
|
||||
aSubject.close();
|
||||
});
|
||||
Services.obs.removeObserver(observer1, "domwindowopened");
|
||||
}, false);
|
||||
}, "domwindowopened", false);
|
||||
OpenBrowserWindow({private: PrivateBrowsingUtils.isWindowPrivate(window)});
|
||||
}
|
||||
|
||||
// test the gPrivateBrowsingUI object
|
||||
ok(gPrivateBrowsingUI, "The gPrivateBrowsingUI object exists");
|
||||
is(pb.privateBrowsingEnabled, false, "The private browsing mode should not be started initially");
|
||||
is(gPrivateBrowsingUI.privateBrowsingEnabled, false, "gPrivateBrowsingUI should expose the correct private browsing status");
|
||||
is(PrivateBrowsingUtils.isWindowPrivate(window), false, "PrivateBrowsingUtils should expose the correct per-window private browsing status");
|
||||
ok(pbMenuItem, "The Private Browsing menu item exists");
|
||||
is(pbMenuItem.getAttribute("label"), pbMenuItem.getAttribute("startlabel"), "The Private Browsing menu item should read \"Start Private Browsing\"");
|
||||
testNewWindow(function() {
|
||||
gPrivateBrowsingUI.toggleMode();
|
||||
is(pb.privateBrowsingEnabled, true, "The private browsing mode should be started");
|
||||
is(gPrivateBrowsingUI.privateBrowsingEnabled, true, "gPrivateBrowsingUI should expose the correct private browsing status");
|
||||
is(PrivateBrowsingUtils.isWindowPrivate(window), true, "PrivateBrowsingUtils should expose the correct per-window private browsing status");
|
||||
// check to see if the Private Browsing mode was activated successfully
|
||||
is(observerData, "enter", "Private Browsing mode was activated using the gPrivateBrowsingUI object");
|
||||
is(pbMenuItem.getAttribute("label"), pbMenuItem.getAttribute("stoplabel"), "The Private Browsing menu item should read \"Stop Private Browsing\"");
|
||||
testNewWindow(function() {
|
||||
gPrivateBrowsingUI.toggleMode()
|
||||
is(pb.privateBrowsingEnabled, false, "The private browsing mode should not be started");
|
||||
is(gPrivateBrowsingUI.privateBrowsingEnabled, false, "gPrivateBrowsingUI should expose the correct private browsing status");
|
||||
is(PrivateBrowsingUtils.isWindowPrivate(window), false, "PrivateBrowsingUtils should expose the correct per-window private browsing status");
|
||||
// check to see if the Private Browsing mode was deactivated successfully
|
||||
is(observerData, "exit", "Private Browsing mode was deactivated using the gPrivateBrowsingUI object");
|
||||
is(pbMenuItem.getAttribute("label"), pbMenuItem.getAttribute("startlabel"), "The Private Browsing menu item should read \"Start Private Browsing\"");
|
||||
|
||||
testNewWindow(function() {
|
||||
// These are tests for the private bit setter. Note that the setter should
|
||||
// not be used anywhere else for now!
|
||||
setPrivateWindow(window, true);
|
||||
is(PrivateBrowsingUtils.isWindowPrivate(window), true, "PrivateBrowsingUtils should accept the correct per-window private browsing status");
|
||||
setPrivateWindow(window, false);
|
||||
is(PrivateBrowsingUtils.isWindowPrivate(window), false, "PrivateBrowsingUtils should accept the correct per-window private browsing status");
|
||||
|
||||
// now, test using the <command> object
|
||||
let cmd = document.getElementById("Tools:PrivateBrowsing");
|
||||
isnot(cmd, null, "XUL command object for the private browsing service exists");
|
||||
var func = new Function("", cmd.getAttribute("oncommand"));
|
||||
func.call(cmd);
|
||||
// check to see if the Private Browsing mode was activated successfully
|
||||
is(observerData, "enter", "Private Browsing mode was activated using the command object");
|
||||
// check to see that the window title has been changed correctly
|
||||
isnot(document.title, originalTitle, "Private browsing mode has correctly changed the title");
|
||||
func.call(cmd);
|
||||
// check to see if the Private Browsing mode was deactivated successfully
|
||||
is(observerData, "exit", "Private Browsing mode was deactivated using the command object");
|
||||
// check to see that the window title has been restored correctly
|
||||
is(document.title, originalTitle, "Private browsing mode has correctly restored the title");
|
||||
|
||||
// cleanup
|
||||
gBrowser.removeCurrentTab();
|
||||
Services.obs.removeObserver(observer, "private-browsing");
|
||||
gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
|
||||
finish();
|
||||
}, false);
|
||||
}, true);
|
||||
}, false);
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
// This test makes sure that the URL bar is focused when entering the private browsing mode.
|
||||
|
||||
function test() {
|
||||
// initialization
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
|
||||
const TEST_URL = "data:text/plain,test";
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
let browser = gBrowser.selectedBrowser;
|
||||
browser.addEventListener("load", function() {
|
||||
browser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
// ensure that the URL bar is not focused initially
|
||||
browser.focus();
|
||||
isnot(document.commandDispatcher.focusedElement, gURLBar.inputField,
|
||||
"URL Bar should not be focused before entering the private browsing mode");
|
||||
// ensure that the URL bar is not empty initially
|
||||
isnot(gURLBar.value, "", "URL Bar should no longer be empty after leaving the private browsing mode");
|
||||
|
||||
// enter private browsing mode
|
||||
pb.privateBrowsingEnabled = true;
|
||||
browser = gBrowser.selectedBrowser;
|
||||
browser.addEventListener("load", function() {
|
||||
browser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
// setTimeout is needed here because the onload handler of about:privatebrowsing sets the focus
|
||||
setTimeout(function() {
|
||||
// ensure that the URL bar is focused inside the private browsing mode
|
||||
is(document.commandDispatcher.focusedElement, gURLBar.inputField,
|
||||
"URL Bar should be focused inside the private browsing mode");
|
||||
|
||||
// ensure that the URL bar is emptied inside the private browsing mode
|
||||
is(gURLBar.value, "", "URL Bar should be empty inside the private browsing mode");
|
||||
|
||||
// leave private browsing mode
|
||||
pb.privateBrowsingEnabled = false;
|
||||
browser = gBrowser.selectedBrowser;
|
||||
browser.addEventListener("load", function() {
|
||||
browser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
// ensure that the URL bar is no longer focused after leaving the private browsing mode
|
||||
isnot(document.commandDispatcher.focusedElement, gURLBar.inputField,
|
||||
"URL Bar should no longer be focused after leaving the private browsing mode");
|
||||
|
||||
// ensure that the URL bar is no longer empty after leaving the private browsing mode
|
||||
isnot(gURLBar.value, "", "URL Bar should no longer be empty after leaving the private browsing mode");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
}, true);
|
||||
}, 0);
|
||||
}, true);
|
||||
}, true);
|
||||
content.location = TEST_URL;
|
||||
|
||||
waitForExplicitFinish();
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
// This test makes sure that the window title changes correctly while switching
|
||||
// from and to private browsing mode.
|
||||
|
||||
function test() {
|
||||
// initialization
|
||||
gPrefService.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
|
||||
const testPageURL = "http://mochi.test:8888/browser/" +
|
||||
"browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_windowtitle_page.html";
|
||||
waitForExplicitFinish();
|
||||
requestLongerTimeout(2);
|
||||
|
||||
// initialization of expected titles
|
||||
let test_title = "Test title";
|
||||
let app_name = document.documentElement.getAttribute("title");
|
||||
const isOSX = ("nsILocalFileMac" in Ci);
|
||||
let page_with_title;
|
||||
let page_without_title;
|
||||
let about_pb_title;
|
||||
let pb_page_with_title;
|
||||
let pb_page_without_title;
|
||||
let pb_about_pb_title;
|
||||
if (isOSX) {
|
||||
page_with_title = test_title;
|
||||
page_without_title = app_name;
|
||||
about_pb_title = "Would you like to start Private Browsing?";
|
||||
pb_page_with_title = test_title + " - (Private Browsing)";
|
||||
pb_page_without_title = app_name + " - (Private Browsing)";
|
||||
pb_about_pb_title = pb_page_without_title;
|
||||
}
|
||||
else {
|
||||
page_with_title = test_title + " - " + app_name;
|
||||
page_without_title = app_name;
|
||||
about_pb_title = "Would you like to start Private Browsing?" + " - " + app_name;
|
||||
pb_page_with_title = test_title + " - " + app_name + " (Private Browsing)";
|
||||
pb_page_without_title = app_name + " (Private Browsing)";
|
||||
pb_about_pb_title = "Private Browsing - " + app_name + " (Private Browsing)";
|
||||
}
|
||||
|
||||
function testTabTitle(url, insidePB, expected_title, funcNext) {
|
||||
pb.privateBrowsingEnabled = insidePB;
|
||||
|
||||
let tab = gBrowser.selectedTab = gBrowser.addTab();
|
||||
let browser = gBrowser.selectedBrowser;
|
||||
browser.stop();
|
||||
// ensure that the test is run after the titlebar has been updated
|
||||
browser.addEventListener("pageshow", function () {
|
||||
browser.removeEventListener("pageshow", arguments.callee, false);
|
||||
executeSoon(function () {
|
||||
is(document.title, expected_title, "The window title for " + url +
|
||||
" is correct (" + (insidePB ? "inside" : "outside") +
|
||||
" private browsing mode)");
|
||||
|
||||
let win = gBrowser.replaceTabWithWindow(tab);
|
||||
win.addEventListener("load", function() {
|
||||
win.removeEventListener("load", arguments.callee, false);
|
||||
|
||||
executeSoon(function() {
|
||||
is(win.document.title, expected_title, "The window title for " + url +
|
||||
" detached tab is correct (" + (insidePB ? "inside" : "outside") +
|
||||
" private browsing mode)");
|
||||
win.close();
|
||||
|
||||
setTimeout(funcNext, 0);
|
||||
});
|
||||
}, false);
|
||||
});
|
||||
}, false);
|
||||
|
||||
browser.loadURI(url);
|
||||
}
|
||||
|
||||
function cleanup() {
|
||||
pb.privateBrowsingEnabled = false;
|
||||
gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
finish();
|
||||
}
|
||||
|
||||
testTabTitle("about:blank", false, page_without_title, function() {
|
||||
testTabTitle(testPageURL, false, page_with_title, function() {
|
||||
testTabTitle("about:privatebrowsing", false, about_pb_title, function() {
|
||||
testTabTitle("about:blank", true, pb_page_without_title, function() {
|
||||
testTabTitle(testPageURL, true, pb_page_with_title, function() {
|
||||
testTabTitle("about:privatebrowsing", true, pb_about_pb_title, cleanup);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Test title</title>
|
||||
</head>
|
||||
<body>
|
||||
Test page for the window title test
|
||||
</body>
|
||||
</html>
|
@ -1,62 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
// This test makes sure that private browsing turns off doesn't cause zoom
|
||||
// settings to be reset on tab switch (bug 464962)
|
||||
|
||||
function test() {
|
||||
// initialization
|
||||
gPrefService.setBoolPref("browser.privatebrowsing.keep_current_session", true);
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
|
||||
// enter private browsing mode
|
||||
pb.privateBrowsingEnabled = true;
|
||||
|
||||
let tabAbout = gBrowser.addTab();
|
||||
gBrowser.selectedTab = tabAbout;
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
let aboutBrowser = gBrowser.getBrowserForTab(tabAbout);
|
||||
aboutBrowser.addEventListener("load", function onAboutBrowserLoad() {
|
||||
aboutBrowser.removeEventListener("load", onAboutBrowserLoad, true);
|
||||
let tabMozilla = gBrowser.addTab();
|
||||
gBrowser.selectedTab = tabMozilla;
|
||||
|
||||
let mozillaBrowser = gBrowser.getBrowserForTab(tabMozilla);
|
||||
mozillaBrowser.addEventListener("load", function onMozillaBrowserLoad() {
|
||||
mozillaBrowser.removeEventListener("load", onMozillaBrowserLoad, true);
|
||||
let mozillaZoom = ZoomManager.zoom;
|
||||
|
||||
// change the zoom on the mozilla page
|
||||
FullZoom.enlarge();
|
||||
// make sure the zoom level has been changed
|
||||
isnot(ZoomManager.zoom, mozillaZoom, "Zoom level can be changed");
|
||||
mozillaZoom = ZoomManager.zoom;
|
||||
|
||||
// switch to about: tab
|
||||
gBrowser.selectedTab = tabAbout;
|
||||
|
||||
// switch back to mozilla tab
|
||||
gBrowser.selectedTab = tabMozilla;
|
||||
|
||||
// make sure the zoom level has not changed
|
||||
is(ZoomManager.zoom, mozillaZoom,
|
||||
"Entering private browsing should not reset the zoom on a tab");
|
||||
|
||||
// leave private browsing mode
|
||||
pb.privateBrowsingEnabled = false;
|
||||
|
||||
// cleanup
|
||||
gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
FullZoom.reset();
|
||||
gBrowser.removeTab(tabMozilla);
|
||||
gBrowser.removeTab(tabAbout);
|
||||
finish();
|
||||
}, true);
|
||||
mozillaBrowser.contentWindow.location = "about:mozilla";
|
||||
}, true);
|
||||
aboutBrowser.contentWindow.location = "about:";
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
// This test makes sure that about:privatebrowsing does not appear zoomed in
|
||||
// if there is already a zoom site pref for about:blank (bug 487656).
|
||||
|
||||
function test() {
|
||||
// initialization
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
waitForExplicitFinish();
|
||||
|
||||
let tabBlank = gBrowser.selectedTab;
|
||||
let blankBrowser = gBrowser.getBrowserForTab(tabBlank);
|
||||
blankBrowser.addEventListener("load", function() {
|
||||
blankBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
// change the zoom on the blank page
|
||||
FullZoom.enlarge();
|
||||
isnot(ZoomManager.zoom, 1, "Zoom level for about:blank should be changed");
|
||||
|
||||
// enter private browsing mode
|
||||
pb.privateBrowsingEnabled = true;
|
||||
let tabAboutPB = gBrowser.selectedTab;
|
||||
let browserAboutPB = gBrowser.getBrowserForTab(tabAboutPB);
|
||||
browserAboutPB.addEventListener("load", function() {
|
||||
browserAboutPB.removeEventListener("load", arguments.callee, true);
|
||||
setTimeout(function() {
|
||||
// make sure the zoom level is set to 1
|
||||
is(ZoomManager.zoom, 1, "Zoom level for about:privatebrowsing should be reset");
|
||||
finishTest();
|
||||
}, 0);
|
||||
}, true);
|
||||
}, true);
|
||||
blankBrowser.loadURI("about:blank");
|
||||
}
|
||||
|
||||
function finishTest() {
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
// leave private browsing mode
|
||||
pb.privateBrowsingEnabled = false;
|
||||
let tabBlank = gBrowser.selectedTab;
|
||||
let blankBrowser = gBrowser.getBrowserForTab(tabBlank);
|
||||
blankBrowser.addEventListener("load", function() {
|
||||
blankBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
executeSoon(function() {
|
||||
// cleanup
|
||||
FullZoom.reset();
|
||||
finish();
|
||||
});
|
||||
}, true);
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 5.3 KiB |
@ -1,9 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Page containing an image</title>
|
||||
</head>
|
||||
<body>
|
||||
<img src="ctxmenu-image.png">
|
||||
</body>
|
||||
</html>
|
@ -1,40 +0,0 @@
|
||||
// Make sure that we clean up after each test if it times out, for example.
|
||||
registerCleanupFunction(function() {
|
||||
var pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
ok(!pb.privateBrowsingEnabled, "Private browsing should be terminated after finishing the test");
|
||||
pb.privateBrowsingEnabled = false;
|
||||
try {
|
||||
Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session");
|
||||
} catch(e) {}
|
||||
});
|
||||
|
||||
/**
|
||||
* Waits for completion of a clear history operation, before
|
||||
* proceeding with aCallback.
|
||||
*
|
||||
* @param aCallback
|
||||
* Function to be called when done.
|
||||
*/
|
||||
function waitForClearHistory(aCallback) {
|
||||
Services.obs.addObserver(function observeCH(aSubject, aTopic, aData) {
|
||||
Services.obs.removeObserver(observeCH, PlacesUtils.TOPIC_EXPIRATION_FINISHED);
|
||||
aCallback();
|
||||
}, PlacesUtils.TOPIC_EXPIRATION_FINISHED, false);
|
||||
PlacesUtils.bhistory.removeAllPages();
|
||||
}
|
||||
|
||||
/*
|
||||
* Function created to put a window in PB mode.
|
||||
* THIS IS DANGEROUS. DO NOT DO THIS OUTSIDE OF TESTS!
|
||||
*/
|
||||
function setPrivateWindow(aWindow, aEnable) {
|
||||
return aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShellTreeItem)
|
||||
.treeOwner
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIXULWindow)
|
||||
.docShell.QueryInterface(Ci.nsILoadContext)
|
||||
.usePrivateBrowsing = aEnable;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user