Bug 1466479 - Remove unused Profiler module. r=jdescottes draft
authorAlexandre Poirot <poirot.alex@gmail.com>
Mon, 04 Jun 2018 06:28:16 -0700
changeset 806955 a0dee03ae9b2c1c8ca531a9800cc2c0a38828e69
parent 806954 0f757437db50e93ec46ad8cf4a96e942da0d9825
child 806956 75d826c38ce9d9b6ba344ac787116db3c8c31bdb
child 807041 e4e4e6cb011c293eede47f4db0da3d2c9191a8fc
push id113002
push userbmo:poirot.alex@gmail.com
push dateTue, 12 Jun 2018 23:19:12 +0000
reviewersjdescottes
bugs1466479
milestone62.0a1
Bug 1466479 - Remove unused Profiler module. r=jdescottes MozReview-Commit-ID: OHOSkjxzzF
testing/talos/talos/pageloader/chrome/Profiler.js
testing/talos/talos/scripts/Profiler.js
testing/talos/talos/startup_test/tresize/addon/content/Profiler.js
testing/talos/talos/tests/devtools/addon/content/Profiler.js
testing/talos/talos/tests/devtools/addon/content/damp.js
testing/talos/talos/tests/devtools/addon/content/initialize_browser.js
testing/talos/talos/tests/tart/addon/content/Profiler.js
--- a/testing/talos/talos/pageloader/chrome/Profiler.js
+++ b/testing/talos/talos/pageloader/chrome/Profiler.js
@@ -1,16 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // - NOTE: This file is duplicated verbatim at:
 //         - talos/scripts/Profiler.js
 //         - talos/pageloader/chrome/Profiler.js
-//         - talos/tests/devtools/addon/content/Profiler.js
 //         - talos/tests/tart/addon/content/Profiler.js
 //         - talos/startup_test/tresize/addon/content/Profiler.js
 //
 //  - Please keep these copies in sync.
 //  - Please make sure your changes apply cleanly to all use cases.
 
 // Finer grained profiler control
 //
--- a/testing/talos/talos/scripts/Profiler.js
+++ b/testing/talos/talos/scripts/Profiler.js
@@ -1,16 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // - NOTE: This file is duplicated verbatim at:
 //         - talos/scripts/Profiler.js
 //         - talos/pageloader/chrome/Profiler.js
-//         - talos/tests/devtools/addon/content/Profiler.js
 //         - talos/tests/tart/addon/content/Profiler.js
 //         - talos/startup_test/tresize/addon/content/Profiler.js
 //
 //  - Please keep these copies in sync.
 //  - Please make sure your changes apply cleanly to all use cases.
 
 // Finer grained profiler control
 //
--- a/testing/talos/talos/startup_test/tresize/addon/content/Profiler.js
+++ b/testing/talos/talos/startup_test/tresize/addon/content/Profiler.js
@@ -1,16 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // - NOTE: This file is duplicated verbatim at:
 //         - talos/scripts/Profiler.js
 //         - talos/pageloader/chrome/Profiler.js
-//         - talos/tests/devtools/addon/content/Profiler.js
 //         - talos/tests/tart/addon/content/Profiler.js
 //         - talos/startup_test/tresize/addon/content/Profiler.js
 //
 //  - Please keep these copies in sync.
 //  - Please make sure your changes apply cleanly to all use cases.
 
 // Finer grained profiler control
 //
