Bug 1518999 - Refactor some performance.getEntries related tests r=mstange
authorSean Feng <sefeng@mozilla.com>
Tue, 27 Oct 2020 16:25:50 +0000
changeset 554729 18977625f8a4df6ed7c0bd4829ef1be2c6226c26
parent 554728 47629f89cb6a8a8a663789855591a3d17466493b
child 554730 434cacd927bfe60fc6c2563070d35faf83f692f4
push id37898
push userabutkovits@mozilla.com
push dateWed, 28 Oct 2020 09:24:21 +0000
treeherdermozilla-central@83bf4fd3b1fb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1518999
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 1518999 - Refactor some performance.getEntries related tests r=mstange Some tests made some assumptions about the number of returned entries by performance.getEntries, and these assumptions are not valid anymore once we added new entries. Depends on D66463 Differential Revision: https://phabricator.services.mozilla.com/D68645
browser/components/resistfingerprinting/test/browser/browser_performanceAPI.js
devtools/client/webconsole/test/browser/browser_webconsole_console_table.js
dom/tests/mochitest/general/file_resource_timing_nocors.html
--- a/browser/components/resistfingerprinting/test/browser/browser_performanceAPI.js
+++ b/browser/components/resistfingerprinting/test/browser/browser_performanceAPI.js
@@ -187,23 +187,30 @@ add_task(async function runRTPTests() {
     }
 
     // Try to add some entries.
     content.performance.mark("Test");
     content.performance.mark("Test-End");
     content.performance.measure("Test-Measure", "Test", "Test-End");
 
     // Check the entries for performance.getEntries/getEntriesByType/getEntriesByName.
+    await new Promise(resolve => {
+      const paintObserver = new content.PerformanceObserver(() => {
+        resolve();
+      });
+      paintObserver.observe({ type: "paint", buffered: true });
+    });
+
     is(
       content.performance.getEntries().length,
-      4,
+      5,
       "For reduceTimerPrecision, there should be 4 entries for performance.getEntries()"
-      // PerformanceNavigationTiming, PerformanceMark, PerformanceMark, PerformanceMeasure
+      // PerformancePaintTiming, PerformanceNavigationTiming, PerformanceMark, PerformanceMark, PerformanceMeasure
     );
-    for (var i = 0; i < 4; i++) {
+    for (var i = 0; i < 5; i++) {
       let startTime = content.performance.getEntries()[i].startTime;
       let duration = content.performance.getEntries()[i].duration;
       ok(
         isRounded(startTime, expectedPrecision),
         "For reduceTimerPrecision(" +
           expectedPrecision +
           "), performance.getEntries(" +
           i +
--- a/devtools/client/webconsole/test/browser/browser_webconsole_console_table.js
+++ b/devtools/client/webconsole/test/browser/browser_webconsole_console_table.js
@@ -402,17 +402,19 @@ add_task(async function() {
 
   await SpecialPowers.spawn(
     gBrowser.selectedBrowser,
     [testCases.map(({ input, headers }) => ({ input, headers }))],
     function(tests) {
       tests.forEach(test => {
         let { input, headers } = test;
         if (input === "PERFORMANCE_ENTRIES") {
-          input = content.wrappedJSObject.performance.getEntries();
+          input = content.wrappedJSObject.performance.getEntriesByType(
+            "navigation"
+          );
         }
         content.wrappedJSObject.doConsoleTable(input, headers);
       });
     }
   );
   const nodes = [];
   for (const testCase of testCases) {
     const node = await waitFor(() =>
--- a/dom/tests/mochitest/general/file_resource_timing_nocors.html
+++ b/dom/tests/mochitest/general/file_resource_timing_nocors.html
@@ -139,19 +139,18 @@ var allResources = {
   // 8
   "http://example.net/tests/dom/tests/mochitest/general/generateCss.sjs?Q" : "link",
 
   // 9
   "http://example.net/tests/dom/tests/mochitest/general/generateCss.sjs?R" : "link",
 };
 
 window.onload = function() {
-  let entries = performance.getEntries();
-  // The entries.slice() to drop first 'document' item.
-  for (let entry of entries.slice(1)) {
+  let entries = performance.getEntriesByType('resource');
+  for (let entry of entries) {
     //dump(entry.name + " || "+ entry.initiatorType+ "\n");
     if (!(entry.name in allResources)) {
       if (entry.name.substr(-4) == ".ttf") {
         // TODO: fix hiding of font files
         continue;
       }
       ok(false, "Did not expect timing for resource: " + entry.name);
       continue;