tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

TestInterfaceMaplikeJSObject.h (1959B)


      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/. */
      6 
      7 #ifndef mozilla_dom_TestInterfaceMaplikeJSObject_h
      8 #define mozilla_dom_TestInterfaceMaplikeJSObject_h
      9 
     10 #include "nsCOMPtr.h"
     11 #include "nsWrapperCache.h"
     12 
     13 class nsPIDOMWindowInner;
     14 
     15 namespace mozilla {
     16 
     17 class ErrorResult;
     18 
     19 namespace dom {
     20 
     21 class GlobalObject;
     22 
     23 // Implementation of test binding for webidl maplike interfaces, using
     24 // primitives for key types and objects for value types.
     25 class TestInterfaceMaplikeJSObject final : public nsISupports,
     26                                           public nsWrapperCache {
     27 public:
     28  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     29  NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(TestInterfaceMaplikeJSObject)
     30 
     31  explicit TestInterfaceMaplikeJSObject(nsPIDOMWindowInner* aParent);
     32  nsPIDOMWindowInner* GetParentObject() const;
     33  virtual JSObject* WrapObject(JSContext* aCx,
     34                               JS::Handle<JSObject*> aGivenProto) override;
     35  static already_AddRefed<TestInterfaceMaplikeJSObject> Constructor(
     36      const GlobalObject& aGlobal, ErrorResult& rv);
     37 
     38  // External access for testing internal convenience functions.
     39  void SetInternal(JSContext* aCx, const nsAString& aKey,
     40                   JS::Handle<JSObject*> aObject);
     41  void ClearInternal();
     42  bool DeleteInternal(const nsAString& aKey);
     43  bool HasInternal(const nsAString& aKey);
     44  void GetInternal(JSContext* aCx, const nsAString& aKey,
     45                   JS::MutableHandle<JSObject*> aRetVal, ErrorResult& aRv);
     46 
     47 private:
     48  virtual ~TestInterfaceMaplikeJSObject() = default;
     49  nsCOMPtr<nsPIDOMWindowInner> mParent;
     50 };
     51 
     52 }  // namespace dom
     53 }  // namespace mozilla
     54 
     55 #endif  // mozilla_dom_TestInterfaceMaplikeJSObject_h