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 #ifndef __ChromeObjectWrapper_h__
8 #define __ChromeObjectWrapper_h__
10 #include "mozilla/Attributes.h"
12 #include "FilteringWrapper.h"
16 struct OpaqueWithSilentFailing
;
18 // When a vanilla chrome JS object is exposed to content, we use a wrapper that
19 // fails silently on GET, ENUMERATE, and GET_PROPERTY_DESCRIPTOR for legacy
20 // reasons. For extra security, we override the traps that allow content to pass
21 // an object to chrome, and perform extra security checks on them.
22 #define ChromeObjectWrapperBase \
23 FilteringWrapper<js::CrossCompartmentSecurityWrapper, OpaqueWithSilentFailing>
25 class ChromeObjectWrapper
: public ChromeObjectWrapperBase
{
27 constexpr ChromeObjectWrapper() : ChromeObjectWrapperBase(0) {}
29 virtual bool defineProperty(JSContext
* cx
, JS::Handle
<JSObject
*> wrapper
,
31 JS::Handle
<JS::PropertyDescriptor
> desc
,
32 JS::ObjectOpResult
& result
) const override
;
33 virtual bool set(JSContext
* cx
, JS::HandleObject wrapper
, JS::HandleId id
,
34 JS::HandleValue v
, JS::HandleValue receiver
,
35 JS::ObjectOpResult
& result
) const override
;
37 static const ChromeObjectWrapper singleton
;
42 #endif /* __ChromeObjectWrapper_h__ */