Backing out part of bug 483672 to see if this part is what caused the performance regression.
authorJohnny Stenback <jst@mozilla.com>
Thu, 21 May 2009 20:27:30 -0700
changeset 28714 ed1f93938bf528ae39397637c26112eb1128726a
parent 28713 5a34c5c12c37c46a12408a239ac071912d572b5d
child 28715 d37e68656412544a8cd7c2f3622d21daf20c0ad3
push id7204
push userjst@mozilla.com
push dateFri, 22 May 2009 03:28:18 +0000
treeherdermozilla-central@ed1f93938bf5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs483672
milestone1.9.2a1pre
Backing out part of bug 483672 to see if this part is what caused the performance regression.
js/src/xpconnect/src/xpcwrappedjsclass.cpp
--- a/js/src/xpconnect/src/xpcwrappedjsclass.cpp
+++ b/js/src/xpconnect/src/xpcwrappedjsclass.cpp
@@ -549,77 +549,16 @@ GetContextFromObject(JSObject *obj)
         JSContext *cx = xpcc->GetJSContext();
         if(cx->thread->id == js_CurrentThreadId())
             return cx;
     }
 
     return nsnull;
 }
 
-#ifndef XPCONNECT_STANDALONE
-class SameOriginCheckedComponent : public nsISecurityCheckedComponent
-{
-public:
-    SameOriginCheckedComponent(nsXPCWrappedJS* delegate)
-        : mDelegate(delegate)
-    {}
-
-    NS_DECL_ISUPPORTS
-    NS_DECL_NSISECURITYCHECKEDCOMPONENT
-
-private:
-    nsRefPtr<nsXPCWrappedJS> mDelegate;
-};
-
-NS_IMPL_ADDREF(SameOriginCheckedComponent)
-NS_IMPL_RELEASE(SameOriginCheckedComponent)
-
-NS_INTERFACE_MAP_BEGIN(SameOriginCheckedComponent)
-    NS_INTERFACE_MAP_ENTRY(nsISecurityCheckedComponent)
-NS_INTERFACE_MAP_END_AGGREGATED(mDelegate)
-
-NS_IMETHODIMP
-SameOriginCheckedComponent::CanCreateWrapper(const nsIID * iid,
-                                             char **_retval NS_OUTPARAM)
-{
-    // XXX This doesn't actually work because nsScriptSecurityManager doesn't
-    // know what to do with "sameOrigin" for canCreateWrapper.
-    *_retval = NS_strdup("sameOrigin");
-    return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
-}
-
-NS_IMETHODIMP
-SameOriginCheckedComponent::CanCallMethod(const nsIID * iid,
-                                          const PRUnichar *methodName,
-                                          char **_retval NS_OUTPARAM)
-{
-    *_retval = NS_strdup("sameOrigin");
-    return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
-}
-
-NS_IMETHODIMP
-SameOriginCheckedComponent::CanGetProperty(const nsIID * iid,
-                                           const PRUnichar *propertyName,
-                                           char **_retval NS_OUTPARAM)
-{
-    *_retval = NS_strdup("sameOrigin");
-    return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
-}
-
-NS_IMETHODIMP
-SameOriginCheckedComponent::CanSetProperty(const nsIID * iid,
-                                           const PRUnichar *propertyName,
-                                           char **_retval NS_OUTPARAM)
-{
-    *_retval = NS_strdup("sameOrigin");
-    return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
-}
-
-#endif
-
 NS_IMETHODIMP
 nsXPCWrappedJSClass::DelegatedQueryInterface(nsXPCWrappedJS* self,
                                              REFNSIID aIID,
                                              void** aInstancePtr)
 {
     if(aIID.Equals(NS_GET_IID(nsIXPConnectJSObjectHolder)))
     {
         NS_ADDREF(self);
@@ -715,61 +654,46 @@ nsXPCWrappedJSClass::DelegatedQueryInter
     }
 
     // else we do the more expensive stuff...
 
 #ifndef XPCONNECT_STANDALONE
     // Before calling out, ensure that we're not about to claim to implement
     // nsISecurityCheckedComponent for an untrusted object. Doing so causes
     // problems. See bug 352882.
-    // But if this is a content object, then we might be wrapping it for
-    // content. If our JS object isn't a double-wrapped object (that is, we
-    // don't have XPCWrappedJS(XPCWrappedNative(some C++ object))), then it
-    // definitely will not have classinfo (and therefore won't be a DOM
-    // object). Since content wants to be able to use these objects (directly
-    // or indirectly, see bug 483672), we implement nsISecurityCheckedComponent
-    // for them and tell caps that they are also bound by the same origin
-    // model.
 
     if(aIID.Equals(NS_GET_IID(nsISecurityCheckedComponent)))
     {
         // XXX This code checks to see if the given object has chrome (also
         // known as system) principals. It really wants to do a
         // UniversalXPConnect type check.
 
-        *aInstancePtr = nsnull;
-
-        if(!XPCPerThreadData::IsMainThread(ccx.GetJSContext()))
-            return NS_NOINTERFACE;
-
         nsXPConnect *xpc = nsXPConnect::GetXPConnect();
         nsCOMPtr<nsIScriptSecurityManager> secMan =
             do_QueryInterface(xpc->GetDefaultSecurityManager());
         if(!secMan)
+        {
+            *aInstancePtr = nsnull;
             return NS_NOINTERFACE;
-
-        JSObject *selfObj = self->GetJSObject();
+        }
         nsCOMPtr<nsIPrincipal> objPrin;
-        nsresult rv = secMan->GetObjectPrincipal(ccx, selfObj,
+        nsresult rv = secMan->GetObjectPrincipal(ccx, self->GetJSObject(),
                                                  getter_AddRefs(objPrin));
-        if(NS_FAILED(rv))
-            return rv;
+        if(NS_SUCCEEDED(rv))
+        {
+            nsCOMPtr<nsIPrincipal> systemPrin;
+            rv = secMan->GetSystemPrincipal(getter_AddRefs(systemPrin));
+            if(systemPrin != objPrin)
+                rv = NS_NOINTERFACE;
+        }
 
-        PRBool isSystem;
-        rv = secMan->IsSystemPrincipal(objPrin, &isSystem);
-        if((NS_FAILED(rv) || !isSystem) &&
-           !IS_WRAPPER_CLASS(STOBJ_GET_CLASS(selfObj)))
+        if(NS_FAILED(rv))
         {
-            // A content object.
-            nsRefPtr<SameOriginCheckedComponent> checked =
-                new SameOriginCheckedComponent(self);
-            if(!checked)
-                return NS_ERROR_OUT_OF_MEMORY;
-            *aInstancePtr = checked.forget().get();
-            return NS_OK;
+            *aInstancePtr = nsnull;
+            return rv;
         }
     }
 #endif
 
     // check if the JSObject claims to implement this interface
     JSObject* jsobj = CallQueryInterfaceOnJSObject(ccx, self->GetJSObject(),
                                                    aIID);
     if(jsobj)