Backed out bug 789897 due to regressions.

This commit is contained in:
Ryan VanderMeulen 2013-03-29 14:07:32 -04:00
Родитель 3e2b83c475
Коммит 114ddf1599
25 изменённых файлов: 18 добавлений и 267 удалений

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

@ -75,20 +75,6 @@ DOMProxyHandler::EnsureExpandoObject(JSContext* cx, JSObject* obj)
return expando;
}
bool
DOMProxyHandler::isExtensible(JSObject *proxy)
{
return true; // always extensible per WebIDL
}
bool
DOMProxyHandler::preventExtensions(JSContext *cx, JS::Handle<JSObject*> proxy)
{
// Throw a TypeError, per WebIDL.
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_CHANGE_EXTENSIBILITY);
return false;
}
bool
DOMProxyHandler::getPropertyDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
JSPropertyDescriptor* desc, unsigned flags)

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

@ -36,7 +36,6 @@ public:
{
}
bool preventExtensions(JSContext *cx, JS::Handle<JSObject*> proxy) MOZ_OVERRIDE;
bool getPropertyDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
JSPropertyDescriptor* desc, unsigned flags) MOZ_OVERRIDE;
bool defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
@ -45,7 +44,6 @@ public:
JS::Handle<jsid> id, bool* bp) MOZ_OVERRIDE;
bool enumerate(JSContext* cx, JS::Handle<JSObject*> proxy, JS::AutoIdVector& props) MOZ_OVERRIDE;
bool has(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) MOZ_OVERRIDE;
bool isExtensible(JSObject *proxy) MOZ_OVERRIDE;
using js::BaseProxyHandler::obj_toString;
static JSObject* GetExpandoObject(JSObject* obj)

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

@ -914,7 +914,7 @@ obj_preventExtensions(JSContext *cx, unsigned argc, Value *vp)
if (!obj->isExtensible())
return true;
return JSObject::preventExtensions(cx, obj);
return obj->preventExtensions(cx);
}
static JSBool

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

@ -24,12 +24,5 @@ var desc = {
enumerable: false,
configurable: true
};
var p = new Proxy(target, handler);
Object.defineProperty(p, 'foo', desc);
Object.defineProperty(new Proxy(target, handler), 'foo', desc);
assertEq(called, true);
assertEq(Object.isExtensible(target), true);
assertEq(Object.isExtensible(p), true);
Object.preventExtensions(target);
assertEq(Object.isExtensible(target), false);
assertEq(Object.isExtensible(p), false);

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

@ -1,4 +0,0 @@
// Forward to the target if the trap is not defined
var target = {};
Object.preventExtensions(new Proxy(target, {}));
assertEq(Object.isExtensible(target), false);

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

@ -1,17 +0,0 @@
/*
* Call the trap with the handler as the this value and the target as the first
* argument.
*/
var target = {};
var called = false;
var handler = {
preventExtensions: function (target1) {
assertEq(this, handler);
assertEq(target1, target);
Object.preventExtensions(target1);
called = true;
return true;
}
};
Object.preventExtensions(new Proxy(target, handler));
assertEq(called, true);

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

@ -1,10 +0,0 @@
load(libdir + "asserts.js");
// Throw a TypeError if the trap reports an extensible object as non-extensible
assertThrowsInstanceOf(function () {
Object.preventExtensions(new Proxy({}, {
preventExtensions: function () {
return true;
}
}));
}, TypeError);

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

@ -1,10 +0,0 @@
load(libdir + "asserts.js");
// Throw a TypeError if the object refuses to be made non-extensible
assertThrowsInstanceOf(function () {
Object.preventExtensions(new Proxy({}, {
preventExtensions: function () {
return false;
}
}));
}, TypeError);

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

