Bug 741266. document.open with 3 or more arguments should invoke the scriptable version of window.open, not the noscript one. r=jst

This commit is contained in:
Boris Zbarsky 2012-04-06 17:12:41 -04:00
parent 0782fdf9c0
commit bb8e5969a5
3 changed files with 38 additions and 2 deletions

View File

@ -135,6 +135,7 @@
#include "nsIRequest.h"
#include "nsHtml5TreeOpExecutor.h"
#include "nsHtml5Parser.h"
#include "nsIDOMJSWindow.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -1326,9 +1327,10 @@ nsHTMLDocument::Open(const nsAString& aContentTypeOrUrl,
if (!window) {
return NS_OK;
}
nsCOMPtr<nsIDOMJSWindow> win = do_QueryInterface(window);
nsCOMPtr<nsIDOMWindow> newWindow;
nsresult rv = window->Open(aContentTypeOrUrl, aReplaceOrName, aFeatures,
getter_AddRefs(newWindow));
nsresult rv = win->OpenJS(aContentTypeOrUrl, aReplaceOrName, aFeatures,
getter_AddRefs(newWindow));
*aReturn = newWindow.forget().get();
return rv;
}

View File

@ -107,6 +107,7 @@ _TEST_FILES = test_bug1682.html \
test_bug677495.html \
test_bug677495-1.html \
test_bug742261.html \
test_bug741266.html \
$(NULL)
ifneq (mobile,$(MOZ_BUILD_APP))

View File

@ -0,0 +1,33 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=741266
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 741266</title>
<script type="application/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=741266">Mozilla Bug 741266</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 741266 **/
var w = window.open("", "", "width=100,height=100");
is(w.innerHeight, 100, "Popup height should be 100 when opened with window.open");
is(w.innerWidth, 100, "Popup width should be 100 when opened with window.open");
w.close();
w = document.open("", "", "width=100,height=100");
is(w.innerHeight, 100, "Popup height should be 100 when opened with document.open");
is(w.innerWidth, 100, "Popup width should be 100 when opened with document.open");
w.close();
</script>
</pre>
</body>
</html>