Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 sw=2 et tw=78: */
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 {
13 namespace dom {
15 class WindowNamedPropertiesHandler : public BaseDOMProxyHandler
16 {
17 public:
18 WindowNamedPropertiesHandler() : BaseDOMProxyHandler(nullptr)
19 {
20 setHasPrototype(true);
21 }
22 virtual bool
23 preventExtensions(JSContext* aCx, JS::Handle<JSObject*> aProxy) MOZ_OVERRIDE
24 {
25 // Throw a TypeError, per WebIDL.
26 JS_ReportErrorNumber(aCx, js_GetErrorMessage, nullptr,
27 JSMSG_CANT_CHANGE_EXTENSIBILITY);
28 return false;
29 }
30 virtual bool
31 getOwnPropDescriptor(JSContext* aCx, JS::Handle<JSObject*> aProxy,
32 JS::Handle<jsid> aId,
33 bool /* unused */,
34 JS::MutableHandle<JSPropertyDescriptor> aDesc) MOZ_OVERRIDE;
35 virtual bool
36 defineProperty(JSContext* aCx, JS::Handle<JSObject*> aProxy,
37 JS::Handle<jsid> aId,
38 JS::MutableHandle<JSPropertyDescriptor> aDesc) MOZ_OVERRIDE;
39 virtual bool
40 ownPropNames(JSContext* aCx, JS::Handle<JSObject*> aProxy, unsigned flags,
41 JS::AutoIdVector& aProps) MOZ_OVERRIDE;
42 virtual bool
43 delete_(JSContext* aCx, JS::Handle<JSObject*> aProxy, JS::Handle<jsid> aId,
44 bool* aBp) MOZ_OVERRIDE;
45 virtual bool
46 isExtensible(JSContext* aCx, JS::Handle<JSObject*> aProxy,
47 bool* aIsExtensible) MOZ_OVERRIDE
48 {
49 *aIsExtensible = true;
50 return true;
51 }
52 virtual const char*
53 className(JSContext *aCx, JS::Handle<JSObject*> aProxy) MOZ_OVERRIDE
54 {
55 return "WindowProperties";
56 }
58 static WindowNamedPropertiesHandler*
59 getInstance()
60 {
61 static WindowNamedPropertiesHandler instance;
62 return &instance;
63 }
65 // For Install, aProto is the proto of the Window we're associated with.
66 static void
67 Install(JSContext *aCx, JS::Handle<JSObject*> aProto);
68 };
70 } // namespace dom
71 } // namespace mozilla
73 #endif /* mozilla_dom_WindowNamedPropertiesHandler_h */