Backed out changesets 180e7905987e, 91101cbcc319, and 211567afcc5f (bug 1108547) for timeouts in the new test.
CLOSED TREE
This commit is contained in:
@@ -4761,22 +4761,18 @@ nsBrowserAccess.prototype = {
|
|||||||
else
|
else
|
||||||
aWhere = gPrefService.getIntPref("browser.link.open_newwindow");
|
aWhere = gPrefService.getIntPref("browser.link.open_newwindow");
|
||||||
}
|
}
|
||||||
let isPrivate = PrivateBrowsingUtils.isWindowPrivate(aOpener || window);
|
|
||||||
switch (aWhere) {
|
switch (aWhere) {
|
||||||
case Ci.nsIBrowserDOMWindow.OPEN_NEWWINDOW :
|
case Ci.nsIBrowserDOMWindow.OPEN_NEWWINDOW :
|
||||||
// FIXME: Bug 408379. So how come this doesn't send the
|
// FIXME: Bug 408379. So how come this doesn't send the
|
||||||
// referrer like the other loads do?
|
// referrer like the other loads do?
|
||||||
var url = aURI ? aURI.spec : "about:blank";
|
var url = aURI ? aURI.spec : "about:blank";
|
||||||
let features = "all,dialog=no";
|
|
||||||
if (isPrivate) {
|
|
||||||
features += ",private";
|
|
||||||
}
|
|
||||||
// Pass all params to openDialog to ensure that "url" isn't passed through
|
// Pass all params to openDialog to ensure that "url" isn't passed through
|
||||||
// loadOneOrMoreURIs, which splits based on "|"
|
// loadOneOrMoreURIs, which splits based on "|"
|
||||||
newWindow = openDialog(getBrowserURL(), "_blank", features, url, null, null, null);
|
newWindow = openDialog(getBrowserURL(), "_blank", "all,dialog=no", url, null, null, null);
|
||||||
break;
|
break;
|
||||||
case Ci.nsIBrowserDOMWindow.OPEN_NEWTAB :
|
case Ci.nsIBrowserDOMWindow.OPEN_NEWTAB :
|
||||||
let referrer = aOpener ? makeURI(aOpener.location.href) : null;
|
let referrer = aOpener ? makeURI(aOpener.location.href) : null;
|
||||||
|
let isPrivate = PrivateBrowsingUtils.isWindowPrivate(aOpener || window);
|
||||||
let browser = this._openURIInNewTab(aURI, referrer, isPrivate, isExternal);
|
let browser = this._openURIInNewTab(aURI, referrer, isPrivate, isExternal);
|
||||||
if (browser)
|
if (browser)
|
||||||
newWindow = browser.contentWindow;
|
newWindow = browser.contentWindow;
|
||||||
|
|||||||
@@ -9635,13 +9635,9 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
|||||||
nsAutoCString spec;
|
nsAutoCString spec;
|
||||||
if (aURI)
|
if (aURI)
|
||||||
aURI->GetSpec(spec);
|
aURI->GetSpec(spec);
|
||||||
nsAutoString features;
|
|
||||||
if (mInPrivateBrowsing) {
|
|
||||||
features.AssignLiteral("private");
|
|
||||||
}
|
|
||||||
rv = win->OpenNoNavigate(NS_ConvertUTF8toUTF16(spec),
|
rv = win->OpenNoNavigate(NS_ConvertUTF8toUTF16(spec),
|
||||||
name, // window name
|
name, // window name
|
||||||
features,
|
EmptyString(), // Features
|
||||||
getter_AddRefs(newWin));
|
getter_AddRefs(newWin));
|
||||||
|
|
||||||
// In some cases the Open call doesn't actually result in a new
|
// In some cases the Open call doesn't actually result in a new
|
||||||
|
|||||||
@@ -1225,32 +1225,6 @@ nsHTMLDocument::GetCookie(nsAString& aCookie)
|
|||||||
return rv.ErrorCode();
|
return rv.ErrorCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<nsIChannel>
|
|
||||||
nsHTMLDocument::CreateDummyChannelForCookies(nsIURI* aCodebaseURI)
|
|
||||||
{
|
|
||||||
// The cookie service reads the privacy status of the channel we pass to it in
|
|
||||||
// order to determine which cookie database to query. In some cases we don't
|
|
||||||
// have a proper channel to hand it to the cookie service though. This
|
|
||||||
// function creates a dummy channel that is not used to load anything, for the
|
|
||||||
// sole purpose of handing it to the cookie service. DO NOT USE THIS CHANNEL
|
|
||||||
// FOR ANY OTHER PURPOSE.
|
|
||||||
MOZ_ASSERT(!mChannel);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIChannel> channel;
|
|
||||||
NS_NewChannel(getter_AddRefs(channel), aCodebaseURI, this,
|
|
||||||
nsILoadInfo::SEC_NORMAL,
|
|
||||||
nsIContentPolicy::TYPE_INVALID);
|
|
||||||
nsCOMPtr<nsIPrivateBrowsingChannel> pbChannel =
|
|
||||||
do_QueryInterface(channel);
|
|
||||||
nsCOMPtr<nsIDocShell> docShell(mDocumentContainer);
|
|
||||||
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(docShell);
|
|
||||||
if (!pbChannel || !loadContext) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
pbChannel->SetPrivate(loadContext->UsePrivateBrowsing());
|
|
||||||
return channel.forget();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
nsHTMLDocument::GetCookie(nsAString& aCookie, ErrorResult& rv)
|
nsHTMLDocument::GetCookie(nsAString& aCookie, ErrorResult& rv)
|
||||||
{
|
{
|
||||||
@@ -1283,16 +1257,8 @@ nsHTMLDocument::GetCookie(nsAString& aCookie, ErrorResult& rv)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIChannel> channel(mChannel);
|
|
||||||
if (!channel) {
|
|
||||||
channel = CreateDummyChannelForCookies(codebaseURI);
|
|
||||||
if (!channel) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nsXPIDLCString cookie;
|
nsXPIDLCString cookie;
|
||||||
service->GetCookieString(codebaseURI, channel, getter_Copies(cookie));
|
service->GetCookieString(codebaseURI, mChannel, getter_Copies(cookie));
|
||||||
// CopyUTF8toUTF16 doesn't handle error
|
// CopyUTF8toUTF16 doesn't handle error
|
||||||
// because it assumes that the input is valid.
|
// because it assumes that the input is valid.
|
||||||
nsContentUtils::ConvertStringFromEncoding(NS_LITERAL_CSTRING("UTF-8"),
|
nsContentUtils::ConvertStringFromEncoding(NS_LITERAL_CSTRING("UTF-8"),
|
||||||
@@ -1336,16 +1302,8 @@ nsHTMLDocument::SetCookie(const nsAString& aCookie, ErrorResult& rv)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIChannel> channel(mChannel);
|
|
||||||
if (!channel) {
|
|
||||||
channel = CreateDummyChannelForCookies(codebaseURI);
|
|
||||||
if (!channel) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_ConvertUTF16toUTF8 cookie(aCookie);
|
NS_ConvertUTF16toUTF8 cookie(aCookie);
|
||||||
service->SetCookieString(codebaseURI, nullptr, cookie.get(), channel);
|
service->SetCookieString(codebaseURI, nullptr, cookie.get(), mChannel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -275,9 +275,6 @@ protected:
|
|||||||
nsresult CreateAndAddWyciwygChannel(void);
|
nsresult CreateAndAddWyciwygChannel(void);
|
||||||
nsresult RemoveWyciwygChannel(void);
|
nsresult RemoveWyciwygChannel(void);
|
||||||
|
|
||||||
// This should *ONLY* be used in GetCookie/SetCookie.
|
|
||||||
already_AddRefed<nsIChannel> CreateDummyChannelForCookies(nsIURI* aCodebaseURI);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Like IsEditingOn(), but will flush as needed first.
|
* Like IsEditingOn(), but will flush as needed first.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -8,8 +8,3 @@ support-files =
|
|||||||
[browser_bug649778.js]
|
[browser_bug649778.js]
|
||||||
skip-if = e10s # Bug ?????? - leaked until shutdown [nsGlobalWindow #16 about:blank]
|
skip-if = e10s # Bug ?????? - leaked until shutdown [nsGlobalWindow #16 about:blank]
|
||||||
[browser_bug1081537.js]
|
[browser_bug1081537.js]
|
||||||
[browser_bug1108547.js]
|
|
||||||
support-files =
|
|
||||||
file_bug1108547-1.html
|
|
||||||
file_bug1108547-2.html
|
|
||||||
file_bug1108547-3.html
|
|
||||||
|
|||||||
@@ -1,120 +0,0 @@
|
|||||||
/* Any copyright is dedicated to the Public Domain.
|
|
||||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
||||||
|
|
||||||
function test() {
|
|
||||||
waitForExplicitFinish();
|
|
||||||
|
|
||||||
runPass("file_bug1108547-2.html", function() {
|
|
||||||
runPass("file_bug1108547-3.html", function() {
|
|
||||||
finish();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function runPass(getterFile, finishedCallback) {
|
|
||||||
var rootDir = "http://mochi.test:8888/browser/dom/html/test/";
|
|
||||||
var testBrowser;
|
|
||||||
var privateWin;
|
|
||||||
|
|
||||||
function whenWindowLoaded(win, callback) {
|
|
||||||
win.addEventListener("load", function onLoad() {
|
|
||||||
win.removeEventListener("load", onLoad, false);
|
|
||||||
executeSoon(callback);
|
|
||||||
}, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
function whenDelayedStartupFinished(win, callback) {
|
|
||||||
let topic = "browser-delayed-startup-finished";
|
|
||||||
Services.obs.addObserver(function onStartup(aSubject) {
|
|
||||||
if (win != aSubject)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Services.obs.removeObserver(onStartup, topic);
|
|
||||||
executeSoon(callback);
|
|
||||||
}, topic, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// First, set the cookie in a normal window.
|
|
||||||
gBrowser.selectedTab = gBrowser.addTab(rootDir + "file_bug1108547-1.html");
|
|
||||||
gBrowser.selectedBrowser.addEventListener("load", afterOpenCookieSetter, true);
|
|
||||||
|
|
||||||
function afterOpenCookieSetter() {
|
|
||||||
gBrowser.selectedBrowser.removeEventListener("load", afterOpenCookieSetter, true);
|
|
||||||
gBrowser.removeCurrentTab();
|
|
||||||
|
|
||||||
// Now, open a private window.
|
|
||||||
privateWin = OpenBrowserWindow({private: true});
|
|
||||||
whenWindowLoaded(privateWin, function() {
|
|
||||||
whenDelayedStartupFinished(privateWin, afterPrivateWindowOpened);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function afterPrivateWindowOpened() {
|
|
||||||
// In the private window, open the getter file, and wait for a new tab to be opened.
|
|
||||||
privateWin.gBrowser.selectedTab = privateWin.gBrowser.addTab(rootDir + getterFile);
|
|
||||||
testBrowser = privateWin.gBrowser.selectedBrowser;
|
|
||||||
privateWin.gBrowser.tabContainer.addEventListener("TabOpen", onNewTabOpened, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function onNewTabOpened() {
|
|
||||||
// When the new tab is opened, wait for it to load.
|
|
||||||
privateWin.gBrowser.tabContainer.removeEventListener("TabOpen", onNewTabOpened, true);
|
|
||||||
privateWin.gBrowser.tabs[privateWin.gBrowser.tabs.length - 1].linkedBrowser.addEventListener("load", onNewTabLoaded, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function onNewTabLoaded() {
|
|
||||||
privateWin.gBrowser.tabs[privateWin.gBrowser.tabs.length - 1].linkedBrowser.removeEventListener("load", onNewTabLoaded, true);
|
|
||||||
|
|
||||||
// Now, ensure that the private tab doesn't have access to the cookie set in normal mode.
|
|
||||||
is(testBrowser.contentDocument.getElementById("result").textContent, "",
|
|
||||||
"Shouldn't have access to the cookies");
|
|
||||||
|
|
||||||
// We're done with the private window, close it.
|
|
||||||
privateWin.close();
|
|
||||||
|
|
||||||
// Clear all cookies.
|
|
||||||
Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager).removeAll();
|
|
||||||
|
|
||||||
// Open a new private window, this time to set a cookie inside it.
|
|
||||||
privateWin = OpenBrowserWindow({private: true});
|
|
||||||
whenWindowLoaded(privateWin, function() {
|
|
||||||
whenDelayedStartupFinished(privateWin, afterPrivateWindowOpened2);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function afterPrivateWindowOpened2() {
|
|
||||||
// In the private window, open the setter file, and wait for it to load.
|
|
||||||
privateWin.gBrowser.selectedTab = privateWin.gBrowser.addTab(rootDir + "file_bug1108547-1.html");
|
|
||||||
privateWin.gBrowser.selectedBrowser.addEventListener("load", afterOpenCookieSetter2, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function afterOpenCookieSetter2() {
|
|
||||||
// We're done with the private window now, close it.
|
|
||||||
privateWin.close();
|
|
||||||
|
|
||||||
// Now try to read the cookie in a normal window, and wait for a new tab to be opened.
|
|
||||||
gBrowser.selectedTab = gBrowser.addTab(rootDir + getterFile);
|
|
||||||
testBrowser = gBrowser.selectedBrowser;
|
|
||||||
gBrowser.tabContainer.addEventListener("TabOpen", onNewTabOpened2, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function onNewTabOpened2() {
|
|
||||||
// When the new tab is opened, wait for it to load.
|
|
||||||
gBrowser.tabContainer.removeEventListener("TabOpen", onNewTabOpened2, true);
|
|
||||||
gBrowser.tabs[gBrowser.tabs.length - 1].linkedBrowser.addEventListener("load", onNewTabLoaded2, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function onNewTabLoaded2() {
|
|
||||||
gBrowser.tabs[gBrowser.tabs.length - 1].linkedBrowser.removeEventListener("load", onNewTabLoaded2, true);
|
|
||||||
|
|
||||||
// Now, ensure that the normal tab doesn't have access to the cookie set in private mode.
|
|
||||||
is(testBrowser.contentDocument.getElementById("result").textContent, "",
|
|
||||||
"Shouldn't have access to the cookies");
|
|
||||||
|
|
||||||
// Remove both of the tabs opened here.
|
|
||||||
gBrowser.removeCurrentTab();
|
|
||||||
gBrowser.removeCurrentTab();
|
|
||||||
|
|
||||||
finishedCallback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<script>
|
|
||||||
document.cookie = "foo=bar";
|
|
||||||
</script>
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<body onload="document.querySelector('form').submit();">
|
|
||||||
<form action="javascript:opener.document.getElementById('result').textContent = document.cookie;" target="_blank">
|
|
||||||
</form>
|
|
||||||
<div id="result">not tested yet</div>
|
|
||||||
</body>
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<body onload="document.querySelector('a').click();">
|
|
||||||
<a href="javascript:opener.document.getElementById('result').textContent = document.cookie;" target="_blank">test</a>
|
|
||||||
<div id="result">not tested yet</div>
|
|
||||||
</body>
|
|
||||||
Reference in New Issue
Block a user