Bug 1941128 - Turn off network.dns.native_https_query on Mac again
[gecko.git] / dom / bindings / test / TestInterfaceMaplikeObject.cpp
blobb05e33df6b21adedb4ee7d98a566d0627ceb3747
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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/dom/TestInterfaceMaplikeObject.h"
8 #include "mozilla/dom/TestInterfaceMaplike.h"
9 #include "mozilla/dom/TestInterfaceJSMaplikeSetlikeIterableBinding.h"
10 #include "nsPIDOMWindow.h"
11 #include "mozilla/dom/BindingUtils.h"
13 namespace mozilla::dom {
15 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(TestInterfaceMaplikeObject, mParent)
17 NS_IMPL_CYCLE_COLLECTING_ADDREF(TestInterfaceMaplikeObject)
18 NS_IMPL_CYCLE_COLLECTING_RELEASE(TestInterfaceMaplikeObject)
20 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TestInterfaceMaplikeObject)
21 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
22 NS_INTERFACE_MAP_ENTRY(nsISupports)
23 NS_INTERFACE_MAP_END
25 TestInterfaceMaplikeObject::TestInterfaceMaplikeObject(
26 nsPIDOMWindowInner* aParent)
27 : mParent(aParent) {}
29 // static
30 already_AddRefed<TestInterfaceMaplikeObject>
31 TestInterfaceMaplikeObject::Constructor(const GlobalObject& aGlobal,
32 ErrorResult& aRv) {
33 nsCOMPtr<nsPIDOMWindowInner> window =
34 do_QueryInterface(aGlobal.GetAsSupports());
35 if (!window) {
36 aRv.Throw(NS_ERROR_FAILURE);
37 return nullptr;
40 RefPtr<TestInterfaceMaplikeObject> r = new TestInterfaceMaplikeObject(window);
41 return r.forget();
44 JSObject* TestInterfaceMaplikeObject::WrapObject(
45 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
46 return TestInterfaceMaplikeObject_Binding::Wrap(aCx, this, aGivenProto);
49 nsPIDOMWindowInner* TestInterfaceMaplikeObject::GetParentObject() const {
50 return mParent;
53 void TestInterfaceMaplikeObject::SetInternal(const nsAString& aKey) {
54 RefPtr<TestInterfaceMaplike> p(new TestInterfaceMaplike(mParent));
55 ErrorResult rv;
56 TestInterfaceMaplikeObject_Binding::MaplikeHelpers::Set(this, aKey, *p, rv);
59 void TestInterfaceMaplikeObject::ClearInternal() {
60 ErrorResult rv;
61 TestInterfaceMaplikeObject_Binding::MaplikeHelpers::Clear(this, rv);
64 bool TestInterfaceMaplikeObject::DeleteInternal(const nsAString& aKey) {
65 ErrorResult rv;
66 return TestInterfaceMaplikeObject_Binding::MaplikeHelpers::Delete(this, aKey,
67 rv);
70 bool TestInterfaceMaplikeObject::HasInternal(const nsAString& aKey) {
71 ErrorResult rv;
72 return TestInterfaceMaplikeObject_Binding::MaplikeHelpers::Has(this, aKey,
73 rv);
76 already_AddRefed<TestInterfaceMaplike> TestInterfaceMaplikeObject::GetInternal(
77 const nsAString& aKey, ErrorResult& aRv) {
78 return TestInterfaceMaplikeObject_Binding::MaplikeHelpers::Get(this, aKey,
79 aRv);
81 } // namespace mozilla::dom