Bug 1388391 - Track DOMError usage with telemetry; r?smaug,francois draft
authorAryeh Gregor <ayg@aryeh.name>
Tue, 08 Aug 2017 17:43:32 +0300
changeset 647489 d281914933d4dee9fa1a8a8cce385c9bf20d3b4f
parent 646884 7ff4c2f1fe11f6b98686f783294692893b1e1e8b
child 726516 c0798aa2b2d018e6b36e646a2903a5f6b08c5b37
push id74419
push userbmo:ayg@aryeh.name
push dateWed, 16 Aug 2017 11:28:17 +0000
reviewerssmaug, francois
bugs1388391
milestone57.0a1
Bug 1388391 - Track DOMError usage with telemetry; r?smaug,francois MozReview-Commit-ID: A0kH6xsg4mm
dom/base/DOMError.cpp
dom/base/UseCounters.conf
dom/webidl/DOMError.webidl
--- a/dom/base/DOMError.cpp
+++ b/dom/base/DOMError.cpp
@@ -2,16 +2,17 @@
 /* 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/DOMError.h"
 #include "mozilla/dom/DOMErrorBinding.h"
 #include "mozilla/dom/DOMException.h"
+#include "mozilla/UseCounter.h"
 #include "nsPIDOMWindow.h"
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMError, mWindow)
 NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMError)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMError)
@@ -62,16 +63,23 @@ DOMError::WrapObject(JSContext* aCx, JS:
 
 /* static */ already_AddRefed<DOMError>
 DOMError::Constructor(const GlobalObject& aGlobal,
                       const nsAString& aName, const nsAString& aMessage,
                       ErrorResult& aRv)
 {
   nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal.GetAsSupports());
 
+  if (window) {
+    nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
+    if (doc) {
+      doc->SetDocumentAndPageUseCounter(eUseCounter_custom_DOMErrorConstructor);
+    }
+  }
+
   // Window is null for chrome code.
 
   RefPtr<DOMError> ret = new DOMError(window, aName, aMessage);
   return ret.forget();
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/base/UseCounters.conf
+++ b/dom/base/UseCounters.conf
@@ -44,16 +44,19 @@
 // annotating the WebIDL files does nothing for identifying CSS
 // property usage, which we would also like to track.
 
 method SVGSVGElement.getElementById
 attribute SVGSVGElement.currentScale
 property Fill
 property FillOpacity
 attribute XMLDocument.async
+attribute DOMError.name
+attribute DOMError.message
+custom DOMErrorConstructor constructed a DOMError
 
 // Push API
 method PushManager.subscribe
 method PushSubscription.unsubscribe
 
 // window.sidebar.addSearchEngine
 attribute Window.sidebar
 method External.addSearchEngine
--- a/dom/webidl/DOMError.webidl
+++ b/dom/webidl/DOMError.webidl
@@ -8,14 +8,14 @@
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
 [Constructor(DOMString name, optional DOMString message = ""),
  Exposed=(Window,Worker,System)]
 interface DOMError {
-  [Constant]
+  [Constant, UseCounter]
   readonly attribute DOMString name;
 
-  [Constant]
+  [Constant, UseCounter]
   readonly attribute DOMString message;
 };