Bug 545314 - Force an inner window here so that we return a working location object. r=peterv

This commit is contained in:
Blake Kaplan 2010-05-28 15:40:29 -07:00
parent b57a6ad5d3
commit 54ca1d9bd6
3 changed files with 37 additions and 0 deletions

View File

@ -6590,6 +6590,12 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
// here) since we must define window.location to prevent the
// getter from being overriden (for security reasons).
// Note: Because we explicitly don't forward to the inner window
// above, we have to ensure here that our window has a current
// inner window so that the location object we return will work.
win->EnsureInnerWindow();
nsCOMPtr<nsIDOMLocation> location;
rv = win->GetLocation(getter_AddRefs(location));
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -114,6 +114,7 @@ _TEST_FILES = \
test_bug534149.html \
test_bug558973.html \
test_bug563487.html \
test_bug545314.html \
test_bug548828.html \
$(NULL)

View File

@ -0,0 +1,30 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=545314
-->
<head>
<title>Test for Bug 545314</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<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=545314">Mozilla Bug 545314</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<iframe id="ifr"></iframe>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 545314 **/
var frame = window.frames[0];
frame.location.assign("http://localhost:8888/");
ok(true, "location.assign didn't throw");
</script>
</pre>
</body>
</html>