Bug 1204994 - part 3 - update use counter tests for new CONTENT_DOCUMENT histograms; r=bz
☠☠ backed out by 42e8d6b514a9 ☠ ☠
authorNathan Froyd <froydnj@mozilla.com>
Thu, 17 Sep 2015 00:08:21 -0400
changeset 295534 c5b25c30befc555a669338a15badd715744923ab
parent 295533 5f676d5115992f3efb370cea26e21070ff1b8b0e
child 295535 61baabe617c9786b3ce315709a39fa17e78b15fc
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1204994
milestone43.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 1204994 - part 3 - update use counter tests for new CONTENT_DOCUMENT histograms; r=bz
dom/base/test/browser_use_counters.js
--- a/dom/base/test/browser_use_counters.js
+++ b/dom/base/test/browser_use_counters.js
@@ -103,30 +103,34 @@ function grabHistogramsFromContent(brows
     function snapshot_histogram(name) {
       return telemetry.getHistogramById(name).snapshot();
     }
 
     let histogram_page_name = "USE_COUNTER2_" + arg.middlefix + "_PAGE";
     let histogram_document_name = "USE_COUNTER2_" + arg.middlefix + "_DOCUMENT";
     let histogram_page = snapshot_histogram(histogram_page_name);
     let histogram_document = snapshot_histogram(histogram_document_name);
-    return [histogram_page.sum, histogram_document.sum];
+    let histogram_docs = snapshot_histogram("CONTENT_DOCUMENTS_DESTROYED");
+    let histogram_toplevel_docs = snapshot_histogram("TOP_LEVEL_CONTENT_DOCUMENTS_DESTROYED");
+    return [histogram_page.sum, histogram_document.sum,
+            histogram_docs.sum, histogram_toplevel_docs.sum];
   });
 }
 
 var check_use_counter_iframe = Task.async(function* (file, use_counter_middlefix, check_documents=true) {
   info("checking " + file + " with histogram " + use_counter_middlefix);
 
   let newTab = gBrowser.addTab( "about:blank");
   gBrowser.selectedTab = newTab;
   newTab.linkedBrowser.stop();
 
   // Hold on to the current values of the telemetry histograms we're
   // interested in.
-  let [histogram_page_before, histogram_document_before] =
+  let [histogram_page_before, histogram_document_before,
+       histogram_docs_before, histogram_toplevel_docs_before] =
       yield grabHistogramsFromContent(gBrowser.selectedBrowser, use_counter_middlefix);
 
   gBrowser.selectedBrowser.loadURI(gHttpTestRoot + "file_use_counter_outer.html");
   yield waitForPageLoad(gBrowser.selectedBrowser);
 
   // Inject our desired file into the iframe of the newly-loaded page.
   yield ContentTask.spawn(gBrowser.selectedBrowser, { file: file }, function(opts) {
     Cu.import("resource://gre/modules/PromiseUtils.jsm");
@@ -156,37 +160,41 @@ var check_use_counter_iframe = Task.asyn
   gBrowser.removeTab(newTab);
 
   // The histograms only get recorded when the document actually gets
   // destroyed, which might not have happened yet due to GC/CC effects, etc.
   // Try to force document destruction.
   yield waitForDestroyedDocuments();
 
   // Grab histograms again and compare.
-  let [histogram_page_after, histogram_document_after] =
+  let [histogram_page_after, histogram_document_after,
+       histogram_docs_after, histogram_toplevel_docs_after] =
       yield grabHistogramsFromContent(gBrowser.selectedBrowser, use_counter_middlefix);
 
   is(histogram_page_after, histogram_page_before + 1,
      "page counts for " + use_counter_middlefix + " after are correct");
+  is(histogram_toplevel_docs_after, histogram_toplevel_docs_before + 1,
+     "top level document counts are correct");
   if (check_documents) {
     is(histogram_document_after, histogram_document_before + 1,
-       "document counts " + use_counter_middlefix + " after are correct");
+       "document counts for " + use_counter_middlefix + " after are correct");
   }
 });
 
 var check_use_counter_img = Task.async(function* (file, use_counter_middlefix) {
   info("checking " + file + " as image with histogram " + use_counter_middlefix);
 
   let newTab = gBrowser.addTab("about:blank");
   gBrowser.selectedTab = newTab;
   newTab.linkedBrowser.stop();
 
   // Hold on to the current values of the telemetry histograms we're
   // interested in.
-  let [histogram_page_before, histogram_document_before] =
+  let [histogram_page_before, histogram_document_before,
+       histogram_docs_before, histogram_toplevel_docs_before] =
       yield grabHistogramsFromContent(gBrowser.selectedBrowser, use_counter_middlefix);
 
   gBrowser.selectedBrowser.loadURI(gHttpTestRoot + "file_use_counter_outer.html");
   yield waitForPageLoad(gBrowser.selectedBrowser);
 
   // Inject our desired file into the img of the newly-loaded page.
   yield ContentTask.spawn(gBrowser.selectedBrowser, { file: file }, function(opts) {
     Cu.import("resource://gre/modules/PromiseUtils.jsm");
@@ -217,34 +225,42 @@ var check_use_counter_img = Task.async(f
   gBrowser.removeTab(newTab);
 
   // The histograms only get recorded when the document actually gets
   // destroyed, which might not have happened yet due to GC/CC effects, etc.
   // Try to force document destruction.
   yield waitForDestroyedDocuments();
 
   // Grab histograms again and compare.
-  let [histogram_page_after, histogram_document_after] =
+  let [histogram_page_after, histogram_document_after,
+       histogram_docs_after, histogram_toplevel_docs_after] =
       yield grabHistogramsFromContent(gBrowser.selectedBrowser, use_counter_middlefix);
   is(histogram_page_after, histogram_page_before + 1,
      "page counts for " + use_counter_middlefix + " after are correct");
   is(histogram_document_after, histogram_document_before + 1,
-     "document counts " + use_counter_middlefix + " after are correct");
+     "document counts for " + use_counter_middlefix + " after are correct");
+  is(histogram_toplevel_docs_after, histogram_toplevel_docs_before + 1,
+     "top level document counts are correct");
+  // 2 documents: one for the outer html page containing the <img> element, and
+  // one for the SVG image itself.
+  is(histogram_docs_after, histogram_docs_before + 2,
+     "document counts are correct");
 });
 
 var check_use_counter_direct = Task.async(function* (file, use_counter_middlefix, xfail=false) {
   info("checking " + file + " with histogram " + use_counter_middlefix);
 
   let newTab = gBrowser.addTab( "about:blank");
   gBrowser.selectedTab = newTab;
   newTab.linkedBrowser.stop();
 
   // Hold on to the current values of the telemetry histograms we're
   // interested in.
-  let [histogram_page_before, histogram_document_before] =
+  let [histogram_page_before, histogram_document_before,
+       histogram_docs_before, histogram_toplevel_docs_before] =
       yield grabHistogramsFromContent(gBrowser.selectedBrowser, use_counter_middlefix);
 
   gBrowser.selectedBrowser.loadURI(gHttpTestRoot + file);
   yield ContentTask.spawn(gBrowser.selectedBrowser, null, function*() {
     Cu.import("resource://gre/modules/PromiseUtils.jsm");
     yield new Promise(resolve => {
       let listener = () => {
         removeEventListener("load", listener, true);
@@ -262,15 +278,20 @@ var check_use_counter_direct = Task.asyn
   gBrowser.removeTab(newTab);
 
   // The histograms only get recorded when the document actually gets
   // destroyed, which might not have happened yet due to GC/CC effects, etc.
   // Try to force document destruction.
   yield waitForDestroyedDocuments();
 
   // Grab histograms again and compare.
-  let [histogram_page_after, histogram_document_after] =
+  let [histogram_page_after, histogram_document_after,
+       histogram_docs_after, histogram_toplevel_docs_after] =
       yield grabHistogramsFromContent(gBrowser.selectedBrowser, use_counter_middlefix);
   (xfail ? todo_is : is)(histogram_page_after, histogram_page_before + 1,
                          "page counts for " + use_counter_middlefix + " after are correct");
   (xfail ? todo_is : is)(histogram_document_after, histogram_document_before + 1,
-                         "document counts " + use_counter_middlefix + " after are correct");
+                         "document counts for " + use_counter_middlefix + " after are correct");
+  is(histogram_toplevel_docs_after, histogram_toplevel_docs_before + 1,
+     "top level document counts are correct");
+  is(histogram_docs_after, histogram_docs_before + 1,
+     "document counts are correct");
 });