Backed out changeset cc665373ff61 (bug 829383). CLOSED TREEs don't bother me.

This commit is contained in:
Josh Matthews 2013-01-21 16:22:38 +00:00
parent 77bcbdf4a7
commit c0e3542fc9
6 changed files with 33 additions and 116 deletions

View File

@ -222,6 +222,13 @@ static int32_t gDocShellCount = 0;
// Global count of docshells with the private attribute set
static uint32_t gNumberOfPrivateDocShells = 0;
// Global count of private docshells which will always remain open
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
static uint32_t gNumberOfAlwaysOpenPrivateDocShells = 0; // the private hidden window
#else
static const uint32_t gNumberOfAlwaysOpenPrivateDocShells = 0;
#endif
// Global reference to the URI fixup service.
nsIURIFixup *nsDocShell::sURIFixup = 0;
@ -685,11 +692,27 @@ ConvertLoadTypeToNavigationType(uint32_t aLoadType)
static nsISHEntry* GetRootSHEntry(nsISHEntry *entry);
static void
AdjustAlwaysOpenPrivateDocShellCount()
{
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
nsCOMPtr<nsIAppShellService> appShell
(do_GetService(NS_APPSHELLSERVICE_CONTRACTID));
bool hasHiddenPrivateWindow = false;
if (appShell) {
appShell->GetHasHiddenPrivateWindow(&hasHiddenPrivateWindow);
}
gNumberOfAlwaysOpenPrivateDocShells = hasHiddenPrivateWindow ? 1 : 0;
#endif
}
static void
IncreasePrivateDocShellCount()
{
AdjustAlwaysOpenPrivateDocShellCount();
gNumberOfPrivateDocShells++;
if (gNumberOfPrivateDocShells > 1 ||
if (gNumberOfPrivateDocShells > gNumberOfAlwaysOpenPrivateDocShells + 1 ||
XRE_GetProcessType() != GeckoProcessType_Content) {
return;
}
@ -701,9 +724,11 @@ IncreasePrivateDocShellCount()
static void
DecreasePrivateDocShellCount()
{
AdjustAlwaysOpenPrivateDocShellCount();
MOZ_ASSERT(gNumberOfPrivateDocShells > 0);
gNumberOfPrivateDocShells--;
if (!gNumberOfPrivateDocShells)
if (gNumberOfPrivateDocShells == gNumberOfAlwaysOpenPrivateDocShells)
{
if (XRE_GetProcessType() == GeckoProcessType_Content) {
mozilla::dom::ContentChild* cc = mozilla::dom::ContentChild::GetSingleton();
@ -770,7 +795,6 @@ nsDocShell::nsDocShell():
#ifdef DEBUG
mInEnsureScriptEnv(false),
#endif
mAffectPrivateSessionLifetime(true),
mFrameType(eFrameTypeRegular),
mOwnOrContainingAppId(nsIScriptSecurityManager::UNKNOWN_APP_ID),
mParentCharsetSource(0)
@ -2045,12 +2069,10 @@ nsDocShell::SetPrivateBrowsing(bool aUsePrivateBrowsing)
bool changed = aUsePrivateBrowsing != mInPrivateBrowsing;
if (changed) {
mInPrivateBrowsing = aUsePrivateBrowsing;
if (mAffectPrivateSessionLifetime) {
if (aUsePrivateBrowsing) {
IncreasePrivateDocShellCount();
} else {
DecreasePrivateDocShellCount();
}
if (aUsePrivateBrowsing) {
IncreasePrivateDocShellCount();
} else {
DecreasePrivateDocShellCount();
}
}
@ -2077,36 +2099,6 @@ nsDocShell::SetPrivateBrowsing(bool aUsePrivateBrowsing)
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::SetAffectPrivateSessionLifetime(bool aAffectLifetime)
{
bool change = aAffectLifetime != mAffectPrivateSessionLifetime;
if (change && mInPrivateBrowsing) {
if (aAffectLifetime) {
IncreasePrivateDocShellCount();
} else {
DecreasePrivateDocShellCount();
}
}
mAffectPrivateSessionLifetime = aAffectLifetime;
int32_t count = mChildList.Count();
for (int32_t i = 0; i < count; ++i) {
nsCOMPtr<nsIDocShell> shell = do_QueryInterface(ChildAt(i));
if (shell) {
shell->SetAffectPrivateSessionLifetime(aAffectLifetime);
}
}
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::GetAffectPrivateSessionLifetime(bool* aAffectLifetime)
{
*aAffectLifetime = mAffectPrivateSessionLifetime;
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::AddWeakPrivacyTransitionObserver(nsIPrivacyTransitionObserver* aObserver)
{
@ -2841,8 +2833,6 @@ nsDocShell::SetDocLoaderParent(nsDocLoader * aParent)
value = false;
}
SetAllowDNSPrefetch(value);
value = parentAsDocShell->GetAffectPrivateSessionLifetime();
SetAffectPrivateSessionLifetime(value);
}
nsCOMPtr<nsILoadContext> parentAsLoadContext(do_QueryInterface(parent));
@ -4987,9 +4977,7 @@ nsDocShell::Destroy()
if (mInPrivateBrowsing) {
mInPrivateBrowsing = false;
if (mAffectPrivateSessionLifetime) {
DecreasePrivateDocShellCount();
}
DecreasePrivateDocShellCount();
}
return NS_OK;

View File

@ -842,7 +842,6 @@ protected:
#ifdef DEBUG
bool mInEnsureScriptEnv;
#endif
bool mAffectPrivateSessionLifetime;
uint64_t mHistoryID;
static nsIURIFixup *sURIFixup;

View File

@ -39,7 +39,7 @@ interface nsIWebBrowserPrint;
interface nsIVariant;
interface nsIPrivacyTransitionObserver;
[scriptable, builtinclass, uuid(fc7e18cd-c671-4d78-a022-7de87555e15f)]
[scriptable, builtinclass, uuid(ca15d803-1330-4154-b3f9-063fb2b443e7)]
interface nsIDocShell : nsISupports
{
/**
@ -726,8 +726,6 @@ interface nsIDocShell : nsISupports
void setFullscreenAllowed(in boolean allowed);
[noscript, infallible] attribute boolean affectPrivateSessionLifetime;
/**
* Indicates whether the UI may enable the character encoding menu. The UI
* must disable the menu when this property is false.

View File

@ -94,7 +94,6 @@ MOCHITEST_CHROME_FILES = \
test_mozFrameType.xul \
mozFrameType_window.xul \
test_bug789773.xul \
test_private_hidden_window.html \
docshell_helpers.js \
generic.html \
$(NULL)

View File

@ -1,61 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=829383
-->
<head>
<title>Test for Bug 829383</title>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=829383">Mozilla Bug 829383</a>
<p id="display"></p>
<div id="content" style="display: none">
<iframe name="target"></iframe>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
const Ci = Components.interfaces;
var mainWindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
// We need to wait for the hidden window to load, but can't access
// an event target for a regular event listener.
var hidden = mainWindow.Services.appShell.hiddenPrivateDOMWindow;
var tmp = setTimeout(function poll() {
if (hidden.location.href != "resource://gre-resources/hiddenWindow.html") {
setTimeout(poll, 100);
return;
}
var iframe = hidden.document.createElement('iframe');
iframe.src = 'generic.html';
hidden.document.body.appendChild(iframe);
var win = mainWindow.OpenBrowserWindow({private: true});
win.addEventListener("load", function onLoad() {
win.removeEventListener("load", onLoad, false);
win.close();
win = null;
}, false);
}, 100);
function observer(aSubject, aTopic, aData) {
is(aTopic, "last-pb-context-exited", "Unexpected observer topic");
mainWindow.Services.obs.removeObserver(observer, "last-pb-context-exited");
SimpleTest.finish();
}
mainWindow.Services.obs.addObserver(observer, "last-pb-context-exited", false);
</script>
</pre>
</body>
</html>

View File

@ -140,12 +140,6 @@ nsAppShellService::CreateHiddenWindowHelper(bool aIsPrivate)
true, getter_AddRefs(newWindow));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocShell> docShell;
newWindow->GetDocShell(getter_AddRefs(docShell));
if (docShell) {
docShell->SetAffectPrivateSessionLifetime(false);
}
mHiddenPrivateWindow.swap(newWindow);
}
#endif