michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 sw=2 et tw=78: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_WindowNamedPropertiesHandler_h michael@0: #define mozilla_dom_WindowNamedPropertiesHandler_h michael@0: michael@0: #include "mozilla/dom/DOMJSProxyHandler.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: class WindowNamedPropertiesHandler : public BaseDOMProxyHandler michael@0: { michael@0: public: michael@0: WindowNamedPropertiesHandler() : BaseDOMProxyHandler(nullptr) michael@0: { michael@0: setHasPrototype(true); michael@0: } michael@0: virtual bool michael@0: preventExtensions(JSContext* aCx, JS::Handle aProxy) MOZ_OVERRIDE michael@0: { michael@0: // Throw a TypeError, per WebIDL. michael@0: JS_ReportErrorNumber(aCx, js_GetErrorMessage, nullptr, michael@0: JSMSG_CANT_CHANGE_EXTENSIBILITY); michael@0: return false; michael@0: } michael@0: virtual bool michael@0: getOwnPropDescriptor(JSContext* aCx, JS::Handle aProxy, michael@0: JS::Handle aId, michael@0: bool /* unused */, michael@0: JS::MutableHandle aDesc) MOZ_OVERRIDE; michael@0: virtual bool michael@0: defineProperty(JSContext* aCx, JS::Handle aProxy, michael@0: JS::Handle aId, michael@0: JS::MutableHandle aDesc) MOZ_OVERRIDE; michael@0: virtual bool michael@0: ownPropNames(JSContext* aCx, JS::Handle aProxy, unsigned flags, michael@0: JS::AutoIdVector& aProps) MOZ_OVERRIDE; michael@0: virtual bool michael@0: delete_(JSContext* aCx, JS::Handle aProxy, JS::Handle aId, michael@0: bool* aBp) MOZ_OVERRIDE; michael@0: virtual bool michael@0: isExtensible(JSContext* aCx, JS::Handle aProxy, michael@0: bool* aIsExtensible) MOZ_OVERRIDE michael@0: { michael@0: *aIsExtensible = true; michael@0: return true; michael@0: } michael@0: virtual const char* michael@0: className(JSContext *aCx, JS::Handle aProxy) MOZ_OVERRIDE michael@0: { michael@0: return "WindowProperties"; michael@0: } michael@0: michael@0: static WindowNamedPropertiesHandler* michael@0: getInstance() michael@0: { michael@0: static WindowNamedPropertiesHandler instance; michael@0: return &instance; michael@0: } michael@0: michael@0: // For Install, aProto is the proto of the Window we're associated with. michael@0: static void michael@0: Install(JSContext *aCx, JS::Handle aProto); michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #endif /* mozilla_dom_WindowNamedPropertiesHandler_h */