author | Ryan VanderMeulen <ryanvm@gmail.com> |
Tue, 24 Apr 2012 22:09:23 -0400 | |
changeset 96427 | 9c5557c4d1fe84b3c8c9e52f73a872e77724112d |
parent 96426 | 46f40f1d0da2615b1a69431bb5266bc5394b2956 |
child 96428 | 1ea9d262f0dd5beb61fda8093f999ab4bb6d5795 |
push id | 1116 |
push user | lsblakk@mozilla.com |
push date | Mon, 16 Jul 2012 19:38:18 +0000 |
treeherder | mozilla-beta@95f959a8b4dc [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
bugs | 735280 |
milestone | 15.0a1 |
backs out | 0b170d1f5d105ab22cf2679ff2b199ed82235860 |
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
|
--- a/caps/tests/mochitest/test_bug246699.html +++ b/caps/tests/mochitest/test_bug246699.html @@ -1,39 +1,34 @@ <!DOCTYPE HTML> <html> <!-- https://bugzilla.mozilla.org/show_bug.cgi?id=246699 --> <head> <title>Test for Bug 246699</title> - <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> </head> <body> <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=246699">Mozilla Bug 246699</a> <p id="display"></p> <div id="content" style="display: none"> -<iframe id="load-frame"></iframe> +<iframe id="load-frame"></iframe> </div> <pre id="test"> <script class="testbody" type="text/javascript"> /** ** Test for Bug 246699 ** (should produce stack information for caps errors) **/ -function isError(e) -{ - return e.constructor.name === "Error" || e.constructor.name === "TypeError"; -} - function hasStack(e) { - return isError(e) && /inciteCaps/.test(e.stack); + return e.constructor.name === "Error" && /inciteCaps/.test(e.stack); } function inciteCaps(f) { try { f(); return "operation succeeded"; } catch (e if hasStack(e)) {
--- a/js/src/tests/js1_5/Regress/regress-328897.js +++ b/js/src/tests/js1_5/Regress/regress-328897.js @@ -47,30 +47,29 @@ printBugNumber(BUGNUMBER); printStatus (summary); if (typeof window == 'undefined') { reportCompare(expect, actual, summary); } else { - expect = /(Script error.|Permission denied to access property 'classes')/; + expect = /(Script error.|Permission denied for <file:\/\/> to get property XPCComponents.classes)/; window._onerror = window.onerror; window.onerror = (function (msg, page, line) { actual = msg; gDelayTestDriverEnd = false; jsTestDriverEnd(); reportMatch(expect, actual, summary); }); gDelayTestDriverEnd = true; - // Trying to set Components.classes will trigger a Permission denied exception - window.location="javascript:Components.classes = 42"; + window.location="javascript:Components.classes"; actual = 'No Error'; } function onload() { if (actual == 'No Error') { gDelayTestDriverEnd = false;
--- a/js/xpconnect/src/XPCComponents.cpp +++ b/js/xpconnect/src/XPCComponents.cpp @@ -55,17 +55,16 @@ #include "WrapperFactory.h" #include "XrayWrapper.h" #include "nsNullPrincipal.h" #include "nsJSUtils.h" #include "mozJSComponentLoader.h" #include "nsContentUtils.h" #include "jsgc.h" #include "jsfriendapi.h" -#include "AccessCheck.h" #include "mozilla/dom/bindings/Utils.h" using namespace mozilla; using namespace js; using mozilla::dom::bindings::DestroyProtoOrIfaceCache; /***************************************************************************/ @@ -4189,18 +4188,17 @@ oom: return NS_ERROR_OUT_OF_MEMORY; } /* nsISupports getHelperForLanguage (in PRUint32 language); */ NS_IMETHODIMP nsXPCComponents::GetHelperForLanguage(PRUint32 language, nsISupports **retval) { - *retval = static_cast<nsIXPCComponents*>(this); - NS_ADDREF(this); + *retval = nsnull; return NS_OK; } /* readonly attribute string contractID; */ NS_IMETHODIMP nsXPCComponents::GetContractID(char * *aContractID) { *aContractID = nsnull; @@ -4242,29 +4240,27 @@ nsXPCComponents::GetFlags(PRUint32 *aFla /* [notxpcom] readonly attribute nsCID classIDNoAlloc; */ NS_IMETHODIMP nsXPCComponents::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) { return NS_ERROR_NOT_AVAILABLE; } -nsXPCComponents::nsXPCComponents(XPCWrappedNativeScope* aScope) - : mScope(aScope), - mInterfaces(nsnull), +nsXPCComponents::nsXPCComponents() + : mInterfaces(nsnull), mInterfacesByID(nsnull), mClasses(nsnull), mClassesByID(nsnull), mResults(nsnull), mID(nsnull), mException(nsnull), mConstructor(nsnull), mUtils(nsnull) { - MOZ_ASSERT(aScope, "aScope must not be null"); } nsXPCComponents::~nsXPCComponents() { ClearMembers(); } void @@ -4338,17 +4334,16 @@ nsXPCComponents::GetManager(nsIComponent /**********************************************/ // The nsIXPCScriptable map declaration that will generate stubs for us... #define XPC_MAP_CLASSNAME nsXPCComponents #define XPC_MAP_QUOTED_CLASSNAME "nsXPCComponents" #define XPC_MAP_WANT_NEWRESOLVE #define XPC_MAP_WANT_GETPROPERTY #define XPC_MAP_WANT_SETPROPERTY -#define XPC_MAP_WANT_PRECREATE #define XPC_MAP_FLAGS nsIXPCScriptable::ALLOW_PROP_MODS_DURING_RESOLVE #include "xpc_map_end.h" /* This will #undef the above */ /* bool newResolve (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in jsval id, in PRUint32 flags, out JSObjectPtr objp); */ NS_IMETHODIMP nsXPCComponents::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext * cx, JSObject * obj, jsid id, PRUint32 flags, @@ -4427,53 +4422,50 @@ nsXPCComponents::SetProperty(nsIXPConnec return NS_ERROR_FAILURE; } return NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN; } // static JSBool -nsXPCComponents::AttachComponentsObject(XPCCallContext& ccx, - XPCWrappedNativeScope* aScope, - JSObject* aGlobal) +nsXPCComponents::AttachNewComponentsObject(XPCCallContext& ccx, + XPCWrappedNativeScope* aScope, + JSObject* aGlobal) { if (!aGlobal) return false; - nsXPCComponents* components = aScope->GetComponents(); - if (!components) { - components = new nsXPCComponents(aScope); - if (!components) - return false; - aScope->SetComponents(components); - } + nsXPCComponents* components = new nsXPCComponents(); + if (!components) + return false; nsCOMPtr<nsIXPCComponents> cholder(components); AutoMarkingNativeInterfacePtr iface(ccx); iface = XPCNativeInterface::GetNewOrUsed(ccx, &NS_GET_IID(nsIXPCComponents)); if (!iface) return false; nsCOMPtr<XPCWrappedNative> wrapper; xpcObjectHelper helper(cholder); XPCWrappedNative::GetNewOrUsed(ccx, helper, aScope, iface, getter_AddRefs(wrapper)); if (!wrapper) return false; + aScope->SetComponents(components); + jsid id = ccx.GetRuntime()->GetStringID(XPCJSRuntime::IDX_COMPONENTS); - JSObject* obj = wrapper->GetSameCompartmentSecurityWrapper(ccx); - if (!wrapper) - return false; - - return JS_DefinePropertyById(ccx, aGlobal, id, OBJECT_TO_JSVAL(obj), - nsnull, nsnull, - JSPROP_PERMANENT | JSPROP_READONLY); + JSObject* obj; + + return NS_SUCCEEDED(wrapper->GetJSObject(&obj)) && + obj && JS_DefinePropertyById(ccx, aGlobal, id, OBJECT_TO_JSVAL(obj), + nsnull, nsnull, + JSPROP_PERMANENT | JSPROP_READONLY); } /* void lookupMethod (); */ NS_IMETHODIMP nsXPCComponents::LookupMethod(const JS::Value& object, const JS::Value& name, JSContext *cx, JS::Value *retval) @@ -4531,20 +4523,8 @@ nsXPCComponents::CanGetProperty(const ns /* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */ NS_IMETHODIMP nsXPCComponents::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval) { // If you have to ask, then the answer is NO *_retval = nsnull; 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; - } - *parentObj = mScope->GetGlobalJSObject(); - return NS_OK; -} \ No newline at end of file
--- a/js/xpconnect/src/XPCWrappedNative.cpp +++ b/js/xpconnect/src/XPCWrappedNative.cpp @@ -1678,18 +1678,16 @@ XPCWrappedNative::ReparentWrapperIfFound if (!innerAC.enter(ccx, aOldScope->GetGlobalJSObject()) || !wrapper->GetSameCompartmentSecurityWrapper(ccx)) return NS_ERROR_FAILURE; } JSObject *ww = wrapper->GetWrapper(); if (ww) { JSObject *newwrapper; - MOZ_ASSERT(!xpc::WrapperFactory::IsComponentsObject(flat), - "Components object should never get here"); if (xpc::WrapperFactory::IsLocationObject(flat)) { newwrapper = xpc::WrapperFactory::WrapLocationObject(ccx, newobj); if (!newwrapper) return NS_ERROR_FAILURE; } else { NS_ASSERTION(wrapper->NeedsSOW(), "weird wrapper wrapper"); newwrapper = xpc::WrapperFactory::WrapSOWObject(ccx, newobj); if (!newwrapper) @@ -2237,20 +2235,16 @@ XPCWrappedNative::GetSameCompartmentSecu if (xpc::WrapperFactory::IsLocationObject(flat)) { wrapper = xpc::WrapperFactory::WrapLocationObject(cx, flat); if (!wrapper) return NULL; } else if (NeedsSOW()) { wrapper = xpc::WrapperFactory::WrapSOWObject(cx, flat); if (!wrapper) return NULL; - } else if (xpc::WrapperFactory::IsComponentsObject(flat)) { - wrapper = xpc::WrapperFactory::WrapComponentsObject(cx, flat); - if (!wrapper) - return NULL; } // If we made a wrapper, cache it and return it. if (wrapper) { SetWrapper(wrapper); return wrapper; }
--- a/js/xpconnect/src/XPCWrappedNativeScope.cpp +++ b/js/xpconnect/src/XPCWrappedNativeScope.cpp @@ -185,25 +185,21 @@ XPCWrappedNativeScope::IsDyingScope(XPCW return true; } return false; } void XPCWrappedNativeScope::SetComponents(nsXPCComponents* aComponents) { + NS_IF_ADDREF(aComponents); + NS_IF_RELEASE(mComponents); mComponents = aComponents; } -nsXPCComponents* -XPCWrappedNativeScope::GetComponents() -{ - return mComponents; -} - // Dummy JS class to let wrappers w/o an xpc prototype share // scopes. By doing this we avoid allocating a new scope for every // wrapper on creation of the wrapper, and most wrappers won't need // their own scope at all for the lifetime of the wrapper. // WRAPPER_SLOTS is key here (even though there's never anything // in the private data slot in these prototypes), as the number of // reserved slots in this class needs to match that of the wrappers // for the JS engine to share scopes. @@ -307,24 +303,19 @@ XPCWrappedNativeScope::~XPCWrappedNative if (mMainThreadWrappedNativeProtoMap) { NS_ASSERTION(0 == mMainThreadWrappedNativeProtoMap->Count(), "scope has non-empty map"); delete mMainThreadWrappedNativeProtoMap; } if (mContext) mContext->RemoveScope(this); - // This should not be necessary, since the Components object should die - // with the scope but just in case. - if (mComponents) - mComponents->mScope = nsnull; - // XXX we should assert that we are dead or that xpconnect has shutdown // XXX might not want to do this at xpconnect shutdown time??? - mComponents = nsnull; + NS_IF_RELEASE(mComponents); JSRuntime *rt = mRuntime->GetJSRuntime(); mGlobalJSObject.finalize(rt); mPrototypeJSObject.finalize(rt); } JSObject * XPCWrappedNativeScope::GetPrototypeNoHelper(XPCCallContext& ccx)
--- a/js/xpconnect/src/nsXPConnect.cpp +++ b/js/xpconnect/src/nsXPConnect.cpp @@ -1126,17 +1126,17 @@ nsXPConnect::InitClasses(JSContext * aJS XPCWrappedNativeScope* scope = XPCWrappedNativeScope::GetNewOrUsed(ccx, aGlobalJSObj); if (!scope) return UnexpectedFailure(NS_ERROR_FAILURE); scope->RemoveWrappedNativeProtos(); - if (!nsXPCComponents::AttachComponentsObject(ccx, scope, aGlobalJSObj)) + if (!nsXPCComponents::AttachNewComponentsObject(ccx, scope, aGlobalJSObj)) return UnexpectedFailure(NS_ERROR_FAILURE); if (XPCPerThreadData::IsMainThread(ccx)) { if (!XPCNativeWrapper::AttachNewConstructorObject(ccx, aGlobalJSObj)) return UnexpectedFailure(NS_ERROR_FAILURE); } return NS_OK; @@ -1328,17 +1328,17 @@ nsXPConnect::InitClassesWithNewWrappedGl // Apply the system flag, if requested. bool system = (aFlags & nsIXPConnect::FLAG_SYSTEM_GLOBAL_OBJECT) != 0; if (system && !JS_MakeSystemObject(aJSContext, global)) return UnexpectedFailure(NS_ERROR_FAILURE); if (!(aFlags & nsIXPConnect::OMIT_COMPONENTS_OBJECT)) { // XPCCallContext gives us an active request needed to save/restore. - if (!nsXPCComponents::AttachComponentsObject(ccx, wrappedGlobal->GetScope(), global)) + if (!nsXPCComponents::AttachNewComponentsObject(ccx, wrappedGlobal->GetScope(), global)) return UnexpectedFailure(NS_ERROR_FAILURE); if (XPCPerThreadData::IsMainThread(ccx)) { if (!XPCNativeWrapper::AttachNewConstructorObject(ccx, global)) return UnexpectedFailure(NS_ERROR_FAILURE); } }
--- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -1605,17 +1605,16 @@ public: JSBool IsValid() const {return mRuntime != nsnull;} static JSBool IsDyingScope(XPCWrappedNativeScope *scope); void SetComponents(nsXPCComponents* aComponents); - nsXPCComponents *GetComponents(); void SetGlobal(XPCCallContext& ccx, JSObject* aGlobal, nsISupports* aNative); static void InitStatics() { gScopes = nsnull; gDyingScopes = nsnull; } XPCContext *GetContext() { return mContext; } void SetContext(XPCContext *xpcc) { mContext = nsnull; } nsDataHashtable<nsDepCharHashKey, JSObject*>& GetCachedDOMPrototypes() @@ -1655,17 +1654,17 @@ protected: private: static XPCWrappedNativeScope* gScopes; static XPCWrappedNativeScope* gDyingScopes; XPCJSRuntime* mRuntime; Native2WrappedNativeMap* mWrappedNativeMap; ClassInfo2WrappedNativeProtoMap* mWrappedNativeProtoMap; ClassInfo2WrappedNativeProtoMap* mMainThreadWrappedNativeProtoMap; - nsRefPtr<nsXPCComponents> mComponents; + nsXPCComponents* mComponents; XPCWrappedNativeScope* mNext; // The JS global object for this scope. If non-null, this will be the // default parent for the XPCWrappedNatives that have us as the scope, // unless a PreCreate hook overrides it. Note that this _may_ be null (see // constructor). js::ObjectPtr mGlobalJSObject; // Cached value of Object.prototype @@ -3898,31 +3897,29 @@ public: NS_DECL_ISUPPORTS NS_DECL_NSIXPCCOMPONENTS NS_DECL_NSIXPCSCRIPTABLE NS_DECL_NSICLASSINFO NS_DECL_NSISECURITYCHECKEDCOMPONENT public: static JSBool - AttachComponentsObject(XPCCallContext& ccx, - XPCWrappedNativeScope* aScope, - JSObject* aGlobal); + AttachNewComponentsObject(XPCCallContext& ccx, + XPCWrappedNativeScope* aScope, + JSObject* aGlobal); void SystemIsBeingShutDown() {ClearMembers();} virtual ~nsXPCComponents(); private: - nsXPCComponents(XPCWrappedNativeScope* aScope); + nsXPCComponents(); void ClearMembers(); private: - friend class XPCWrappedNativeScope; - XPCWrappedNativeScope* mScope; nsXPCComponents_Interfaces* mInterfaces; nsXPCComponents_InterfacesByID* mInterfacesByID; nsXPCComponents_Classes* mClasses; nsXPCComponents_ClassesByID* mClassesByID; nsXPCComponents_Results* mResults; nsXPCComponents_ID* mID; nsXPCComponents_Exception* mException; nsXPCComponents_Constructor* mConstructor;
deleted file mode 100644 --- a/js/xpconnect/tests/unit/test_components.js +++ /dev/null @@ -1,43 +0,0 @@ -function run_test() { - var Cu = Components.utils; - var sb1 = Cu.Sandbox("http://www.blah.com"); - var sb2 = Cu.Sandbox("http://www.blah.com"); - var sb3 = Cu.Sandbox(this); - var sb4 = Cu.Sandbox("http://www.other.com"); - var rv; - - // non-chrome accessing chrome Components - sb1.C = Components; - rv = Cu.evalInSandbox("C.utils", sb1); - do_check_eq(rv, undefined); - rv = Cu.evalInSandbox("C.interfaces", sb1); - do_check_neq(rv, undefined); - - // non-chrome accessing own Components - rv = Cu.evalInSandbox("Components.utils", sb1); - do_check_eq(rv, undefined); - rv = Cu.evalInSandbox("Components.interfaces", sb1); - do_check_neq(rv, undefined); - - // non-chrome same origin - var C2 = Cu.evalInSandbox("Components", sb2); - do_check_neq(rv, C2.utils); - sb1.C2 = C2; - rv = Cu.evalInSandbox("C2.utils", sb1); - do_check_eq(rv, undefined); - rv = Cu.evalInSandbox("C2.interfaces", sb1); - do_check_neq(rv, undefined); - - // chrome accessing chrome - sb3.C = Components; - rv = Cu.evalInSandbox("C.utils", sb3); - do_check_eq(rv, Cu); - - // non-chrome cross origin - sb4.C2 = C2; - rv = Cu.evalInSandbox("C2.interfaces", sb1); - do_check_neq(rv, undefined); - rv = Cu.evalInSandbox("C2.utils", sb1); - do_check_eq(rv, undefined); - -} \ No newline at end of file
--- a/js/xpconnect/tests/unit/xpcshell.ini +++ b/js/xpconnect/tests/unit/xpcshell.ini @@ -20,9 +20,8 @@ tail = [test_localeCompare.js] # Bug 676965: test fails consistently on Android fail-if = os == "android" [test_recursive_import.js] [test_xpcomutils.js] [test_unload.js] [test_attributes.js] [test_params.js] -[test_components.js]
--- a/js/xpconnect/wrappers/AccessCheck.cpp +++ b/js/xpconnect/wrappers/AccessCheck.cpp @@ -602,34 +602,9 @@ ExposedPropertiesOnly::check(JSContext * (act != Wrapper::SET && !(access & READ))) { return PermitIfUniversalXPConnect(cx, id, act, perm); // Deny } perm = PermitPropertyAccess; return true; // Allow } -bool -ComponentsObjectPolicy::check(JSContext *cx, JSObject *wrapper, jsid id, Wrapper::Action act, - Permission &perm) -{ - perm = DenyAccess; - JSAutoEnterCompartment ac; - if (!ac.enter(cx, wrapper)) - return false; - - if (JSID_IS_STRING(id) && act == Wrapper::GET) { - JSFlatString *flatId = JSID_TO_FLAT_STRING(id); - if (JS_FlatStringEqualsAscii(flatId, "isSuccessCode") || - JS_FlatStringEqualsAscii(flatId, "lookupMethod") || - JS_FlatStringEqualsAscii(flatId, "interfaces") || - JS_FlatStringEqualsAscii(flatId, "interfacesByID") || - JS_FlatStringEqualsAscii(flatId, "results")) - { - perm = PermitPropertyAccess; - return true; - } - } - - return PermitIfUniversalXPConnect(cx, id, act, perm); // Deny } - -}
--- a/js/xpconnect/wrappers/AccessCheck.h +++ b/js/xpconnect/wrappers/AccessCheck.h @@ -170,15 +170,9 @@ struct LocationPolicy : public Policy { // This policy only permits access to properties if they appear in the // objects exposed properties list. struct ExposedPropertiesOnly : public Policy { static bool check(JSContext *cx, JSObject *wrapper, jsid id, js::Wrapper::Action act, Permission &perm); }; -// Components specific policy -struct ComponentsObjectPolicy : public Policy { - static bool check(JSContext *cx, JSObject *wrapper, jsid id, js::Wrapper::Action act, - Permission &perm); -}; - }
--- a/js/xpconnect/wrappers/FilteringWrapper.cpp +++ b/js/xpconnect/wrappers/FilteringWrapper.cpp @@ -146,39 +146,33 @@ FilteringWrapper<Base, Policy>::enter(JS #define DXOW FilteringWrapper<XrayDOM, \ CrossOriginAccessiblePropertiesOnly> #define NNXOW FilteringWrapper<CrossCompartmentSecurityWrapper, \ CrossOriginAccessiblePropertiesOnly> #define LW FilteringWrapper<XrayWrapper<SameCompartmentSecurityWrapper>, \ LocationPolicy> #define XLW FilteringWrapper<XrayWrapper<CrossCompartmentSecurityWrapper>, \ LocationPolicy> -#define CW FilteringWrapper<SameCompartmentSecurityWrapper, \ - ComponentsObjectPolicy> -#define XCW FilteringWrapper<CrossCompartmentSecurityWrapper, \ - ComponentsObjectPolicy> + template<> SOW SOW::singleton(WrapperFactory::SCRIPT_ACCESS_ONLY_FLAG | WrapperFactory::SOW_FLAG); template<> SCSOW SCSOW::singleton(WrapperFactory::SCRIPT_ACCESS_ONLY_FLAG | WrapperFactory::SOW_FLAG); template<> COW COW::singleton(0); template<> XOW XOW::singleton(WrapperFactory::SCRIPT_ACCESS_ONLY_FLAG | WrapperFactory::PARTIALLY_TRANSPARENT); template<> PXOW PXOW::singleton(WrapperFactory::SCRIPT_ACCESS_ONLY_FLAG | WrapperFactory::PARTIALLY_TRANSPARENT); template<> DXOW DXOW::singleton(WrapperFactory::SCRIPT_ACCESS_ONLY_FLAG | WrapperFactory::PARTIALLY_TRANSPARENT); template<> NNXOW NNXOW::singleton(WrapperFactory::SCRIPT_ACCESS_ONLY_FLAG | WrapperFactory::PARTIALLY_TRANSPARENT); template<> LW LW::singleton(WrapperFactory::SHADOWING_FORBIDDEN); template<> XLW XLW::singleton(WrapperFactory::SHADOWING_FORBIDDEN); -template<> CW CW::singleton(0); -template<> XCW XCW::singleton(0); - template class SOW; template class COW; template class XOW; template class PXOW; template class DXOW; template class NNXOW; template class LW; template class XLW;
--- a/js/xpconnect/wrappers/WrapperFactory.cpp +++ b/js/xpconnect/wrappers/WrapperFactory.cpp @@ -361,19 +361,16 @@ WrapperFactory::Rewrap(JSContext *cx, JS if (IsLocationObject(obj)) wrapper = &FilteringWrapper<Xray, LocationPolicy>::singleton; else wrapper = &FilteringWrapper<Xray, CrossOriginAccessiblePropertiesOnly>::singleton; } else if (mozilla::dom::binding::instanceIsProxy(obj)) { wrapper = &FilteringWrapper<XrayProxy, CrossOriginAccessiblePropertiesOnly>::singleton; } else if (mozilla::dom::bindings::IsDOMClass(JS_GetClass(obj))) { wrapper = &FilteringWrapper<XrayDOM, CrossOriginAccessiblePropertiesOnly>::singleton; - } else if (IsComponentsObject(obj)) { - wrapper = &FilteringWrapper<CrossCompartmentSecurityWrapper, - ComponentsObjectPolicy>::singleton; } else { wrapper = &FilteringWrapper<CrossCompartmentSecurityWrapper, ExposedPropertiesOnly>::singleton; } } else if (AccessCheck::isSameOrigin(origin, target)) { // For the same-origin case we use a transparent wrapper, unless one // of the following is true: // * The object is flagged as needing a SOW. @@ -398,19 +395,16 @@ WrapperFactory::Rewrap(JSContext *cx, JS // to the LW in the host compartment, rather than an XLW directly to the // Location object. This still doesn't share expandos in the // document.domain case, but that's probably fine. Double-wrapping sucks, // but it's kind of unavoidable here. XrayType type; if (AccessCheck::needsSystemOnlyWrapper(obj)) { wrapper = &FilteringWrapper<CrossCompartmentSecurityWrapper, OnlyIfSubjectIsSystem>::singleton; - } else if (IsComponentsObject(obj)) { - wrapper = &FilteringWrapper<CrossCompartmentSecurityWrapper, - ComponentsObjectPolicy>::singleton; } else if (!targetdata || !targetdata->wantXrays || (type = GetXrayType(obj)) == NotXray) { // Do the double-wrapping if need be. if (IsLocationObject(obj)) { JSAutoEnterCompartment ac; if (!ac.enter(cx, obj)) return nsnull; XPCWrappedNative *wn = GetWrappedNative(cx, obj); @@ -525,26 +519,9 @@ WrapperFactory::WrapSOWObject(JSContext { JSObject *wrapperObj = Wrapper::New(cx, obj, JS_GetPrototype(obj), JS_GetGlobalForObject(cx, obj), &FilteringWrapper<SameCompartmentSecurityWrapper, OnlyIfSubjectIsSystem>::singleton); return wrapperObj; } -bool -WrapperFactory::IsComponentsObject(JSObject *obj) -{ - const char *name = js::GetObjectClass(obj)->name; - return name[0] == 'n' && !strcmp(name, "nsXPCComponents"); } - -JSObject * -WrapperFactory::WrapComponentsObject(JSContext *cx, JSObject *obj) -{ - JSObject *wrapperObj = - Wrapper::New(cx, obj, JS_GetPrototype(obj), JS_GetGlobalForObject(cx, obj), - &FilteringWrapper<SameCompartmentSecurityWrapper, ComponentsObjectPolicy>::singleton); - - return wrapperObj; -} - -}
--- a/js/xpconnect/wrappers/WrapperFactory.h +++ b/js/xpconnect/wrappers/WrapperFactory.h @@ -105,21 +105,15 @@ class WrapperFactory { // Wrap a location object. static JSObject *WrapLocationObject(JSContext *cx, JSObject *obj); // Wrap wrapped object into a waiver wrapper and then re-wrap it. static bool WaiveXrayAndWrap(JSContext *cx, jsval *vp); // Wrap a (same compartment) object in a SOW. static JSObject *WrapSOWObject(JSContext *cx, JSObject *obj); - - // Return true if this is a Components object. - static bool IsComponentsObject(JSObject *obj); - - // Wrap a (same compartment) Components object. - static JSObject *WrapComponentsObject(JSContext *cx, JSObject *obj); }; extern js::Wrapper WaiveXrayWrapperWrapper; } #endif /* _xpc_WRAPPERFACTORY_H */