Backed out changeset 9157ea42ff41 (bug 914925) for Android/B2G test bustage.
[gecko.git] / dom / base / WindowNamedPropertiesHandler.h
blobce3b79a151454383228a1b2c4c0ae068a7a95e81
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
17 public:
18 WindowNamedPropertiesHandler() : BaseDOMProxyHandler(nullptr)
20 setHasPrototype(true);
22 virtual bool
23 preventExtensions(JSContext* aCx, JS::Handle<JSObject*> aProxy) MOZ_OVERRIDE
25 // Throw a TypeError, per WebIDL.
26 JS_ReportErrorNumber(aCx, js_GetErrorMessage, nullptr,
27 JSMSG_CANT_CHANGE_EXTENSIBILITY);
28 return false;
30 virtual bool
31 getOwnPropertyDescriptor(JSContext* aCx, JS::Handle<JSObject*> aProxy,
32 JS::Handle<jsid> aId,
33 JS::MutableHandle<JSPropertyDescriptor> aDesc,
34 unsigned aFlags) 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 getOwnPropertyNames(JSContext* aCx, JS::Handle<JSObject*> aProxy,
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
49 *aIsExtensible = true;
50 return true;
52 virtual const char*
53 className(JSContext *aCx, JS::Handle<JSObject*> aProxy) MOZ_OVERRIDE
55 return "WindowProperties";
58 static WindowNamedPropertiesHandler*
59 getInstance()
61 static WindowNamedPropertiesHandler instance;
62 return &instance;
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);
70 } // namespace dom
71 } // namespace mozilla
73 #endif /* mozilla_dom_WindowNamedPropertiesHandler_h */