Bug 795275 - Turn Components into a JS value getter for content scopes. r=mrbkap
authorBobby Holley <bobbyholley@gmail.com>
Wed, 03 Oct 2012 11:44:18 +0200
changeset 109031 43de19945cb1beacc8d20595627216e7b76f4954
parent 109030 fb8bb92771523f9a59d125b6775b403ef7a29906
child 109032 aeda4978c97c9c65cd73bc98b7c23b08bd3f9163
push id23602
push useremorley@mozilla.com
push dateWed, 03 Oct 2012 12:57:12 +0000
treeherdermozilla-central@5ac283a12f02 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs795275
milestone18.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 795275 - Turn Components into a JS value getter for content scopes. r=mrbkap
js/xpconnect/src/XPCComponents.cpp
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -4765,35 +4765,43 @@ nsXPCComponents::SetProperty(nsIXPConnec
             return NS_SUCCESS_I_DID_SOMETHING;
         }
         return NS_ERROR_FAILURE;
     }
 
     return NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN;
 }
 
+static JSBool
+ContentComponentsGetterOp(JSContext *cx, JSHandleObject obj, JSHandleId id,
+                          JSMutableHandleValue vp)
+{
+    return true;
+}
+
 // static
 JSBool
 nsXPCComponents::AttachComponentsObject(XPCCallContext& ccx,
                                         XPCWrappedNativeScope* aScope,
                                         JSObject* aTarget)
 {
     JSObject *components = aScope->GetComponentsJSObject(ccx);
     if (!components)
         return false;
 
     JSObject *global = aScope->GetGlobalJSObject();
     MOZ_ASSERT(js::IsObjectInContextCompartment(global, ccx));
     if (!aTarget)
         aTarget = global;
 
     jsid id = ccx.GetRuntime()->GetStringID(XPCJSRuntime::IDX_COMPONENTS);
+    JSPropertyOp getter = AccessCheck::isChrome(global) ? nullptr
+                                                        : &ContentComponentsGetterOp;
     return JS_DefinePropertyById(ccx, aTarget, id, js::ObjectValue(*components),
-                                 nullptr, nullptr,
-                                 JSPROP_PERMANENT | JSPROP_READONLY);
+                                 getter, nullptr, JSPROP_PERMANENT | JSPROP_READONLY);
 }
 
 /* void lookupMethod (); */
 NS_IMETHODIMP
 nsXPCComponents::LookupMethod(const JS::Value& object,
                               const JS::Value& name,
                               JSContext *cx,
                               JS::Value *retval)