Fixing bug 414291. Make window.open() ignore modal=yes for backwards compatibility. r+sr=bzbarsky@mit.edu and jonas@sicking.cc

This commit is contained in:
jst@mozilla.org 2008-03-14 14:31:24 -07:00
Родитель 21356f92ba
Коммит 630d5b60da
4 изменённых файлов: 45 добавлений и 4 удалений

Просмотреть файл

@ -5884,7 +5884,7 @@ nsGlobalWindow::ShowModalDialog(const nsAString& aURI, nsIVariant *aArgs,
*aRetVal = nsnull;
nsCOMPtr<nsIDOMWindow> dlgWin;
nsAutoString options(NS_LITERAL_STRING("modal=1,status=1"));
nsAutoString options(NS_LITERAL_STRING("-moz-internal-modal=1,status=1"));
ConvertDialogOptions(aOptions, options);

Просмотреть файл

@ -67,6 +67,7 @@ _TEST_FILES = \
test_bug409349.html \
iframe_bug409349.html \
test_bug411103.html \
test_bug414291.html \
$(NULL)
libs:: $(_TEST_FILES)

Просмотреть файл

@ -0,0 +1,34 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=414291
-->
<head>
<title>Test for Bug 414291</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.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=414291">Mozilla Bug 414291</a>
<script class="testbody" type="text/javascript">
/** Test for Bug 414291 **/
var result1 = 0;
var result2 = 0;
var result3 = 0;
window.open("data:text/html,<html><body onload='close(); opener.result1 = 1;'>", "w1");
is(result1, 0, "window either opened as modal or loaded synchronously.");
window.open("data:text/html,<html><body onload='close(); opener.result2 = 2;'>", "w2", "modal=yes");
is(result2, 0, "window either opened as modal or data loaded synchronously.");
result3 = window.showModalDialog("data:text/html,<html><body onload='close(); returnValue = 3;'>");
is(result3, 3, "window didn't open as modal.");
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -556,9 +556,14 @@ nsWindowWatcher::OpenWindowJSInternal(nsIDOMWindow *aParent,
aDialog, uriToLoadIsChrome,
!aParent || chromeParent);
if ((chromeFlags & nsIWebBrowserChrome::CHROME_MODAL) &&
!(chromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME)) {
// If we're not called through our JS version of the API, and we got
// our internal modal option, treat the window we're opening as a
// modal content window (and set the modal chrome flag).
if (!aCalledFromJS && argv &&
WinHasOption(features.get(), "-moz-internal-modal", 0, nsnull)) {
windowIsModalContentDialog = PR_TRUE;
chromeFlags |= nsIWebBrowserChrome::CHROME_MODAL;
}
SizeSpec sizeSpec;
@ -1541,7 +1546,8 @@ PRUint32 nsWindowWatcher::CalculateChromeFlags(const char *aFeatures,
prevents untrusted script from opening modal windows in general
while still allowing alerts and the like. */
if (!aChromeURL)
chromeFlags &= ~nsIWebBrowserChrome::CHROME_OPENAS_CHROME;
chromeFlags &= ~(nsIWebBrowserChrome::CHROME_MODAL |
nsIWebBrowserChrome::CHROME_OPENAS_CHROME);
}
if (!(chromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME)) {