Source code

Revision control

Other Tools

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/. */
6
7
#include "js/Wrapper.h"
8
9
#include "vm/JSObject-inl.h"
10
11
using namespace js;
12
13
bool OpaqueCrossCompartmentWrapper::getOwnPropertyDescriptor(
14
JSContext* cx, HandleObject wrapper, HandleId id,
15
MutableHandle<PropertyDescriptor> desc) const {
16
desc.object().set(nullptr);
17
return true;
18
}
19
20
bool OpaqueCrossCompartmentWrapper::defineProperty(
21
JSContext* cx, HandleObject wrapper, HandleId id,
22
Handle<PropertyDescriptor> desc, ObjectOpResult& result) const {
23
return result.succeed();
24
}
25
26
bool OpaqueCrossCompartmentWrapper::ownPropertyKeys(
27
JSContext* cx, HandleObject wrapper, MutableHandleIdVector props) const {
28
return true;
29
}
30
31
bool OpaqueCrossCompartmentWrapper::delete_(JSContext* cx, HandleObject wrapper,
32
HandleId id,
33
ObjectOpResult& result) const {
34
return result.succeed();
35
}
36
37
bool OpaqueCrossCompartmentWrapper::enumerate(
38
JSContext* cx, HandleObject proxy, MutableHandleIdVector props) const {
39
return BaseProxyHandler::enumerate(cx, proxy, props);
40
}
41
42
bool OpaqueCrossCompartmentWrapper::getPrototype(
43
JSContext* cx, HandleObject proxy, MutableHandleObject protop) const {
44
protop.set(nullptr);
45
return true;
46
}
47
48
bool OpaqueCrossCompartmentWrapper::setPrototype(JSContext* cx,
49
HandleObject proxy,
50
HandleObject proto,
51
ObjectOpResult& result) const {
52
return result.succeed();
53
}
54
55
bool OpaqueCrossCompartmentWrapper::getPrototypeIfOrdinary(
56
JSContext* cx, HandleObject proxy, bool* isOrdinary,
57
MutableHandleObject protop) const {
58
*isOrdinary = false;
59
return true;
60
}
61
62
bool OpaqueCrossCompartmentWrapper::setImmutablePrototype(
63
JSContext* cx, HandleObject proxy, bool* succeeded) const {
64
*succeeded = false;
65
return true;
66
}
67
68
bool OpaqueCrossCompartmentWrapper::preventExtensions(
69
JSContext* cx, HandleObject wrapper, ObjectOpResult& result) const {
70
return result.failCantPreventExtensions();
71
}
72
73
bool OpaqueCrossCompartmentWrapper::isExtensible(JSContext* cx,
74
HandleObject wrapper,
75
bool* extensible) const {
76
*extensible = true;
77
return true;
78
}
79
80
bool OpaqueCrossCompartmentWrapper::has(JSContext* cx, HandleObject wrapper,
81
HandleId id, bool* bp) const {
82
return BaseProxyHandler::has(cx, wrapper, id, bp);
83
}
84
85
bool OpaqueCrossCompartmentWrapper::get(JSContext* cx, HandleObject wrapper,
86
HandleValue receiver, HandleId id,
87
MutableHandleValue vp) const {
88
return BaseProxyHandler::get(cx, wrapper, receiver, id, vp);
89
}
90
91
bool OpaqueCrossCompartmentWrapper::set(JSContext* cx, HandleObject wrapper,
92
HandleId id, HandleValue v,
93
HandleValue receiver,
94
ObjectOpResult& result) const {
95
return BaseProxyHandler::set(cx, wrapper, id, v, receiver, result);
96
}
97
98
bool OpaqueCrossCompartmentWrapper::call(JSContext* cx, HandleObject wrapper,
99
const CallArgs& args) const {
100
RootedValue v(cx, ObjectValue(*wrapper));
101
ReportIsNotFunction(cx, v);
102
return false;
103
}
104
105
bool OpaqueCrossCompartmentWrapper::construct(JSContext* cx,
106
HandleObject wrapper,
107
const CallArgs& args) const {
108
RootedValue v(cx, ObjectValue(*wrapper));
109
ReportIsNotFunction(cx, v);
110
return false;
111
}
112
113
bool OpaqueCrossCompartmentWrapper::hasOwn(JSContext* cx, HandleObject wrapper,
114
HandleId id, bool* bp) const {
115
return BaseProxyHandler::hasOwn(cx, wrapper, id, bp);
116
}
117
118
bool OpaqueCrossCompartmentWrapper::getOwnEnumerablePropertyKeys(
119
JSContext* cx, HandleObject wrapper, MutableHandleIdVector props) const {
120
return BaseProxyHandler::getOwnEnumerablePropertyKeys(cx, wrapper, props);
121
}
122
123
bool OpaqueCrossCompartmentWrapper::getBuiltinClass(JSContext* cx,
124
HandleObject wrapper,
125
ESClass* cls) const {
126
*cls = ESClass::Other;
127
return true;
128
}
129
130
bool OpaqueCrossCompartmentWrapper::isArray(JSContext* cx, HandleObject obj,
131
JS::IsArrayAnswer* answer) const {
132
*answer = JS::IsArrayAnswer::NotArray;
133
return true;
134
}
135
136
bool OpaqueCrossCompartmentWrapper::hasInstance(JSContext* cx,
137
HandleObject wrapper,
138
MutableHandleValue v,
139
bool* bp) const {
140
*bp = false;
141
return true;
142
}
143
144
const char* OpaqueCrossCompartmentWrapper::className(JSContext* cx,
145
HandleObject proxy) const {
146
return "Opaque";
147
}
148
149
JSString* OpaqueCrossCompartmentWrapper::fun_toString(JSContext* cx,
150
HandleObject proxy,
151
bool isToSource) const {
152
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
153
JSMSG_INCOMPATIBLE_PROTO, js_Function_str,
154
js_toString_str, "object");
155
return nullptr;
156
}
157
158
const OpaqueCrossCompartmentWrapper OpaqueCrossCompartmentWrapper::singleton;