Bug 854503 - Rename JS unwrapping functions. r=bholley

This commit is contained in:
Jacek Szpot 2013-04-11 11:50:18 -07:00
parent e76c82d92e
commit 514f40e52a
45 changed files with 135 additions and 136 deletions

View File

@ -3087,7 +3087,7 @@ nsObjectLoadingContent::TeardownProtoChain()
}
// Unwrap while checking the jsclass - if the prototype is a wrapper for
// an NP object, that counts too.
if (JS_GetClass(js::UnwrapObject(proto)) == &sNPObjectJSWrapperClass) {
if (JS_GetClass(js::UncheckedUnwrap(proto)) == &sNPObjectJSWrapperClass) {
// We found an NPObject on the proto chain, get its prototype...
if (!::JS_GetPrototype(cx, proto, &proto)) {
return;

View File

@ -183,7 +183,7 @@ InstallXBLField(JSContext* cx,
// If a separate XBL scope is being used, the callee is not same-compartment
// with the xbl prototype, and the object is a cross-compartment wrapper.
xblProto = js::UnwrapObject(xblProto);
xblProto = js::UncheckedUnwrap(xblProto);
JSAutoCompartment ac2(cx, xblProto);
JS::Value slotVal = ::JS_GetReservedSlot(xblProto, 0);
protoBinding = static_cast<nsXBLPrototypeBinding*>(slotVal.toPrivate());
@ -230,7 +230,7 @@ FieldGetterImpl(JSContext *cx, JS::CallArgs args)
// wrapper. In this case, we know we want to do an unsafe unwrap, and
// InstallXBLField knows how to handle cross-compartment pointers.
bool installed = false;
JS::Rooted<JSObject*> callee(cx, js::UnwrapObject(&args.calleev().toObject()));
JS::Rooted<JSObject*> callee(cx, js::UncheckedUnwrap(&args.calleev().toObject()));
JS::Rooted<jsid> id(cx);
if (!InstallXBLField(cx, callee, thisObj, &id, &installed)) {
return false;
@ -299,7 +299,7 @@ FieldSetterImpl(JSContext *cx, JS::CallArgs args)
// wrapper. In this case, we know we want to do an unsafe unwrap, and
// InstallXBLField knows how to handle cross-compartment pointers.
bool installed = false;
JS::Rooted<JSObject*> callee(cx, js::UnwrapObject(&args.calleev().toObject()));
JS::Rooted<JSObject*> callee(cx, js::UncheckedUnwrap(&args.calleev().toObject()));
JS::Rooted<jsid> id(cx);
if (!InstallXBLField(cx, callee, thisObj, &id, &installed)) {
return false;

View File

@ -4169,7 +4169,7 @@ nsDOMConstructor::HasInstance(nsIXPConnectWrappedNative *wrapper,
NS_ASSERTION(dom_obj, "nsDOMConstructor::HasInstance couldn't get object");
// This might not be the right object, if there are wrappers. Unwrap if we can.
JSObject *wrapped_obj = js::UnwrapObjectChecked(dom_obj, /* stopAtOuter = */ false);
JSObject *wrapped_obj = js::CheckedUnwrap(dom_obj, /* stopAtOuter = */ false);
if (wrapped_obj)
dom_obj = wrapped_obj;
@ -4684,7 +4684,7 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
JSObject* global;
bool defineOnXray = ObjectIsNativeWrapper(cx, obj);
if (defineOnXray) {
global = js::UnwrapObjectChecked(obj, /* stopAtOuter = */ false);
global = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
if (!global) {
return NS_ERROR_DOM_SECURITY_ERR;
}
@ -4932,7 +4932,7 @@ static nsresult
LocationSetterGuts(JSContext *cx, JSObject *obj, jsval *vp)
{
// This function duplicates some of the logic in XPC_WN_HelperSetProperty
obj = js::UnwrapObjectChecked(obj, /* stopAtOuter = */ false);
obj = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
if (!IS_WN_WRAPPER(obj))
return NS_ERROR_XPC_BAD_CONVERT_JS;
XPCWrappedNative *wrapper = XPCWrappedNative::Get(obj);

View File

@ -6540,7 +6540,7 @@ nsGlobalWindow::CallerInnerWindow()
bool ok = JS_GetPrototype(cx, scope, &scopeProto);
NS_ENSURE_TRUE(ok, nullptr);
if (scopeProto && xpc::IsSandboxPrototypeProxy(scopeProto) &&
(scopeProto = js::UnwrapObjectChecked(scopeProto, /* stopAtOuter = */ false)))
(scopeProto = js::CheckedUnwrap(scopeProto, /* stopAtOuter = */ false)))
{
scope = scopeProto;
}

View File

@ -671,7 +671,7 @@ QueryInterface(JSContext* cx, unsigned argc, JS::Value* vp)
// Get the object. It might be a security wrapper, in which case we do a checked
// unwrap.
JSObject* origObj = JSVAL_TO_OBJECT(thisv);
JSObject* obj = js::UnwrapObjectChecked(origObj);
JSObject* obj = js::CheckedUnwrap(origObj);
if (!obj) {
JS_ReportError(cx, "Permission denied to access object");
return false;
@ -1249,7 +1249,7 @@ HasPropertyOnPrototype(JSContext* cx, JSObject* proxy, DOMProxyHandler* handler,
{
Maybe<JSAutoCompartment> ac;
if (xpc::WrapperFactory::IsXrayWrapper(proxy)) {
proxy = js::UnwrapObject(proxy);
proxy = js::UncheckedUnwrap(proxy);
ac.construct(cx, proxy);
}
MOZ_ASSERT(js::IsProxy(proxy) && js::GetProxyHandler(proxy) == handler);
@ -1592,7 +1592,7 @@ GetGlobalObject(JSContext* aCx, JSObject* aObject,
Maybe<JSAutoCompartment>& aAutoCompartment)
{
if (js::IsWrapper(aObject)) {
aObject = js::UnwrapObjectChecked(aObject, /* stopAtOuter = */ false);
aObject = js::CheckedUnwrap(aObject, /* stopAtOuter = */ false);
if (!aObject) {
Throw<mainThread>(aCx, NS_ERROR_XPC_SECURITY_MANAGER_VETO);
return nullptr;
@ -1641,7 +1641,7 @@ InterfaceHasInstance(JSContext* cx, JSHandleObject obj, JSObject* instance,
const DOMIfaceAndProtoJSClass* clasp =
DOMIfaceAndProtoJSClass::FromJSClass(js::GetObjectClass(obj));
const DOMClass* domClass = GetDOMClass(js::UnwrapObject(instance));
const DOMClass* domClass = GetDOMClass(js::UncheckedUnwrap(instance));
MOZ_ASSERT(!domClass || clasp->mPrototypeID != prototypes::id::_ID_Count,
"Why do we have a hasInstance hook if we don't have a prototype "

View File

@ -160,7 +160,7 @@ UnwrapObject(JSContext* cx, JSObject* obj, U& value)
return NS_ERROR_XPC_BAD_CONVERT_JS;
}
obj = js::UnwrapObjectChecked(obj, /* stopAtOuter = */ false);
obj = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
if (!obj) {
return NS_ERROR_XPC_SECURITY_MANAGER_VETO;
}
@ -621,7 +621,7 @@ WrapNewBindingNonWrapperCachedObject(JSContext* cx, JSObject* scope, T* value,
// before we call JS_WrapValue.
Maybe<JSAutoCompartment> ac;
if (js::IsWrapper(scope)) {
scope = js::UnwrapObjectChecked(scope, /* stopAtOuter = */ false);
scope = js::CheckedUnwrap(scope, /* stopAtOuter = */ false);
if (!scope)
return false;
ac.construct(cx, scope);

View File

@ -50,7 +50,7 @@ CallbackObject::CallSetup::CallSetup(JSObject* const aCallback,
// callable.
// First, find the real underlying callback.
JSObject* realCallback = js::UnwrapObject(aCallback);
JSObject* realCallback = js::UncheckedUnwrap(aCallback);
// Now get the nsIScriptGlobalObject for this callback.
JSContext* cx = nullptr;
@ -106,7 +106,7 @@ CallbackObject::CallSetup::CallSetup(JSObject* const aCallback,
// Make sure to unwrap aCallback before passing it in, because
// getting principals from wrappers is silly.
nsresult rv = nsContentUtils::GetSecurityManager()->
CheckFunctionAccess(cx, js::UnwrapObject(aCallback), nullptr);
CheckFunctionAccess(cx, js::UncheckedUnwrap(aCallback), nullptr);
// Construct a termination func holder even if we're not planning to
// run any script. We need this because we're going to call

View File

@ -54,7 +54,7 @@ public:
// If aOwner is not null, enter the compartment of aOwner's
// underlying object.
if (aOwner) {
aOwner = js::UnwrapObject(aOwner);
aOwner = js::UncheckedUnwrap(aOwner);
JSAutoCompartment ac(cx, aOwner);
if (!JS_WrapObject(cx, &aCallback)) {
*aInited = false;
@ -282,9 +282,9 @@ public:
}
JSObject* thisObj =
js::UnwrapObject(GetWebIDLCallback()->CallbackPreserveColor());
js::UncheckedUnwrap(GetWebIDLCallback()->CallbackPreserveColor());
JSObject* otherObj =
js::UnwrapObject(aOtherCallback->CallbackPreserveColor());
js::UncheckedUnwrap(aOtherCallback->CallbackPreserveColor());
return thisObj == otherObj;
}

View File

@ -1111,14 +1111,14 @@ class CGClassHasInstanceHook(CGAbstractStaticMethod):
// FIXME Limit this to chrome by checking xpc::AccessCheck::isChrome(obj).
nsISupports* native =
nsContentUtils::XPConnect()->GetNativeOfWrapper(cx,
js::UnwrapObject(instance));
js::UncheckedUnwrap(instance));
nsCOMPtr<nsIDOM%s> qiResult = do_QueryInterface(native);
*bp = !!qiResult;
return true;
""" % self.descriptor.interface.identifier.name
hasInstanceCode = """
const DOMClass* domClass = GetDOMClass(js::UnwrapObject(instance));
const DOMClass* domClass = GetDOMClass(js::UncheckedUnwrap(instance));
*bp = false;
if (!domClass) {
// Not a DOM object, so certainly not an instance of this interface
@ -6090,7 +6090,7 @@ class CGProxyUnwrap(CGAbstractMethod):
return """ MOZ_ASSERT(js::IsProxy(obj));
if (js::GetProxyHandler(obj) != DOMProxyHandler::getInstance()) {
MOZ_ASSERT(xpc::WrapperFactory::IsXrayWrapper(obj));
obj = js::UnwrapObject(obj);
obj = js::UncheckedUnwrap(obj);
}
MOZ_ASSERT(IsProxy(obj));
return static_cast<%s*>(js::GetProxyPrivate(obj).toPrivate());""" % (self.descriptor.nativeType)

View File

@ -465,7 +465,7 @@ JSValToNPVariant(NPP npp, JSContext *cx, JS::Value val, NPVariant *variant)
// legitimate cases where a security wrapper ends up here (for example,
// Location objects, which are _always_ behind security wrappers).
JSObject *obj = JSVAL_TO_OBJECT(val);
obj = js::UnwrapObjectChecked(obj);
obj = js::CheckedUnwrap(obj);
if (!obj) {
obj = JSVAL_TO_OBJECT(val);
}
@ -1127,7 +1127,7 @@ nsJSObjWrapper::GetNewOrUsed(NPP npp, JSContext *cx, JSObject *obj)
static JSObject *
GetNPObjectWrapper(JSContext *cx, JSObject *obj, bool wrapResult = true)
{
while (obj && (obj = js::UnwrapObjectChecked(obj))) {
while (obj && (obj = js::CheckedUnwrap(obj))) {
if (JS_GetClass(obj) == &sNPObjectJSWrapperClass) {
if (wrapResult && !JS_WrapObject(cx, &obj)) {
return NULL;

View File

@ -294,7 +294,7 @@ nsresult nsJSThunk::EvaluateScript(nsIChannel *aChannel,
JSObject *sandboxObj;
rv = sandbox->GetJSObject(&sandboxObj);
NS_ENSURE_SUCCESS(rv, rv);
sandboxObj = js::UnwrapObject(sandboxObj);
sandboxObj = js::UncheckedUnwrap(sandboxObj);
JSAutoCompartment ac(cx, sandboxObj);
// Push our JSContext on the context stack so the JS_ValueToString call (and

View File

@ -60,7 +60,7 @@ nsresult CentralizedAdminPrefManagerInit()
// Unwrap, store and root the sandbox.
rv = sandbox->GetJSObject(&autoconfigSb);
NS_ENSURE_SUCCESS(rv, rv);
autoconfigSb = js::UnwrapObject(autoconfigSb);
autoconfigSb = js::UncheckedUnwrap(autoconfigSb);
JSAutoCompartment ac(cx, autoconfigSb);
if (!JS_AddNamedObjectRoot(cx, &autoconfigSb, "AutoConfig Sandbox"))
return NS_ERROR_FAILURE;

View File

@ -205,7 +205,7 @@ GC(JSContext *cx, unsigned argc, jsval *vp)
if (!JS_StringEqualsAscii(cx, arg.toString(), "compartment", &compartment))
return false;
} else if (arg.isObject()) {
PrepareZoneForGC(UnwrapObject(&arg.toObject())->zone());
PrepareZoneForGC(UncheckedUnwrap(&arg.toObject())->zone());
compartment = true;
}
}
@ -408,7 +408,7 @@ ScheduleGC(JSContext *cx, unsigned argc, jsval *vp)
JS_ScheduleGC(cx, args[0].toInt32());
} else if (args[0].isObject()) {
/* Ensure that |zone| is collected during the next GC. */
Zone *zone = UnwrapObject(&args[0].toObject())->zone();
Zone *zone = UncheckedUnwrap(&args[0].toObject())->zone();
PrepareZoneForGC(zone);
} else if (args[0].isString()) {
/* This allows us to schedule atomsCompartment for GC. */

View File

@ -34,7 +34,7 @@ BooleanGetPrimitiveValue(JSContext *cx, HandleObject obj, Value *vp)
inline bool
EmulatesUndefined(RawObject obj)
{
RawObject actual = MOZ_LIKELY(!obj->isWrapper()) ? obj : UnwrapObject(obj);
RawObject actual = MOZ_LIKELY(!obj->isWrapper()) ? obj : UncheckedUnwrap(obj);
bool emulatesUndefined = actual->getClass()->emulatesUndefined();
MOZ_ASSERT_IF(emulatesUndefined, obj->type()->flags & types::OBJECT_FLAG_EMULATES_UNDEFINED);
return emulatesUndefined;

View File

@ -461,7 +461,7 @@ JSStructuredCloneWriter::parseTransferable()
return false;
}
JSObject* tObj = UnwrapObjectChecked(&v.toObject());
JSObject* tObj = CheckedUnwrap(&v.toObject());
if (!tObj) {
JS_ReportError(context(), "Permission denied to access object");
return false;
@ -544,7 +544,7 @@ JS_WriteTypedArray(JSStructuredCloneWriter *w, jsval v)
// If the object is a security wrapper, see if we're allowed to unwrap it.
// If we aren't, throw.
if (obj->isWrapper())
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
if (!obj) {
JS_ReportError(w->context(), "Permission denied to access object");
return false;
@ -648,7 +648,7 @@ JSStructuredCloneWriter::startWrite(const Value &v)
// The object might be a security wrapper. See if we can clone what's
// behind it. If we can, unwrap the object.
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
if (!obj) {
JS_ReportError(context(), "Permission denied to access object");
return false;

View File

@ -263,7 +263,7 @@ JSCompartment::wrap(JSContext *cx, MutableHandleValue vp, HandleObject existingA
return js_FindClassObject(cx, JSProto_StopIteration, vp);
/* Unwrap the object, but don't unwrap outer windows. */
obj = UnwrapObject(obj, /* stopAtOuter = */ true, &flags);
obj = UncheckedUnwrap(obj, /* stopAtOuter = */ true, &flags);
if (obj->compartment() == this)
return WrapForSameCompartment(cx, obj, vp);

View File

@ -923,13 +923,13 @@ JS_DumpCompartmentPCCounts(JSContext *cx)
JS_PUBLIC_API(JSObject *)
JS_UnwrapObject(JSObject *obj)
{
return UnwrapObject(obj);
return UncheckedUnwrap(obj);
}
JS_PUBLIC_API(JSObject *)
JS_UnwrapObjectAndInnerize(JSObject *obj)
{
return UnwrapObject(obj, /* stopAtOuter = */ false);
return UncheckedUnwrap(obj, /* stopAtOuter = */ false);
}
JS_FRIEND_API(JSBool)

View File

@ -71,7 +71,7 @@ JS_FindCompilationScope(JSContext *cx, RawObject objArg)
* asked of us.
*/
if (obj->isWrapper())
obj = UnwrapObject(obj);
obj = UncheckedUnwrap(obj);
/*
* Innerize the target_obj so that we compile in the correct (inner)

View File

@ -563,7 +563,7 @@ DirectProxyHandler::defaultValue(JSContext *cx, HandleObject proxy, JSType hint,
JSObject *
DirectProxyHandler::weakmapKeyDelegate(JSObject *proxy)
{
return UnwrapObject(proxy);
return UncheckedUnwrap(proxy);
}
DirectProxyHandler::DirectProxyHandler(void *family)

View File

@ -1839,7 +1839,7 @@ class TypedArrayTemplate
* properties from the object, treating it as some sort of array.
* Note that offset and length will be ignored
*/
if (!UnwrapObject(dataObj)->isArrayBuffer())
if (!UncheckedUnwrap(dataObj)->isArrayBuffer())
return fromArray(cx, dataObj);
/* (ArrayBuffer, [byteOffset, [length]]) */
@ -2122,7 +2122,7 @@ class TypedArrayTemplate
* compartment for a view in the target compartment referencing the
* ArrayBuffer in that same compartment.
*/
JSObject *wrapped = UnwrapObjectChecked(bufobj);
JSObject *wrapped = CheckedUnwrap(bufobj);
if (!wrapped) {
JS_ReportError(cx, "Permission denied to access object");
return NULL;
@ -2745,7 +2745,7 @@ DataViewObject::class_constructor(JSContext *cx, unsigned argc, Value *vp)
if (!GetFirstArgumentAsObject(cx, args, "DataView constructor", &bufobj))
return false;
if (bufobj->isWrapper() && UnwrapObject(bufobj)->isArrayBuffer()) {
if (bufobj->isWrapper() && UncheckedUnwrap(bufobj)->isArrayBuffer()) {
Rooted<GlobalObject*> global(cx, cx->compartment->maybeGlobal());
Rooted<JSObject*> proto(cx, global->getOrCreateDataViewPrototype(cx));
if (!proto)
@ -3392,7 +3392,7 @@ JSFunctionSpec _typedArray::jsfuncs[] = { \
} \
JS_FRIEND_API(JSBool) JS_Is ## Name ## Array(JSObject *obj) \
{ \
if (!(obj = UnwrapObjectChecked(obj))) \
if (!(obj = CheckedUnwrap(obj))) \
return false; \
Class *clasp = obj->getClass(); \
return (clasp == &TypedArray::classes[TypedArrayTemplate<NativeType>::ArrayTypeID()]); \
@ -3413,7 +3413,7 @@ IMPL_TYPED_ARRAY_JSAPI_CONSTRUCTORS(Float64, double)
uint32_t *length, \
ExternalType **data) \
{ \
if (!(obj = UnwrapObjectChecked(obj))) \
if (!(obj = CheckedUnwrap(obj))) \
return NULL; \
\
Class *clasp = obj->getClass(); \
@ -3861,35 +3861,35 @@ js::IsTypedArrayBuffer(const Value &v)
JS_FRIEND_API(JSBool)
JS_IsArrayBufferObject(JSObject *obj)
{
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
return obj ? obj->isArrayBuffer() : false;
}
JS_FRIEND_API(JSBool)
JS_IsTypedArrayObject(JSObject *obj)
{
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
return obj ? obj->isTypedArray() : false;
}
JS_FRIEND_API(JSBool)
JS_IsArrayBufferViewObject(JSObject *obj)
{
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
return obj ? (obj->isTypedArray() || obj->isDataView()) : false;
}
JS_FRIEND_API(uint32_t)
JS_GetArrayBufferByteLength(JSObject *obj)
{
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
return obj ? obj->asArrayBuffer().byteLength() : 0;
}
JS_FRIEND_API(uint8_t *)
JS_GetArrayBufferData(JSObject *obj)
{
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
if (!obj)
return NULL;
ArrayBufferObject &buffer = obj->asArrayBuffer();
@ -3935,7 +3935,7 @@ JS_PUBLIC_API(JSBool)
JS_StealArrayBufferContents(JSContext *cx, JSObject *obj, void **contents,
uint8_t **data)
{
if (!(obj = UnwrapObjectChecked(obj)))
if (!(obj = CheckedUnwrap(obj)))
return false;
if (!obj->isArrayBuffer()) {
@ -3952,7 +3952,7 @@ JS_StealArrayBufferContents(JSContext *cx, JSObject *obj, void **contents,
JS_FRIEND_API(uint32_t)
JS_GetTypedArrayLength(JSObject *obj)
{
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
if (!obj)
return 0;
JS_ASSERT(obj->isTypedArray());
@ -3962,7 +3962,7 @@ JS_GetTypedArrayLength(JSObject *obj)
JS_FRIEND_API(uint32_t)
JS_GetTypedArrayByteOffset(JSObject *obj)
{
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
if (!obj)
return 0;
JS_ASSERT(obj->isTypedArray());
@ -3972,7 +3972,7 @@ JS_GetTypedArrayByteOffset(JSObject *obj)
JS_FRIEND_API(uint32_t)
JS_GetTypedArrayByteLength(JSObject *obj)
{
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
if (!obj)
return 0;
JS_ASSERT(obj->isTypedArray());
@ -3982,7 +3982,7 @@ JS_GetTypedArrayByteLength(JSObject *obj)
JS_FRIEND_API(JSArrayBufferViewType)
JS_GetArrayBufferViewType(JSObject *obj)
{
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
if (!obj)
return ArrayBufferView::TYPE_MAX;
@ -3997,7 +3997,7 @@ JS_GetArrayBufferViewType(JSObject *obj)
JS_FRIEND_API(int8_t *)
JS_GetInt8ArrayData(JSObject *obj)
{
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
if (!obj)
return NULL;
JS_ASSERT(obj->isTypedArray());
@ -4008,7 +4008,7 @@ JS_GetInt8ArrayData(JSObject *obj)
JS_FRIEND_API(uint8_t *)
JS_GetUint8ArrayData(JSObject *obj)
{
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
if (!obj)
return NULL;
JS_ASSERT(obj->isTypedArray());
@ -4019,7 +4019,7 @@ JS_GetUint8ArrayData(JSObject *obj)
JS_FRIEND_API(uint8_t *)
JS_GetUint8ClampedArrayData(JSObject *obj)
{
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
if (!obj)
return NULL;
JS_ASSERT(obj->isTypedArray());
@ -4030,7 +4030,7 @@ JS_GetUint8ClampedArrayData(JSObject *obj)
JS_FRIEND_API(int16_t *)
JS_GetInt16ArrayData(JSObject *obj)
{
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
if (!obj)
return NULL;
JS_ASSERT(obj->isTypedArray());
@ -4041,7 +4041,7 @@ JS_GetInt16ArrayData(JSObject *obj)
JS_FRIEND_API(uint16_t *)
JS_GetUint16ArrayData(JSObject *obj)
{
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
if (!obj)
return NULL;
JS_ASSERT(obj->isTypedArray());
@ -4052,7 +4052,7 @@ JS_GetUint16ArrayData(JSObject *obj)
JS_FRIEND_API(int32_t *)
JS_GetInt32ArrayData(JSObject *obj)
{
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
if (!obj)
return NULL;
JS_ASSERT(obj->isTypedArray());
@ -4063,7 +4063,7 @@ JS_GetInt32ArrayData(JSObject *obj)
JS_FRIEND_API(uint32_t *)
JS_GetUint32ArrayData(JSObject *obj)
{
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
if (!obj)
return NULL;
JS_ASSERT(obj->isTypedArray());
@ -4074,7 +4074,7 @@ JS_GetUint32ArrayData(JSObject *obj)
JS_FRIEND_API(float *)
JS_GetFloat32ArrayData(JSObject *obj)
{
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
if (!obj)
return NULL;
JS_ASSERT(obj->isTypedArray());
@ -4085,7 +4085,7 @@ JS_GetFloat32ArrayData(JSObject *obj)
JS_FRIEND_API(double *)
JS_GetFloat64ArrayData(JSObject *obj)
{
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
if (!obj)
return NULL;
JS_ASSERT(obj->isTypedArray());
@ -4096,14 +4096,14 @@ JS_GetFloat64ArrayData(JSObject *obj)
JS_FRIEND_API(JSBool)
JS_IsDataViewObject(JSObject *obj)
{
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
return obj ? obj->isDataView() : false;
}
JS_FRIEND_API(uint32_t)
JS_GetDataViewByteOffset(JSObject *obj)
{
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
if (!obj)
return 0;
return obj->asDataView().byteOffset();
@ -4112,7 +4112,7 @@ JS_GetDataViewByteOffset(JSObject *obj)
JS_FRIEND_API(void *)
JS_GetDataViewData(JSObject *obj)
{
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
if (!obj)
return NULL;
JS_ASSERT(obj->isDataView());
@ -4122,7 +4122,7 @@ JS_GetDataViewData(JSObject *obj)
JS_FRIEND_API(uint32_t)
JS_GetDataViewByteLength(JSObject *obj)
{
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
if (!obj)
return 0;
JS_ASSERT(obj->isDataView());
@ -4132,7 +4132,7 @@ JS_GetDataViewByteLength(JSObject *obj)
JS_FRIEND_API(void *)
JS_GetArrayBufferViewData(JSObject *obj)
{
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
if (!obj)
return NULL;
JS_ASSERT(obj->isTypedArray() || obj->isDataView());
@ -4142,7 +4142,7 @@ JS_GetArrayBufferViewData(JSObject *obj)
JS_FRIEND_API(JSObject *)
JS_GetArrayBufferViewBuffer(JSObject *obj)
{
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
if (!obj)
return NULL;
JS_ASSERT(obj->isTypedArray() || obj->isDataView());
@ -4152,7 +4152,7 @@ JS_GetArrayBufferViewBuffer(JSObject *obj)
JS_FRIEND_API(uint32_t)
JS_GetArrayBufferViewByteLength(JSObject *obj)
{
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
if (!obj)
return 0;
JS_ASSERT(obj->isTypedArray() || obj->isDataView());
@ -4164,7 +4164,7 @@ JS_GetArrayBufferViewByteLength(JSObject *obj)
JS_FRIEND_API(JSObject *)
JS_GetObjectAsArrayBufferView(JSObject *obj, uint32_t *length, uint8_t **data)
{
if (!(obj = UnwrapObjectChecked(obj)))
if (!(obj = CheckedUnwrap(obj)))
return NULL;
if (!(obj->isTypedArray() || obj->isDataView()))
return NULL;
@ -4180,7 +4180,7 @@ JS_GetObjectAsArrayBufferView(JSObject *obj, uint32_t *length, uint8_t **data)
JS_FRIEND_API(JSObject *)
JS_GetObjectAsArrayBuffer(JSObject *obj, uint32_t *length, uint8_t **data)
{
if (!(obj = UnwrapObjectChecked(obj)))
if (!(obj = CheckedUnwrap(obj)))
return NULL;
if (!obj->isArrayBuffer())
return NULL;

View File

@ -339,7 +339,7 @@ JS_FRIEND_API(JSBool)
JS_NondeterministicGetWeakMapKeys(JSContext *cx, JSObject *objArg, JSObject **ret)
{
RootedObject obj(cx, objArg);
obj = UnwrapObject(obj);
obj = UncheckedUnwrap(obj);
if (!obj || !obj->isWeakMap()) {
*ret = NULL;
return true;

View File

@ -71,7 +71,7 @@ Wrapper::wrappedObject(RawObject wrapper)
}
JS_FRIEND_API(JSObject *)
js::UnwrapObject(JSObject *wrapped, bool stopAtOuter, unsigned *flagsp)
js::UncheckedUnwrap(JSObject *wrapped, bool stopAtOuter, unsigned *flagsp)
{
unsigned flags = 0;
while (wrapped->isWrapper() &&
@ -85,7 +85,7 @@ js::UnwrapObject(JSObject *wrapped, bool stopAtOuter, unsigned *flagsp)
}
JS_FRIEND_API(JSObject *)
js::UnwrapObjectChecked(RawObject obj, bool stopAtOuter)
js::CheckedUnwrap(RawObject obj, bool stopAtOuter)
{
while (true) {
JSObject *wrapper = obj;
@ -485,7 +485,7 @@ CrossCompartmentWrapper::nativeCall(JSContext *cx, IsAcceptableThis test, Native
{
RootedObject wrapper(cx, &srcArgs.thisv().toObject());
JS_ASSERT(srcArgs.thisv().isMagic(JS_IS_CONSTRUCTING) ||
!UnwrapObject(wrapper)->isCrossCompartmentWrapper());
!UncheckedUnwrap(wrapper)->isCrossCompartmentWrapper());
RootedObject wrapped(cx, wrappedObject(wrapper));
{
@ -926,7 +926,7 @@ js::NukeCrossCompartmentWrappers(JSContext* cx,
continue;
AutoWrapperRooter wobj(cx, WrapperValue(e));
JSObject *wrapped = UnwrapObject(wobj);
JSObject *wrapped = UncheckedUnwrap(wobj);
if (nukeReferencesToWindow == DontNukeWindowReferences &&
wrapped->getClass()->ext.innerObject)

View File

@ -43,7 +43,7 @@ class JS_FRIEND_API(Wrapper) : public DirectProxyHandler
* Wrappers can explicitly specify that they are unsafe to unwrap from a
* security perspective (as is the case for SecurityWrappers). If a wrapper
* is not safe to unwrap, operations requiring full access to the underlying
* object (via UnwrapObjectChecked) will throw. Otherwise, they will succeed.
* object (via CheckedUnwrap) will throw. Otherwise, they will succeed.
*/
void setSafeToUnwrap(bool safe) { mSafeToUnwrap = safe; }
virtual bool isSafeToUnwrap() { return mSafeToUnwrap; }
@ -224,14 +224,14 @@ IsWrapper(RawObject obj)
// previously wrapped. Otherwise, this returns the first object for
// which JSObject::isWrapper returns false.
JS_FRIEND_API(JSObject *)
UnwrapObject(JSObject *obj, bool stopAtOuter = true, unsigned *flagsp = NULL);
UncheckedUnwrap(JSObject *obj, bool stopAtOuter = true, unsigned *flagsp = NULL);
// Given a JSObject, returns that object stripped of wrappers. At each stage,
// the security wrapper has the opportunity to veto the unwrap. Since checked
// code should never be unwrapping outer window wrappers, we always stop at
// outer windows.
JS_FRIEND_API(JSObject *)
UnwrapObjectChecked(RawObject obj, bool stopAtOuter = true);
CheckedUnwrap(RawObject obj, bool stopAtOuter = true);
// Unwrap only the outermost security wrapper, with the same semantics as
// above. This is the checked version of Wrapper::wrappedObject.

View File

@ -2284,7 +2284,7 @@ Clone(JSContext *cx, unsigned argc, jsval *vp)
RootedObject obj(cx, JSVAL_IS_PRIMITIVE(args[0]) ? NULL : &args[0].toObject());
if (obj && IsCrossCompartmentWrapper(obj)) {
obj = UnwrapObject(obj);
obj = UncheckedUnwrap(obj);
ac.construct(cx, obj);
args[0] = ObjectValue(*obj);
}
@ -2520,7 +2520,7 @@ EvalInContext(JSContext *cx, unsigned argc, jsval *vp)
{
Maybe<JSAutoCompartment> ac;
unsigned flags;
JSObject *unwrapped = UnwrapObject(sobj, true, &flags);
JSObject *unwrapped = UncheckedUnwrap(sobj, true, &flags);
if (flags & Wrapper::CROSS_COMPARTMENT) {
sobj = unwrapped;
ac.construct(cx, sobj);
@ -3460,7 +3460,7 @@ NewGlobal(JSContext *cx, unsigned argc, jsval *vp)
{
JSObject *sameZoneAs = NULL;
if (argc == 1 && JS_ARGV(cx, vp)[0].isObject())
sameZoneAs = UnwrapObject(&JS_ARGV(cx, vp)[0].toObject());
sameZoneAs = UncheckedUnwrap(&JS_ARGV(cx, vp)[0].toObject());
RootedObject global(cx, NewGlobalObject(cx, sameZoneAs));
if (!global)

View File

@ -1863,7 +1863,7 @@ Debugger::unwrapDebuggeeArgument(JSContext *cx, const Value &v)
}
/* If we have a cross-compartment wrapper, dereference as far as is secure. */
obj = UnwrapObjectChecked(obj);
obj = CheckedUnwrap(obj);
if (!obj) {
JS_ReportError(cx, "Permission denied to access object");
return NULL;
@ -4721,7 +4721,7 @@ RequireGlobalObject(JSContext *cx, HandleValue dbgobj, HandleObject obj)
if (!obj->isGlobal()) {
/* Help the poor programmer by pointing out wrappers around globals. */
if (obj->isWrapper()) {
JSObject *unwrapped = js::UnwrapObject(obj);
JSObject *unwrapped = js::UncheckedUnwrap(obj);
if (unwrapped->isGlobal()) {
js_ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_DEBUG_WRAPPER_IN_WAY,
JSDVG_SEARCH_STACK, dbgobj, NullPtr(),

View File

@ -152,7 +152,7 @@ XPCCallContext::Init(XPCContext::LangType callerLanguage,
if (wrapperInitOptions == INIT_SHOULD_LOOKUP_WRAPPER) {
// If the object is a security wrapper, GetWrappedNativeOfJSObject can't
// handle it. Do special handling here to make cross-origin Xrays work.
JSObject *unwrapped = js::UnwrapObjectChecked(obj, /* stopAtOuter = */ false);
JSObject *unwrapped = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
if (!unwrapped) {
mWrapper = UnwrapThisIfAllowed(obj, funobj, argc);
if (!mWrapper) {
@ -463,7 +463,7 @@ XPCCallContext::UnwrapThisIfAllowed(JSObject *object, JSObject *fun, unsigned ar
{
JS::Rooted<JSObject *> obj(mJSContext, object);
// We should only get here for objects that aren't safe to unwrap.
MOZ_ASSERT(!js::UnwrapObjectChecked(obj));
MOZ_ASSERT(!js::CheckedUnwrap(obj));
MOZ_ASSERT(js::IsObjectInContextCompartment(obj, mJSContext));
// We can't do anything here without a function.
@ -482,7 +482,7 @@ XPCCallContext::UnwrapThisIfAllowed(JSObject *object, JSObject *fun, unsigned ar
// First, get the XPCWN out of the underlying object. We should have a wrapper
// here, potentially an outer window proxy, and then an XPCWN.
MOZ_ASSERT(js::IsWrapper(obj));
JSObject *unwrapped = js::UnwrapObject(obj, /* stopAtOuter = */ false);
JSObject *unwrapped = js::UncheckedUnwrap(obj, /* stopAtOuter = */ false);
MOZ_ASSERT(unwrapped == JS_ObjectToInnerObject(mJSContext, js::Wrapper::wrappedObject(obj)));
// Make sure we have an XPCWN, and grab it.

View File

@ -2748,7 +2748,7 @@ nsXPCComponents_Utils::LookupMethod(const JS::Value& object,
// If |obj| is a security wrapper, try to unwrap it. If this fails, we
// don't have full acccess to the object, in which case we throw.
// Otherwise, enter a compartment, since we may have just unwrapped a CCW.
obj = js::UnwrapObjectChecked(obj);
obj = js::CheckedUnwrap(obj);
if (!obj) {
JS_ReportError(cx, "Permission denied to unwrap object");
return NS_ERROR_XPC_BAD_CONVERT_JS;
@ -3351,7 +3351,7 @@ xpc_CreateSandboxObject(JSContext *cx, jsval *vp, nsISupports *prinOrSop, Sandbo
}
JS::ZoneSpecifier zoneSpec = options.sameZoneAs
? JS::SameZoneAs(js::UnwrapObject(options.sameZoneAs))
? JS::SameZoneAs(js::UncheckedUnwrap(options.sameZoneAs))
: JS::SystemZone;
RootedObject sandbox(cx, xpc::CreateGlobalObject(cx, &SandboxClass, principal, zoneSpec));
if (!sandbox)
@ -3387,7 +3387,7 @@ xpc_CreateSandboxObject(JSContext *cx, jsval *vp, nsISupports *prinOrSop, Sandbo
}
// Now check what sort of thing we've got in |proto|
JSObject *unwrappedProto = js::UnwrapObject(options.proto, false);
JSObject *unwrappedProto = js::UncheckedUnwrap(options.proto, false);
js::Class *unwrappedClass = js::GetObjectClass(unwrappedProto);
if (IS_WRAPPER_CLASS(unwrappedClass) ||
mozilla::dom::IsDOMClass(Jsvalify(unwrappedClass))) {
@ -3956,7 +3956,7 @@ xpc_EvalInSandbox(JSContext *cx, HandleObject sandboxArg, const nsAString& sourc
rval.set(UndefinedValue());
bool waiveXray = xpc::WrapperFactory::HasWaiveXrayFlag(sandboxArg);
RootedObject sandbox(cx, js::UnwrapObjectChecked(sandboxArg));
RootedObject sandbox(cx, js::CheckedUnwrap(sandboxArg));
if (!sandbox || js::GetObjectJSClass(sandbox) != &SandboxClass) {
return NS_ERROR_INVALID_ARG;
}
@ -4216,7 +4216,7 @@ nsXPCComponents_Utils::GetGlobalForObject(const JS::Value& object,
// parent, enter the compartment for the duration of the call, and wrap the
// result.
JS::Rooted<JSObject*> obj(cx, JSVAL_TO_OBJECT(object));
obj = js::UnwrapObject(obj);
obj = js::UncheckedUnwrap(obj);
{
JSAutoCompartment ac(cx, obj);
obj = JS_GetGlobalForObject(cx, obj);
@ -4242,7 +4242,7 @@ nsXPCComponents_Utils::CreateObjectIn(const Value &vobj, JSContext *cx, Value *r
if (vobj.isPrimitive())
return NS_ERROR_XPC_BAD_CONVERT_JS;
RootedObject scope(cx, js::UnwrapObject(&vobj.toObject()));
RootedObject scope(cx, js::UncheckedUnwrap(&vobj.toObject()));
RootedObject obj(cx);
{
JSAutoCompartment ac(cx, scope);
@ -4269,7 +4269,7 @@ nsXPCComponents_Utils::CreateArrayIn(const Value &vobj, JSContext *cx, Value *rv
if (vobj.isPrimitive())
return NS_ERROR_XPC_BAD_CONVERT_JS;
RootedObject scope(cx, js::UnwrapObject(&vobj.toObject()));
RootedObject scope(cx, js::UncheckedUnwrap(&vobj.toObject()));
RootedObject obj(cx);
{
JSAutoCompartment ac(cx, scope);
@ -4296,7 +4296,7 @@ nsXPCComponents_Utils::CreateDateIn(const Value &vobj, int64_t msec,JSContext *c
if (JSVAL_IS_PRIMITIVE(vobj))
return NS_ERROR_XPC_BAD_CONVERT_JS;
JSObject *scope = js::UnwrapObject(JSVAL_TO_OBJECT(vobj));
JSObject *scope = js::UncheckedUnwrap(JSVAL_TO_OBJECT(vobj));
JSObject *obj;
{
JSAutoCompartment ac(cx, scope);
@ -4352,8 +4352,7 @@ nsXPCComponents_Utils::MakeObjectPropsNormal(const Value &vobj, JSContext *cx)
if (vobj.isPrimitive())
return NS_ERROR_XPC_BAD_CONVERT_JS;
RootedObject obj(cx, js::UnwrapObject(&vobj.toObject()));
RootedObject obj(cx, js::UncheckedUnwrap(&vobj.toObject()));
JSAutoCompartment ac(cx, obj);
JS::AutoIdArray ida(cx, JS_Enumerate(cx, obj));
if (!ida)
@ -4400,7 +4399,7 @@ nsXPCComponents_Utils::RecomputeWrappers(const jsval &vobj, JSContext *cx)
{
// Determine the compartment of the given object, if any.
JSCompartment *c = vobj.isObject()
? js::GetObjectCompartment(js::UnwrapObject(&vobj.toObject()))
? js::GetObjectCompartment(js::UncheckedUnwrap(&vobj.toObject()))
: NULL;
// If no compartment was given, recompute all.
@ -4420,7 +4419,7 @@ nsXPCComponents_Utils::SetWantXrays(const jsval &vscope, JSContext *cx)
{
if (!vscope.isObject())
return NS_ERROR_INVALID_ARG;
JSObject *scopeObj = js::UnwrapObject(&vscope.toObject());
JSObject *scopeObj = js::UncheckedUnwrap(&vscope.toObject());
JSCompartment *compartment = js::GetObjectCompartment(scopeObj);
EnsureCompartmentPrivate(scopeObj)->wantXrays = true;
bool ok = js::RecomputeWrappers(cx, js::SingleCompartment(compartment),
@ -4436,7 +4435,7 @@ nsXPCComponents_Utils::GetComponentsForScope(const jsval &vscope, JSContext *cx,
{
if (!vscope.isObject())
return NS_ERROR_INVALID_ARG;
JSObject *scopeObj = js::UnwrapObject(&vscope.toObject());
JSObject *scopeObj = js::UncheckedUnwrap(&vscope.toObject());
XPCWrappedNativeScope *scope = GetObjectScope(scopeObj);
XPCCallContext ccx(NATIVE_CALLER, cx);
JSObject *components = scope->GetComponentsJSObject(ccx);
@ -4456,7 +4455,7 @@ nsXPCComponents_Utils::Dispatch(const jsval &runnable_, const jsval &scope,
Maybe<JSAutoCompartment> ac;
RootedValue runnable(cx, runnable_);
if (scope.isObject()) {
JSObject *scopeObj = js::UnwrapObject(&scope.toObject());
JSObject *scopeObj = js::UncheckedUnwrap(&scope.toObject());
if (!scopeObj)
return NS_ERROR_FAILURE;
ac.construct(cx, scopeObj);
@ -4570,7 +4569,7 @@ nsXPCComponents_Utils::NukeSandbox(const JS::Value &obj, JSContext *cx)
NS_ENSURE_TRUE(obj.isObject(), NS_ERROR_INVALID_ARG);
JSObject *wrapper = &obj.toObject();
NS_ENSURE_TRUE(IsWrapper(wrapper), NS_ERROR_INVALID_ARG);
JSObject *sb = UnwrapObject(wrapper);
JSObject *sb = UncheckedUnwrap(wrapper);
NS_ENSURE_TRUE(GetObjectJSClass(sb) == &SandboxClass, NS_ERROR_INVALID_ARG);
NukeCrossCompartmentWrappers(cx, AllCompartments(),
SingleCompartment(GetObjectCompartment(sb)),

View File

@ -1031,7 +1031,7 @@ XPCConvert::JSObject2NativeInterface(JSContext* cx,
// If we're looking at a security wrapper, see now if we're allowed to
// pass it to C++. If we are, then fall through to the code below. If
// we aren't, throw an exception eagerly.
JSObject* inner = js::UnwrapObjectChecked(src, /* stopAtOuter = */ false);
JSObject* inner = js::CheckedUnwrap(src, /* stopAtOuter = */ false);
// Hack - For historical reasons, wrapped chrome JS objects have been
// passable as native interfaces. We'd like to fix this, but it
@ -1039,7 +1039,7 @@ XPCConvert::JSObject2NativeInterface(JSContext* cx,
// COWs. This needs to happen, but for now just preserve the old
// behavior.
if (!inner && MOZ_UNLIKELY(xpc::WrapperFactory::IsCOW(src)))
inner = js::UnwrapObject(src);
inner = js::UncheckedUnwrap(src);
if (!inner) {
if (pErr)
*pErr = NS_ERROR_XPC_SECURITY_MANAGER_VETO;
@ -1176,7 +1176,7 @@ XPCConvert::JSValToXPCException(XPCCallContext& ccx,
}
// is this really a native xpcom object with a wrapper?
JSObject *unwrapped = js::UnwrapObjectChecked(obj, /* stopAtOuter = */ false);
JSObject *unwrapped = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
if (!unwrapped)
return NS_ERROR_XPC_SECURITY_MANAGER_VETO;
XPCWrappedNative* wrapper = IS_WN_WRAPPER(unwrapped) ? XPCWrappedNative::Get(unwrapped)

View File

@ -457,7 +457,7 @@ nsJSIID::Enumerate(nsIXPConnectWrappedNative *wrapper,
* system principal. The success of an instanceof check should not depend
* on which compartment an object comes from. At the same time, we want to
* make sure we don't unwrap important security wrappers.
* UnwrapObjectChecked does the right thing here.
* CheckedUnwrap does the right thing here.
*
* 2 - Prototype chains. Suppose someone creates a vanilla JS object |a| and
* sets its __proto__ to some WN |b|. If |b instanceof nsIFoo| returns true,
@ -475,7 +475,7 @@ FindObjectForHasInstance(JSContext *cx, JSObject *obj)
while (obj && !IS_WRAPPER_CLASS(js::GetObjectClass(obj)) && !IsDOMObject(obj))
{
if (js::IsWrapper(obj))
obj = js::UnwrapObjectChecked(obj, /* stopAtOuter = */ false);
obj = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
else if (!js::GetObjectProto(cx, obj, &obj))
return nullptr;
}
@ -909,7 +909,7 @@ xpc_JSObjectToID(JSContext *cx, JSObject* obj)
// NOTE: this call does NOT addref
XPCWrappedNative* wrapper = nullptr;
obj = js::UnwrapObjectChecked(obj);
obj = js::CheckedUnwrap(obj);
if (obj && IS_WN_WRAPPER(obj))
wrapper = XPCWrappedNative::Get(obj);
if (wrapper &&
@ -927,7 +927,7 @@ xpc_JSObjectIsID(JSContext *cx, JSObject* obj)
NS_ASSERTION(cx && obj, "bad param");
// NOTE: this call does NOT addref
XPCWrappedNative* wrapper = nullptr;
obj = js::UnwrapObjectChecked(obj);
obj = js::CheckedUnwrap(obj);
if (obj && IS_WN_WRAPPER(obj))
wrapper = XPCWrappedNative::Get(obj);
return wrapper &&

View File

@ -3030,7 +3030,7 @@ XPCJSRuntime::GetJunkScope()
NS_ENSURE_SUCCESS(rv, nullptr);
mJunkScope = js::UnwrapObject(&v.toObject());
mJunkScope = js::UncheckedUnwrap(&v.toObject());
JS_AddNamedObjectRoot(cx, &mJunkScope, "XPConnect Junk Compartment");
}
return mJunkScope;

View File

@ -545,9 +545,9 @@ getWrapper(JSContext *cx,
// * A (possible) outer window
//
// If we pass stopAtOuter == false, we can handle all three with one call
// to js::UnwrapObjectChecked.
// to js::CheckedUnwrap.
if (js::IsWrapper(obj)) {
obj = js::UnwrapObjectChecked(obj, /* stopAtOuter = */ false);
obj = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
// The safe unwrap might have failed if we encountered an object that
// we're not allowed to unwrap. If it didn't fail though, we should be

View File

@ -40,7 +40,7 @@ XPCVariant::XPCVariant(JSContext* cx, jsval aJSVal)
JSObject *obj = JS_ObjectToInnerObject(cx, JSVAL_TO_OBJECT(mJSVal));
mJSVal = OBJECT_TO_JSVAL(obj);
JSObject *unwrapped = js::UnwrapObjectChecked(obj, /* stopAtOuter = */ false);
JSObject *unwrapped = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
mReturnRawObject = !(unwrapped && IS_WN_WRAPPER(unwrapped));
} else
mReturnRawObject = false;

View File

@ -752,7 +752,7 @@ nsXPCWrappedJSClass::GetRootJSObject(JSContext* cx, JSObject* aJSObj)
NS_GET_IID(nsISupports));
if (!result)
return aJSObj;
JSObject* inner = js::UnwrapObject(result);
JSObject* inner = js::UncheckedUnwrap(result);
if (inner)
return inner;
return result;

View File

@ -1685,7 +1685,7 @@ RescueOrphans(XPCCallContext& ccx, JSObject* obj)
JSObject *parentObj = js::GetObjectParent(obj);
if (!parentObj)
return NS_OK; // Global object. We're done.
parentObj = js::UnwrapObject(parentObj, /* stopAtOuter = */ false);
parentObj = js::UncheckedUnwrap(parentObj, /* stopAtOuter = */ false);
// PreCreate may touch dead compartments.
js::AutoMaybeTouchDeadZones agc(parentObj);
@ -1730,7 +1730,7 @@ RescueOrphans(XPCCallContext& ccx, JSObject* obj)
// We've been orphaned. Find where our parent went, and follow it.
if (isWN) {
JSObject *realParent = js::UnwrapObject(parentObj);
JSObject *realParent = js::UncheckedUnwrap(parentObj);
XPCWrappedNative *wn =
static_cast<XPCWrappedNative*>(js::GetObjectPrivate(obj));
return wn->ReparentWrapperIfFound(ccx, GetObjectScope(parentObj),

View File

@ -18,7 +18,7 @@ XPCNativeMember::GetCallInfo(JSObject* funobj,
XPCNativeInterface** pInterface,
XPCNativeMember** pMember)
{
funobj = js::UnwrapObject(funobj);
funobj = js::UncheckedUnwrap(funobj);
jsval ifaceVal = js::GetFunctionNativeReserved(funobj, 0);
jsval memberVal = js::GetFunctionNativeReserved(funobj, 1);

View File

@ -850,7 +850,7 @@ XPC_WN_MaybeResolvingStrictPropertyStub(JSContext *cx, JSHandleObject obj, JSHan
#define PRE_HELPER_STUB \
XPCWrappedNative* wrapper; \
nsIXPCScriptable* si; \
JSObject *unwrapped = js::UnwrapObjectChecked(obj, false); \
JSObject *unwrapped = js::CheckedUnwrap(obj, false); \
if (!unwrapped) { \
JS_ReportError(cx, "Permission denied to operate on object."); \
return false; \

View File

@ -261,7 +261,7 @@ XPCWrappedNativeScope::EnsureXBLScope(JSContext *cx)
mXBLScope = &v.toObject();
// Tag it.
EnsureCompartmentPrivate(js::UnwrapObject(mXBLScope))->scope->mIsXBLScope = true;
EnsureCompartmentPrivate(js::UncheckedUnwrap(mXBLScope))->scope->mIsXBLScope = true;
// Good to go!
return mXBLScope;
@ -274,7 +274,7 @@ JSObject *GetXBLScope(JSContext *cx, JSObject *contentScope_)
JSAutoCompartment ac(cx, contentScope);
JSObject *scope = EnsureCompartmentPrivate(contentScope)->scope->EnsureXBLScope(cx);
NS_ENSURE_TRUE(scope, nullptr); // See bug 858642.
scope = js::UnwrapObject(scope);
scope = js::UncheckedUnwrap(scope);
xpc_UnmarkGrayObject(scope);
return scope;
}

View File

@ -64,7 +64,7 @@ XrayWrapperConstructor(JSContext *cx, unsigned argc, jsval *vp)
return true;
}
obj = js::UnwrapObject(obj);
obj = js::UncheckedUnwrap(obj);
*vp = OBJECT_TO_JSVAL(obj);
return JS_WrapValue(cx, vp);
@ -92,7 +92,7 @@ JSObject *
UnsafeUnwrapSecurityWrapper(JSObject *obj)
{
if (js::IsProxy(obj)) {
return js::UnwrapObject(obj);
return js::UncheckedUnwrap(obj);
}
return obj;

View File

@ -1332,7 +1332,7 @@ nsXPConnect::GetNativeOfWrapper(JSContext * aJSContext,
return nullptr;
}
aJSObj = js::UnwrapObjectChecked(aJSObj, /* stopAtOuter = */ false);
aJSObj = js::CheckedUnwrap(aJSObj, /* stopAtOuter = */ false);
if (!aJSObj) {
JS_ReportError(aJSContext, "Permission denied to get native of security wrapper");
return nullptr;

View File

@ -2775,7 +2775,7 @@ public:
static XPCWrappedNative*
GetAndMorphWrappedNativeOfJSObject(JSContext* cx, JSObject* obj)
{
obj = js::UnwrapObjectChecked(obj, /* stopAtOuter = */ false);
obj = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
if (!obj)
return nullptr;
if (!IS_WRAPPER_CLASS(js::GetObjectClass(obj)))

View File

@ -83,7 +83,7 @@ bool
AccessCheck::wrapperSubsumes(JSObject *wrapper)
{
MOZ_ASSERT(js::IsWrapper(wrapper));
JSObject *wrapped = js::UnwrapObject(wrapper);
JSObject *wrapped = js::UncheckedUnwrap(wrapper);
return AccessCheck::subsumes(js::GetObjectCompartment(wrapper),
js::GetObjectCompartment(wrapped));
}
@ -258,7 +258,7 @@ bool
OnlyIfSubjectIsSystem::isSafeToUnwrap()
{
// It's nasty to use the context stack here, but the alternative is passing cx all
// the way down through UnwrapObjectChecked, which we just undid in a 100k patch. :-(
// the way down through CheckedUnwrap, which we just undid in a 100k patch. :-(
JSContext *cx = nsContentUtils::GetCurrentJSContext();
if (!cx)
return true;
@ -328,7 +328,7 @@ ExposedPropertiesOnly::check(JSContext *cx, JSObject *wrapper, jsid id, Wrapper:
JSObject *hallpass = &exposedProps.toObject();
if (!AccessCheck::subsumes(js::UnwrapObject(hallpass), wrappedObject)) {
if (!AccessCheck::subsumes(js::UncheckedUnwrap(hallpass), wrappedObject)) {
EnterAndThrow(cx, wrapper, "Invalid __exposedProps__");
return false;
}

View File

@ -31,7 +31,7 @@ static bool
PropIsFromStandardPrototype(JSContext *cx, JSPropertyDescriptor *desc)
{
MOZ_ASSERT(desc->obj);
JSObject *unwrapped = js::UnwrapObject(desc->obj);
JSObject *unwrapped = js::UncheckedUnwrap(desc->obj);
JSAutoCompartment ac(cx, unwrapped);
return JS_IdentifyClassPrototype(cx, unwrapped) != JSProto_Null;
}

View File

@ -50,7 +50,7 @@ JSObject *
WrapperFactory::GetXrayWaiver(JSObject *obj)
{
// Object should come fully unwrapped but outerized.
MOZ_ASSERT(obj == UnwrapObject(obj));
MOZ_ASSERT(obj == UncheckedUnwrap(obj));
MOZ_ASSERT(!js::GetObjectClass(obj)->ext.outerObject);
XPCWrappedNativeScope *scope = GetObjectScope(obj);
MOZ_ASSERT(scope);
@ -100,7 +100,7 @@ WrapperFactory::CreateXrayWaiver(JSContext *cx, JSObject *obj)
JSObject *
WrapperFactory::WaiveXray(JSContext *cx, JSObject *obj)
{
obj = UnwrapObject(obj);
obj = UncheckedUnwrap(obj);
MOZ_ASSERT(!js::IsInnerObject(obj));
JSObject *waiver = GetXrayWaiver(obj);
@ -134,7 +134,7 @@ WrapperFactory::PrepareForWrapping(JSContext *cx, JSObject *scope, JSObject *obj
NS_ENSURE_TRUE(obj, nullptr);
// The outerization hook wraps, which means that we can end up with a
// CCW here if |obj| was a navigated-away-from inner. Strip any CCWs.
obj = js::UnwrapObject(obj);
obj = js::UncheckedUnwrap(obj);
MOZ_ASSERT(js::IsOuterObject(obj));
}
@ -524,7 +524,7 @@ WrapperFactory::WrapForSameCompartment(JSContext *cx, JSObject *obj)
// The WN knows what to do.
JSObject *wrapper = wn->GetSameCompartmentSecurityWrapper(cx);
MOZ_ASSERT_IF(wrapper != obj && IsComponentsObject(js::UnwrapObject(obj)),
MOZ_ASSERT_IF(wrapper != obj && IsComponentsObject(js::UncheckedUnwrap(obj)),
!Wrapper::wrapperHandler(wrapper)->isSafeToUnwrap());
return wrapper;
}
@ -539,7 +539,7 @@ WrapperFactory::WaiveXrayAndWrap(JSContext *cx, jsval *vp)
if (JSVAL_IS_PRIMITIVE(*vp))
return JS_WrapValue(cx, vp);
JSObject *obj = js::UnwrapObject(JSVAL_TO_OBJECT(*vp));
JSObject *obj = js::UncheckedUnwrap(JSVAL_TO_OBJECT(*vp));
MOZ_ASSERT(!js::IsInnerObject(obj));
if (js::IsObjectInContextCompartment(obj, cx)) {
*vp = OBJECT_TO_JSVAL(obj);

View File

@ -22,7 +22,7 @@ class WrapperFactory {
// Return true if any of any of the nested wrappers have the flag set.
static bool HasWrapperFlag(JSObject *wrapper, unsigned flag) {
unsigned flags = 0;
js::UnwrapObject(wrapper, true, &flags);
js::UncheckedUnwrap(wrapper, true, &flags);
return !!(flags & flag);
}
@ -35,7 +35,7 @@ class WrapperFactory {
}
static bool IsSecurityWrapper(JSObject *obj) {
return !js::UnwrapObjectChecked(obj);
return !js::CheckedUnwrap(obj);
}
static bool IsCOW(JSObject *wrapper);

View File

@ -52,7 +52,7 @@ using namespace XrayUtils;
XrayType
GetXrayType(JSObject *obj)
{
obj = js::UnwrapObject(obj, /* stopAtOuter = */ false);
obj = js::UncheckedUnwrap(obj, /* stopAtOuter = */ false);
if (mozilla::dom::UseDOMXray(obj))
return XrayForDOMObject;
@ -131,7 +131,7 @@ class XrayTraits
{
public:
static JSObject* getTargetObject(JSObject *wrapper) {
return js::UnwrapObject(wrapper, /* stopAtOuter = */ false);
return js::UncheckedUnwrap(wrapper, /* stopAtOuter = */ false);
}
virtual bool resolveOwnProperty(JSContext *cx, Wrapper &jsWrapper,