dom/base/WindowNamedPropertiesHandler.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/base/WindowNamedPropertiesHandler.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,73 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim: set ts=2 sw=2 et tw=78: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef mozilla_dom_WindowNamedPropertiesHandler_h
    1.11 +#define mozilla_dom_WindowNamedPropertiesHandler_h
    1.12 +
    1.13 +#include "mozilla/dom/DOMJSProxyHandler.h"
    1.14 +
    1.15 +namespace mozilla {
    1.16 +namespace dom {
    1.17 +
    1.18 +class WindowNamedPropertiesHandler : public BaseDOMProxyHandler
    1.19 +{
    1.20 +public:
    1.21 +  WindowNamedPropertiesHandler() : BaseDOMProxyHandler(nullptr)
    1.22 +  {
    1.23 +    setHasPrototype(true);
    1.24 +  }
    1.25 +  virtual bool
    1.26 +  preventExtensions(JSContext* aCx, JS::Handle<JSObject*> aProxy) MOZ_OVERRIDE
    1.27 +  {
    1.28 +    // Throw a TypeError, per WebIDL.
    1.29 +    JS_ReportErrorNumber(aCx, js_GetErrorMessage, nullptr,
    1.30 +                         JSMSG_CANT_CHANGE_EXTENSIBILITY);
    1.31 +    return false;
    1.32 +  }
    1.33 +  virtual bool
    1.34 +  getOwnPropDescriptor(JSContext* aCx, JS::Handle<JSObject*> aProxy,
    1.35 +                       JS::Handle<jsid> aId,
    1.36 +                       bool /* unused */,
    1.37 +                       JS::MutableHandle<JSPropertyDescriptor> aDesc) MOZ_OVERRIDE;
    1.38 +  virtual bool
    1.39 +  defineProperty(JSContext* aCx, JS::Handle<JSObject*> aProxy,
    1.40 +                 JS::Handle<jsid> aId,
    1.41 +                 JS::MutableHandle<JSPropertyDescriptor> aDesc) MOZ_OVERRIDE;
    1.42 +  virtual bool
    1.43 +  ownPropNames(JSContext* aCx, JS::Handle<JSObject*> aProxy, unsigned flags,
    1.44 +               JS::AutoIdVector& aProps) MOZ_OVERRIDE;
    1.45 +  virtual bool
    1.46 +  delete_(JSContext* aCx, JS::Handle<JSObject*> aProxy, JS::Handle<jsid> aId,
    1.47 +          bool* aBp) MOZ_OVERRIDE;
    1.48 +  virtual bool
    1.49 +  isExtensible(JSContext* aCx, JS::Handle<JSObject*> aProxy,
    1.50 +               bool* aIsExtensible) MOZ_OVERRIDE
    1.51 +  {
    1.52 +    *aIsExtensible = true;
    1.53 +    return true;
    1.54 +  }
    1.55 +  virtual const char*
    1.56 +  className(JSContext *aCx, JS::Handle<JSObject*> aProxy) MOZ_OVERRIDE
    1.57 +  {
    1.58 +    return "WindowProperties";
    1.59 +  }
    1.60 +
    1.61 +  static WindowNamedPropertiesHandler*
    1.62 +  getInstance()
    1.63 +  {
    1.64 +    static WindowNamedPropertiesHandler instance;
    1.65 +    return &instance;
    1.66 +  }
    1.67 +
    1.68 +  // For Install, aProto is the proto of the Window we're associated with.
    1.69 +  static void
    1.70 +  Install(JSContext *aCx, JS::Handle<JSObject*> aProto);
    1.71 +};
    1.72 +
    1.73 +} // namespace dom
    1.74 +} // namespace mozilla
    1.75 +
    1.76 +#endif /* mozilla_dom_WindowNamedPropertiesHandler_h */

mercurial