mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
bug 308856: Make sure that we enumerate over the inner window object, since no properties are actually stored on the outer window's js object. r=brendan sr=jst
This commit is contained in:
parent
4361539600
commit
6a80c2c3e3
@ -408,7 +408,7 @@ static const char kDOMStringBundleURL[] =
|
||||
nsIXPCScriptable::WANT_FINALIZE | \
|
||||
nsIXPCScriptable::WANT_ADDPROPERTY | \
|
||||
nsIXPCScriptable::WANT_DELPROPERTY | \
|
||||
nsIXPCScriptable::WANT_ENUMERATE | \
|
||||
nsIXPCScriptable::WANT_NEWENUMERATE | \
|
||||
nsIXPCScriptable::WANT_EQUALITY | \
|
||||
nsIXPCScriptable::WANT_OUTER_OBJECT | \
|
||||
nsIXPCScriptable::DONT_ENUM_QUERY_INTERFACE)
|
||||
@ -5964,6 +5964,72 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
_retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowSH::NewEnumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, PRUint32 enum_op, jsval *statep,
|
||||
jsid *idp, PRBool *_retval)
|
||||
{
|
||||
switch (enum_op) {
|
||||
case JSENUMERATE_INIT:
|
||||
{
|
||||
// First, do the security check that nsDOMClassInfo does to see if we need to
|
||||
// do any work at all.
|
||||
nsDOMClassInfo::Enumerate(wrapper, cx, obj, _retval);
|
||||
if (!*_retval) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// The security check passed, let's see if we need to get the inner
|
||||
// window's JS object or if we can just start enumerating.
|
||||
nsGlobalWindow *win = nsGlobalWindow::FromWrapper(wrapper);
|
||||
JSObject *enumobj = win->GetGlobalJSObject();
|
||||
if (win->IsOuterWindow()) {
|
||||
nsGlobalWindow *inner = win->GetCurrentInnerWindowInternal();
|
||||
if (inner) {
|
||||
enumobj = inner->GetGlobalJSObject();
|
||||
}
|
||||
}
|
||||
|
||||
// Great, we have the js object, now let's enumerate it.
|
||||
JSObject *iterator = JS_NewPropertyIterator(cx, enumobj);
|
||||
if (!iterator) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
*statep = OBJECT_TO_JSVAL(iterator);
|
||||
if (idp) {
|
||||
// Note: With these property iterators, we can't tell ahead of time how
|
||||
// many properties we're going to be iterating over.
|
||||
*idp = JSVAL_ZERO;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case JSENUMERATE_NEXT:
|
||||
{
|
||||
JSObject *iterator = (JSObject*)JSVAL_TO_OBJECT(*statep);
|
||||
if (!JS_NextProperty(cx, iterator, idp)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
if (*idp != JSVAL_VOID) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Fall through.
|
||||
}
|
||||
case JSENUMERATE_DESTROY:
|
||||
// Let GC at our iterator object.
|
||||
*statep = JSVAL_NULL;
|
||||
break;
|
||||
|
||||
default:
|
||||
NS_NOTREACHED("Bad call from the JS engine");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowSH::Finalize(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj)
|
||||
|
@ -435,6 +435,9 @@ public:
|
||||
NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, PRUint32 flags,
|
||||
JSObject **objp, PRBool *_retval);
|
||||
NS_IMETHOD NewEnumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, PRUint32 enum_op, jsval *statep,
|
||||
jsid *id, PRBool *_retval);
|
||||
NS_IMETHOD Finalize(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj);
|
||||
NS_IMETHOD Equality(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
|
||||
|
Loading…
Reference in New Issue
Block a user