deleted file mode 100644
--- a/testing/talos/talos/tests/devtools/addon/content/Profiler.js
+++ /dev/null
@@ -1,136 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-// - NOTE: This file is duplicated verbatim at:
-//         - talos/scripts/Profiler.js
-//         - talos/pageloader/chrome/Profiler.js
-//         - talos/tests/devtools/addon/content/Profiler.js
-//         - talos/tests/tart/addon/content/Profiler.js
-//         - talos/startup_test/tresize/addon/content/Profiler.js
-//
-//  - Please keep these copies in sync.
-//  - Please make sure your changes apply cleanly to all use cases.
-
-// Finer grained profiler control
-//
-// Use this object to pause and resume the profiler so that it only profiles the
-// relevant parts of our tests.
-var Profiler;
-
-(function() {
-  var _profiler;
-
-  // If this script is loaded in a framescript context, there won't be a
-  // document object, so just use a fallback value in that case.
-  var test_name = this.document ? this.document.location.pathname : "unknown";
-
-  // Whether Profiler has been initialized. Until that happens, most calls
-  // will be ignored.
-  var enabled = false;
-
-  // The subtest name that beginTest() was called with.
-  var currentTest = "";
-
-  // Profiling settings.
-  var profiler_interval, profiler_entries, profiler_threadsArray, profiler_dir;
-
-  try {
-    // Outside of talos, this throws a security exception which no-op this file.
-    // (It's not required nor allowed for addons since Firefox 17)
-    // It's used inside talos from non-privileged pages (like during tscroll),
-    // and it works because talos disables all/most security measures.
-    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-  } catch (e) {}
-
-  try {
-    // eslint-disable-next-line mozilla/use-services
-    _profiler = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler);
-  } catch (ex) { (typeof(dumpLog) == "undefined" ? dump : dumpLog)(ex + "\n"); }
-
-  // Parses an url query string into a JS object.
-  function searchToObject(locationSearch) {
-    var pairs = locationSearch.substring(1).split("&");
-    var result = {};
-
-    for (var i in pairs) {
-      if (pairs[i] !== "") {
-        var pair = pairs[i].split("=");
-        result[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || "");
-      }
-    }
-
-    return result;
-  }
-
-  Profiler = {
-    /**
-     * Initialize the profiler using profiler settings supplied in a JS object.
-     * The following properties on the object are respected:
-     *  - gecko_profile_interval
-     *  - gecko_profile_entries
-     *  - gecko_profile_threads
-     *  - gecko_profile_dir
-     */
-    initFromObject: function Profiler__initFromObject(obj) {
-      if (obj &&
-          ("gecko_profile_dir" in obj) && typeof obj.gecko_profile_dir == "string" &&
-          ("gecko_profile_interval" in obj) && Number.isFinite(obj.gecko_profile_interval * 1) &&
-          ("gecko_profile_entries" in obj) && Number.isFinite(obj.gecko_profile_entries * 1) &&
-          ("gecko_profile_threads" in obj) && typeof obj.gecko_profile_threads == "string") {
-        profiler_interval = obj.gecko_profile_interval;
-        profiler_entries = obj.gecko_profile_entries;
-        profiler_threadsArray = obj.gecko_profile_threads.split(",");
-        profiler_dir = obj.gecko_profile_dir;
-        enabled = true;
-      }
-    },
-    initFromURLQueryParams: function Profiler__initFromURLQueryParams(locationSearch) {
-      this.initFromObject(searchToObject(locationSearch));
-    },
-    beginTest: function Profiler__beginTest(testName) {
-      currentTest = testName;
-      if (_profiler && enabled) {
-        _profiler.StartProfiler(profiler_entries, profiler_interval,
-                                ["js", "leaf", "stackwalk", "threads"], 4,
-                                profiler_threadsArray, profiler_threadsArray.length);
-        if (_profiler.PauseSampling) {
-          _profiler.PauseSampling();
-        }
-      }
-    },
-    finishTest: function Profiler__finishTest() {
-      if (_profiler && enabled) {
-        _profiler.dumpProfileToFile(profiler_dir + "/" + currentTest + ".profile");
-        _profiler.StopProfiler();
-      }
-    },
-    finishStartupProfiling: function Profiler__finishStartupProfiling() {
-      if (_profiler && enabled) {
-        _profiler.dumpProfileToFile(profiler_dir + "/startup.profile");
-        _profiler.StopProfiler();
-      }
-    },
-    resume: function Profiler__resume(name, explicit) {
-      if (_profiler) {
-        if (_profiler.ResumeSampling) {
-          _profiler.ResumeSampling();
-        }
-        _profiler.AddMarker(explicit ? name : 'Start of test "' + (name || test_name) + '"');
-      }
-    },
-    pause: function Profiler__pause(name, explicit) {
-      if (_profiler) {
-        if (_profiler.PauseSampling) {
-          _profiler.PauseSampling();
-        }
-        _profiler.AddMarker(explicit ? name : 'End of test "' + (name || test_name) + '"');
-      }
-    },
-    mark: function Profiler__mark(marker, explicit) {
-      if (_profiler) {
-        _profiler.AddMarker(explicit ? marker : 'Profiler: "' + (marker || test_name) + '"');
-      }
-    }
-  };
-})();
--- a/testing/talos/talos/tests/devtools/addon/content/damp.js
+++ b/testing/talos/talos/tests/devtools/addon/content/damp.js
@@ -1,12 +1,15 @@
 const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm", {});
 const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm", {});
 const { AddonManager } = ChromeUtils.import("resource://gre/modules/AddonManager.jsm", {});
 const env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
+let scope = {};
+Services.scriptloader.loadSubScript("chrome://talos-powers-content/content/TalosParentProfiler.js", scope);
+const { TalosParentProfiler } = scope;
 
 XPCOMUtils.defineLazyGetter(this, "require", function() {
   let { require } =
     ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
   return require;
 });
 XPCOMUtils.defineLazyGetter(this, "gDevTools", function() {
   let { gDevTools } = require("devtools/client/framework/devtools");
--- a/testing/talos/talos/tests/devtools/addon/content/initialize_browser.js
+++ b/testing/talos/talos/tests/devtools/addon/content/initialize_browser.js
@@ -1,10 +1,9 @@
 function initializeBrowser(win) {
-  Services.scriptloader.loadSubScript("chrome://talos-powers-content/content/TalosParentProfiler.js", win);
   Services.scriptloader.loadSubScript("chrome://damp/content/damp.js", win);
 
   const PREFIX = "damp@mozilla.org:";
 
   // "services" which the framescript can execute at the chrome process
   var proxiedServices = {
     runTest(config, callback) {
       (new win.Damp()).startTest(callback, config);
--- a/testing/talos/talos/tests/tart/addon/content/Profiler.js
+++ b/testing/talos/talos/tests/tart/addon/content/Profiler.js
@@ -1,16 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // - NOTE: This file is duplicated verbatim at:
 //         - talos/scripts/Profiler.js
 //         - talos/pageloader/chrome/Profiler.js
-//         - talos/tests/devtools/addon/content/Profiler.js
 //         - talos/tests/tart/addon/content/Profiler.js
 //         - talos/startup_test/tresize/addon/content/Profiler.js
 //
 //  - Please keep these copies in sync.
 //  - Please make sure your changes apply cleanly to all use cases.
 
 // Finer grained profiler control
 //