diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp index f6cb668782c6..2d3085fb454f 100644 --- a/dom/bindings/BindingUtils.cpp +++ b/dom/bindings/BindingUtils.cpp @@ -1898,10 +1898,11 @@ InterfaceHasInstance(JSContext* cx, JS::Handle obj, return true; } - if (jsipc::IsWrappedCPOW(instance)) { + JS::Rooted unwrapped(cx, js::CheckedUnwrap(instance, true)); + if (unwrapped && jsipc::IsCPOW(unwrapped)) { bool boolp = false; - if (!jsipc::DOMInstanceOf(cx, js::CheckedUnwrap(instance), clasp->mPrototypeID, - clasp->mDepth, &boolp)) { + if (!jsipc::DOMInstanceOf(cx, unwrapped, clasp->mPrototypeID, + clasp->mDepth, &boolp)) { return false; } *bp = boolp; diff --git a/js/ipc/WrapperOwner.cpp b/js/ipc/WrapperOwner.cpp index d418f89ee30c..942a0f4677d2 100644 --- a/js/ipc/WrapperOwner.cpp +++ b/js/ipc/WrapperOwner.cpp @@ -676,15 +676,6 @@ IsCPOW(JSObject *obj) return IsProxy(obj) && GetProxyHandler(obj) == &CPOWProxyHandler::singleton; } -bool -IsWrappedCPOW(JSObject *obj) -{ - JSObject *unwrapped = js::CheckedUnwrap(obj, true); - if (!unwrapped) - return false; - return IsCPOW(unwrapped); -} - nsresult InstanceOf(JSObject *proxy, const nsID *id, bool *bp) { diff --git a/js/ipc/WrapperOwner.h b/js/ipc/WrapperOwner.h index 5621646a1c83..26ce1adb8f19 100644 --- a/js/ipc/WrapperOwner.h +++ b/js/ipc/WrapperOwner.h @@ -144,9 +144,6 @@ class WrapperOwner : public virtual JavaScriptShared bool IsCPOW(JSObject *obj); -bool -IsWrappedCPOW(JSObject *obj); - nsresult InstanceOf(JSObject *obj, const nsID *id, bool *bp); diff --git a/js/xpconnect/src/XPCComponents.cpp b/js/xpconnect/src/XPCComponents.cpp index 6e2d5c2b6fc7..26893dddb3eb 100644 --- a/js/xpconnect/src/XPCComponents.cpp +++ b/js/xpconnect/src/XPCComponents.cpp @@ -3113,7 +3113,7 @@ nsXPCComponents_Utils::IsCrossProcessWrapper(HandleValue obj, bool *out) if (obj.isPrimitive()) return NS_ERROR_INVALID_ARG; - *out = jsipc::IsWrappedCPOW(&obj.toObject()); + *out = jsipc::IsCPOW(js::CheckedUnwrap(&obj.toObject())); return NS_OK; } diff --git a/js/xpconnect/src/XPCConvert.cpp b/js/xpconnect/src/XPCConvert.cpp index 2d5f8901b2b7..4b5a1fe8e491 100644 --- a/js/xpconnect/src/XPCConvert.cpp +++ b/js/xpconnect/src/XPCConvert.cpp @@ -65,8 +65,8 @@ UnwrapNativeCPOW(nsISupports* wrapper) { nsCOMPtr underware = do_QueryInterface(wrapper); if (underware) { - JSObject *mainObj = underware->GetJSObject(); - if (mainObj && mozilla::jsipc::IsWrappedCPOW(mainObj)) + JSObject* mainObj = underware->GetJSObject(); + if (mainObj && mozilla::jsipc::IsCPOW(mainObj)) return mainObj; } return nullptr; diff --git a/js/xpconnect/src/XPCWrappedJS.cpp b/js/xpconnect/src/XPCWrappedJS.cpp index 35af471c36b6..d4520aafe4c6 100644 --- a/js/xpconnect/src/XPCWrappedJS.cpp +++ b/js/xpconnect/src/XPCWrappedJS.cpp @@ -12,7 +12,6 @@ #include "nsCxPusher.h" #include "nsContentUtils.h" #include "nsThreadUtils.h" -#include "JavaScriptParent.h" using namespace mozilla; @@ -335,9 +334,7 @@ nsXPCWrappedJS::GetNewOrUsed(JS::HandleObject jsObj, return NS_ERROR_FAILURE; } - bool allowNonScriptable = mozilla::jsipc::IsWrappedCPOW(jsObj); - nsRefPtr clasp = nsXPCWrappedJSClass::GetNewOrUsed(cx, aIID, - allowNonScriptable); + nsRefPtr clasp = nsXPCWrappedJSClass::GetNewOrUsed(cx, aIID); if (!clasp) return NS_ERROR_FAILURE; diff --git a/js/xpconnect/src/XPCWrappedJSClass.cpp b/js/xpconnect/src/XPCWrappedJSClass.cpp index 62d6074654d2..a5b6e1d5b471 100644 --- a/js/xpconnect/src/XPCWrappedJSClass.cpp +++ b/js/xpconnect/src/XPCWrappedJSClass.cpp @@ -90,7 +90,7 @@ bool xpc_IsReportableErrorCode(nsresult code) // static already_AddRefed -nsXPCWrappedJSClass::GetNewOrUsed(JSContext* cx, REFNSIID aIID, bool allowNonScriptable) +nsXPCWrappedJSClass::GetNewOrUsed(JSContext* cx, REFNSIID aIID) { XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance(); IID2WrappedJSClassMap* map = rt->GetWrappedJSClassMap(); @@ -101,7 +101,7 @@ nsXPCWrappedJSClass::GetNewOrUsed(JSContext* cx, REFNSIID aIID, bool allowNonScr nsXPConnect::XPConnect()->GetInfoForIID(&aIID, getter_AddRefs(info)); if (info) { bool canScript, isBuiltin; - if (NS_SUCCEEDED(info->IsScriptable(&canScript)) && (canScript || allowNonScriptable) && + if (NS_SUCCEEDED(info->IsScriptable(&canScript)) && canScript && NS_SUCCEEDED(info->IsBuiltinClass(&isBuiltin)) && !isBuiltin && nsXPConnect::IsISupportsDescendant(info)) { @@ -202,14 +202,12 @@ nsXPCWrappedJSClass::CallQueryInterfaceOnJSObject(JSContext* cx, // implement intentionally (for security) unscriptable interfaces. // We so often ask for nsISupports that we can short-circuit the test... if (!aIID.Equals(NS_GET_IID(nsISupports))) { - bool allowNonScriptable = mozilla::jsipc::IsWrappedCPOW(jsobj); - nsCOMPtr info; nsXPConnect::XPConnect()->GetInfoForIID(&aIID, getter_AddRefs(info)); if (!info) return nullptr; bool canScript, isBuiltin; - if (NS_FAILED(info->IsScriptable(&canScript)) || (!canScript && !allowNonScriptable) || + if (NS_FAILED(info->IsScriptable(&canScript)) || !canScript || NS_FAILED(info->IsBuiltinClass(&isBuiltin)) || isBuiltin) return nullptr; } diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h index dfc90a65d7ea..2c67e23168c9 100644 --- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -2241,8 +2241,7 @@ public: static already_AddRefed GetNewOrUsed(JSContext* cx, - REFNSIID aIID, - bool allowNonScriptable = false); + REFNSIID aIID); REFNSIID GetIID() const {return mIID;} XPCJSRuntime* GetRuntime() const {return mRuntime;}