Bug 856067 - Add some helpful logging to the console when we deny access to a non-Xrayable object. r=gabor

This commit is contained in:
Bobby Holley 2014-07-14 10:09:07 -07:00
Родитель 2fac4671d3
Коммит d65aa88546
1 изменённых файлов: 15 добавлений и 2 удалений

Просмотреть файл

@ -69,6 +69,8 @@ IsTypedArrayKey(JSProtoKey key)
return key >= JSProto_Int8Array && key <= JSProto_Uint8ClampedArray;
}
bool SilentFailure(JSContext *cx, JS::HandleId id, const char *reason);
// Whitelist for the standard ES classes we can Xray to.
static bool
IsJSXraySupported(JSProtoKey key)
@ -493,6 +495,17 @@ public:
MOZ_CRASH("resolveNativeProperty hook should never be called with HasPrototype = 1");
}
virtual bool resolveOwnProperty(JSContext *cx, const Wrapper &jsWrapper, HandleObject wrapper,
HandleObject holder, HandleId id,
MutableHandle<JSPropertyDescriptor> desc) MOZ_OVERRIDE
{
bool ok = XrayTraits::resolveOwnProperty(cx, jsWrapper, wrapper, holder, id, desc);
if (!ok || desc.object())
return ok;
return SilentFailure(cx, id, "Object is not safely Xrayable");
}
bool defineProperty(JSContext *cx, HandleObject wrapper, HandleId id,
MutableHandle<JSPropertyDescriptor> desc,
Handle<JSPropertyDescriptor> existingDesc, bool *defined)
@ -560,7 +573,7 @@ public:
static OpaqueXrayTraits singleton;
};
inline bool
bool
SilentFailure(JSContext *cx, HandleId id, const char *reason)
{
#ifdef DEBUG
@ -570,7 +583,7 @@ SilentFailure(JSContext *cx, HandleId id, const char *reason)
AutoFilename filename;
unsigned line = 0;
DescribeScriptedCaller(cx, &filename, &line);
NS_WARNING(nsPrintfCString("Denied access to property |%s| on Xrayed Object: %s (@%s:%u)",
NS_WARNING(nsPrintfCString("Silently denied access to property |%s|: %s (@%s:%u)",
NS_LossyConvertUTF16toASCII(name).get(), reason,
filename.get(), line).get());
#endif