1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* vim: set ts=8 sts=4 et sw=4 tw=99: */
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 __FilteringWrapper_h__
8 #define __FilteringWrapper_h__
10 #include "XrayWrapper.h"
11 #include "mozilla/Attributes.h"
12 #include "jswrapper.h"
13 #include "js/CallNonGenericMethod.h"
15 struct JSPropertyDescriptor
;
23 template <typename Base
, typename Policy
>
24 class FilteringWrapper
: public Base
{
26 MOZ_CONSTEXPR
explicit FilteringWrapper(unsigned flags
) : Base(flags
) {}
28 virtual bool getPropertyDescriptor(JSContext
* cx
, JS::Handle
<JSObject
*> wrapper
,
30 JS::MutableHandle
<JSPropertyDescriptor
> desc
) const MOZ_OVERRIDE
;
31 virtual bool getOwnPropertyDescriptor(JSContext
* cx
, JS::Handle
<JSObject
*> wrapper
,
33 JS::MutableHandle
<JSPropertyDescriptor
> desc
) const MOZ_OVERRIDE
;
34 virtual bool getOwnPropertyNames(JSContext
* cx
, JS::Handle
<JSObject
*> wrapper
,
35 JS::AutoIdVector
& props
) const MOZ_OVERRIDE
;
36 virtual bool enumerate(JSContext
* cx
, JS::Handle
<JSObject
*> wrapper
,
37 JS::AutoIdVector
& props
) const MOZ_OVERRIDE
;
38 virtual bool keys(JSContext
* cx
, JS::Handle
<JSObject
*> wrapper
,
39 JS::AutoIdVector
& props
) const MOZ_OVERRIDE
;
40 virtual bool iterate(JSContext
* cx
, JS::Handle
<JSObject
*> wrapper
, unsigned flags
,
41 JS::MutableHandle
<JS::Value
> vp
) const MOZ_OVERRIDE
;
42 virtual bool nativeCall(JSContext
* cx
, JS::IsAcceptableThis test
, JS::NativeImpl impl
,
43 JS::CallArgs args
) const MOZ_OVERRIDE
;
45 virtual bool defaultValue(JSContext
* cx
, JS::Handle
<JSObject
*> obj
, JSType hint
,
46 JS::MutableHandleValue vp
) const MOZ_OVERRIDE
;
48 virtual bool enter(JSContext
* cx
, JS::Handle
<JSObject
*> wrapper
, JS::Handle
<jsid
> id
,
49 js::Wrapper::Action act
, bool* bp
) const MOZ_OVERRIDE
;
51 static const FilteringWrapper singleton
;
55 * The HTML5 spec mandates very particular object behavior for cross-origin DOM
56 * objects (Window and Location), some of which runs contrary to the way that
57 * other XrayWrappers behave. We use this class to implement those semantics.
59 class CrossOriginXrayWrapper
: public SecurityXrayDOM
{
61 explicit CrossOriginXrayWrapper(unsigned flags
);
63 virtual bool getPropertyDescriptor(JSContext
* cx
, JS::Handle
<JSObject
*> wrapper
,
65 JS::MutableHandle
<JSPropertyDescriptor
> desc
) const MOZ_OVERRIDE
;
66 virtual bool getOwnPropertyDescriptor(JSContext
* cx
, JS::Handle
<JSObject
*> wrapper
,
68 JS::MutableHandle
<JSPropertyDescriptor
> desc
) const MOZ_OVERRIDE
;
70 virtual bool getOwnPropertyNames(JSContext
* cx
, JS::Handle
<JSObject
*> wrapper
,
71 JS::AutoIdVector
& props
) const MOZ_OVERRIDE
;
73 virtual bool defineProperty(JSContext
* cx
, JS::Handle
<JSObject
*> wrapper
,
75 JS::MutableHandle
<JSPropertyDescriptor
> desc
) const MOZ_OVERRIDE
;
76 virtual bool delete_(JSContext
* cx
, JS::Handle
<JSObject
*> wrapper
,
77 JS::Handle
<jsid
> id
, bool* bp
) const MOZ_OVERRIDE
;
79 virtual bool enumerate(JSContext
* cx
, JS::Handle
<JSObject
*> wrapper
,
80 JS::AutoIdVector
& props
) const MOZ_OVERRIDE
;
82 virtual bool getPrototypeOf(JSContext
* cx
, JS::HandleObject wrapper
,
83 JS::MutableHandleObject protop
) const MOZ_OVERRIDE
;
88 #endif /* __FilteringWrapper_h__ */