Backout 714c402f3050, 80d09e39cd0d & 3a1129278710 (bug 764718) for frequent intermittent failures

This commit is contained in:
Ed Morley 2012-06-22 11:04:47 +01:00
parent 3a4cddc21b
commit 91815d3c91
11 changed files with 7 additions and 179 deletions

View File

@ -444,15 +444,10 @@ nsFrameLoader::ReallyStartLoadingInternal()
mDocShell->CreateLoadInfo(getter_AddRefs(loadInfo));
NS_ENSURE_TRUE(loadInfo, NS_ERROR_FAILURE);
if (!OwnerIsBrowserFrame()) {
// We'll use our principal, not that of the document loaded inside us.
// This is very important; needed to prevent XSS attacks on documents
// loaded in subframes!
//
// (For <iframe mozbrowser>, don't set an owner; it's as though the iframe
// is a top-level window.)
loadInfo->SetOwner(mOwnerContent->NodePrincipal());
}
// We'll use our principal, not that of the document loaded inside us. This
// is very important; needed to prevent XSS attacks on documents loaded in
// subframes!
loadInfo->SetOwner(mOwnerContent->NodePrincipal());
nsCOMPtr<nsIURI> referrer;
rv = mOwnerContent->NodePrincipal()->GetURI(getter_AddRefs(referrer));

View File

@ -8810,9 +8810,7 @@ nsDocShell::GetInheritedPrincipal(bool aConsiderCurrentDocument)
inheritedFromCurrent = true;
}
// Browser frames don't inherit their principal from their parent. This
// makes them more like top-level windows.
if (!document && !mIsBrowserFrame) {
if (!document) {
nsCOMPtr<nsIDocShellTreeItem> parentItem;
GetSameTypeParent(getter_AddRefs(parentItem));
if (parentItem) {

View File

@ -48,9 +48,6 @@ _TEST_FILES = \
test_browserElement_inproc_PromptConfirm.html \
browserElement_Close.js \
test_browserElement_inproc_Close.html \
browserElement_CloseFromOpener.js \
test_browserElement_inproc_CloseFromOpener.html \
file_browserElement_CloseFromOpener.html \
browserElement_OpenWindow.js \
test_browserElement_inproc_OpenWindow.html \
file_browserElement_Open1.html \
@ -62,8 +59,6 @@ _TEST_FILES = \
test_browserElement_inproc_SecurityChange.html \
file_browserElement_SecurityChange.html \
browserElement_BackForward.js \
browserElement_Principal.js \
test_browserElement_inproc_Principal.html \
$(NULL)
# OOP tests don't work on Windows (bug 763081).
@ -83,12 +78,10 @@ _TEST_FILES += \
test_browserElement_oop_PromptCheck.html \
test_browserElement_oop_PromptConfirm.html \
test_browserElement_oop_Close.html \
test_browserElement_oop_CloseFromOpener.html \
test_browserElement_oop_OpenWindow.html \
test_browserElement_oop_OpenWindowRejected.html \
test_browserElement_oop_SecurityChange.html \
test_browserElement_oop_BackForward.html \
test_browserElement_oop_Principal.html \
$(NULL)
endif

View File

@ -1,34 +0,0 @@
/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Bug 764718 - Test that window.close() works from the opener window.
"use strict";
SimpleTest.waitForExplicitFinish();
function runTest() {
browserElementTestHelpers.setEnabledPref(true);
browserElementTestHelpers.addToWhitelist();
var iframe = document.createElement('iframe');
iframe.mozbrowser = true;
iframe.addEventListener('mozbrowseropenwindow', function(e) {
ok(true, "got openwindow event.");
document.body.appendChild(e.detail.frameElement);
e.detail.frameElement.addEventListener("mozbrowserclose", function(e) {
ok(true, "got mozbrowserclose event.");
SimpleTest.finish();
});
});
document.body.appendChild(iframe);
// file_browserElement_CloseFromOpener opens a new window and then calls
// close() on it.
iframe.src = "file_browserElement_CloseFromOpener.html";
}
runTest();

View File

@ -1,44 +0,0 @@
/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Bug 764718 - Test that <iframe mozbrowser>'s have a different principal than
// their creator.
"use strict";
function runTest() {
browserElementTestHelpers.setEnabledPref(true);
browserElementTestHelpers.addToWhitelist();
var iframe = document.createElement('iframe');
iframe.mozbrowser = true;
document.body.appendChild(iframe);
if (!iframe.contentWindow) {
ok(true, "OOP, can't access contentWindow.");
return;
}
SimpleTest.waitForExplicitFinish();
// Try reading iframe.contentWindow.location now, and then from a timeout.
// They both should throw exceptions.
checkCantReadLocation(iframe);
SimpleTest.executeSoon(function() {
checkCantReadLocation(iframe);
SimpleTest.finish();
});
}
function checkCantReadLocation(iframe) {
try {
if (iframe.contentWindow.location == 'foo') {
ok(false, 'not reached');
}
ok(false, 'should have gotten exception');
}
catch(e) {
ok(true, 'got exception reading contentWindow.location');
}
}
runTest();

View File

@ -1,8 +0,0 @@
<html>
<body>
<script>
var win = window.open('file_empty.html');
win.close();
</script>
</body>
</html>

View File

@ -1,18 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=757182
-->
<head>
<title>Test for Bug 757182</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=757182">Mozilla Bug 757182</a>
<script type="application/javascript;version=1.7" src="browserElement_CloseFromOpener.js">
</script>
</body>
</html>

View File

@ -1,18 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=757182
-->
<head>
<title>Test for Bug 757182</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=757182">Mozilla Bug 757182</a>
<script type="application/javascript;version=1.7" src="browserElement_Principal.js">
</script>
</body>
</html>

View File

@ -1,18 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=757182
-->
<head>
<title>Test for Bug 757182</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=757182">Mozilla Bug 757182</a>
<script type="application/javascript;version=1.7" src="browserElement_CloseFromOpener.js">
</script>
</body>
</html>

View File

@ -1,18 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=757182
-->
<head>
<title>Test for Bug 757182</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=757182">Mozilla Bug 757182</a>
<script type="application/javascript;version=1.7" src="browserElement_Principal.js">
</script>
</body>
</html>

View File

@ -851,14 +851,14 @@ nsContentTreeOwner::ProvideWindow(nsIDOMWindow* aParent,
!(aChromeFlags & (nsIWebBrowserChrome::CHROME_MODAL |
nsIWebBrowserChrome::CHROME_OPENAS_DIALOG |
nsIWebBrowserChrome::CHROME_OPENAS_CHROME))) {
*aWindowIsNew =
bool openSucceeded =
BrowserElementParent::OpenWindowInProcess(aParent, aURI, aName,
aFeatures, aReturn);
// If OpenWindowInProcess failed (perhaps because the embedder blocked the
// popup), tell our caller not to proceed trying to create a new window
// through other means.
return *aWindowIsNew ? NS_OK : NS_ERROR_ABORT;
return openSucceeded ? NS_OK : NS_ERROR_ABORT;
}
// Where should we open this?