@ -235,7 +235,7 @@ MSG_DEF(JSMSG_UNUSED181, 181, 0, JSEXN_NONE, "")
MSG_DEF(JSMSG_BAD_GENERATOR_SEND, 182, 1, JSEXN_TYPEERR, "attempt to send {0} to newborn generator")
MSG_DEF(JSMSG_UNUSED183, 183, 0, JSEXN_NONE, "")
MSG_DEF(JSMSG_UNUSED184, 184, 0, JSEXN_NONE, "")
MSG_DEF(JSMSG_CANT_REPORT_AS_NON_EXTENSIBLE, 185, 0, JSEXN_TYPEERR, "proxy can't report an extensible object as non-extensible")
MSG_DEF(JSMSG_UNUSED185, 185, 0, JSEXN_NONE, "")
MSG_DEF(JSMSG_UNUSED186, 186, 0, JSEXN_NONE, "")
MSG_DEF(JSMSG_UNUSED187, 187, 0, JSEXN_NONE, "")
MSG_DEF(JSMSG_INCOMPATIBLE_METHOD, 188, 3, JSEXN_TYPEERR, "{0} {1} called on incompatible {2}")

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

@ -1072,7 +1072,7 @@ JSObject::sealOrFreeze(JSContext *cx, HandleObject obj, ImmutabilityType it)
assertSameCompartment(cx, obj);
JS_ASSERT(it == SEAL || it == FREEZE);
if (obj->isExtensible() && !JSObject::preventExtensions(cx, obj))
if (obj->isExtensible() && !obj->preventExtensions(cx))
return false;
AutoIdVector props(cx);

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

@ -548,6 +548,8 @@ class JSObject : public js::ObjectImpl
static inline unsigned getSealedOrFrozenAttributes(unsigned attrs, ImmutabilityType it);
public:
bool preventExtensions(JSContext *cx);
/* ES5 15.2.3.8: non-extensible, all props non-configurable */
static inline bool seal(JSContext *cx, js::HandleObject obj) { return sealOrFreeze(cx, obj, SEAL); }
/* ES5 15.2.3.9: non-extensible, all properties non-configurable, all data props read-only */
@ -958,7 +960,7 @@ class JSObject : public js::ObjectImpl
inline bool isObject() const;
inline bool isPrimitive() const;
inline bool isPropertyIterator() const;
using js::ObjectImpl::isProxy;
inline bool isProxy() const;
inline bool isRegExp() const;
inline bool isRegExpStatics() const;
inline bool isScope() const;

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

@ -1258,9 +1258,9 @@ JSObject::getSpecialAttributes(JSContext *cx, js::HandleObject obj,
}
inline bool
js::ObjectImpl::isProxy() const
JSObject::isProxy() const
{
return js::IsProxy(const_cast<JSObject*>(this->asObjectPtr()));
return js::IsProxy(const_cast<JSObject*>(this));
}
inline bool

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

