michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
michael@0: * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
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: /**
michael@0: * This is a mock Link object which can be used in tests.
michael@0: */
michael@0:
michael@0: #ifndef mock_Link_h__
michael@0: #define mock_Link_h__
michael@0:
michael@0: #include "mozilla/MemoryReporting.h"
michael@0: #include "mozilla/dom/Link.h"
michael@0: #include "mozilla/dom/URLSearchParams.h"
michael@0:
michael@0: class mock_Link : public mozilla::dom::Link
michael@0: {
michael@0: public:
michael@0: NS_DECL_ISUPPORTS
michael@0:
michael@0: mock_Link(void (*aHandlerFunction)(nsLinkState),
michael@0: bool aRunNextTest = true)
michael@0: : mozilla::dom::Link(nullptr)
michael@0: , mHandler(aHandlerFunction)
michael@0: , mRunNextTest(aRunNextTest)
michael@0: {
michael@0: // Create a cyclic ownership, so that the link will be released only
michael@0: // after its status has been updated. This will ensure that, when it should
michael@0: // run the next test, it will happen at the end of the test function, if
michael@0: // the link status has already been set before. Indeed the link status is
michael@0: // updated on a separate connection, thus may happen at any time.
michael@0: mDeathGrip = this;
michael@0: }
michael@0:
michael@0: virtual void SetLinkState(nsLinkState aState)
michael@0: {
michael@0: // Notify our callback function.
michael@0: mHandler(aState);
michael@0:
michael@0: // Break the cycle so the object can be destroyed.
michael@0: mDeathGrip = 0;
michael@0: }
michael@0:
michael@0: virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
michael@0: {
michael@0: return 0; // the value shouldn't matter
michael@0: }
michael@0:
michael@0: ~mock_Link() {
michael@0: // Run the next test if we are supposed to.
michael@0: if (mRunNextTest) {
michael@0: run_next_test();
michael@0: }
michael@0: }
michael@0:
michael@0: private:
michael@0: void (*mHandler)(nsLinkState);
michael@0: bool mRunNextTest;
michael@0: nsRefPtr mDeathGrip;
michael@0: };
michael@0:
michael@0: NS_IMPL_ISUPPORTS(
michael@0: mock_Link,
michael@0: mozilla::dom::Link
michael@0: )
michael@0:
michael@0: ////////////////////////////////////////////////////////////////////////////////
michael@0: //// Needed Link Methods
michael@0:
michael@0: namespace mozilla {
michael@0: namespace dom {
michael@0:
michael@0: Link::Link(Element* aElement)
michael@0: : mElement(aElement)
michael@0: , mLinkState(eLinkState_NotLink)
michael@0: , mRegistered(false)
michael@0: {
michael@0: }
michael@0:
michael@0: Link::~Link()
michael@0: {
michael@0: }
michael@0:
michael@0: bool
michael@0: Link::ElementHasHref() const
michael@0: {
michael@0: NS_NOTREACHED("Unexpected call to Link::ElementHasHref");
michael@0: return false; // suppress compiler warning
michael@0: }
michael@0:
michael@0: void
michael@0: Link::SetLinkState(nsLinkState aState)
michael@0: {
michael@0: NS_NOTREACHED("Unexpected call to Link::SetLinkState");
michael@0: }
michael@0:
michael@0: void
michael@0: Link::ResetLinkState(bool aNotify, bool aHasHref)
michael@0: {
michael@0: NS_NOTREACHED("Unexpected call to Link::ResetLinkState");
michael@0: }
michael@0:
michael@0: nsIURI*
michael@0: Link::GetURI() const
michael@0: {
michael@0: NS_NOTREACHED("Unexpected call to Link::GetURI");
michael@0: return nullptr; // suppress compiler warning
michael@0: }
michael@0:
michael@0: size_t
michael@0: Link::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
michael@0: {
michael@0: NS_NOTREACHED("Unexpected call to Link::SizeOfExcludingThis");
michael@0: return 0;
michael@0: }
michael@0:
michael@0: void
michael@0: Link::URLSearchParamsUpdated()
michael@0: {
michael@0: NS_NOTREACHED("Unexpected call to Link::URLSearchParamsUpdated");
michael@0: }
michael@0:
michael@0: void
michael@0: Link::UpdateURLSearchParams()
michael@0: {
michael@0: NS_NOTREACHED("Unexpected call to Link::UpdateURLSearchParams");
michael@0: }
michael@0:
michael@0: NS_IMPL_CYCLE_COLLECTION_CLASS(URLSearchParams)
michael@0: NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(URLSearchParams)
michael@0: NS_IMPL_CYCLE_COLLECTION_UNLINK_END
michael@0: NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(URLSearchParams)
michael@0: NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
michael@0: NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(URLSearchParams)
michael@0:
michael@0: NS_IMPL_CYCLE_COLLECTING_ADDREF(URLSearchParams)
michael@0: NS_IMPL_CYCLE_COLLECTING_RELEASE(URLSearchParams)
michael@0:
michael@0: NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(URLSearchParams)
michael@0: NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
michael@0: NS_INTERFACE_MAP_ENTRY(nsISupports)
michael@0: NS_INTERFACE_MAP_END
michael@0:
michael@0:
michael@0: URLSearchParams::URLSearchParams()
michael@0: {
michael@0: }
michael@0:
michael@0: URLSearchParams::~URLSearchParams()
michael@0: {
michael@0: }
michael@0:
michael@0: JSObject*
michael@0: URLSearchParams::WrapObject(JSContext* aCx)
michael@0: {
michael@0: return nullptr;
michael@0: }
michael@0:
michael@0: void
michael@0: URLSearchParams::ParseInput(const nsACString& aInput,
michael@0: URLSearchParamsObserver* aObserver)
michael@0: {
michael@0: NS_NOTREACHED("Unexpected call to URLSearchParams::ParseInput");
michael@0: }
michael@0:
michael@0: void
michael@0: URLSearchParams::AddObserver(URLSearchParamsObserver* aObserver)
michael@0: {
michael@0: NS_NOTREACHED("Unexpected call to URLSearchParams::SetObserver");
michael@0: }
michael@0:
michael@0: void
michael@0: URLSearchParams::RemoveObserver(URLSearchParamsObserver* aObserver)
michael@0: {
michael@0: NS_NOTREACHED("Unexpected call to URLSearchParams::SetObserver");
michael@0: }
michael@0:
michael@0: void
michael@0: URLSearchParams::Serialize(nsAString& aValue) const
michael@0: {
michael@0: NS_NOTREACHED("Unexpected call to URLSearchParams::Serialize");
michael@0: }
michael@0:
michael@0: void
michael@0: URLSearchParams::Get(const nsAString& aName, nsString& aRetval)
michael@0: {
michael@0: NS_NOTREACHED("Unexpected call to URLSearchParams::Get");
michael@0: }
michael@0:
michael@0: void
michael@0: URLSearchParams::GetAll(const nsAString& aName, nsTArray& aRetval)
michael@0: {
michael@0: NS_NOTREACHED("Unexpected call to URLSearchParams::GetAll");
michael@0: }
michael@0:
michael@0: void
michael@0: URLSearchParams::Set(const nsAString& aName, const nsAString& aValue)
michael@0: {
michael@0: NS_NOTREACHED("Unexpected call to URLSearchParams::Set");
michael@0: }
michael@0:
michael@0: void
michael@0: URLSearchParams::Append(const nsAString& aName, const nsAString& aValue)
michael@0: {
michael@0: NS_NOTREACHED("Unexpected call to URLSearchParams::Append");
michael@0: }
michael@0:
michael@0: void
michael@0: URLSearchParams::AppendInternal(const nsAString& aName, const nsAString& aValue)
michael@0: {
michael@0: NS_NOTREACHED("Unexpected call to URLSearchParams::AppendInternal");
michael@0: }
michael@0:
michael@0: bool
michael@0: URLSearchParams::Has(const nsAString& aName)
michael@0: {
michael@0: NS_NOTREACHED("Unexpected call to URLSearchParams::Has");
michael@0: return false;
michael@0: }
michael@0:
michael@0: void
michael@0: URLSearchParams::Delete(const nsAString& aName)
michael@0: {
michael@0: NS_NOTREACHED("Unexpected call to URLSearchParams::Delete");
michael@0: }
michael@0:
michael@0: void
michael@0: URLSearchParams::DeleteAll()
michael@0: {
michael@0: NS_NOTREACHED("Unexpected call to URLSearchParams::DeleteAll");
michael@0: }
michael@0:
michael@0: void
michael@0: URLSearchParams::NotifyObservers(URLSearchParamsObserver* aExceptObserver)
michael@0: {
michael@0: NS_NOTREACHED("Unexpected call to URLSearchParams::NotifyObservers");
michael@0: }
michael@0:
michael@0: } // namespace dom
michael@0: } // namespace mozilla
michael@0:
michael@0: #endif // mock_Link_h__