Bug 1492036 - Reporting API - part 2 - WebIDL for DeprecationReportBody, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 14 Nov 2018 20:02:32 +0100
changeset 502917 a599388cbfe7515ea0b4e616c7bb2e60624c0072
parent 502916 e8d5d9f9ecc80a6870155fc3d7de0ab726b114f4
child 502918 a86e9cde89bbbbb7b6d755a9daacf2e03dc5947e
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1492036
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1492036 - Reporting API - part 2 - WebIDL for DeprecationReportBody, r=smaug
dom/reporting/DeprecationReportBody.cpp
dom/reporting/DeprecationReportBody.h
dom/reporting/ReportBody.h
dom/reporting/moz.build
dom/webidl/Reporting.webidl
testing/web-platform/meta/reporting/idlharness.window.js.ini
new file mode 100644
--- /dev/null
+++ b/dom/reporting/DeprecationReportBody.cpp
@@ -0,0 +1,76 @@
+/* -*- 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/DeprecationReportBody.h"
+#include "mozilla/dom/ReportingBinding.h"
+
+namespace mozilla {
+namespace dom {
+
+DeprecationReportBody::DeprecationReportBody(nsPIDOMWindowInner* aWindow,
+                                             const nsAString& aId,
+                                             Nullable<Date> aDate,
+                                             const nsAString& aMessage,
+                                             const nsAString& aSourceFile,
+                                             Nullable<uint32_t> aLineNumber,
+                                             Nullable<uint32_t> aColumnNumber)
+  : ReportBody(aWindow)
+  , mId(aId)
+  , mDate(aDate)
+  , mMessage(aMessage)
+  , mSourceFile(aSourceFile)
+  , mLineNumber(aLineNumber)
+  , mColumnNumber(aColumnNumber)
+{
+  MOZ_ASSERT(aWindow);
+}
+
+DeprecationReportBody::~DeprecationReportBody() = default;
+
+JSObject*
+DeprecationReportBody::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
+{
+  return DeprecationReportBody_Binding::Wrap(aCx, this, aGivenProto);
+}
+
+void
+DeprecationReportBody::GetId(nsAString& aId) const
+{
+  aId = mId;
+}
+
+Nullable<Date>
+DeprecationReportBody::GetAnticipatedRemoval() const
+{
+  return mDate;
+}
+
+void
+DeprecationReportBody::GetMessage(nsAString& aMessage) const
+{
+  aMessage = mMessage;
+}
+
+void
+DeprecationReportBody::GetSourceFile(nsAString& aSourceFile) const
+{
+  aSourceFile = mSourceFile;
+}
+
+Nullable<uint32_t>
+DeprecationReportBody::GetLineNumber() const
+{
+  return mLineNumber;
+}
+
+Nullable<uint32_t>
+DeprecationReportBody::GetColumnNumber() const
+{
+  return mColumnNumber;
+}
+
+} // dom namespace
+} // mozilla namespace
new file mode 100644
--- /dev/null
+++ b/dom/reporting/DeprecationReportBody.h
@@ -0,0 +1,62 @@
+/* -*- 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_DeprecationReportBody_h
+#define mozilla_dom_DeprecationReportBody_h
+
+#include "mozilla/dom/ReportBody.h"
+#include "mozilla/dom/Date.h"
+
+namespace mozilla {
+namespace dom {
+
+class DeprecationReportBody final : public ReportBody
+{
+public:
+  DeprecationReportBody(nsPIDOMWindowInner* aWindow,
+                        const nsAString& aId,
+                        Nullable<Date> aDate,
+                        const nsAString& aMessage,
+                        const nsAString& aSourceFile,
+                        Nullable<uint32_t> aLineNumber,
+                        Nullable<uint32_t> aColumnNumber);
+
+  JSObject*
+  WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
+
+  void
+  GetId(nsAString& aId) const;
+
+  Nullable<Date>
+  GetAnticipatedRemoval() const;
+
+  void
+  GetMessage(nsAString& aMessage) const;
+
+  void
+  GetSourceFile(nsAString& aSourceFile) const;
+
+  Nullable<uint32_t>
+  GetLineNumber() const;
+
+  Nullable<uint32_t>
+  GetColumnNumber() const;
+
+private:
+  ~DeprecationReportBody();
+
+  const nsString mId;
+  const Nullable<Date> mDate;
+  const nsString mMessage;
+  const nsString mSourceFile;
+  const Nullable<uint32_t> mLineNumber;
+  const Nullable<uint32_t> mColumnNumber;
+};
+
+} // dom namespace
+} // mozilla namespace
+
+#endif // mozilla_dom_DeprecationReportBody_h
--- a/dom/reporting/ReportBody.h
+++ b/dom/reporting/ReportBody.h
@@ -12,36 +12,36 @@
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
 
 class nsPIDOMWindowInner;
 
 namespace mozilla {
 namespace dom {
 
-class ReportBody final : public nsISupports
-                       , public nsWrapperCache
+class ReportBody : public nsISupports
+                 , public nsWrapperCache
 {
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ReportBody)
 
   explicit ReportBody(nsPIDOMWindowInner* aWindow);
 
-  JSObject*
+  virtual JSObject*
   WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
   nsPIDOMWindowInner*
   GetParentObject() const
   {
     return mWindow;
   }
 
-private:
-  ~ReportBody();
+protected:
+  virtual ~ReportBody();
 
   nsCOMPtr<nsPIDOMWindowInner> mWindow;
 };
 
 } // dom namespace
 } // mozilla namespace
 
 #endif // mozilla_dom_ReportBody_h
--- a/dom/reporting/moz.build
+++ b/dom/reporting/moz.build
@@ -1,21 +1,23 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
 EXPORTS.mozilla.dom = [
+    'DeprecationReportBody.h',
     'Report.h',
     'ReportBody.h',
     'ReportingObserver.h',
 ]
 
 UNIFIED_SOURCES += [
+    'DeprecationReportBody.cpp',
     'Report.cpp',
     'ReportBody.cpp',
     'ReportingObserver.cpp',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 with Files('**'):
--- a/dom/webidl/Reporting.webidl
+++ b/dom/webidl/Reporting.webidl
@@ -29,8 +29,18 @@ interface ReportingObserver {
 callback ReportingObserverCallback = void (sequence<Report> reports, ReportingObserver observer);
 
 dictionary ReportingObserverOptions {
   sequence<DOMString> types;
   boolean buffered = false;
 };
 
 typedef sequence<Report> ReportList;
+
+[Func="mozilla::dom::DOMPrefs::dom_reporting_enabled"]
+interface DeprecationReportBody : ReportBody {
+  readonly attribute DOMString id;
+  readonly attribute Date? anticipatedRemoval;
+  readonly attribute DOMString message;
+  readonly attribute DOMString? sourceFile;
+  readonly attribute unsigned long? lineNumber;
+  readonly attribute unsigned long? columnNumber;
+};
--- a/testing/web-platform/meta/reporting/idlharness.window.js.ini
+++ b/testing/web-platform/meta/reporting/idlharness.window.js.ini
@@ -1,48 +1,21 @@
 [idlharness.window.html]
-  [DeprecationReportBody interface object length]
-    expected: FAIL
-
-  [DeprecationReportBody interface: existence and properties of interface prototype object's "constructor" property]
-    expected: FAIL
-
-  [DeprecationReportBody interface: attribute lineNumber]
-    expected: FAIL
-
-  [DeprecationReportBody interface object name]
-    expected: FAIL
-
-  [DeprecationReportBody interface: attribute anticipatedRemoval]
-    expected: FAIL
-
   [CrashReportBody interface: existence and properties of interface prototype object]
     expected: FAIL
 
   [CrashReportBody interface: existence and properties of interface prototype object's @@unscopables property]
     expected: FAIL
 
-  [DeprecationReportBody interface: existence and properties of interface prototype object]
-    expected: FAIL
-
-  [DeprecationReportBody interface: attribute message]
-    expected: FAIL
-
   [CrashReportBody interface: attribute reason]
     expected: FAIL
 
-  [DeprecationReportBody interface: attribute columnNumber]
-    expected: FAIL
-
   [InterventionReportBody interface: attribute lineNumber]
     expected: FAIL
 
-  [DeprecationReportBody interface: existence and properties of interface prototype object's @@unscopables property]
-    expected: FAIL
-
   [InterventionReportBody interface: attribute id]
     expected: FAIL
 
   [CrashReportBody interface object name]
     expected: FAIL
 
   [InterventionReportBody interface: attribute columnNumber]
     expected: FAIL
@@ -54,25 +27,19 @@
     expected: FAIL
 
   [InterventionReportBody interface: existence and properties of interface prototype object's @@unscopables property]
     expected: FAIL
 
   [InterventionReportBody interface object length]
     expected: FAIL
 
-  [DeprecationReportBody interface: attribute sourceFile]
-    expected: FAIL
-
   [CrashReportBody interface object length]
     expected: FAIL
 
-  [DeprecationReportBody interface: attribute id]
-    expected: FAIL
-
   [CrashReportBody interface: attribute crashId]
     expected: FAIL
 
   [InterventionReportBody interface: existence and properties of interface object]
     expected: FAIL
 
   [InterventionReportBody interface: existence and properties of interface prototype object]
     expected: FAIL
@@ -81,14 +48,11 @@
     expected: FAIL
 
   [InterventionReportBody interface object name]
     expected: FAIL
 
   [InterventionReportBody interface: attribute message]
     expected: FAIL
 
-  [DeprecationReportBody interface: existence and properties of interface object]
-    expected: FAIL
-
   [InterventionReportBody interface: attribute sourceFile]
     expected: FAIL