Bug 1860712 [wpt PR 42705] - Port popover test to WPT and adjust for close requests...
[gecko.git] / dom / base / WindowNamedPropertiesHandler.h
blobe1aec931a17bdb01730f881fdc819cf88d2bc24f
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"
12 namespace mozilla::dom {
14 class WindowNamedPropertiesHandler : public BaseDOMProxyHandler {
15 public:
16 constexpr WindowNamedPropertiesHandler()
17 : BaseDOMProxyHandler(nullptr, /* hasPrototype = */ true) {}
18 virtual bool getOwnPropDescriptor(
19 JSContext* aCx, JS::Handle<JSObject*> aProxy, JS::Handle<jsid> aId,
20 bool /* unused */,
21 JS::MutableHandle<Maybe<JS::PropertyDescriptor>> aDesc) const override;
22 virtual bool defineProperty(JSContext* aCx, JS::Handle<JSObject*> aProxy,
23 JS::Handle<jsid> aId,
24 JS::Handle<JS::PropertyDescriptor> aDesc,
25 JS::ObjectOpResult& result) const override;
26 virtual bool ownPropNames(
27 JSContext* aCx, JS::Handle<JSObject*> aProxy, unsigned flags,
28 JS::MutableHandleVector<jsid> aProps) const override;
29 virtual bool delete_(JSContext* aCx, JS::Handle<JSObject*> aProxy,
30 JS::Handle<jsid> aId,
31 JS::ObjectOpResult& aResult) const override;
33 // No need for getPrototypeIfOrdinary here: window named-properties objects
34 // have static prototypes, so the version inherited from BaseDOMProxyHandler
35 // will do the right thing.
37 virtual bool preventExtensions(JSContext* aCx, JS::Handle<JSObject*> aProxy,
38 JS::ObjectOpResult& aResult) const override {
39 return aResult.failCantPreventExtensions();
41 virtual bool isExtensible(JSContext* aCx, JS::Handle<JSObject*> aProxy,
42 bool* aIsExtensible) const override {
43 *aIsExtensible = true;
44 return true;
46 virtual const char* className(JSContext* aCx,
47 JS::Handle<JSObject*> aProxy) const override {
48 return "WindowProperties";
51 static const WindowNamedPropertiesHandler* getInstance() {
52 static const WindowNamedPropertiesHandler instance;
53 return &instance;
56 // For Create, aProto is the parent of the interface prototype object of the
57 // Window we're associated with.
58 static JSObject* Create(JSContext* aCx, JS::Handle<JSObject*> aProto);
61 } // namespace mozilla::dom
63 #endif /* mozilla_dom_WindowNamedPropertiesHandler_h */