Bug 1487295 - Add defaults to PaymentMethodChangeEventInit's members. r=baku
☠☠ backed out by a63bcec434ac ☠ ☠
authorMarcos Cáceres <marcos@marcosc.com>
Tue, 04 Sep 2018 01:21:00 +0300
changeset 482933 f7d509458e63f9cc004ed8d7c702a23a9e752b1a
parent 482932 64c4f420467683e20721a1f8b62002f0755970fd
child 482934 5e99f6ed6c2fb16ee861a5534d14dcde2e4a2573
push id232
push userfmarier@mozilla.com
push dateWed, 05 Sep 2018 20:45:54 +0000
reviewersbaku
bugs1487295
milestone63.0a1
Bug 1487295 - Add defaults to PaymentMethodChangeEventInit's members. r=baku
dom/payments/PaymentMethodChangeEvent.cpp
dom/payments/PaymentMethodChangeEvent.h
dom/webidl/PaymentMethodChangeEvent.webidl
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/payment-request/PaymentMethodChangeEvent/methodDetails-attribute.https.html
testing/web-platform/tests/payment-request/PaymentMethodChangeEvent/methodName-attribute.https.html
--- a/dom/payments/PaymentMethodChangeEvent.cpp
+++ b/dom/payments/PaymentMethodChangeEvent.cpp
@@ -67,19 +67,17 @@ PaymentMethodChangeEvent::PaymentMethodC
   mozilla::HoldJSObjects(this);
 }
 
 void
 PaymentMethodChangeEvent::init(
   const PaymentMethodChangeEventInit& aEventInitDict)
 {
   mMethodName.Assign(aEventInitDict.mMethodName);
-  if (aEventInitDict.mMethodDetails.WasPassed()) {
-    mMethodDetails = aEventInitDict.mMethodDetails.Value();
-  }
+  mMethodDetails = aEventInitDict.mMethodDetails;
 }
 
 void
 PaymentMethodChangeEvent::GetMethodName(nsAString& aMethodName)
 {
   aMethodName.Assign(mMethodName);
 }
 
--- a/dom/payments/PaymentMethodChangeEvent.h
+++ b/dom/payments/PaymentMethodChangeEvent.h
@@ -9,16 +9,17 @@
 
 #include "mozilla/ErrorResult.h"
 #include "mozilla/dom/PaymentMethodChangeEventBinding.h"
 #include "mozilla/dom/PaymentRequestUpdateEvent.h"
 
 namespace mozilla {
 namespace dom {
 class PaymentRequestUpdateEvent;
+struct PaymentMethodChangeEventInit;
 class PaymentMethodChangeEvent final : public PaymentRequestUpdateEvent
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
     PaymentMethodChangeEvent,
     PaymentRequestUpdateEvent)
 
--- a/dom/webidl/PaymentMethodChangeEvent.webidl
+++ b/dom/webidl/PaymentMethodChangeEvent.webidl
@@ -3,11 +3,11 @@
  Exposed=Window,
  Func="mozilla::dom::PaymentRequest::PrefEnabled"]
 interface PaymentMethodChangeEvent : PaymentRequestUpdateEvent {
     readonly attribute DOMString methodName;
     readonly attribute object?   methodDetails;
 };
 
 dictionary PaymentMethodChangeEventInit : PaymentRequestUpdateEventInit {
-    required DOMString methodName;
-             object?   methodDetails;
+    DOMString methodName = "";
+    object?   methodDetails = null;
 };
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -620612,21 +620612,21 @@
    "65d56e7490111f6fc9e91f4470379fc89ae42972",
    "manual"
   ],
   "payment-request/PaymentItem/type_member.https.html": [
    "dc62a83f597a0b53c686689fb8f549130982242a",
    "testharness"
   ],
   "payment-request/PaymentMethodChangeEvent/methodDetails-attribute.https.html": [
-   "a478c559d497e8dea9d471ce1e36427bfb741aa7",
+   "ec0aa96dddb46b26617064ab54e9d02e2a588cbb",
    "testharness"
   ],
   "payment-request/PaymentMethodChangeEvent/methodName-attribute.https.html": [
-   "e6e0bf9a91971b3a20acf59cf27097281f0d2085",
+   "176638c7852f6f0f8fd7a8c3dfefdf439a829d22",
    "testharness"
   ],
   "payment-request/PaymentRequestUpdateEvent/constructor.http.html": [
    "db7765f7bf98c38935804c2588614911a97a2290",
    "testharness"
   ],
   "payment-request/PaymentRequestUpdateEvent/constructor.https.html": [
    "fd66493bf4f2aa006e99198094d1b7afd34f4543",
--- a/testing/web-platform/tests/payment-request/PaymentMethodChangeEvent/methodDetails-attribute.https.html
+++ b/testing/web-platform/tests/payment-request/PaymentMethodChangeEvent/methodDetails-attribute.https.html
@@ -14,9 +14,20 @@ test(() => {
     methodName: "wpt-test",
     methodDetails
   });
   assert_idl_attribute(event, "methodDetails");
   const { test } = event.methodDetails;
   assert_equals(test, "pass");
   assert_equals(event.methodDetails, methodDetails);
 }, "Must have a methodDetails IDL attribute, which is initialized with to the methodName dictionary value");
+
+test(() => {
+  const event = new PaymentMethodChangeEvent("test");
+  assert_equals(event.methodDetails, null, "methodDetails attribute must initialize to null");
+
+  const event2 = new PaymentMethodChangeEvent("test", { methodName: "basic-card" });
+  assert_equals(event2.methodDetails, null, "methodDetails attribute must initialize to null");
+
+  const event3 = new PaymentMethodChangeEvent("test", {});
+  assert_equals(event2.methodDetails, null, "methodDetails attribute must initialize to null");
+}, "The methodDetails member defaults to null");
 </script>
--- a/testing/web-platform/tests/payment-request/PaymentMethodChangeEvent/methodName-attribute.https.html
+++ b/testing/web-platform/tests/payment-request/PaymentMethodChangeEvent/methodName-attribute.https.html
@@ -9,9 +9,20 @@
 test(() => {
   const event = new PaymentMethodChangeEvent("test", {
     methodName: "wpt-test",
   });
   assert_idl_attribute(event, "methodName");
   const { methodName } = event;
   assert_equals(methodName, "wpt-test");
 }, "Must have a methodName IDL attribute, which is initialized with to the methodName dictionary value");
+
+test(() => {
+  const event = new PaymentMethodChangeEvent("test");
+  assert_equals(event.methodName, "", "methodName attribute must initialize to empty string");
+
+  const event2 = new PaymentMethodChangeEvent("test", { methodDetails: {} });
+  assert_equals(event2.methodName, "", "methodName attribute must initialize to empty string");
+
+  const event3 = new PaymentMethodChangeEvent("test", {});
+  assert_equals(event3.methodName, "", "methodName attribute must initialize to empty string");
+}, "When no dictionary is passed, the methodName member defaults to the empty string");
 </script>