Bug 1470128 - Instrument inspector shadowdom support;r=pbro draft
authorJulian Descottes <jdescottes@mozilla.com>
Mon, 25 Jun 2018 14:33:21 +0200
changeset 810601 111a0a89e6d5b42ae06309c6c4cd7cc01e68fea5
parent 809159 9390a911ee68708cf873677fae1e1711041fa5cd
push id114049
push userjdescottes@mozilla.com
push dateTue, 26 Jun 2018 07:59:00 +0000
reviewerspbro
bugs1470128
milestone62.0a1
Bug 1470128 - Instrument inspector shadowdom support;r=pbro MozReview-Commit-ID: JCknoaPiSlR
devtools/client/inspector/markup/views/markup-container.js
devtools/client/inspector/markup/views/slotted-node-container.js
toolkit/components/telemetry/Scalars.yaml
--- a/devtools/client/inspector/markup/views/markup-container.js
+++ b/devtools/client/inspector/markup/views/markup-container.js
@@ -69,16 +69,20 @@ MarkupContainer.prototype = {
     this.elt.addEventListener("mousedown", this._onMouseDown);
     this.elt.addEventListener("dblclick", this._onToggle);
     if (this.expander) {
       this.expander.addEventListener("click", this._onToggle);
     }
 
     // Marking the node as shown or hidden
     this.updateIsDisplayed();
+
+    if (node.isShadowRoot) {
+      this.markup.telemetry.scalarAdd("devtools.shadowdom.shadow_root_displayed", 1);
+    }
   },
 
   buildMarkup: function() {
     this.elt = this.win.document.createElement("li");
     this.elt.classList.add("child", "collapsed");
     this.elt.setAttribute("role", "presentation");
 
     this.tagLine = this.win.document.createElement("div");
@@ -327,16 +331,23 @@ MarkupContainer.prototype = {
       this.elt.classList.add("collapsed");
       this.expander.removeAttribute("open");
       this.markup.emit("collapsed");
     }
 
     if (this.showExpander) {
       this.tagLine.setAttribute("aria-expanded", this.expanded);
     }
+
+    if (this.node.isShadowRoot && !this._shadowRootExpandedTelemetryRecorded) {
+      // Record shadow root expands only once in order to compare this measure to
+      // shadow_root_displayed.
+      this._shadowRootExpandedTelemetryRecorded = true;
+      this.markup.telemetry.scalarAdd("devtools.shadowdom.shadow_root_expanded", 1);
+    }
   },
 
   /**
    * Expanding a node means cloning its "inline" closing tag into a new
    * tag-line that the user can interact with and showing the children.
    */
   showCloseTagLine: function() {
     // Only element containers display a closing tag line. #document has no closing line.
--- a/devtools/client/inspector/markup/views/slotted-node-container.js
+++ b/devtools/client/inspector/markup/views/slotted-node-container.js
@@ -38,16 +38,17 @@ SlottedNodeContainer.prototype = extend(
     if (!event.target.classList.contains("reveal-link")) {
       return;
     }
 
     const selection = this.markup.inspector.selection;
     if (selection.nodeFront != this.node || selection.isSlotted()) {
       const reason = "reveal-from-slot";
       this.markup.inspector.selection.setNodeFront(this.node, { reason });
+      this.markup.telemetry.scalarAdd("devtools.shadowdom.reveal_link_clicked", 1);
     }
   },
 
   isDraggable: function() {
     return false;
   },
 
   isSlotted: function() {
--- a/toolkit/components/telemetry/Scalars.yaml
+++ b/toolkit/components/telemetry/Scalars.yaml
@@ -943,16 +943,59 @@ devtools.inspector:
     keyed: true
     notification_emails:
       - dev-developer-tools@lists.mozilla.org
       - gl@mozilla.com
     release_channel_collection: opt-out
     record_in_processes:
       - 'main'
 
+devtools.shadowdom:
+  shadow_root_displayed:
+    bug_numbers:
+      - 1470128
+    description: >
+      Number of times shadow root elements are displayed in the markup view.
+    expires: "66"
+    kind: uint
+    notification_emails:
+      - dev-developer-tools@lists.mozilla.org
+      - jdescottes@mozilla.com
+    release_channel_collection: opt-out
+    record_in_processes:
+      - 'main'
+  shadow_root_expanded:
+    bug_numbers:
+      - 1470128
+    description: >
+      Number of times shadow root elements are expanded in the markup view. Successive
+      expands of the same shadow root element only count as 1.
+    expires: "66"
+    kind: uint
+    notification_emails:
+      - dev-developer-tools@lists.mozilla.org
+      - jdescottes@mozilla.com
+    release_channel_collection: opt-out
+    record_in_processes:
+      - 'main'
+  reveal_link_clicked:
+    bug_numbers:
+      - 1470128
+    description: >
+      Number of times a "reveal" link was clicked. "reveal" links are displayed in
+      shadow dom trees in the markup view.
+    expires: "66"
+    kind: uint
+    notification_emails:
+      - dev-developer-tools@lists.mozilla.org
+      - jdescottes@mozilla.com
+    release_channel_collection: opt-out
+    record_in_processes:
+      - 'main'
+
 devtools:
   current_theme:
     bug_numbers:
       - 1396811
     description: >
       Number of times DevTools was opened, keyed by theme.
     expires: never
     kind: uint