Bug 1882593 [wpt PR 44836] - Add test for unknown, invalid ancillary chunk which...
[gecko.git] / dom / payments / MerchantValidationEvent.h
blobe4ace4c6b8249802d8c65f5dd571aef8dda90f1b
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/. */
7 #ifndef mozilla_dom_MerchantValidationEvent_h
8 #define mozilla_dom_MerchantValidationEvent_h
10 #include "mozilla/Attributes.h"
11 #include "mozilla/Result.h"
12 #include "mozilla/dom/Event.h"
13 #include "mozilla/dom/MerchantValidationEventBinding.h"
14 #include "mozilla/dom/PromiseNativeHandler.h"
16 class nsIURI;
18 namespace mozilla {
19 class ErrorResult;
21 namespace dom {
23 class Promise;
24 class PaymentRequest;
25 class MerchantValidationEvent : public Event, public PromiseNativeHandler {
26 public:
27 NS_DECL_ISUPPORTS_INHERITED
28 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
29 MerchantValidationEvent, Event)
31 explicit MerchantValidationEvent(EventTarget* aOwner);
33 virtual JSObject* WrapObjectInternal(
34 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
36 virtual void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
37 ErrorResult& aRv) override;
38 virtual void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
39 ErrorResult& aRv) override;
41 static already_AddRefed<MerchantValidationEvent> Constructor(
42 EventTarget* aOwner, const nsAString& aType,
43 const MerchantValidationEventInit& aEventInitDict, ErrorResult& aRv);
45 // Called by WebIDL constructor
46 static already_AddRefed<MerchantValidationEvent> Constructor(
47 const GlobalObject& aGlobal, const nsAString& aType,
48 const MerchantValidationEventInit& aEventInitDict, ErrorResult& aRv);
50 void Complete(Promise& aPromise, ErrorResult& aRv);
52 void SetRequest(PaymentRequest* aRequest);
54 void GetValidationURL(nsAString& aValidationURL);
56 void GetMethodName(nsAString& aMethodName);
58 void SetMethodName(const nsAString& aMethodName);
60 protected:
61 void init(const MerchantValidationEventInit& aEventInitDict,
62 ErrorResult& aRv);
63 ~MerchantValidationEvent();
65 private:
66 // Indicating whether an Complete()-initiated update is currently in progress.
67 bool mWaitForUpdate;
68 nsCOMPtr<nsIURI> mValidationURL;
69 RefPtr<PaymentRequest> mRequest;
70 nsString mMethodName;
73 } // namespace dom
74 } // namespace mozilla
76 #endif // mozilla_dom_MerchantValidationEvent_h