summaryrefslogtreecommitdiffstats
path: root/js/src/proxy/SecurityWrapper.cpp
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/proxy/SecurityWrapper.cpp
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/proxy/SecurityWrapper.cpp')
-rw-r--r--js/src/proxy/SecurityWrapper.cpp153
1 files changed, 153 insertions, 0 deletions
diff --git a/js/src/proxy/SecurityWrapper.cpp b/js/src/proxy/SecurityWrapper.cpp
new file mode 100644
index 000000000..710faf9b0
--- /dev/null
+++ b/js/src/proxy/SecurityWrapper.cpp
@@ -0,0 +1,153 @@
+/* -*- 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 "jsapi.h"
+#include "jswrapper.h"
+
+#include "jsatominlines.h"
+
+using namespace js;
+
+static void
+ReportUnwrapDenied(JSContext *cx)
+{
+ JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_UNWRAP_DENIED);
+}
+
+template <class Base>
+bool
+SecurityWrapper<Base>::enter(JSContext* cx, HandleObject wrapper, HandleId id,
+ Wrapper::Action act, bool* bp) const
+{
+ ReportUnwrapDenied(cx);
+ *bp = false;
+ return false;
+}
+
+template <class Base>
+bool
+SecurityWrapper<Base>::nativeCall(JSContext* cx, IsAcceptableThis test, NativeImpl impl,
+ const CallArgs& args) const
+{
+ ReportUnwrapDenied(cx);
+ return false;
+}
+
+template <class Base>
+bool
+SecurityWrapper<Base>::setPrototype(JSContext* cx, HandleObject wrapper, HandleObject proto,
+ ObjectOpResult& result) const
+{
+ ReportUnwrapDenied(cx);
+ return false;
+}
+
+template <class Base>
+bool
+SecurityWrapper<Base>::setImmutablePrototype(JSContext* cx, HandleObject wrapper,
+ bool* succeeded) const
+{
+ ReportUnwrapDenied(cx);
+ return false;
+}
+
+template <class Base>
+bool
+SecurityWrapper<Base>::preventExtensions(JSContext* cx, HandleObject wrapper,
+ ObjectOpResult& result) const
+{
+ // 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 result.fail(JSMSG_CANT_CHANGE_EXTENSIBILITY);
+}
+
+template <class Base>
+bool
+SecurityWrapper<Base>::isExtensible(JSContext* cx, HandleObject wrapper, bool* extensible) const
+{
+ // See above.
+ *extensible = true;
+ return true;
+}
+
+template <class Base>
+bool
+SecurityWrapper<Base>::getBuiltinClass(JSContext* cx, HandleObject wrapper,
+ ESClass* cls) const
+{
+ *cls = ESClass::Other;
+ return true;
+}
+
+template <class Base>
+bool
+SecurityWrapper<Base>::isArray(JSContext* cx, HandleObject obj, JS::IsArrayAnswer* answer) const
+{
+ // This should ReportUnwrapDenied(cx), but bug 849730 disagrees. :-(
+ *answer = JS::IsArrayAnswer::NotArray;
+ return true;
+}
+
+template <class Base>
+bool
+SecurityWrapper<Base>::regexp_toShared(JSContext* cx, HandleObject obj, RegExpGuard* g) const
+{
+ return Base::regexp_toShared(cx, obj, g);
+}
+
+template <class Base>
+bool
+SecurityWrapper<Base>::boxedValue_unbox(JSContext* cx, HandleObject obj, MutableHandleValue vp) const
+{
+ vp.setUndefined();
+ return true;
+}
+
+template <class Base>
+bool
+SecurityWrapper<Base>::defineProperty(JSContext* cx, HandleObject wrapper, HandleId id,
+ Handle<PropertyDescriptor> desc,
+ ObjectOpResult& result) const
+{
+ if (desc.getter() || desc.setter()) {
+ RootedValue idVal(cx, IdToValue(id));
+ JSString* str = ValueToSource(cx, idVal);
+ if (!str)
+ return false;
+ AutoStableStringChars chars(cx);
+ const char16_t* prop = nullptr;
+ if (str->ensureFlat(cx) && chars.initTwoByte(cx, str))
+ prop = chars.twoByteChars();
+ JS_ReportErrorNumberUC(cx, GetErrorMessage, nullptr,
+ JSMSG_ACCESSOR_DEF_DENIED, prop);
+ return false;
+ }
+
+ return Base::defineProperty(cx, wrapper, id, desc, result);
+}
+
+template <class Base>
+bool
+SecurityWrapper<Base>::watch(JSContext* cx, HandleObject proxy,
+ HandleId id, HandleObject callable) const
+{
+ ReportUnwrapDenied(cx);
+ return false;
+}
+
+template <class Base>
+bool
+SecurityWrapper<Base>::unwatch(JSContext* cx, HandleObject proxy,
+ HandleId id) const
+{
+ ReportUnwrapDenied(cx);
+ return false;
+}
+
+
+template class js::SecurityWrapper<Wrapper>;
+template class js::SecurityWrapper<CrossCompartmentWrapper>;