@ -639,19 +639,6 @@ DirectProxyHandler::iterate(JSContext *cx, HandleObject proxy, unsigned flags,
return GetIterator(cx, target, flags, vp);
}
bool
DirectProxyHandler::isExtensible(JSObject *proxy)
{
return GetProxyTargetObject(proxy)->isExtensible();
}
bool
DirectProxyHandler::preventExtensions(JSContext *cx, HandleObject proxy)
{
RootedObject target(cx, GetProxyTargetObject(proxy));
return JSObject::preventExtensions(cx, target);
}
static bool
GetFundamentalTrap(JSContext *cx, HandleObject handler, HandlePropertyName name,
MutableHandleValue fvalp)
@ -776,7 +763,6 @@ class ScriptedIndirectProxyHandler : public BaseProxyHandler {
virtual ~ScriptedIndirectProxyHandler();
/* ES5 Harmony fundamental proxy traps. */
virtual bool preventExtensions(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE;
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
@ -799,7 +785,6 @@ class ScriptedIndirectProxyHandler : public BaseProxyHandler {
MutableHandleValue vp) MOZ_OVERRIDE;
/* Spidermonkey extensions. */
virtual bool isExtensible(JSObject *proxy) MOZ_OVERRIDE;
virtual bool call(JSContext *cx, HandleObject proxy, unsigned argc, Value *vp) MOZ_OVERRIDE;
virtual bool construct(JSContext *cx, HandleObject proxy, unsigned argc,
Value *argv, MutableHandleValue rval) MOZ_OVERRIDE;
@ -823,14 +808,6 @@ ScriptedIndirectProxyHandler::~ScriptedIndirectProxyHandler()
{
}
bool
ScriptedIndirectProxyHandler::preventExtensions(JSContext *cx, HandleObject proxy)
{
// Scripted indirect proxies don't support extensibility changes.
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_CHANGE_EXTENSIBILITY);
return false;
}
static bool
ReturnedValueMustNotBePrimitive(JSContext *cx, HandleObject proxy, JSAtom *atom, const Value &v)
{
@ -1011,13 +988,6 @@ ScriptedIndirectProxyHandler::iterate(JSContext *cx, HandleObject proxy, unsigne
ReturnedValueMustNotBePrimitive(cx, proxy, cx->names().iterate, vp);
}
bool
ScriptedIndirectProxyHandler::isExtensible(JSObject *proxy)
{
// Scripted indirect proxies don't support extensibility changes.
return true;
}
bool
ScriptedIndirectProxyHandler::call(JSContext *cx, HandleObject proxy, unsigned argc,
Value *vp)
@ -1092,7 +1062,6 @@ class ScriptedDirectProxyHandler : public DirectProxyHandler {
virtual ~ScriptedDirectProxyHandler();
/* ES5 Harmony fundamental proxy traps. */
virtual bool preventExtensions(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE;
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
@ -1661,48 +1630,6 @@ ScriptedDirectProxyHandler::~ScriptedDirectProxyHandler()
{
}
bool
ScriptedDirectProxyHandler::preventExtensions(JSContext *cx, HandleObject proxy)
{
// step a
RootedObject handler(cx, GetDirectProxyHandlerObject(proxy));
// step b
RootedObject target(cx, GetProxyTargetObject(proxy));
// step c
RootedValue trap(cx);
if (!JSObject::getProperty(cx, handler, handler, cx->names().preventExtensions, &trap))
return false;
// step d
if (trap.isUndefined())
return DirectProxyHandler::preventExtensions(cx, proxy);
// step e
Value argv[] = {
ObjectValue(*target)
};
RootedValue trapResult(cx);
if (!Invoke(cx, ObjectValue(*handler), trap, 1, argv, trapResult.address()))
return false;
// step f
bool success = ToBoolean(trapResult);
if (success) {
// step g
if (target->isExtensible()) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_REPORT_AS_NON_EXTENSIBLE);
return false;
}
return true;
}
// step h
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_CHANGE_EXTENSIBILITY);
return false;
}
// FIXME: Move to Proxy::getPropertyDescriptor once ScriptedIndirectProxy is removed
bool
ScriptedDirectProxyHandler::getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
@ -2595,20 +2522,6 @@ Proxy::iterate(JSContext *cx, HandleObject proxy, unsigned flags, MutableHandleV
return EnumeratedIdVectorToIterator(cx, proxy, flags, props, vp);
}
bool
Proxy::preventExtensions(JSContext *cx, HandleObject proxy)
{
JS_CHECK_RECURSION(cx, return false);
BaseProxyHandler *handler = GetProxyHandler(proxy);
return handler->preventExtensions(cx, proxy);
}
bool
Proxy::isExtensible(JSObject *proxy)
{
return GetProxyHandler(proxy)->isExtensible(proxy);
}
bool
Proxy::call(JSContext *cx, HandleObject proxy, unsigned argc, Value *vp)
{

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

@ -104,7 +104,6 @@ class JS_FRIEND_API(BaseProxyHandler) {
bool *bp);
/* ES5 Harmony fundamental proxy traps. */
virtual bool preventExtensions(JSContext *cx, HandleObject proxy) = 0;
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
PropertyDescriptor *desc, unsigned flags) = 0;
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy,
@ -129,7 +128,6 @@ class JS_FRIEND_API(BaseProxyHandler) {
MutableHandleValue vp);
/* Spidermonkey extensions. */
virtual bool isExtensible(JSObject *proxy) = 0;
virtual bool call(JSContext *cx, HandleObject proxy, unsigned argc, Value *vp);
virtual bool construct(JSContext *cx, HandleObject proxy, unsigned argc,
Value *argv, MutableHandleValue rval);
@ -160,7 +158,6 @@ public:
explicit DirectProxyHandler(void *family);
/* ES5 Harmony fundamental proxy traps. */
virtual bool preventExtensions(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE;
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject proxy,
@ -190,7 +187,6 @@ public:
MutableHandleValue vp) MOZ_OVERRIDE;
/* Spidermonkey extensions. */
virtual bool isExtensible(JSObject *proxy) MOZ_OVERRIDE;
virtual bool call(JSContext *cx, HandleObject proxy, unsigned argc, Value *vp) MOZ_OVERRIDE;
virtual bool construct(JSContext *cx, HandleObject proxy, unsigned argc,
Value *argv, MutableHandleValue rval) MOZ_OVERRIDE;
@ -214,7 +210,6 @@ public:
class Proxy {
public:
/* ES5 Harmony fundamental proxy traps. */
static bool preventExtensions(JSContext *cx, HandleObject proxy);
static bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id,
PropertyDescriptor *desc, unsigned flags);
static bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, unsigned flags, HandleId id,
@ -242,7 +237,6 @@ class Proxy {
static bool iterate(JSContext *cx, HandleObject proxy, unsigned flags, MutableHandleValue vp);
/* Spidermonkey extensions. */
static bool isExtensible(JSObject *proxy);
static bool call(JSContext *cx, HandleObject proxy, unsigned argc, Value *vp);
static bool construct(JSContext *cx, HandleObject proxy, unsigned argc, Value *argv,
MutableHandleValue rval);

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

@ -626,25 +626,6 @@ SecurityWrapper<Base>::SecurityWrapper(unsigned flags)
BaseProxyHandler::setHasPolicy(true);
}
template <class Base>
bool
SecurityWrapper<Base>::isExtensible(JSObject *wrapper)
{
// Just like BaseProxyHandler, SecurityWrappers claim by default to always
// be extensible, so as not to leak information about the state of the
// underlying wrapped thing.
return true;
}
template <class Base>
bool
SecurityWrapper<Base>::preventExtensions(JSContext *cx, HandleObject wrapper)
{
// See above.
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_UNWRAP_DENIED);
return false;
}
template <class Base>
bool
SecurityWrapper<Base>::enter(JSContext *cx, HandleObject wrapper, HandleId id,
@ -655,8 +636,8 @@ SecurityWrapper<Base>::enter(JSContext *cx, HandleObject wrapper, HandleId id,
return false;
}
template <class Base>
bool
template <class Base>
bool
SecurityWrapper<Base>::nativeCall(JSContext *cx, IsAcceptableThis test, NativeImpl impl,
CallArgs args)
{
@ -687,13 +668,6 @@ DeadObjectProxy::DeadObjectProxy()
{
}
bool
DeadObjectProxy::preventExtensions(JSContext *cx, HandleObject proxy)
{
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_DEAD_OBJECT);
return false;
}
bool
DeadObjectProxy::getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
PropertyDescriptor *desc, unsigned flags)
@ -740,14 +714,6 @@ DeadObjectProxy::enumerate(JSContext *cx, HandleObject wrapper, AutoIdVector &pr
return false;
}
bool
DeadObjectProxy::isExtensible(JSObject *proxy)
{
// This is kind of meaningless, but dead-object semantics aside,
// [[Extensible]] always being true is consistent with other proxy types.
return true;
}
bool
DeadObjectProxy::call(JSContext *cx, HandleObject wrapper, unsigned argc, Value *vp)
{

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

@ -143,8 +143,6 @@ class JS_FRIEND_API(SecurityWrapper) : public Base
public:
SecurityWrapper(unsigned flags);
virtual bool isExtensible(JSObject *wrapper) MOZ_OVERRIDE;
virtual bool preventExtensions(JSContext *cx, HandleObject wrapper) MOZ_OVERRIDE;
virtual bool enter(JSContext *cx, HandleObject wrapper, HandleId id, Wrapper::Action act,
bool *bp) MOZ_OVERRIDE;
virtual bool nativeCall(JSContext *cx, IsAcceptableThis test, NativeImpl impl,
@ -172,7 +170,6 @@ class JS_FRIEND_API(DeadObjectProxy) : public BaseProxyHandler
explicit DeadObjectProxy();
/* ES5 Harmony fundamental wrapper traps. */
virtual bool preventExtensions(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE;
virtual bool getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
@ -185,7 +182,6 @@ class JS_FRIEND_API(DeadObjectProxy) : public BaseProxyHandler
virtual bool enumerate(JSContext *cx, HandleObject wrapper, AutoIdVector &props) MOZ_OVERRIDE;
/* Spidermonkey extensions. */
virtual bool isExtensible(JSObject *proxy) MOZ_OVERRIDE;
virtual bool call(JSContext *cx, HandleObject proxy, unsigned argc, Value *vp);
virtual bool construct(JSContext *cx, HandleObject proxy, unsigned argc,
Value *argv, MutableHandleValue rval);

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

@ -114,7 +114,6 @@
macro(parseFloat, parseFloat, "parseFloat") \
macro(parseInt, parseInt, "parseInt") \
macro(pattern, pattern, "pattern") \
macro(preventExtensions, preventExtensions, "preventExtensions") \
macro(propertyIsEnumerable, propertyIsEnumerable, "propertyIsEnumerable") \
macro(proto, proto, "__proto__") \
macro(return, return_, "return") \

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

@ -4499,7 +4499,7 @@ DebuggerObject_sealHelper(JSContext *cx, unsigned argc, Value *vp, SealHelperOp
args.rval().setUndefined();
return true;
}
ok = JSObject::preventExtensions(cx, obj);
ok = obj->preventExtensions(cx);
}
if (!ok)
return false;

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

@ -376,7 +376,7 @@ GlobalObject::initFunctionAndObjectClasses(JSContext *cx)
JSFunction::NATIVE_FUN, self, NullPtr()));
if (!throwTypeError)
return NULL;
if (!JSObject::preventExtensions(cx, throwTypeError))
if (!throwTypeError->preventExtensions(cx))
return NULL;
self->setThrowTypeError(throwTypeError);

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

