Bug 765527. r=mrbkap

This commit is contained in:
Andrew McCreight 2012-08-25 14:56:45 -07:00
parent d8dbdf5d60
commit d22deaa03b
2 changed files with 27 additions and 0 deletions

View File

@ -1851,6 +1851,7 @@ jsid nsDOMClassInfo::sItem_id = JSID_VOID;
jsid nsDOMClassInfo::sNamedItem_id = JSID_VOID;
jsid nsDOMClassInfo::sEnumerate_id = JSID_VOID;
jsid nsDOMClassInfo::sNavigator_id = JSID_VOID;
jsid nsDOMClassInfo::sTop_id = JSID_VOID;
jsid nsDOMClassInfo::sDocument_id = JSID_VOID;
jsid nsDOMClassInfo::sFrames_id = JSID_VOID;
jsid nsDOMClassInfo::sSelf_id = JSID_VOID;
@ -2130,6 +2131,7 @@ nsDOMClassInfo::DefineStaticJSVals(JSContext *cx)
SET_JSID_TO_STRING(sNamedItem_id, cx, "namedItem");
SET_JSID_TO_STRING(sEnumerate_id, cx, "enumerateProperties");
SET_JSID_TO_STRING(sNavigator_id, cx, "navigator");
SET_JSID_TO_STRING(sTop_id, cx, "top");
SET_JSID_TO_STRING(sDocument_id, cx, "document");
SET_JSID_TO_STRING(sFrames_id, cx, "frames");
SET_JSID_TO_STRING(sSelf_id, cx, "self");
@ -5246,6 +5248,7 @@ nsDOMClassInfo::ShutDown()
sItem_id = JSID_VOID;
sEnumerate_id = JSID_VOID;
sNavigator_id = JSID_VOID;
sTop_id = JSID_VOID;
sDocument_id = JSID_VOID;
sFrames_id = JSID_VOID;
sSelf_id = JSID_VOID;
@ -7350,6 +7353,29 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
return NS_OK;
}
if (sTop_id == id) {
nsCOMPtr<nsIDOMWindow> top;
rv = win->GetScriptableTop(getter_AddRefs(top));
NS_ENSURE_SUCCESS(rv, rv);
jsval v;
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
rv = WrapNative(cx, obj, top, &NS_GET_IID(nsIDOMWindow), true,
&v, getter_AddRefs(holder));
NS_ENSURE_SUCCESS(rv, rv);
// Hold on to the top window object as a global property so we
// don't need to worry about losing expando properties etc.
if (!::JS_DefinePropertyById(cx, obj, id, v, nullptr, nullptr,
JSPROP_READONLY | JSPROP_PERMANENT |
JSPROP_ENUMERATE)) {
return NS_ERROR_FAILURE;
}
*objp = obj;
return NS_OK;
}
if (sDocument_id == id) {
nsCOMPtr<nsIDocument> document = win->GetDoc();
JS::Value v;

View File

@ -243,6 +243,7 @@ public:
static jsid sNamedItem_id;
static jsid sEnumerate_id;
static jsid sNavigator_id;
static jsid sTop_id;
static jsid sDocument_id;
static jsid sFrames_id;
static jsid sSelf_id;