Bug 554833 - Define 'document' on XPCNativeWrapped windows properly. r=jst
authorBlake Kaplan <mrbkap@gmail.com>
Wed, 24 Mar 2010 19:08:50 -0700
changeset 40557 537a709ba7cea14ad8f1e2c183386ecc4b3bdf0d
parent 40556 07303da1d8266b6ed8920924a767361f24ec3a45
child 40558 0a8b08d8f142570c7bfcb07cb269072eddea813b
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst
bugs554833
milestone1.9.3a5pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
Bug 554833 - Define 'document' on XPCNativeWrapped windows properly. r=jst
dom/base/nsDOMClassInfo.cpp
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -6620,16 +6620,27 @@ nsWindowSH::NewResolve(nsIXPConnectWrapp
       rv = WrapNative(cx, obj, document, &NS_GET_IID(nsIDOMDocument), PR_FALSE,
                       &v, getter_AddRefs(holder));
       NS_ENSURE_SUCCESS(rv, rv);
 
       // The PostCreate hook for the document will handle defining the
       // property
       *objp = obj;
 
+      if (ObjectIsNativeWrapper(cx, obj)) {
+        // Unless our object is a native wrapper, in which case we have to
+        // define it ourselves.
+
+        *_retval = JS_DefineProperty(cx, obj, "document", v, NULL, NULL,
+                                     JSPROP_READONLY | JSPROP_ENUMERATE);
+        if (!*_retval) {
+          return NS_ERROR_UNEXPECTED;
+        }
+      }
+
       return NS_OK;
     }
 
     if (id == sWindow_id) {
       // window should *always* be the outer window object.
       nsGlobalWindow *oldWin = win;
       win = win->GetOuterWindowInternal();
       NS_ENSURE_TRUE(win, NS_ERROR_NOT_AVAILABLE);