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 mozilla_dom_WindowNamedPropertiesHandler_h
8 #define mozilla_dom_WindowNamedPropertiesHandler_h
10 #include "mozilla/dom/DOMJSProxyHandler.h"
15 class WindowNamedPropertiesHandler
: public BaseDOMProxyHandler
{
17 constexpr WindowNamedPropertiesHandler()
18 : BaseDOMProxyHandler(nullptr, /* hasPrototype = */ true) {}
19 virtual bool getOwnPropDescriptor(
20 JSContext
* aCx
, JS::Handle
<JSObject
*> aProxy
, JS::Handle
<jsid
> aId
,
22 JS::MutableHandle
<Maybe
<JS::PropertyDescriptor
>> aDesc
) const override
;
23 virtual bool defineProperty(JSContext
* aCx
, JS::Handle
<JSObject
*> aProxy
,
25 JS::Handle
<JS::PropertyDescriptor
> aDesc
,
26 JS::ObjectOpResult
& result
) const override
;
27 virtual bool ownPropNames(
28 JSContext
* aCx
, JS::Handle
<JSObject
*> aProxy
, unsigned flags
,
29 JS::MutableHandleVector
<jsid
> aProps
) const override
;
30 virtual bool delete_(JSContext
* aCx
, JS::Handle
<JSObject
*> aProxy
,
32 JS::ObjectOpResult
& aResult
) const override
;
34 // No need for getPrototypeIfOrdinary here: window named-properties objects
35 // have static prototypes, so the version inherited from BaseDOMProxyHandler
36 // will do the right thing.
38 virtual bool preventExtensions(JSContext
* aCx
, JS::Handle
<JSObject
*> aProxy
,
39 JS::ObjectOpResult
& aResult
) const override
{
40 return aResult
.failCantPreventExtensions();
42 virtual bool isExtensible(JSContext
* aCx
, JS::Handle
<JSObject
*> aProxy
,
43 bool* aIsExtensible
) const override
{
44 *aIsExtensible
= true;
47 virtual const char* className(JSContext
* aCx
,
48 JS::Handle
<JSObject
*> aProxy
) const override
{
49 return "WindowProperties";
52 static const WindowNamedPropertiesHandler
* getInstance() {
53 static const WindowNamedPropertiesHandler instance
;
57 // For Create, aProto is the parent of the interface prototype object of the
58 // Window we're associated with.
59 static JSObject
* Create(JSContext
* aCx
, JS::Handle
<JSObject
*> aProto
);
63 } // namespace mozilla
65 #endif /* mozilla_dom_WindowNamedPropertiesHandler_h */