author | Bobby Holley <bobbyholley@gmail.com> |
Tue, 14 Jan 2014 18:49:28 -0800 | |
changeset 163431 | 8773a793e758963998188063314e0d92e8efec9a |
parent 163430 | 1469d62ddbf48b3f78b71e660c90f2b2535fc30d |
child 163432 | 9469174aff9bc98b834c58ba5521d08cd8066279 |
push id | 25996 |
push user | emorley@mozilla.com |
push date | Wed, 15 Jan 2014 15:54:39 +0000 |
treeherder | mozilla-central@dd2cf81c56b7 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mrbkap |
bugs | 951948 |
milestone | 29.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
|
js/xpconnect/src/XPCComponents.cpp | file | annotate | diff | comparison | revisions | |
js/xpconnect/src/xpcprivate.h | file | annotate | diff | comparison | revisions |
--- a/js/xpconnect/src/XPCComponents.cpp +++ b/js/xpconnect/src/XPCComponents.cpp @@ -85,26 +85,24 @@ xpc::CheckAccessList(const char16_t *wid /***************************************************************************/ /***************************************************************************/ /***************************************************************************/ class nsXPCComponents_Interfaces : public nsIXPCComponents_Interfaces, public nsIXPCScriptable, - public nsIClassInfo, - public nsISecurityCheckedComponent + public nsIClassInfo { public: // all the interface method declarations... NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIXPCCOMPONENTS_INTERFACES NS_DECL_NSIXPCSCRIPTABLE NS_DECL_NSICLASSINFO - NS_DECL_NSISECURITYCHECKEDCOMPONENT public: nsXPCComponents_Interfaces(); virtual ~nsXPCComponents_Interfaces(); private: nsCOMArray<nsIInterfaceInfo> mInterfaces; }; @@ -185,17 +183,19 @@ nsXPCComponents_Interfaces::GetImplement *aImplementationLanguage = nsIProgrammingLanguage::CPLUSPLUS; return NS_OK; } /* readonly attribute uint32_t flags; */ NS_IMETHODIMP nsXPCComponents_Interfaces::GetFlags(uint32_t *aFlags) { - *aFlags = nsIClassInfo::THREADSAFE; + // Mark ourselves as a DOM object so that instances may be created in + // unprivileged scopes. + *aFlags = nsIClassInfo::DOM_OBJECT; return NS_OK; } /* [notxpcom] readonly attribute nsCID classIDNoAlloc; */ NS_IMETHODIMP nsXPCComponents_Interfaces::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) { return NS_ERROR_NOT_AVAILABLE; @@ -210,17 +210,16 @@ nsXPCComponents_Interfaces::~nsXPCCompon // empty } NS_INTERFACE_MAP_BEGIN(nsXPCComponents_Interfaces) NS_INTERFACE_MAP_ENTRY(nsIXPCComponents_Interfaces) NS_INTERFACE_MAP_ENTRY(nsIXPCScriptable) NS_INTERFACE_MAP_ENTRY(nsIClassInfo) - NS_INTERFACE_MAP_ENTRY(nsISecurityCheckedComponent) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIXPCComponents_Interfaces) NS_INTERFACE_MAP_END_THREADSAFE NS_IMPL_ADDREF(nsXPCComponents_Interfaces) NS_IMPL_RELEASE(nsXPCComponents_Interfaces) // The nsIXPCScriptable map declaration that will generate stubs for us... #define XPC_MAP_CLASSNAME nsXPCComponents_Interfaces @@ -328,69 +327,31 @@ nsXPCComponents_Interfaces::NewResolve(n JSPROP_PERMANENT); } } } } return NS_OK; } -/* string canCreateWrapper (in nsIIDPtr iid); */ -NS_IMETHODIMP -nsXPCComponents_Interfaces::CanCreateWrapper(const nsIID * iid, char **_retval) -{ - // We let anyone do this... - *_retval = CloneAllAccess(); - return NS_OK; -} - -/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */ -NS_IMETHODIMP -nsXPCComponents_Interfaces::CanCallMethod(const nsIID * iid, const char16_t *methodName, char **_retval) -{ - // If you have to ask, then the answer is NO - *_retval = nullptr; - return NS_OK; -} - -/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */ -NS_IMETHODIMP -nsXPCComponents_Interfaces::CanGetProperty(const nsIID * iid, const char16_t *propertyName, char **_retval) -{ - // If you have to ask, then the answer is NO - *_retval = nullptr; - return NS_OK; -} - -/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */ -NS_IMETHODIMP -nsXPCComponents_Interfaces::CanSetProperty(const nsIID * iid, const char16_t *propertyName, char **_retval) -{ - // If you have to ask, then the answer is NO - *_retval = nullptr; - return NS_OK; -} - /***************************************************************************/ /***************************************************************************/ /***************************************************************************/ class nsXPCComponents_InterfacesByID : public nsIXPCComponents_InterfacesByID, public nsIXPCScriptable, - public nsIClassInfo, - public nsISecurityCheckedComponent + public nsIClassInfo { public: // all the interface method declarations... NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIXPCCOMPONENTS_INTERFACESBYID NS_DECL_NSIXPCSCRIPTABLE NS_DECL_NSICLASSINFO - NS_DECL_NSISECURITYCHECKEDCOMPONENT public: nsXPCComponents_InterfacesByID(); virtual ~nsXPCComponents_InterfacesByID(); private: nsCOMArray<nsIInterfaceInfo> mInterfaces; }; @@ -472,17 +433,19 @@ nsXPCComponents_InterfacesByID::GetImple *aImplementationLanguage = nsIProgrammingLanguage::CPLUSPLUS; return NS_OK; } /* readonly attribute uint32_t flags; */ NS_IMETHODIMP nsXPCComponents_InterfacesByID::GetFlags(uint32_t *aFlags) { - *aFlags = nsIClassInfo::THREADSAFE; + // Mark ourselves as a DOM object so that instances may be created in + // unprivileged scopes. + *aFlags = nsIClassInfo::DOM_OBJECT; return NS_OK; } /* [notxpcom] readonly attribute nsCID classIDNoAlloc; */ NS_IMETHODIMP nsXPCComponents_InterfacesByID::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) { return NS_ERROR_NOT_AVAILABLE; @@ -496,17 +459,16 @@ nsXPCComponents_InterfacesByID::~nsXPCCo { // empty } NS_INTERFACE_MAP_BEGIN(nsXPCComponents_InterfacesByID) NS_INTERFACE_MAP_ENTRY(nsIXPCComponents_InterfacesByID) NS_INTERFACE_MAP_ENTRY(nsIXPCScriptable) NS_INTERFACE_MAP_ENTRY(nsIClassInfo) - NS_INTERFACE_MAP_ENTRY(nsISecurityCheckedComponent) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIXPCComponents_InterfacesByID) NS_INTERFACE_MAP_END_THREADSAFE NS_IMPL_ADDREF(nsXPCComponents_InterfacesByID) NS_IMPL_RELEASE(nsXPCComponents_InterfacesByID) // The nsIXPCScriptable map declaration that will generate stubs for us... #define XPC_MAP_CLASSNAME nsXPCComponents_InterfacesByID @@ -621,52 +583,16 @@ nsXPCComponents_InterfacesByID::NewResol JSPROP_READONLY | JSPROP_PERMANENT); } } } return NS_OK; } -/* string canCreateWrapper (in nsIIDPtr iid); */ -NS_IMETHODIMP -nsXPCComponents_InterfacesByID::CanCreateWrapper(const nsIID * iid, char **_retval) -{ - // We let anyone do this... - *_retval = CloneAllAccess(); - return NS_OK; -} - -/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */ -NS_IMETHODIMP -nsXPCComponents_InterfacesByID::CanCallMethod(const nsIID * iid, const char16_t *methodName, char **_retval) -{ - // If you have to ask, then the answer is NO - *_retval = nullptr; - return NS_OK; -} - -/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */ -NS_IMETHODIMP -nsXPCComponents_InterfacesByID::CanGetProperty(const nsIID * iid, const char16_t *propertyName, char **_retval) -{ - // If you have to ask, then the answer is NO - *_retval = nullptr; - return NS_OK; -} - -/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */ -NS_IMETHODIMP -nsXPCComponents_InterfacesByID::CanSetProperty(const nsIID * iid, const char16_t *propertyName, char **_retval) -{ - // If you have to ask, then the answer is NO - *_retval = nullptr; - return NS_OK; -} - /***************************************************************************/ /***************************************************************************/ /***************************************************************************/ class nsXPCComponents_Classes : public nsIXPCComponents_Classes, @@ -761,17 +687,17 @@ nsXPCComponents_Classes::GetImplementati *aImplementationLanguage = nsIProgrammingLanguage::CPLUSPLUS; return NS_OK; } /* readonly attribute uint32_t flags; */ NS_IMETHODIMP nsXPCComponents_Classes::GetFlags(uint32_t *aFlags) { - *aFlags = nsIClassInfo::THREADSAFE; + *aFlags = 0; return NS_OK; } /* [notxpcom] readonly attribute nsCID classIDNoAlloc; */ NS_IMETHODIMP nsXPCComponents_Classes::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) { return NS_ERROR_NOT_AVAILABLE; @@ -1002,17 +928,17 @@ nsXPCComponents_ClassesByID::GetImplemen *aImplementationLanguage = nsIProgrammingLanguage::CPLUSPLUS; return NS_OK; } /* readonly attribute uint32_t flags; */ NS_IMETHODIMP nsXPCComponents_ClassesByID::GetFlags(uint32_t *aFlags) { - *aFlags = nsIClassInfo::THREADSAFE; + *aFlags = 0; return NS_OK; } /* [notxpcom] readonly attribute nsCID classIDNoAlloc; */ NS_IMETHODIMP nsXPCComponents_ClassesByID::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) { return NS_ERROR_NOT_AVAILABLE; @@ -1265,17 +1191,19 @@ nsXPCComponents_Results::GetImplementati *aImplementationLanguage = nsIProgrammingLanguage::CPLUSPLUS; return NS_OK; } /* readonly attribute uint32_t flags; */ NS_IMETHODIMP nsXPCComponents_Results::GetFlags(uint32_t *aFlags) { - *aFlags = nsIClassInfo::THREADSAFE; + // Mark ourselves as a DOM object so that instances may be created in + // unprivileged scopes. + *aFlags = nsIClassInfo::DOM_OBJECT; return NS_OK; } /* [notxpcom] readonly attribute nsCID classIDNoAlloc; */ NS_IMETHODIMP nsXPCComponents_Results::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) { return NS_ERROR_NOT_AVAILABLE; @@ -1487,17 +1415,17 @@ nsXPCComponents_ID::GetImplementationLan *aImplementationLanguage = nsIProgrammingLanguage::CPLUSPLUS; return NS_OK; } /* readonly attribute uint32_t flags; */ NS_IMETHODIMP nsXPCComponents_ID::GetFlags(uint32_t *aFlags) { - *aFlags = nsIClassInfo::THREADSAFE; + *aFlags = 0; return NS_OK; } /* [notxpcom] readonly attribute nsCID classIDNoAlloc; */ NS_IMETHODIMP nsXPCComponents_ID::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) { return NS_ERROR_NOT_AVAILABLE; @@ -1706,17 +1634,17 @@ nsXPCComponents_Exception::GetImplementa *aImplementationLanguage = nsIProgrammingLanguage::CPLUSPLUS; return NS_OK; } /* readonly attribute uint32_t flags; */ NS_IMETHODIMP nsXPCComponents_Exception::GetFlags(uint32_t *aFlags) { - *aFlags = nsIClassInfo::THREADSAFE; + *aFlags = 0; return NS_OK; } /* [notxpcom] readonly attribute nsCID classIDNoAlloc; */ NS_IMETHODIMP nsXPCComponents_Exception::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) { return NS_ERROR_NOT_AVAILABLE; @@ -2095,17 +2023,17 @@ nsXPCConstructor::GetImplementationLangu *aImplementationLanguage = nsIProgrammingLanguage::CPLUSPLUS; return NS_OK; } /* readonly attribute uint32_t flags; */ NS_IMETHODIMP nsXPCConstructor::GetFlags(uint32_t *aFlags) { - *aFlags = nsIClassInfo::THREADSAFE; + *aFlags = 0; return NS_OK; } /* [notxpcom] readonly attribute nsCID classIDNoAlloc; */ NS_IMETHODIMP nsXPCConstructor::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) { return NS_ERROR_NOT_AVAILABLE; @@ -2350,17 +2278,17 @@ nsXPCComponents_Constructor::GetImplemen *aImplementationLanguage = nsIProgrammingLanguage::CPLUSPLUS; return NS_OK; } /* readonly attribute uint32_t flags; */ NS_IMETHODIMP nsXPCComponents_Constructor::GetFlags(uint32_t *aFlags) { - *aFlags = nsIClassInfo::THREADSAFE; + *aFlags = 0; return NS_OK; } /* [notxpcom] readonly attribute nsCID classIDNoAlloc; */ NS_IMETHODIMP nsXPCComponents_Constructor::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) { return NS_ERROR_NOT_AVAILABLE; @@ -2572,38 +2500,35 @@ nsXPCComponents_Constructor::HasInstance RootedValue v(cx, val); if (bp) *bp = JSValIsInterfaceOfType(cx, v, NS_GET_IID(nsIXPCConstructor)); return NS_OK; } class nsXPCComponents_Utils : public nsIXPCComponents_Utils, - public nsIXPCScriptable, - public nsISecurityCheckedComponent + public nsIXPCScriptable { public: // all the interface method declarations... NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIXPCSCRIPTABLE - NS_DECL_NSISECURITYCHECKEDCOMPONENT NS_DECL_NSIXPCCOMPONENTS_UTILS public: nsXPCComponents_Utils() { } virtual ~nsXPCComponents_Utils() { } private: nsCOMPtr<nsIXPCComponents_utils_Sandbox> mSandbox; }; NS_INTERFACE_MAP_BEGIN(nsXPCComponents_Utils) NS_INTERFACE_MAP_ENTRY(nsIXPCComponents_Utils) NS_INTERFACE_MAP_ENTRY(nsIXPCScriptable) - NS_INTERFACE_MAP_ENTRY(nsISecurityCheckedComponent) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIXPCComponents_Utils) NS_INTERFACE_MAP_END_THREADSAFE NS_IMPL_ADDREF(nsXPCComponents_Utils) NS_IMPL_RELEASE(nsXPCComponents_Utils) // The nsIXPCScriptable map declaration that will generate stubs for us... #define XPC_MAP_CLASSNAME nsXPCComponents_Utils @@ -3317,51 +3242,16 @@ nsXPCComponents_Utils::Dispatch(const js getter_AddRefs(run)); NS_ENSURE_SUCCESS(rv, rv); MOZ_ASSERT(run); // Dispatch. return NS_DispatchToMainThread(run); } -/* string canCreateWrapper (in nsIIDPtr iid); */ -NS_IMETHODIMP -nsXPCComponents_Utils::CanCreateWrapper(const nsIID * iid, char **_retval) -{ - // We let anyone do this... - *_retval = CloneAllAccess(); - return NS_OK; -} - -/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */ -NS_IMETHODIMP -nsXPCComponents_Utils::CanCallMethod(const nsIID * iid, const char16_t *methodName, char **_retval) -{ - static const char* const allowed[] = { "evalInSandbox", nullptr }; - *_retval = CheckAccessList(methodName, allowed); - return NS_OK; -} - -/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */ -NS_IMETHODIMP -nsXPCComponents_Utils::CanGetProperty(const nsIID * iid, const char16_t *propertyName, char **_retval) -{ - *_retval = nullptr; - return NS_OK; -} - -/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */ -NS_IMETHODIMP -nsXPCComponents_Utils::CanSetProperty(const nsIID * iid, const char16_t *propertyName, char **_retval) -{ - // If you have to ask, then the answer is NO - *_retval = nullptr; - return NS_OK; -} - #define GENERATE_JSOPTION_GETTER_SETTER(_attr, _getter, _setter) \ NS_IMETHODIMP \ nsXPCComponents_Utils::Get## _attr(JSContext* cx, bool* aValue) \ { \ *aValue = ContextOptionsRef(cx)._getter(); \ return NS_OK; \ } \ NS_IMETHODIMP \ @@ -3578,17 +3468,16 @@ nsXPCComponents_Utils::GetWatchdogTimest // XXXjband We ought to cache the wrapper in the object's slots rather than // re-wrapping on demand NS_INTERFACE_MAP_BEGIN(nsXPCComponents) NS_INTERFACE_MAP_ENTRY(nsIXPCComponents) NS_INTERFACE_MAP_ENTRY(nsIXPCScriptable) NS_INTERFACE_MAP_ENTRY(nsIClassInfo) - NS_INTERFACE_MAP_ENTRY(nsISecurityCheckedComponent) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIXPCComponents) NS_INTERFACE_MAP_END_THREADSAFE NS_IMPL_ADDREF(nsXPCComponents) NS_IMPL_RELEASE(nsXPCComponents) /* void getInterfaces (out uint32_t count, [array, size_is (count), retval] out nsIIDPtr array); */ @@ -3668,17 +3557,19 @@ nsXPCComponents::GetImplementationLangua *aImplementationLanguage = nsIProgrammingLanguage::CPLUSPLUS; return NS_OK; } /* readonly attribute uint32_t flags; */ NS_IMETHODIMP nsXPCComponents::GetFlags(uint32_t *aFlags) { - *aFlags = nsIClassInfo::THREADSAFE; + // Mark ourselves as a DOM object so that instances may be created in + // unprivileged scopes. + *aFlags = nsIClassInfo::DOM_OBJECT; return NS_OK; } /* [notxpcom] readonly attribute nsCID classIDNoAlloc; */ NS_IMETHODIMP nsXPCComponents::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) { return NS_ERROR_NOT_AVAILABLE; @@ -3840,52 +3731,16 @@ NS_IMETHODIMP nsXPCComponents::ReportErr nsCOMPtr<nsIXPCComponents_Utils> utils; nsresult rv = GetUtils(getter_AddRefs(utils)); if (NS_FAILED(rv)) return rv; return utils->ReportError(error, cx); } -/* string canCreateWrapper (in nsIIDPtr iid); */ -NS_IMETHODIMP -nsXPCComponents::CanCreateWrapper(const nsIID * iid, char **_retval) -{ - // We let anyone do this... - *_retval = CloneAllAccess(); - return NS_OK; -} - -/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */ -NS_IMETHODIMP -nsXPCComponents::CanCallMethod(const nsIID * iid, const char16_t *methodName, char **_retval) -{ - static const char* const allowed[] = { "isSuccessCode", nullptr }; - *_retval = CheckAccessList(methodName, allowed); - return NS_OK; -} - -/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */ -NS_IMETHODIMP -nsXPCComponents::CanGetProperty(const nsIID * iid, const char16_t *propertyName, char **_retval) -{ - static const char* const allowed[] = { "interfaces", "interfacesByID", "results", nullptr}; - *_retval = CheckAccessList(propertyName, allowed); - return NS_OK; -} - -/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */ -NS_IMETHODIMP -nsXPCComponents::CanSetProperty(const nsIID * iid, const char16_t *propertyName, char **_retval) -{ - // If you have to ask, then the answer is NO - *_retval = nullptr; - return NS_OK; -} - NS_IMETHODIMP nsXPCComponents::PreCreate(nsISupports *nativeObj, JSContext *cx, JSObject *globalObj, JSObject **parentObj) { // this should never happen if (!mScope) { NS_WARNING("mScope must not be null when nsXPCComponents::PreCreate is called"); return NS_ERROR_FAILURE; }
--- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -2917,25 +2917,23 @@ private: JSContext* mSafeJSContext; }; /***************************************************************************/ // 'Components' object class nsXPCComponents : public nsIXPCComponents, public nsIXPCScriptable, - public nsIClassInfo, - public nsISecurityCheckedComponent + public nsIClassInfo { public: NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIXPCCOMPONENTS NS_DECL_NSIXPCSCRIPTABLE NS_DECL_NSICLASSINFO - NS_DECL_NSISECURITYCHECKEDCOMPONENT public: static bool AttachComponentsObject(JSContext* aCx, XPCWrappedNativeScope* aScope); void SystemIsBeingShutDown() {ClearMembers();} virtual ~nsXPCComponents();