Bug 1661304 - Add an initial UserInteraction for tab opening. r=Gijs,data-review=chutten
authorMike Conley <mconley@mozilla.com>
Tue, 20 Oct 2020 20:17:50 +0000
changeset 553697 9a6e825d7427a00a55832fc646f1536eb235d841
parent 553696 6dba004261322f95e4b001e910e63912450edd97
child 553698 a3815d601038dc3b8103224a5da4d6fa76aea511
push id37880
push userrmaries@mozilla.com
push dateWed, 21 Oct 2020 03:56:30 +0000
treeherdermozilla-central@56302c299235 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1661304
milestone84.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 1661304 - Add an initial UserInteraction for tab opening. r=Gijs,data-review=chutten Depends on D93590 Differential Revision: https://phabricator.services.mozilla.com/D88896
browser/base/content/tabbrowser-tabs.js
browser/base/content/tabbrowser.js
toolkit/components/telemetry/UserInteractions.yaml
--- a/browser/base/content/tabbrowser-tabs.js
+++ b/browser/base/content/tabbrowser-tabs.js
@@ -1933,16 +1933,20 @@
       this.arrowScrollbox._updateScrollButtonsDisabledState();
 
       // If this browser isn't lazy (indicating it's probably created by
       // session restore), preload the next about:newtab if we don't
       // already have a preloaded browser.
       if (tab.linkedPanel) {
         NewTabPagePreloading.maybeCreatePreloadedBrowser(window);
       }
+
+      if (UserInteraction.running("browser.tabs.opening", window)) {
+        UserInteraction.finish("browser.tabs.opening", window);
+      }
     }
 
     _canAdvanceToTab(aTab) {
       return !aTab.closing;
     }
 
     getRelatedElement(aTab) {
       if (!aTab) {
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -2465,16 +2465,20 @@
       // all callers of addTab that pass a params object need to pass
       // a valid triggeringPrincipal.
       if (!triggeringPrincipal) {
         throw new Error(
           "Required argument triggeringPrincipal missing within addTab"
         );
       }
 
+      if (!UserInteraction.running("browser.tabs.opening", window)) {
+        UserInteraction.start("browser.tabs.opening", "initting", window);
+      }
+
       // Don't use document.l10n.setAttributes because the FTL file is loaded
       // lazily and we won't be able to resolve the string.
       document
         .getElementById("History:UndoCloseTab")
         .setAttribute("data-l10n-args", JSON.stringify({ tabCount: 1 }));
       SessionStore.setLastClosedTabCount(window, 1);
 
       // if we're adding tabs, we're past interrupt mode, ditch the owner
@@ -2562,27 +2566,30 @@
         t.setAttribute("pinned", "true");
       }
 
       t.classList.add("tabbrowser-tab");
 
       this.tabContainer._unlockTabSizing();
 
       if (!animate) {
+        UserInteraction.update("browser.tabs.opening", "not-animated", window);
         t.setAttribute("fadein", "true");
 
         // Call _handleNewTab asynchronously as it needs to know if the
         // new tab is selected.
         setTimeout(
           function(tabContainer) {
             tabContainer._handleNewTab(t);
           },
           0,
           this.tabContainer
         );
+      } else {
+        UserInteraction.update("browser.tabs.opening", "animated", window);
       }
 
       let usingPreloadedContent = false;
       let b;
 
       try {
         if (!batchInsertingTabs) {
           // When we are not restoring a session, we need to know
@@ -3284,16 +3291,20 @@
       {
         animate,
         byMouse,
         skipPermitUnload,
         closeWindowWithLastTab,
         prewarmed,
       } = {}
     ) {
+      if (UserInteraction.running("browser.tabs.opening", window)) {
+        UserInteraction.finish("browser.tabs.opening", window);
+      }
+
       // Telemetry stopwatches may already be running if removeTab gets
       // called again for an already closing tab.
       if (
         !TelemetryStopwatch.running("FX_TAB_CLOSE_TIME_ANIM_MS", aTab) &&
         !TelemetryStopwatch.running("FX_TAB_CLOSE_TIME_NO_ANIM_MS", aTab)
       ) {
         // Speculatevely start both stopwatches now. We'll cancel one of
         // the two later depending on whether we're animating.
--- a/toolkit/components/telemetry/UserInteractions.yaml
+++ b/toolkit/components/telemetry/UserInteractions.yaml
@@ -21,12 +21,17 @@
 #   category: <category name>                          # mandatory
 #     name: <interaction name>                         # mandatory
 #       description: <description of user interaction> # mandatory
 #       bug_numbers: [<list of bug numbers>]           # mandatory
 #
 # Precise documentation for UserInteractions can be found at
 # https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/collection/user-interactions.html
 
+browser.tabs:
+  opening:
+    description: A new tab is being opened.
+    bug_numbers: [1662160]
+
 testing:
   interaction:
     description: A user interaction just for testing.
     bug_numbers: [1661304]