Bug 799348 - When creating a new content window, create the surrounding chrome docshell as system. r=bz

This commit is contained in:
Bobby Holley 2012-10-11 19:44:20 +02:00
parent f1d775755a
commit da4fce7951
5 changed files with 71 additions and 1 deletions

View File

@ -41,6 +41,7 @@ MOCHITEST_CHROME_FILES = \
test_bug773962.xul \
test_bug793433.xul \
test_bug795275.xul \
test_bug799348.xul \
test_APIExposer.xul \
test_chrometoSource.xul \
outoflinexulscript.js \

View File

@ -0,0 +1,50 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=799348
-->
<window title="Mozilla Bug 799348"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=799348"
target="_blank">Mozilla Bug 799348</a>
</body>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
/** Test for Bug 799348 **/
SimpleTest.waitForExplicitFinish();
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
gCalledOnload = false;
var myObserver = {
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIObserver]),
observe: function(win, topic, data) {
if (topic == "domwindowopened") {
ok(!gCalledOnload, "domwindowopened notification fired before onload");
win.addEventListener("load", function(evt) {
gCalledOnload = true;
win.close();
}, false);
} else if (topic == "domwindowclosed") {
ok(gCalledOnload, "should have called onload");
Services.ww.unregisterNotification(myObserver);
SimpleTest.finish();
}
else {
ok(false, "unknown topic");
}
}
};
Services.ww.registerNotification(myObserver);
]]>
</script>
<iframe id="frame" type="content" src="http://test1.example.org/tests/js/xpconnect/tests/mochitest/file_bug799348.html" />
</window>

View File

@ -69,6 +69,7 @@ MOCHITEST_FILES = bug500931_helper.html \
test_bug789713.html \
file_bug795275.html \
file_bug795275.xml \
file_bug799348.html \
file_nodelists.html \
file_exnstack.html \
file_expandosharing.html \

View File

@ -0,0 +1,11 @@
<!DOCTYPE HTML>
<html>
<head>
<script>
var foo = window.open('file_empty.html', '', 'width=550, height=420, status=no, resizable=yes, scrollbars=yes, toolbar=no, left=945, top=225');
</script>
</head>
<body>
</body>
</html>

View File

@ -1746,12 +1746,19 @@ NS_IMETHODIMP nsXULWindow::CreateNewContentWindow(int32_t aChromeFlags,
}
NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE);
// We need to create a chrome window to contain the content window we're about
// to pass back. The subject principal needs to be system while we're creating
// it to make things work right, so push a null cx. See bug 799348 comment 13
// for a description of what happens when we don't.
nsCxPusher pusher;
if (!pusher.PushNull())
return NS_ERROR_FAILURE;
nsCOMPtr<nsIXULWindow> newWindow;
appShell->CreateTopLevelWindow(this, uri,
aChromeFlags, 615, 480,
getter_AddRefs(newWindow));
NS_ENSURE_TRUE(newWindow, NS_ERROR_FAILURE);
pusher.Pop();
// Specify that we want the window to remain locked until the chrome has loaded.
nsXULWindow *xulWin = static_cast<nsXULWindow*>