1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "js/friend/ErrorMessages.h" // js::GetErrorMessage, JSMSG_*
8 #include "js/Wrapper.h"
10 #include "vm/JSObject-inl.h"
14 bool OpaqueCrossCompartmentWrapper::getOwnPropertyDescriptor(
15 JSContext
* cx
, HandleObject wrapper
, HandleId id
,
16 MutableHandle
<mozilla::Maybe
<PropertyDescriptor
>> desc
) const {
21 bool OpaqueCrossCompartmentWrapper::defineProperty(
22 JSContext
* cx
, HandleObject wrapper
, HandleId id
,
23 Handle
<PropertyDescriptor
> desc
, ObjectOpResult
& result
) const {
24 return result
.succeed();
27 bool OpaqueCrossCompartmentWrapper::ownPropertyKeys(
28 JSContext
* cx
, HandleObject wrapper
, MutableHandleIdVector props
) const {
32 bool OpaqueCrossCompartmentWrapper::delete_(JSContext
* cx
, HandleObject wrapper
,
34 ObjectOpResult
& result
) const {
35 return result
.succeed();
38 bool OpaqueCrossCompartmentWrapper::enumerate(
39 JSContext
* cx
, HandleObject proxy
, MutableHandleIdVector props
) const {
40 return BaseProxyHandler::enumerate(cx
, proxy
, props
);
43 bool OpaqueCrossCompartmentWrapper::getPrototype(
44 JSContext
* cx
, HandleObject proxy
, MutableHandleObject protop
) const {
49 bool OpaqueCrossCompartmentWrapper::setPrototype(JSContext
* cx
,
52 ObjectOpResult
& result
) const {
53 return result
.succeed();
56 bool OpaqueCrossCompartmentWrapper::getPrototypeIfOrdinary(
57 JSContext
* cx
, HandleObject proxy
, bool* isOrdinary
,
58 MutableHandleObject protop
) const {
63 bool OpaqueCrossCompartmentWrapper::setImmutablePrototype(
64 JSContext
* cx
, HandleObject proxy
, bool* succeeded
) const {
69 bool OpaqueCrossCompartmentWrapper::preventExtensions(
70 JSContext
* cx
, HandleObject wrapper
, ObjectOpResult
& result
) const {
71 return result
.failCantPreventExtensions();
74 bool OpaqueCrossCompartmentWrapper::isExtensible(JSContext
* cx
,
76 bool* extensible
) const {
81 bool OpaqueCrossCompartmentWrapper::has(JSContext
* cx
, HandleObject wrapper
,
82 HandleId id
, bool* bp
) const {
83 return BaseProxyHandler::has(cx
, wrapper
, id
, bp
);
86 bool OpaqueCrossCompartmentWrapper::get(JSContext
* cx
, HandleObject wrapper
,
87 HandleValue receiver
, HandleId id
,
88 MutableHandleValue vp
) const {
89 return BaseProxyHandler::get(cx
, wrapper
, receiver
, id
, vp
);
92 bool OpaqueCrossCompartmentWrapper::set(JSContext
* cx
, HandleObject wrapper
,
93 HandleId id
, HandleValue v
,
95 ObjectOpResult
& result
) const {
96 return BaseProxyHandler::set(cx
, wrapper
, id
, v
, receiver
, result
);
99 bool OpaqueCrossCompartmentWrapper::call(JSContext
* cx
, HandleObject wrapper
,
100 const CallArgs
& args
) const {
101 RootedValue
v(cx
, ObjectValue(*wrapper
));
102 ReportIsNotFunction(cx
, v
);
106 bool OpaqueCrossCompartmentWrapper::construct(JSContext
* cx
,
107 HandleObject wrapper
,
108 const CallArgs
& args
) const {
109 RootedValue
v(cx
, ObjectValue(*wrapper
));
110 ReportIsNotFunction(cx
, v
);
114 bool OpaqueCrossCompartmentWrapper::hasOwn(JSContext
* cx
, HandleObject wrapper
,
115 HandleId id
, bool* bp
) const {
116 return BaseProxyHandler::hasOwn(cx
, wrapper
, id
, bp
);
119 bool OpaqueCrossCompartmentWrapper::getOwnEnumerablePropertyKeys(
120 JSContext
* cx
, HandleObject wrapper
, MutableHandleIdVector props
) const {
121 return BaseProxyHandler::getOwnEnumerablePropertyKeys(cx
, wrapper
, props
);
124 bool OpaqueCrossCompartmentWrapper::getBuiltinClass(JSContext
* cx
,
125 HandleObject wrapper
,
126 ESClass
* cls
) const {
127 *cls
= ESClass::Other
;
131 bool OpaqueCrossCompartmentWrapper::isArray(JSContext
* cx
, HandleObject obj
,
132 JS::IsArrayAnswer
* answer
) const {
133 *answer
= JS::IsArrayAnswer::NotArray
;
137 const char* OpaqueCrossCompartmentWrapper::className(JSContext
* cx
,
138 HandleObject proxy
) const {
142 JSString
* OpaqueCrossCompartmentWrapper::fun_toString(JSContext
* cx
,
144 bool isToSource
) const {
145 JS_ReportErrorNumberASCII(cx
, GetErrorMessage
, nullptr,
146 JSMSG_INCOMPATIBLE_PROTO
, "Function", "toString",
151 const OpaqueCrossCompartmentWrapper
OpaqueCrossCompartmentWrapper::singleton
;