mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-03 12:35:58 +00:00
Bug 500691 - Call JS_ClearScope before XPConnect tries to update our outer window's scope's concept of what {Function,Object}.prototype are so that we forward correctly to the inner window's versions. r=jst sr=bzbarsky
This commit is contained in:
parent
0407de7a49
commit
f8079004d8
@ -2416,11 +2416,6 @@ nsJSContext::ConnectToInner(nsIScriptGlobalObject *aNewInner, void *aOuterGlobal
|
|||||||
JSObject *newInnerJSObject = (JSObject *)aNewInner->GetScriptGlobal(JAVASCRIPT);
|
JSObject *newInnerJSObject = (JSObject *)aNewInner->GetScriptGlobal(JAVASCRIPT);
|
||||||
JSObject *myobject = (JSObject *)aOuterGlobal;
|
JSObject *myobject = (JSObject *)aOuterGlobal;
|
||||||
|
|
||||||
// Call ClearScope to nuke any properties (e.g. Function and Object) on the
|
|
||||||
// outer object. From now on, anybody asking the outer object for these
|
|
||||||
// properties will be forwarded to the inner window.
|
|
||||||
::JS_ClearScope(mContext, myobject);
|
|
||||||
|
|
||||||
// Make the inner and outer window both share the same
|
// Make the inner and outer window both share the same
|
||||||
// prototype. The prototype we share is the outer window's
|
// prototype. The prototype we share is the outer window's
|
||||||
// prototype, this way XPConnect can still find the wrapper to
|
// prototype, this way XPConnect can still find the wrapper to
|
||||||
@ -2520,11 +2515,23 @@ nsJSContext::InitContext(nsIScriptGlobalObject *aGlobalObject)
|
|||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If there's already a global object in mContext we're called
|
// There's already a global object. We are preparing this outer window
|
||||||
// after ::JS_ClearScope() was called. We'll have to tell
|
// object for use as a real outer window (i.e. everything needs to live on
|
||||||
// XPConnect to re-initialize the global object to do things like
|
// the inner window).
|
||||||
|
|
||||||
|
// Call ClearScope to nuke any properties (e.g. Function and Object) on the
|
||||||
|
// outer object. From now on, anybody asking the outer object for these
|
||||||
|
// properties will be forwarded to the inner window.
|
||||||
|
::JS_ClearScope(mContext, global);
|
||||||
|
|
||||||
|
// Tell XPConnect to re-initialize the global object to do things like
|
||||||
// define the Components object on the global again and forget all
|
// define the Components object on the global again and forget all
|
||||||
// old prototypes in this scope.
|
// old prototypes in this scope.
|
||||||
|
// XXX Except that now, the global is thawed and has an inner window. So
|
||||||
|
// anything that XPConnect does to our global will be forwarded. So I
|
||||||
|
// think the only thing that this does for real is to call SetGlobal on
|
||||||
|
// our XPCWrappedNativeScope. Perhaps XPConnect should have a more
|
||||||
|
// targeted API?
|
||||||
rv = xpc->InitClasses(mContext, global);
|
rv = xpc->InitClasses(mContext, global);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
@ -57,6 +57,7 @@ _TEST_FILES = inner.html \
|
|||||||
test_bug478438.html \
|
test_bug478438.html \
|
||||||
test_bug484107.html \
|
test_bug484107.html \
|
||||||
test_bug484459.html \
|
test_bug484459.html \
|
||||||
|
test_bug500691.html \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
libs:: $(_TEST_FILES)
|
libs:: $(_TEST_FILES)
|
||||||
|
28
js/src/xpconnect/tests/mochitest/test_bug500691.html
Normal file
28
js/src/xpconnect/tests/mochitest/test_bug500691.html
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<!--
|
||||||
|
https://bugzilla.mozilla.org/show_bug.cgi?id=500691
|
||||||
|
-->
|
||||||
|
<head>
|
||||||
|
<title>Test for Bug 500691</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=500691">Mozilla Bug 500691</a>
|
||||||
|
<p id="display"></p>
|
||||||
|
<div id="content" style="display: none">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<pre id="test">
|
||||||
|
<script type="application/javascript">
|
||||||
|
|
||||||
|
/** Test for Bug 500691 **/
|
||||||
|
ok(Function === alert.constructor, "alert's constructor is our Function");
|
||||||
|
ok(window.Function === alert.constructor, "window.Function is also correct");
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
x
Reference in New Issue
Block a user