mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-21 17:59:34 +00:00
Merge mozilla-central into mozilla-inbound, but DONTBUILD since this all NPOTB stuff
This commit is contained in:
commit
7587651648
@ -26,8 +26,8 @@
|
||||
#include global-scripts.inc
|
||||
|
||||
<script type="application/javascript">
|
||||
function OpenBrowserWindowFromDockMenu() {
|
||||
let win = OpenBrowserWindow();
|
||||
function OpenBrowserWindowFromDockMenu(options) {
|
||||
let win = OpenBrowserWindow(options);
|
||||
win.addEventListener("load", function listener() {
|
||||
win.removeEventListener("load", listener);
|
||||
let dockSupport = Cc["@mozilla.org/widget/macdocksupport;1"]
|
||||
@ -56,6 +56,9 @@
|
||||
<!-- 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>
|
||||
|
||||
|
@ -19,10 +19,13 @@ function test() {
|
||||
|
||||
let browser = aWindow.gBrowser.selectedBrowser;
|
||||
browser.addEventListener("load", function() {
|
||||
// Ignore non-related loads (could be about:privatebrowsing for example, see bug 817932)
|
||||
if (browser.currentURI.spec != url) {
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -886,9 +886,16 @@ let SessionStoreInternal = {
|
||||
winData._shouldRestore = true;
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
// Save the window if it has multiple tabs or a single saveable tab and
|
||||
// it's not private.
|
||||
if (!winData.isPrivate && (winData.tabs.length > 1 ||
|
||||
(winData.tabs.length == 1 && this._shouldSaveTabState(winData.tabs[0])))) {
|
||||
#else
|
||||
// save the window if it has multiple tabs or a single saveable tab
|
||||
if (winData.tabs.length > 1 ||
|
||||
(winData.tabs.length == 1 && this._shouldSaveTabState(winData.tabs[0]))) {
|
||||
#endif
|
||||
// we don't want to save the busy state
|
||||
delete winData.busy;
|
||||
|
||||
|
@ -36,7 +36,6 @@ MOCHITEST_BROWSER_FILES = \
|
||||
browser_394759_basic.js \
|
||||
browser_394759_behavior.js \
|
||||
browser_394759_purge.js \
|
||||
browser_394759_privatebrowsing.js \
|
||||
browser_408470.js \
|
||||
browser_408470_sample.html \
|
||||
browser_423132.js \
|
||||
@ -139,10 +138,12 @@ MOCHITEST_BROWSER_FILES = \
|
||||
ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
MOCHITEST_BROWSER_FILES += \
|
||||
browser_354894_perwindowpb.js \
|
||||
browser_394759_perwindowpb.js \
|
||||
$(NULL)
|
||||
else
|
||||
MOCHITEST_BROWSER_FILES += \
|
||||
browser_354894.js \
|
||||
browser_394759_privatebrowsing.js \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
|
@ -0,0 +1,119 @@
|
||||
/* 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/. */
|
||||
|
||||
/** Private Browsing Test for Bug 394759 **/
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
let windowsToClose = [];
|
||||
let closedWindowCount = 0;
|
||||
// Prevent VM timers issues, cache now and increment it manually.
|
||||
let now = Date.now();
|
||||
const TESTS = [
|
||||
{ url: "about:config",
|
||||
key: "bug 394759 Non-PB",
|
||||
value: "uniq" + (++now) },
|
||||
{ url: "about:mozilla",
|
||||
key: "bug 394759 PB",
|
||||
value: "uniq" + (++now) },
|
||||
];
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Services.prefs.clearUserPref("browser.sessionstore.interval");
|
||||
windowsToClose.forEach(function(win) {
|
||||
win.close();
|
||||
});
|
||||
});
|
||||
|
||||
function testOpenCloseWindow(aIsPrivate, aTest, aCallback) {
|
||||
whenNewWindowLoaded(aIsPrivate, function(win) {
|
||||
win.gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
|
||||
win.gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
|
||||
executeSoon(function() {
|
||||
// Mark the window with some unique data to be restored later on.
|
||||
ss.setWindowValue(win, aTest.key, aTest.value);
|
||||
// Close.
|
||||
win.close();
|
||||
aCallback();
|
||||
});
|
||||
}, true);
|
||||
win.gBrowser.selectedBrowser.loadURI(aTest.url);
|
||||
});
|
||||
}
|
||||
|
||||
function testOnWindow(aIsPrivate, aValue, aCallback) {
|
||||
whenNewWindowLoaded(aIsPrivate, function(win) {
|
||||
windowsToClose.push(win);
|
||||
executeSoon(function() checkClosedWindows(aIsPrivate, aValue, aCallback));
|
||||
});
|
||||
}
|
||||
|
||||
function checkClosedWindows(aIsPrivate, aValue, aCallback) {
|
||||
let data = JSON.parse(ss.getClosedWindowData())[0];
|
||||
is(ss.getClosedWindowCount(), 1, "Check the closed window count");
|
||||
ok(JSON.stringify(data).indexOf(aValue) > -1,
|
||||
"Check the closed window data was stored correctly");
|
||||
aCallback();
|
||||
}
|
||||
|
||||
function setupBlankState(aCallback) {
|
||||
// Set interval to a large time so state won't be written while we setup
|
||||
// environment.
|
||||
Services.prefs.setIntPref("browser.sessionstore.interval", 100000);
|
||||
|
||||
// Set up the browser in a blank state. Popup windows in previous tests
|
||||
// result in different states on different platforms.
|
||||
let blankState = JSON.stringify({
|
||||
windows: [{
|
||||
tabs: [{ entries: [{ url: "about:blank" }] }],
|
||||
_closedTabs: []
|
||||
}],
|
||||
_closedWindows: []
|
||||
});
|
||||
ss.setBrowserState(blankState);
|
||||
|
||||
// Wait for the sessionstore.js file to be written before going on.
|
||||
// Note: we don't wait for the complete event, since if asyncCopy fails we
|
||||
// would timeout.
|
||||
Services.obs.addObserver(function (aSubject, aTopic, aData) {
|
||||
Services.obs.removeObserver(arguments.callee, aTopic);
|
||||
info("sessionstore.js is being written");
|
||||
|
||||
closedWindowCount = ss.getClosedWindowCount();
|
||||
is(closedWindowCount, 0, "Correctly set window count");
|
||||
|
||||
executeSoon(aCallback);
|
||||
}, "sessionstore-state-write", false);
|
||||
|
||||
// Remove the sessionstore.js file before setting the interval to 0
|
||||
let profilePath = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
let sessionStoreJS = profilePath.clone();
|
||||
sessionStoreJS.append("sessionstore.js");
|
||||
if (sessionStoreJS.exists())
|
||||
sessionStoreJS.remove(false);
|
||||
info("sessionstore.js was correctly removed: " + (!sessionStoreJS.exists()));
|
||||
|
||||
// Make sure that sessionstore.js can be forced to be created by setting
|
||||
// the interval pref to 0.
|
||||
Services.prefs.setIntPref("browser.sessionstore.interval", 0);
|
||||
}
|
||||
|
||||
setupBlankState(function() {
|
||||
testOpenCloseWindow(false, TESTS[0], function() {
|
||||
testOpenCloseWindow(true, TESTS[1], function() {
|
||||
testOnWindow(false, TESTS[0].value, function() {
|
||||
testOnWindow(true, TESTS[0].value, finish);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function whenNewWindowLoaded(aIsPrivate, aCallback) {
|
||||
let win = OpenBrowserWindow({private: aIsPrivate});
|
||||
win.addEventListener("load", function onLoad() {
|
||||
win.removeEventListener("load", onLoad, false);
|
||||
aCallback(win);
|
||||
}, false);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user