Bug 1388391 - Track DOMError usage with telemetry; r=francois,smaug
authorAryeh Gregor <ayg@aryeh.name>
Tue, 08 Aug 2017 17:43:32 +0300
changeset 647764 79823f111dabcdeaa06c5275999225540a40a05d
parent 647763 f7d05f4db14d19c63c7ac3edef620d52aa580b47
child 647765 22aad1598498156460162c9264cf80be344b0fe0
push id74539
push userbmo:mkelly@mozilla.com
push dateWed, 16 Aug 2017 22:39:32 +0000
reviewersfrancois, smaug
bugs1388391
milestone57.0a1
Bug 1388391 - Track DOMError usage with telemetry; r=francois,smaug 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;
 };