mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1029248 - Allow CPOWs to be converted to native interfaces (r=mrbkap)
This commit is contained in:
parent
c3121f05b8
commit
0a2f262d4f
@ -12,6 +12,7 @@
|
||||
#include "nsCxPusher.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "JavaScriptParent.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -334,7 +335,9 @@ nsXPCWrappedJS::GetNewOrUsed(JS::HandleObject jsObj,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsRefPtr<nsXPCWrappedJSClass> clasp = nsXPCWrappedJSClass::GetNewOrUsed(cx, aIID);
|
||||
bool allowNonScriptable = mozilla::jsipc::IsWrappedCPOW(jsObj);
|
||||
nsRefPtr<nsXPCWrappedJSClass> clasp = nsXPCWrappedJSClass::GetNewOrUsed(cx, aIID,
|
||||
allowNonScriptable);
|
||||
if (!clasp)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "nsWrapperCache.h"
|
||||
#include "AccessCheck.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "JavaScriptParent.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/DOMException.h"
|
||||
@ -90,7 +91,7 @@ bool xpc_IsReportableErrorCode(nsresult code)
|
||||
|
||||
// static
|
||||
already_AddRefed<nsXPCWrappedJSClass>
|
||||
nsXPCWrappedJSClass::GetNewOrUsed(JSContext* cx, REFNSIID aIID)
|
||||
nsXPCWrappedJSClass::GetNewOrUsed(JSContext* cx, REFNSIID aIID, bool allowNonScriptable)
|
||||
{
|
||||
XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
|
||||
IID2WrappedJSClassMap* map = rt->GetWrappedJSClassMap();
|
||||
@ -101,7 +102,7 @@ nsXPCWrappedJSClass::GetNewOrUsed(JSContext* cx, REFNSIID aIID)
|
||||
nsXPConnect::XPConnect()->GetInfoForIID(&aIID, getter_AddRefs(info));
|
||||
if (info) {
|
||||
bool canScript, isBuiltin;
|
||||
if (NS_SUCCEEDED(info->IsScriptable(&canScript)) && canScript &&
|
||||
if (NS_SUCCEEDED(info->IsScriptable(&canScript)) && (canScript || allowNonScriptable) &&
|
||||
NS_SUCCEEDED(info->IsBuiltinClass(&isBuiltin)) && !isBuiltin &&
|
||||
nsXPConnect::IsISupportsDescendant(info))
|
||||
{
|
||||
@ -202,12 +203,14 @@ 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<nsIInterfaceInfo> info;
|
||||
nsXPConnect::XPConnect()->GetInfoForIID(&aIID, getter_AddRefs(info));
|
||||
if (!info)
|
||||
return nullptr;
|
||||
bool canScript, isBuiltin;
|
||||
if (NS_FAILED(info->IsScriptable(&canScript)) || !canScript ||
|
||||
if (NS_FAILED(info->IsScriptable(&canScript)) || (!canScript && !allowNonScriptable) ||
|
||||
NS_FAILED(info->IsBuiltinClass(&isBuiltin)) || isBuiltin)
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -2242,7 +2242,8 @@ public:
|
||||
|
||||
static already_AddRefed<nsXPCWrappedJSClass>
|
||||
GetNewOrUsed(JSContext* cx,
|
||||
REFNSIID aIID);
|
||||
REFNSIID aIID,
|
||||
bool allowNonScriptable = false);
|
||||
|
||||
REFNSIID GetIID() const {return mIID;}
|
||||
XPCJSRuntime* GetRuntime() const {return mRuntime;}
|
||||
|
Loading…
Reference in New Issue
Block a user