@ -13,7 +13,6 @@
#include "jscompartment.h"
#include "jsgc.h"
#include "jsinterp.h"
#include "jsproxy.h"
#include "gc/Heap.h"
#include "gc/Marking.h"
@ -86,10 +85,6 @@ js::ObjectImpl::nativeContains(JSContext *cx, Shape *shape)
inline bool
js::ObjectImpl::isExtensible() const
{
if (this->isProxy())
return Proxy::isExtensible(const_cast<JSObject*>(this->asObjectPtr()));
// [[Extensible]] for ordinary non-proxy objects is an object flag.
return !lastProperty()->hasObjectFlag(BaseShape::NOT_EXTENSIBLE);
}

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

@ -1112,11 +1112,6 @@ class ObjectImpl : public gc::Cell
inline bool isExtensible() const;
// Attempt to change the [[Extensible]] bit on |obj| to false. Callers
// must ensure that |obj| is currently extensible before calling this!
static bool
preventExtensions(JSContext *cx, Handle<ObjectImpl*> obj);
inline HeapSlotArray getDenseElements();
inline const Value & getDenseElement(uint32_t idx);
inline bool containsDenseElement(uint32_t idx);
@ -1129,8 +1124,6 @@ class ObjectImpl : public gc::Cell
return false;
}
inline bool isProxy() const;
protected:
#ifdef DEBUG
void checkShapeConsistency();

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

