зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset ebe2c08a2454 (bug 1474499) for failing web platform tests on ValidationEvent/constructor.https.html
This commit is contained in:
Родитель
9b05873885
Коммит
620bc5019f
|
@ -1,197 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/MerchantValidationEvent.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "mozilla/dom/PaymentRequest.h"
|
||||
#include "mozilla/dom/Location.h"
|
||||
#include "mozilla/dom/URL.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(MerchantValidationEvent, Event, mRequest)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(MerchantValidationEvent, Event)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MerchantValidationEvent)
|
||||
NS_INTERFACE_MAP_END_INHERITING(Event)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(MerchantValidationEvent, Event)
|
||||
NS_IMPL_RELEASE_INHERITED(MerchantValidationEvent, Event)
|
||||
|
||||
// User-land code constructor
|
||||
already_AddRefed<MerchantValidationEvent>
|
||||
MerchantValidationEvent::Constructor(
|
||||
const GlobalObject& aGlobal,
|
||||
const nsAString& aType,
|
||||
const MerchantValidationEventInit& aEventInitDict,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
// validate passed URL
|
||||
nsCOMPtr<mozilla::dom::EventTarget> owner =
|
||||
do_QueryInterface(aGlobal.GetAsSupports());
|
||||
return Constructor(owner, aType, aEventInitDict, aRv);
|
||||
}
|
||||
|
||||
// Internal JS object constructor
|
||||
already_AddRefed<MerchantValidationEvent>
|
||||
MerchantValidationEvent::Constructor(
|
||||
EventTarget* aOwner,
|
||||
const nsAString& aType,
|
||||
const MerchantValidationEventInit& aEventInitDict,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
RefPtr<MerchantValidationEvent> e = new MerchantValidationEvent(aOwner);
|
||||
bool trusted = e->Init(aOwner);
|
||||
e->InitEvent(aType, aEventInitDict.mBubbles, aEventInitDict.mCancelable);
|
||||
if (!e->init(aEventInitDict, aRv)) {
|
||||
return nullptr;
|
||||
}
|
||||
e->SetTrusted(trusted);
|
||||
e->SetComposed(aEventInitDict.mComposed);
|
||||
return e.forget();
|
||||
}
|
||||
|
||||
bool
|
||||
MerchantValidationEvent::init(const MerchantValidationEventInit& aEventInitDict,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(GetParentObject());
|
||||
auto doc = window->GetExtantDoc();
|
||||
if (!doc) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return false;
|
||||
}
|
||||
auto principal = doc->NodePrincipal();
|
||||
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
principal->GetURI(getter_AddRefs(baseURI));
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURI> validationUri;
|
||||
rv = NS_NewURI(getter_AddRefs(validationUri),
|
||||
aEventInitDict.mValidationURL,
|
||||
nullptr,
|
||||
baseURI,
|
||||
nsContentUtils::GetIOService());
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
aRv.ThrowTypeError<MSG_INVALID_URL>(aEventInitDict.mValidationURL);
|
||||
return false;
|
||||
}
|
||||
nsAutoCString utf8href;
|
||||
rv = validationUri->GetSpec(utf8href);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(NS_ERROR_DOM_BAD_URI);
|
||||
return false;
|
||||
}
|
||||
CopyUTF8toUTF16(utf8href, mValidationURL);
|
||||
return true;
|
||||
}
|
||||
|
||||
MerchantValidationEvent::MerchantValidationEvent(EventTarget* aOwner)
|
||||
: Event(aOwner, nullptr, nullptr)
|
||||
, mWaitForUpdate(false)
|
||||
{
|
||||
MOZ_ASSERT(aOwner);
|
||||
}
|
||||
|
||||
void
|
||||
MerchantValidationEvent::ResolvedCallback(JSContext* aCx,
|
||||
JS::Handle<JS::Value> aValue)
|
||||
{
|
||||
MOZ_ASSERT(aCx);
|
||||
MOZ_ASSERT(mRequest);
|
||||
|
||||
if (!mWaitForUpdate) {
|
||||
return;
|
||||
}
|
||||
mWaitForUpdate = false;
|
||||
|
||||
// If we eventually end up supporting merchant validation
|
||||
// we would validate `aValue` here, as per:
|
||||
// https://w3c.github.io/payment-request/#validate-merchant-s-details-algorithm
|
||||
//
|
||||
// Right now, MerchantValidationEvent is only implemented for standards
|
||||
// conformance, which is why at this point we throw a NS_ERROR_DOM_NOT_SUPPORTED_ERR.
|
||||
|
||||
mRequest->AbortUpdate(NS_ERROR_DOM_NOT_SUPPORTED_ERR, false);
|
||||
mRequest->SetUpdating(false);
|
||||
}
|
||||
|
||||
void
|
||||
MerchantValidationEvent::RejectedCallback(JSContext* aCx,
|
||||
JS::Handle<JS::Value> aValue)
|
||||
{
|
||||
MOZ_ASSERT(mRequest);
|
||||
if (!mWaitForUpdate) {
|
||||
return;
|
||||
}
|
||||
mWaitForUpdate = false;
|
||||
mRequest->AbortUpdate(NS_ERROR_DOM_ABORT_ERR, false);
|
||||
mRequest->SetUpdating(false);
|
||||
}
|
||||
|
||||
void
|
||||
MerchantValidationEvent::Complete(Promise& aPromise, ErrorResult& aRv)
|
||||
{
|
||||
if (!IsTrusted()) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mRequest);
|
||||
|
||||
if (mWaitForUpdate || !mRequest->ReadyForUpdate()) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
aPromise.AppendNativeHandler(this);
|
||||
|
||||
StopPropagation();
|
||||
StopImmediatePropagation();
|
||||
mWaitForUpdate = true;
|
||||
mRequest->SetUpdating(true);
|
||||
}
|
||||
|
||||
void
|
||||
MerchantValidationEvent::SetRequest(PaymentRequest* aRequest)
|
||||
{
|
||||
MOZ_ASSERT(IsTrusted());
|
||||
MOZ_ASSERT(!mRequest);
|
||||
MOZ_ASSERT(aRequest);
|
||||
|
||||
mRequest = aRequest;
|
||||
}
|
||||
|
||||
void
|
||||
MerchantValidationEvent::GetValidationURL(nsAString& aValidationURL)
|
||||
{
|
||||
aValidationURL.Assign(mValidationURL);
|
||||
}
|
||||
|
||||
void
|
||||
MerchantValidationEvent::SetValidationURL(nsAString& aValidationURL)
|
||||
{
|
||||
mValidationURL.Assign(aValidationURL);
|
||||
}
|
||||
|
||||
MerchantValidationEvent::~MerchantValidationEvent() {}
|
||||
|
||||
JSObject*
|
||||
MerchantValidationEvent::WrapObjectInternal(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return MerchantValidationEvent_Binding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -1,77 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_MerchantValidationEvent_h
|
||||
#define mozilla_dom_MerchantValidationEvent_h
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/dom/Event.h"
|
||||
#include "mozilla/dom/MerchantValidationEventBinding.h"
|
||||
#include "mozilla/dom/PromiseNativeHandler.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class Promise;
|
||||
class PaymentRequest;
|
||||
class MerchantValidationEvent
|
||||
: public Event
|
||||
, public PromiseNativeHandler
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
|
||||
MerchantValidationEvent,
|
||||
Event)
|
||||
|
||||
explicit MerchantValidationEvent(EventTarget* aOwner);
|
||||
|
||||
virtual JSObject* WrapObjectInternal(
|
||||
JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
virtual void ResolvedCallback(JSContext* aCx,
|
||||
JS::Handle<JS::Value> aValue) override;
|
||||
virtual void RejectedCallback(JSContext* aCx,
|
||||
JS::Handle<JS::Value> aValue) override;
|
||||
|
||||
static already_AddRefed<MerchantValidationEvent> Constructor(
|
||||
EventTarget* aOwner,
|
||||
const nsAString& aType,
|
||||
const MerchantValidationEventInit& aEventInitDict,
|
||||
ErrorResult& aRv);
|
||||
|
||||
// Called by WebIDL constructor
|
||||
static already_AddRefed<MerchantValidationEvent> Constructor(
|
||||
const GlobalObject& aGlobal,
|
||||
const nsAString& aType,
|
||||
const MerchantValidationEventInit& aEventInitDict,
|
||||
ErrorResult& aRv);
|
||||
|
||||
void Complete(Promise& aPromise, ErrorResult& aRv);
|
||||
|
||||
void SetRequest(PaymentRequest* aRequest);
|
||||
|
||||
void GetValidationURL(nsAString& aValidationURL);
|
||||
|
||||
void SetValidationURL(nsAString& aValidationURL);
|
||||
|
||||
protected:
|
||||
bool init(const MerchantValidationEventInit& aEventInitDict, ErrorResult& aRv);
|
||||
~MerchantValidationEvent();
|
||||
|
||||
private:
|
||||
// Indicating whether an Complete()-initiated update is currently in progress.
|
||||
bool mWaitForUpdate;
|
||||
nsString mValidationURL;
|
||||
RefPtr<PaymentRequest> mRequest;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_MerchantValidationEvent_h
|
|
@ -14,7 +14,6 @@
|
|||
#include "nsIURLParser.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "PaymentRequestManager.h"
|
||||
#include "mozilla/dom/MerchantValidationEvent.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -984,29 +983,6 @@ PaymentRequest::DispatchUpdateEvent(const nsAString& aType)
|
|||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
nsresult
|
||||
PaymentRequest::DispatchMerchantValidationEvent(const nsAString& aType)
|
||||
{
|
||||
MOZ_ASSERT(ReadyForUpdate());
|
||||
|
||||
MerchantValidationEventInit init;
|
||||
init.mBubbles = false;
|
||||
init.mCancelable = false;
|
||||
init.mValidationURL = EmptyString();
|
||||
|
||||
ErrorResult rv;
|
||||
RefPtr<MerchantValidationEvent> event =
|
||||
MerchantValidationEvent::Constructor(this, aType, init, rv);
|
||||
if (rv.Failed()) {
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
event->SetTrusted(true);
|
||||
event->SetRequest(this);
|
||||
|
||||
DispatchEvent(*event, rv);
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
already_AddRefed<PaymentAddress>
|
||||
PaymentRequest::GetShippingAddress() const
|
||||
{
|
||||
|
|
|
@ -156,7 +156,6 @@ public:
|
|||
void
|
||||
RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override;
|
||||
|
||||
IMPL_EVENT_HANDLER(merchantvalidation);
|
||||
IMPL_EVENT_HANDLER(shippingaddresschange);
|
||||
IMPL_EVENT_HANDLER(shippingoptionchange);
|
||||
IMPL_EVENT_HANDLER(paymentmethodchange);
|
||||
|
@ -179,8 +178,6 @@ protected:
|
|||
|
||||
nsresult DispatchUpdateEvent(const nsAString& aType);
|
||||
|
||||
nsresult DispatchMerchantValidationEvent(const nsAString& aType);
|
||||
|
||||
PaymentRequest(nsPIDOMWindowInner* aWindow, const nsAString& aInternalId);
|
||||
|
||||
// Id for internal identification
|
||||
|
|
|
@ -14,7 +14,6 @@ EXPORTS += [
|
|||
]
|
||||
|
||||
EXPORTS.mozilla.dom += [
|
||||
'MerchantValidationEvent.h',
|
||||
'PaymentAddress.h',
|
||||
'PaymentMethodChangeEvent.h',
|
||||
'PaymentRequest.h',
|
||||
|
@ -25,7 +24,6 @@ EXPORTS.mozilla.dom += [
|
|||
|
||||
UNIFIED_SOURCES += [
|
||||
'BasicCardPayment.cpp',
|
||||
'MerchantValidationEvent.cpp',
|
||||
'PaymentActionResponse.cpp',
|
||||
'PaymentAddress.cpp',
|
||||
'PaymentMethodChangeEvent.cpp',
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this WebIDL file is
|
||||
* https://w3c.github.io/payment-request/#merchantvalidationevent-interface
|
||||
* https://w3c.github.io/payment-request/#merchantvalidationeventinit-dictionary
|
||||
*/
|
||||
|
||||
[Constructor(DOMString type, optional MerchantValidationEventInit eventInitDict),
|
||||
SecureContext,
|
||||
Exposed=Window,
|
||||
Func="mozilla::dom::PaymentRequest::PrefEnabled"]
|
||||
interface MerchantValidationEvent : Event {
|
||||
readonly attribute USVString validationURL;
|
||||
[Throws]
|
||||
void complete(Promise<any> merchantSessionPromise);
|
||||
};
|
||||
|
||||
dictionary MerchantValidationEventInit : EventInit {
|
||||
USVString validationURL = "";
|
||||
};
|
|
@ -120,7 +120,6 @@ interface PaymentRequest : EventTarget {
|
|||
readonly attribute DOMString? shippingOption;
|
||||
readonly attribute PaymentShippingType? shippingType;
|
||||
|
||||
attribute EventHandler onmerchantvalidation;
|
||||
attribute EventHandler onshippingaddresschange;
|
||||
attribute EventHandler onshippingoptionchange;
|
||||
attribute EventHandler onpaymentmethodchange;
|
||||
|
|
|
@ -666,7 +666,6 @@ WEBIDL_FILES = [
|
|||
'MediaTrackSettings.webidl',
|
||||
'MediaTrackSupportedConstraints.webidl',
|
||||
'MenuBoxObject.webidl',
|
||||
'MerchantValidationEvent.webidl',
|
||||
'MessageChannel.webidl',
|
||||
'MessageEvent.webidl',
|
||||
'MessagePort.webidl',
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
prefs: [dom.payments.request.enabled:true]
|
|
@ -1,22 +1,22 @@
|
|||
[constructor.https.html]
|
||||
[MerchantValidationEvent can be dispatched, even if not trusted.]
|
||||
expected: PASS
|
||||
expected: FAIL
|
||||
|
||||
[MerchantValidationEvent can be constructed with an EventInitDict, even if not trusted.]
|
||||
expected: PASS
|
||||
expected: FAIL
|
||||
|
||||
[Relative validationURLs use the document as the base.]
|
||||
expected: PASS
|
||||
expected: FAIL
|
||||
|
||||
[Must have a validationURL IDL attribute, which is initialized with to the validationURL dictionary value.]
|
||||
expected: PASS
|
||||
expected: FAIL
|
||||
|
||||
[MerchantValidationEvent can be constructed in secure-context.]
|
||||
expected: PASS
|
||||
expected: FAIL
|
||||
|
||||
[Must throw if initialized with an invalid URL.]
|
||||
expected: PASS
|
||||
expected: FAIL
|
||||
|
||||
[Must throw TypeError if initialized with an invalid URL.]
|
||||
expected: PASS
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -762,7 +762,6 @@ STATIC_ATOMS = [
|
|||
Atom("onloadingerror", "onloadingerror"),
|
||||
Atom("onpopstate", "onpopstate"),
|
||||
Atom("only", "only"), # this one is not an event
|
||||
Atom("onmerchantvalidation", "onmerchantvalidation"),
|
||||
Atom("onmessage", "onmessage"),
|
||||
Atom("onmessageerror", "onmessageerror"),
|
||||
Atom("onmidimessage", "onmidimessage"),
|
||||
|
|
Загрузка…
Ссылка в новой задаче