From 6aa252b6bf64246a9ff8e91dce08579bec60174a Mon Sep 17 00:00:00 2001 From: Dorel Luca Date: Mon, 6 Jul 2020 15:44:41 +0300 Subject: [PATCH] Backed out changeset d2cfd29e2bb5 (bug 1380676) on Dev's request. CLOSED TREE --- .../talos/talos/pageloader/chrome/lh_hero.js | 2 +- .../talos/pageloader/chrome/pageloader.js | 24 +++++++------------ .../talos/talos/pageloader/chrome/report.js | 2 +- .../talos/talos/pageloader/chrome/tscroll.js | 14 +++++++---- testing/talos/talos/results.py | 2 +- .../startup_test/sessionrestore/addon/api.js | 4 ++-- .../startup_about_home_paint/addon/api.js | 4 ++-- .../talos/startup_test/tspaint_test.html | 3 ++- .../chrome/talos-powers-content.js | 3 ++- testing/talos/talos/tests/a11y/dhtml.html | 6 ++--- .../talos/talos/tests/a11y/tablemutation.html | 6 ++--- testing/talos/talos/tests/tabpaint/api.js | 18 ++++---------- .../talos/talos/tests/tabpaint/tabpaint.html | 4 +--- .../tests/tart/addon/content/framescript.js | 6 ++--- .../tresize/addon/content/framescript.js | 3 ++- 15 files changed, 44 insertions(+), 57 deletions(-) diff --git a/testing/talos/talos/pageloader/chrome/lh_hero.js b/testing/talos/talos/pageloader/chrome/lh_hero.js index 6b4d95a079d9..c7451db5d894 100644 --- a/testing/talos/talos/pageloader/chrome/lh_hero.js +++ b/testing/talos/talos/pageloader/chrome/lh_hero.js @@ -9,7 +9,7 @@ function _contentHeroHandler(isload) { function callback(entries, observer) { entries.forEach(entry => { sendAsyncMessage("PageLoader:LoadEvent", { - time: content.window.performance.now(), + time: Date.now(), // eslint-disable-line name: "tphero", }); obs.disconnect(); diff --git a/testing/talos/talos/pageloader/chrome/pageloader.js b/testing/talos/talos/pageloader/chrome/pageloader.js index b66c1d671ef9..601c45672214 100644 --- a/testing/talos/talos/pageloader/chrome/pageloader.js +++ b/testing/talos/talos/pageloader/chrome/pageloader.js @@ -3,6 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /* import-globals-from report.js */ +/* eslint mozilla/avoid-Date-timing: "off" */ var { AppConstants } = ChromeUtils.import( "resource://gre/modules/AppConstants.jsm" @@ -408,7 +409,7 @@ function startAndLoadURI(pageName) { TalosParentProfiler.resume("Starting to load URI " + pageName); } - start_time = window.performance.now(); + start_time = Date.now(); if (loadNoCache) { content.loadURI(pageName, { triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(), @@ -531,9 +532,9 @@ var plNextPage = async function() { if (doNextPage) { if (forceCC) { - var tccstart = window.performance.now(); + var tccstart = new Date(); window.windowUtils.garbageCollect(); - var tccend = window.performance.now(); + var tccend = new Date(); report.recordCCTime(tccend - tccstart); // Now asynchronously trigger GC / CC in the content process @@ -732,7 +733,7 @@ function _loadHandlerCapturing() { if (useMozAfterPaint) { if (gStartTime != null && gStartTime >= 0) { - gTime = window.performance.now() - gStartTime; + gTime = new Date() - gStartTime; gStartTime = -1; } } @@ -785,18 +786,9 @@ function _loadHandler(paint_time = 0) { if (paint_time !== 0) { // window.performance.timing.timeToNonBlankPaint is a timestamp // this may have a value for hero element (also a timestamp) - - let minDate = new Date("2001"); - - if (paint_time < minDate) { - //paint_time is a performance.now() value - end_time = paint_time; - } else { - //paint_time is a UNIX timestamp - end_time = paint_time - window.performance.timing.navigationStart; - } + end_time = paint_time; } else { - end_time = window.performance.now(); + end_time = Date.now(); } var duration; @@ -851,7 +843,7 @@ function plLoadHandlerMessage(message) { } if (gTime !== -1) { if (useMozAfterPaint && gStartTime >= 0) { - time = window.performance.now() - gStartTime; + time = Date.now() - gStartTime; gStartTime = -1; } else if (!useMozAfterPaint) { time = gTime; diff --git a/testing/talos/talos/pageloader/chrome/report.js b/testing/talos/talos/pageloader/chrome/report.js index 1827aed36b9d..52936052cb93 100644 --- a/testing/talos/talos/pageloader/chrome/report.js +++ b/testing/talos/talos/pageloader/chrome/report.js @@ -90,7 +90,7 @@ Report.prototype.getReport = function() { report += "_x_x_mozilla_cycle_collect," + this.totalCCTime + "\n"; report += "__end_cc_report\n"; } - var now = window.performance.now(); + var now = new Date().getTime(); // eslint-disable-line mozilla/avoid-Date-timing report += "__startTimestamp" + now + "__endTimestamp\n"; // timestamp for determning shutdown time, used by talos return report; diff --git a/testing/talos/talos/pageloader/chrome/tscroll.js b/testing/talos/talos/pageloader/chrome/tscroll.js index 1d2e5f82452e..d3093f99bdb2 100644 --- a/testing/talos/talos/pageloader/chrome/tscroll.js +++ b/testing/talos/talos/pageloader/chrome/tscroll.js @@ -91,8 +91,8 @@ function testScroll(target, stepSize, opt_reportFunc, opt_numSteps) { resolve(); }); - imported.src = - "../../scripts/talos-debug.js?dummy=" + win.performance.now(); // For some browsers to re-read + // eslint-disable-next-line mozilla/avoid-Date-timing + imported.src = "../../scripts/talos-debug.js?dummy=" + Date.now(); // For some browsers to re-read document.head.appendChild(imported); return; } @@ -125,6 +125,12 @@ function testScroll(target, stepSize, opt_reportFunc, opt_numSteps) { }); } + function myNow() { + return win.performance && win.performance.now + ? win.performance.now() + : Date.now(); // eslint-disable-line mozilla/avoid-Date-timing + } + var isWindow = target.self === target; var getPos = isWindow @@ -185,13 +191,13 @@ function testScroll(target, stepSize, opt_reportFunc, opt_numSteps) { function P_syncScrollTest() { return new Promise(function(resolve) { // We should be at the top of the page now. - var start = win.performance.now(); + var start = myNow(); var lastScrollPos = getPos(); var lastScrollTime = start; var durations = []; function tick() { - var now = win.performance.now(); + var now = myNow(); var duration = now - lastScrollTime; lastScrollTime = now; diff --git a/testing/talos/talos/results.py b/testing/talos/talos/results.py index 11df02c3191d..df44c12bfc29 100755 --- a/testing/talos/talos/results.py +++ b/testing/talos/talos/results.py @@ -363,7 +363,7 @@ class BrowserLogResults(object): self.error("Could not find %s in browser output: (tokens: %s)" % (attr, tokens)) try: - value = int(float(value)) + value = int(value) except ValueError: self.error("Could not cast %s to an integer: %s" % (attr, value)) diff --git a/testing/talos/talos/startup_test/sessionrestore/addon/api.js b/testing/talos/talos/startup_test/sessionrestore/addon/api.js index a4621b414360..5768c2d7cdf6 100644 --- a/testing/talos/talos/startup_test/sessionrestore/addon/api.js +++ b/testing/talos/talos/startup_test/sessionrestore/addon/api.js @@ -122,13 +122,13 @@ this.sessionrestore = class extends ExtensionAPI { ? StartupPerformance.latestRestoredTimeStamp : startup_info.sessionRestored; let duration = restoreTime - startup_info.process; - let win = BrowserWindowTracker.getTopWindow(); // Report data to Talos, if possible. dump("__start_report" + duration + "__end_report\n\n"); // Next one is required by the test harness but not used. - dump("__startTimestamp" + win.performance.now() + "__endTimestamp\n\n"); + // eslint-disable-next-line mozilla/avoid-Date-timing + dump("__startTimestamp" + Date.now() + "__endTimestamp\n\n"); } catch (ex) { dump(`SessionRestoreTalosTest: error ${ex}\n`); dump(ex.stack); diff --git a/testing/talos/talos/startup_test/startup_about_home_paint/addon/api.js b/testing/talos/talos/startup_test/startup_about_home_paint/addon/api.js index 898823a29d9f..224cfbdd4bb8 100644 --- a/testing/talos/talos/startup_test/startup_about_home_paint/addon/api.js +++ b/testing/talos/talos/startup_test/startup_about_home_paint/addon/api.js @@ -41,7 +41,6 @@ this.startup_about_home_paint = class extends ExtensionAPI { async checkForTelemetry() { let snapshot = Services.telemetry.getSnapshotForScalars("main"); let measurement = snapshot.parent[SCALAR_KEY]; - let win = BrowserWindowTracker.getTopWindow(); if (!measurement) { if (gAttempts == MAX_ATTEMPTS) { dump(`Failed to get ${SCALAR_KEY} scalar probe in time.\n`); @@ -57,7 +56,8 @@ this.startup_about_home_paint = class extends ExtensionAPI { } else { // Got our measurement. dump("__start_report" + measurement + "__end_report\n\n"); - dump("__startTimestamp" + win.performance.now() + "__endTimestamp\n"); + // eslint-disable-next-line mozilla/avoid-Date-timing + dump("__startTimestamp" + Date.now() + "__endTimestamp\n"); let env = Cc["@mozilla.org/process/environment;1"].getService( Ci.nsIEnvironment diff --git a/testing/talos/talos/startup_test/tspaint_test.html b/testing/talos/talos/startup_test/tspaint_test.html index 9561105b7b2d..94cf288e5663 100644 --- a/testing/talos/talos/startup_test/tspaint_test.html +++ b/testing/talos/talos/startup_test/tspaint_test.html @@ -48,7 +48,8 @@ function dumpConsoleAndQuit() { // Close window asynchronously, there might still be startup operations that still need to run window.setTimeout(function() { if (window.dump) { - dump("__startTimestamp" + window.performance.now() + "__endTimestamp\n"); + // eslint-disable-next-line mozilla/avoid-Date-timing + dump("__startTimestamp" + Date.now() + "__endTimestamp\n"); } TalosPowersContent.goQuitApplication(); }, 0); diff --git a/testing/talos/talos/talos-powers/chrome/talos-powers-content.js b/testing/talos/talos/talos-powers/chrome/talos-powers-content.js index 7364c2f851d8..0d8dc33ebd98 100644 --- a/testing/talos/talos/talos-powers/chrome/talos-powers-content.js +++ b/testing/talos/talos/talos-powers/chrome/talos-powers-content.js @@ -166,7 +166,8 @@ addEventListener( let uniqueMessageId = "TalosPowers:ParentExec:" + content.document.documentURI + - content.window.performance.now() + + // eslint-disable-next-line mozilla/avoid-Date-timing + Date.now() + Math.random(); // Listener for the reply from the parent process diff --git a/testing/talos/talos/tests/a11y/dhtml.html b/testing/talos/talos/tests/a11y/dhtml.html index 2fee1a03fc7c..df21c71fcce9 100644 --- a/testing/talos/talos/tests/a11y/dhtml.html +++ b/testing/talos/talos/tests/a11y/dhtml.html @@ -18,7 +18,7 @@ TalosContentProfiler.resume("dhtml test start", true).then(() => { var container = document.getElementById("container"); var lastchild = document.getElementById("lastchild"); - var start = window.performance.now(); + var start = new Date(); // eslint-disable-line mozilla/avoid-Date-timing var i, div; for (i = 0; i < 2000; i++) { div = document.createElement("div"); @@ -44,8 +44,8 @@ } function postProcessingRecord(s) { - // alert(window.performance.now() - s); - let delta = window.performance.now() - s; + // alert(new Date() - s); + let delta = new Date() - s; // eslint-disable-line mozilla/avoid-Date-timing TalosContentProfiler.pause("dhtml test finish", true).then(() => { tpRecordTime(delta, s); }); diff --git a/testing/talos/talos/tests/a11y/tablemutation.html b/testing/talos/talos/tests/a11y/tablemutation.html index cb44d5f5beda..ae7fbf9e11c1 100644 --- a/testing/talos/talos/tests/a11y/tablemutation.html +++ b/testing/talos/talos/tests/a11y/tablemutation.html @@ -118,7 +118,7 @@ function mutateTable() { ensureAccessibleTreeForId("start"); TalosContentProfiler.resume("tablemutation start", true).then(() => { - var start = window.performance.now(); + var start = new Date(); // eslint-disable-line mozilla/avoid-Date-timing // Cause all kinds of crazy events Range.deleteContents(); @@ -131,8 +131,8 @@ function mutateTable() { } function postProcessingRecord(s) { - // alert(window.performance.now() - s); - let delta = window.performance.now() - s; + // alert(new Date() - s); + let delta = new Date() - s; // eslint-disable-line mozilla/avoid-Date-timing TalosContentProfiler.pause("tablemutation finish", true).then(() => { tpRecordTime(delta, s); }); diff --git a/testing/talos/talos/tests/tabpaint/api.js b/testing/talos/talos/tests/tabpaint/api.js index 501b97b6e85c..f2e641be859c 100644 --- a/testing/talos/talos/tests/tabpaint/api.js +++ b/testing/talos/talos/tests/tabpaint/api.js @@ -30,11 +30,6 @@ ChromeUtils.defineModuleGetter( "TalosParentProfiler", "resource://talos-powers/TalosParentProfiler.jsm" ); -ChromeUtils.defineModuleGetter( - this, - "BrowserWindowTracker", - "resource:///modules/BrowserWindowTracker.jsm" -); const REDUCE_MOTION_PREF = "ui.prefersReducedMotion"; const MULTI_OPT_OUT_PREF = "dom.ipc.multiOptOut"; @@ -133,17 +128,12 @@ this.tabpaint = class extends ExtensionAPI { * with the time (in ms) it took to open the tab from the parent. */ async openTabFromParent(gBrowser, target) { - let win = BrowserWindowTracker.getTopWindow(); TalosParentProfiler.resume("tabpaint parent start"); - gBrowser.selectedTab = gBrowser.addTab( - //win.performance.now() + win.performance.timing.navigationStart gives the UNIX timestamp. - `${target}?${win.performance.now() + - win.performance.timing.navigationStart}`, - { - triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(), - } - ); + // eslint-disable-next-line mozilla/avoid-Date-timing + gBrowser.selectedTab = gBrowser.addTab(`${target}?${Date.now()}`, { + triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(), + }); let { tab, delta } = await this.whenTabShown(); TalosParentProfiler.pause("tabpaint parent end"); diff --git a/testing/talos/talos/tests/tabpaint/tabpaint.html b/testing/talos/talos/tests/tabpaint/tabpaint.html index 0ab7242304da..6ffb61e25d4e 100644 --- a/testing/talos/talos/tests/tabpaint/tabpaint.html +++ b/testing/talos/talos/tests/tabpaint/tabpaint.html @@ -15,9 +15,7 @@ function init() { window.addEventListener("TabPaint:OpenFromContent", (event) => { let target = document.getElementById("target"); - - //win.performance.now() + win.performance.timing.navigationStart gives the UNIX timestamp. - let now = window.performance.now() + window.performance.timing.navigationStart; + let now = Date.now(); // eslint-disable-line mozilla/avoid-Date-timing target.href = `${targetURL.href}?${now}`; target.click(); diff --git a/testing/talos/talos/tests/tart/addon/content/framescript.js b/testing/talos/talos/tests/tart/addon/content/framescript.js index 3a0e5e6d1b15..2b9630e3a5c9 100644 --- a/testing/talos/talos/tests/tart/addon/content/framescript.js +++ b/testing/talos/talos/tests/tart/addon/content/framescript.js @@ -30,10 +30,8 @@ } var uniqueMessageId = - TART_PREFIX + - content.document.documentURI + - content.window.performance.now() + - Math.random(); + // eslint-disable-next-line mozilla/avoid-Date-timing + TART_PREFIX + content.document.documentURI + Date.now() + Math.random(); addMessageListener(TART_PREFIX + "chrome-exec-reply", function done( reply diff --git a/testing/talos/talos/tests/tresize/addon/content/framescript.js b/testing/talos/talos/tests/tresize/addon/content/framescript.js index 61b655fbd526..ac29e46a3152 100644 --- a/testing/talos/talos/tests/tresize/addon/content/framescript.js +++ b/testing/talos/talos/tests/tresize/addon/content/framescript.js @@ -7,7 +7,8 @@ var uniqueMessageId = TRESIZE_PREFIX + content.document.documentURI + - content.window.performance.now() + + // eslint-disable-next-line mozilla/avoid-Date-timing + Date.now() + Math.random(); addMessageListener(TRESIZE_PREFIX + "chrome-run-reply", function done(