@ -1307,12 +1307,6 @@ class DebugScopeProxy : public BaseProxyHandler
DebugScopeProxy() : BaseProxyHandler(&family) {}
bool preventExtensions(JSContext *cx, HandleObject proxy) MOZ_OVERRIDE
{
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_CHANGE_EXTENSIBILITY);
return false;
}
bool getPropertyDescriptor(JSContext *cx, HandleObject proxy, HandleId id, PropertyDescriptor *desc,
unsigned flags) MOZ_OVERRIDE
{
@ -1472,13 +1466,6 @@ class DebugScopeProxy : public BaseProxyHandler
return js_ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_CANT_DELETE,
JSDVG_IGNORE_STACK, idval, NullPtr(), NULL, NULL);
}
bool isExtensible(JSObject *proxy) MOZ_OVERRIDE
{
// always [[Extensible]], can't be made non-[[Extensible]], like most
// proxies
return true;
}
};
int DebugScopeProxy::family = 0;

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

@ -1028,19 +1028,12 @@ Shape::setObjectParent(JSContext *cx, JSObject *parent, TaggedProto proto, Shape
return replaceLastProperty(cx, base, proto, lastRoot);
}
/* static */ bool
js::ObjectImpl::preventExtensions(JSContext *cx, Handle<ObjectImpl*> obj)
bool
JSObject::preventExtensions(JSContext *cx)
{
MOZ_ASSERT(obj->isExtensible(),
"Callers must ensure |obj| is extensible before calling "
"preventExtensions");
JS_ASSERT(isExtensible());
if (obj->isProxy()) {
RootedObject object(cx, obj->asObjectPtr());
return js::Proxy::preventExtensions(cx, object);
}
RootedObject self(cx, obj->asObjectPtr());
RootedObject self(cx, this);
/*
* Force lazy properties to be resolved by iterating over the objects' own

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

@ -1337,7 +1337,7 @@ IsXrayResolving(JSContext *cx, JSObject *wrapper, jsid id)
return XPCWrappedNativeXrayTraits::isResolving(cx, holder, id);
}
} // namespace XrayUtils
}
static JSBool
XrayToString(JSContext *cx, unsigned argc, jsval *vp)
@ -1416,27 +1416,6 @@ DEBUG_CheckXBLLookup(JSContext *cx, JSPropertyDescriptor *desc)
#define DEBUG_CheckXBLLookup(a, b) {}
#endif
template <typename Base, typename Traits>
bool
XrayWrapper<Base, Traits>::isExtensible(JSObject *wrapper)
{
// Xray wrappers are supposed to provide a clean view of the target
// reflector, hiding any modifications by script in the target scope. So
// even if that script freezes the reflector, we don't want to make that
// visible to the caller. DOM reflectors are always extensible by default,
// so we can just return true here.
return true;
}
template <typename Base, typename Traits>
bool
XrayWrapper<Base, Traits>::preventExtensions(JSContext *cx, JS::Handle<JSObject*> wrapper)
{
// See above.
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_CHANGE_EXTENSIBILITY);
return false;
}
template <typename Base, typename Traits>
bool
XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,

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

@ -66,8 +66,6 @@ class XrayWrapper : public Base {
virtual ~XrayWrapper();
/* Fundamental proxy traps. */
virtual bool isExtensible(JSObject *wrapper) MOZ_OVERRIDE;
virtual bool preventExtensions(JSContext *cx, JS::Handle<JSObject*> wrapper) MOZ_OVERRIDE;
virtual bool getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<jsid> id,
js::PropertyDescriptor *desc, unsigned flags);
virtual bool getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper, JS::Handle<jsid> id,