summaryrefslogtreecommitdiffstats
path: root/js/src/proxy/OpaqueCrossCompartmentWrapper.cpp
blob: ff3f4145ccf046f7cf1e801b7abd1c2f228f7d6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 * vim: set ts=8 sts=4 et sw=4 tw=99:
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "jswrapper.h"

#include "jsobjinlines.h"

using namespace js;

bool
OpaqueCrossCompartmentWrapper::getOwnPropertyDescriptor(JSContext* cx,
                                                        HandleObject wrapper,
                                                        HandleId id,
                                                        MutableHandle<PropertyDescriptor> desc) const
{
    desc.object().set(nullptr);
    return true;
}

bool
OpaqueCrossCompartmentWrapper::defineProperty(JSContext* cx, HandleObject wrapper, HandleId id,
                                              Handle<PropertyDescriptor> desc,
                                              ObjectOpResult& result) const
{
    return result.succeed();
}

bool
OpaqueCrossCompartmentWrapper::ownPropertyKeys(JSContext* cx, HandleObject wrapper,
                                               AutoIdVector& props) const
{
    return true;
}

bool
OpaqueCrossCompartmentWrapper::delete_(JSContext* cx, HandleObject wrapper, HandleId id,
                                       ObjectOpResult& result) const
{
    return result.succeed();
}

bool
OpaqueCrossCompartmentWrapper::enumerate(JSContext* cx, HandleObject wrapper,
                                         MutableHandleObject objp) const
{
    return BaseProxyHandler::enumerate(cx, wrapper, objp);
}

bool
OpaqueCrossCompartmentWrapper::getPrototype(JSContext* cx, HandleObject proxy,
                                            MutableHandleObject protop) const
{
    protop.set(nullptr);
    return true;
}

bool
OpaqueCrossCompartmentWrapper::setPrototype(JSContext* cx, HandleObject proxy, HandleObject proto,
                                            ObjectOpResult& result) const
{
    return result.succeed();
}

bool
OpaqueCrossCompartmentWrapper::getPrototypeIfOrdinary(JSContext* cx, HandleObject proxy,
                                                      bool* isOrdinary,
                                                      MutableHandleObject protop) const
{
    *isOrdinary = false;
    return true;
}

bool
OpaqueCrossCompartmentWrapper::setImmutablePrototype(JSContext* cx, HandleObject proxy,
                                                     bool* succeeded) const
{
    *succeeded = false;
    return true;
}

bool
OpaqueCrossCompartmentWrapper::preventExtensions(JSContext* cx, HandleObject wrapper,
                                                 ObjectOpResult& result) const
{
    return result.failCantPreventExtensions();
}

bool
OpaqueCrossCompartmentWrapper::isExtensible(JSContext* cx, HandleObject wrapper,
                                            bool* extensible) const
{
    *extensible = true;
    return true;
}

bool
OpaqueCrossCompartmentWrapper::has(JSContext* cx, HandleObject wrapper, HandleId id,
                                   bool* bp) const
{
    return BaseProxyHandler::has(cx, wrapper, id, bp);
}

bool
OpaqueCrossCompartmentWrapper::get(JSContext* cx, HandleObject wrapper, HandleValue receiver,
                                   HandleId id, MutableHandleValue vp) const
{
    return BaseProxyHandler::get(cx, wrapper, receiver, id, vp);
}

bool
OpaqueCrossCompartmentWrapper::set(JSContext* cx, HandleObject wrapper, HandleId id,
                                   HandleValue v, HandleValue receiver,
                                   ObjectOpResult& result) const
{
    return BaseProxyHandler::set(cx, wrapper, id, v, receiver, result);
}

bool
OpaqueCrossCompartmentWrapper::call(JSContext* cx, HandleObject wrapper,
                                    const CallArgs& args) const
{
    RootedValue v(cx, ObjectValue(*wrapper));
    ReportIsNotFunction(cx, v);
    return false;
}

bool
OpaqueCrossCompartmentWrapper::construct(JSContext* cx, HandleObject wrapper,
                                         const CallArgs& args) const
{
    RootedValue v(cx, ObjectValue(*wrapper));
    ReportIsNotFunction(cx, v);
    return false;
}

bool
OpaqueCrossCompartmentWrapper::getPropertyDescriptor(JSContext* cx,
                                                     HandleObject wrapper,
                                                     HandleId id,
                                                     MutableHandle<PropertyDescriptor> desc) const
{
    return BaseProxyHandler::getPropertyDescriptor(cx, wrapper, id, desc);
}

bool
OpaqueCrossCompartmentWrapper::hasOwn(JSContext* cx, HandleObject wrapper, HandleId id,
                                      bool* bp) const
{
    return BaseProxyHandler::hasOwn(cx, wrapper, id, bp);
}

bool
OpaqueCrossCompartmentWrapper::getOwnEnumerablePropertyKeys(JSContext* cx, HandleObject wrapper,
                                                            AutoIdVector& props) const
{
    return BaseProxyHandler::getOwnEnumerablePropertyKeys(cx, wrapper, props);
}

bool
OpaqueCrossCompartmentWrapper::getBuiltinClass(JSContext* cx, HandleObject wrapper,
                                    ESClass* cls) const
{
    *cls = ESClass::Other;
    return true;
}

bool
OpaqueCrossCompartmentWrapper::isArray(JSContext* cx, HandleObject obj,
                                       JS::IsArrayAnswer* answer) const
{
    *answer = JS::IsArrayAnswer::NotArray;
    return true;
}

const char*
OpaqueCrossCompartmentWrapper::className(JSContext* cx,
                                         HandleObject proxy) const
{
    return "Opaque";
}

JSString*
OpaqueCrossCompartmentWrapper::fun_toString(JSContext* cx, HandleObject proxy,
                                            unsigned indent) const
{
    JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO,
                              js_Function_str, js_toString_str, "object");
    return nullptr;
}

const OpaqueCrossCompartmentWrapper OpaqueCrossCompartmentWrapper::singleton;