2012-11-09 00:36:06 +04:00
|
|
|
/* 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/. */
|
|
|
|
|
2017-01-17 18:48:17 +03:00
|
|
|
"use strict";
|
2012-11-09 00:36:06 +04:00
|
|
|
|
2015-10-07 15:03:21 +03:00
|
|
|
var Ci = Components.interfaces;
|
|
|
|
var Cc = Components.classes;
|
|
|
|
var Cu = Components.utils;
|
2012-11-09 00:36:06 +04:00
|
|
|
|
|
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
2013-06-26 17:45:45 +04:00
|
|
|
Cu.import("resource://gre/modules/TelemetryTimestamps.jsm");
|
2015-04-27 19:07:58 +03:00
|
|
|
Cu.import("resource://gre/modules/TelemetryController.jsm");
|
2015-05-13 22:57:05 +03:00
|
|
|
Cu.import("resource://gre/modules/TelemetryArchive.jsm");
|
|
|
|
Cu.import("resource://gre/modules/TelemetryUtils.jsm");
|
2015-03-20 02:23:56 +03:00
|
|
|
Cu.import("resource://gre/modules/TelemetryLog.jsm");
|
2015-05-13 22:57:05 +03:00
|
|
|
Cu.import("resource://gre/modules/Preferences.jsm");
|
2015-09-16 11:48:57 +03:00
|
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
|
|
|
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
|
|
|
|
"resource://gre/modules/AppConstants.jsm");
|
2017-03-29 18:52:08 +03:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, "Preferences",
|
|
|
|
"resource://gre/modules/Preferences.jsm");
|
2012-11-09 00:36:06 +04:00
|
|
|
|
|
|
|
const Telemetry = Services.telemetry;
|
|
|
|
const bundle = Services.strings.createBundle(
|
|
|
|
"chrome://global/locale/aboutTelemetry.properties");
|
2012-11-27 03:21:04 +04:00
|
|
|
const brandBundle = Services.strings.createBundle(
|
|
|
|
"chrome://branding/locale/brand.properties");
|
2012-11-09 00:36:06 +04:00
|
|
|
|
2013-11-29 21:31:14 +04:00
|
|
|
// Maximum height of a histogram bar (in em for html, in chars for text)
|
2017-07-19 22:28:07 +03:00
|
|
|
const MAX_BAR_HEIGHT = 8;
|
2013-11-29 21:31:14 +04:00
|
|
|
const MAX_BAR_CHARS = 25;
|
2012-11-27 03:21:04 +04:00
|
|
|
const PREF_TELEMETRY_SERVER_OWNER = "toolkit.telemetry.server_owner";
|
2012-11-09 00:36:06 +04:00
|
|
|
const PREF_TELEMETRY_ENABLED = "toolkit.telemetry.enabled";
|
|
|
|
const PREF_DEBUG_SLOW_SQL = "toolkit.telemetry.debugSlowSql";
|
|
|
|
const PREF_SYMBOL_SERVER_URI = "profiler.symbolicationUrl";
|
|
|
|
const DEFAULT_SYMBOL_SERVER_URI = "http://symbolapi.mozilla.org";
|
2015-05-13 22:57:05 +03:00
|
|
|
const PREF_FHR_UPLOAD_ENABLED = "datareporting.healthreport.uploadEnabled";
|
2012-11-09 00:36:06 +04:00
|
|
|
|
2013-12-11 00:54:01 +04:00
|
|
|
// ms idle before applying the filter (allow uninterrupted typing)
|
|
|
|
const FILTER_IDLE_TIMEOUT = 500;
|
|
|
|
|
2015-05-13 22:57:05 +03:00
|
|
|
const isWindows = (Services.appinfo.OS == "WINNT");
|
|
|
|
const EOL = isWindows ? "\r\n" : "\n";
|
2015-05-11 20:40:23 +03:00
|
|
|
|
2015-05-13 22:57:05 +03:00
|
|
|
// This is the ping object currently displayed in the page.
|
2015-09-15 21:19:45 +03:00
|
|
|
var gPingData = null;
|
2015-05-13 22:57:05 +03:00
|
|
|
|
2012-11-09 00:36:06 +04:00
|
|
|
// Cached value of document's RTL mode
|
2015-09-15 21:19:45 +03:00
|
|
|
var documentRTLMode = "";
|
2012-11-09 00:36:06 +04:00
|
|
|
|
2015-05-11 20:40:23 +03:00
|
|
|
/**
|
2015-05-11 23:06:21 +03:00
|
|
|
* Helper function for determining whether the document direction is RTL.
|
|
|
|
* Caches result of check on first invocation.
|
2015-05-11 20:40:23 +03:00
|
|
|
*/
|
2015-05-11 23:06:21 +03:00
|
|
|
function isRTL() {
|
|
|
|
if (!documentRTLMode)
|
|
|
|
documentRTLMode = window.getComputedStyle(document.body).direction;
|
|
|
|
return (documentRTLMode == "rtl");
|
2015-05-11 20:40:23 +03:00
|
|
|
}
|
|
|
|
|
2015-05-13 22:57:05 +03:00
|
|
|
function isFlatArray(obj) {
|
2017-05-26 18:05:18 +03:00
|
|
|
if (!Array.isArray(obj)) {
|
2015-05-13 22:57:05 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return !obj.some(e => typeof(e) == "object");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is a helper function for explodeObject.
|
|
|
|
*/
|
|
|
|
function flattenObject(obj, map, path, array) {
|
|
|
|
for (let k of Object.keys(obj)) {
|
|
|
|
let newPath = [...path, array ? "[" + k + "]" : k];
|
|
|
|
let v = obj[k];
|
|
|
|
if (!v || (typeof(v) != "object")) {
|
|
|
|
map.set(newPath.join("."), v);
|
|
|
|
} else if (isFlatArray(v)) {
|
|
|
|
map.set(newPath.join("."), "[" + v.join(", ") + "]");
|
|
|
|
} else {
|
2017-05-26 18:05:18 +03:00
|
|
|
flattenObject(v, map, newPath, Array.isArray(v));
|
2015-05-13 22:57:05 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This turns a JSON object into a "flat" stringified form.
|
|
|
|
*
|
|
|
|
* For an object like {a: "1", b: {c: "2", d: "3"}} it returns a Map of the
|
|
|
|
* form Map(["a","1"], ["b.c", "2"], ["b.d", "3"]).
|
|
|
|
*/
|
|
|
|
function explodeObject(obj) {
|
|
|
|
let map = new Map();
|
|
|
|
flattenObject(obj, map, []);
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
|
|
|
function filterObject(obj, filterOut) {
|
|
|
|
let ret = {};
|
|
|
|
for (let k of Object.keys(obj)) {
|
|
|
|
if (filterOut.indexOf(k) == -1) {
|
|
|
|
ret[k] = obj[k];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-05-13 22:57:05 +03:00
|
|
|
/**
|
|
|
|
* This turns a JSON object into a "flat" stringified form, separated into top-level sections.
|
|
|
|
*
|
|
|
|
* For an object like:
|
|
|
|
* {
|
|
|
|
* a: {b: "1"},
|
|
|
|
* c: {d: "2", e: {f: "3"}}
|
|
|
|
* }
|
|
|
|
* it returns a Map of the form:
|
|
|
|
* Map([
|
|
|
|
* ["a", Map(["b","1"])],
|
|
|
|
* ["c", Map([["d", "2"], ["e.f", "3"]])]
|
|
|
|
* ])
|
|
|
|
*/
|
|
|
|
function sectionalizeObject(obj) {
|
|
|
|
let map = new Map();
|
|
|
|
for (let k of Object.keys(obj)) {
|
|
|
|
map.set(k, explodeObject(obj[k]));
|
|
|
|
}
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
2015-05-13 22:57:05 +03:00
|
|
|
/**
|
|
|
|
* Obtain the main DOMWindow for the current context.
|
|
|
|
*/
|
|
|
|
function getMainWindow() {
|
|
|
|
return window.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
|
|
.getInterface(Ci.nsIWebNavigation)
|
|
|
|
.QueryInterface(Ci.nsIDocShellTreeItem)
|
|
|
|
.rootTreeItem
|
|
|
|
.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
|
|
.getInterface(Ci.nsIDOMWindow);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Obtain the DOMWindow that can open a preferences pane.
|
|
|
|
*
|
|
|
|
* This is essentially "get the browser chrome window" with the added check
|
|
|
|
* that the supposed browser chrome window is capable of opening a preferences
|
|
|
|
* pane.
|
|
|
|
*
|
|
|
|
* This may return null if we can't find the browser chrome window.
|
|
|
|
*/
|
|
|
|
function getMainWindowWithPreferencesPane() {
|
|
|
|
let mainWindow = getMainWindow();
|
|
|
|
if (mainWindow && "openAdvancedPreferences" in mainWindow) {
|
|
|
|
return mainWindow;
|
|
|
|
}
|
2016-08-04 01:54:59 +03:00
|
|
|
return null;
|
2015-05-13 22:57:05 +03:00
|
|
|
}
|
|
|
|
|
2015-05-13 22:57:05 +03:00
|
|
|
/**
|
|
|
|
* Remove all child nodes of a document node.
|
|
|
|
*/
|
|
|
|
function removeAllChildNodes(node) {
|
|
|
|
while (node.hasChildNodes()) {
|
|
|
|
node.removeChild(node.lastChild);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pad a number to two digits with leading "0".
|
|
|
|
*/
|
|
|
|
function padToTwoDigits(n) {
|
2017-03-13 18:12:00 +03:00
|
|
|
return new String(n).padStart(2, "0");
|
2015-05-13 22:57:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return yesterdays date with the same time.
|
|
|
|
*/
|
|
|
|
function yesterday(date) {
|
|
|
|
let d = new Date(date);
|
|
|
|
d.setDate(d.getDate() - 1);
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
|
2017-06-29 17:44:03 +03:00
|
|
|
/**
|
|
|
|
* Return tomorrow's date with the same time.
|
|
|
|
*/
|
|
|
|
function tomorrow(date) {
|
|
|
|
let d = new Date(date);
|
|
|
|
d.setDate(d.getDate() + 1);
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
|
2015-05-13 22:57:05 +03:00
|
|
|
/**
|
|
|
|
* This returns a short date string of the form YYYY/MM/DD.
|
|
|
|
*/
|
|
|
|
function shortDateString(date) {
|
|
|
|
return date.getFullYear()
|
|
|
|
+ "/" + padToTwoDigits(date.getMonth() + 1)
|
|
|
|
+ "/" + padToTwoDigits(date.getDate());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This returns a short time string of the form hh:mm:ss.
|
|
|
|
*/
|
|
|
|
function shortTimeString(date) {
|
|
|
|
return padToTwoDigits(date.getHours())
|
|
|
|
+ ":" + padToTwoDigits(date.getMinutes())
|
|
|
|
+ ":" + padToTwoDigits(date.getSeconds());
|
|
|
|
}
|
|
|
|
|
2015-09-15 21:19:45 +03:00
|
|
|
var Settings = {
|
2015-05-13 22:57:05 +03:00
|
|
|
SETTINGS: [
|
|
|
|
// data upload
|
|
|
|
{
|
|
|
|
pref: PREF_FHR_UPLOAD_ENABLED,
|
|
|
|
defaultPrefValue: false,
|
|
|
|
},
|
|
|
|
// extended "Telemetry" recording
|
|
|
|
{
|
|
|
|
pref: PREF_TELEMETRY_ENABLED,
|
|
|
|
defaultPrefValue: false,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
attachObservers() {
|
2015-05-13 22:57:05 +03:00
|
|
|
for (let s of this.SETTINGS) {
|
|
|
|
let setting = s;
|
|
|
|
Preferences.observe(setting.pref, this.render, this);
|
|
|
|
}
|
2015-05-13 22:57:05 +03:00
|
|
|
|
|
|
|
let elements = document.getElementsByClassName("change-data-choices-link");
|
|
|
|
for (let el of elements) {
|
|
|
|
el.addEventListener("click", function() {
|
2015-09-16 11:48:57 +03:00
|
|
|
if (AppConstants.platform == "android") {
|
|
|
|
Cu.import("resource://gre/modules/Messaging.jsm");
|
Bug 1321418 - Use GekcoBundle events in GeckoApp/BrowserApp; r=snorp r=sebastian r=gbrown
Bug 1321418 - 1. Use GekcoBundle events in GeckoApp; r=snorp r=sebastian
Switch GeckoApp to using GeckoBundle events everywhere. UI or Gecko
events are used if the event requires the UI or Gecko thread,
respectively, and background events are used for all other events.
There are changes to some other Java classes, such as SnackbarBuilder
and GeckoAccessibility, due to the switch to GeckoBundle.
For "Snackbar:Show", we need the global EventDispatcher because the
event can be sent to both GeckoApp and GeckoPreferences. Howveer, we
only want one listener registered at the same time, so we register and
unregister in GeckoApp's and GeckoPreferences's onPause and onResume
methods.
Bug 1321418 - 2. Use appropriate JS EventDispatcher to send GeckoApp events; r=snorp r=sebastian
Change JS code that sends events to GeckoApp to use either the global
EventDispatcher or the per-window EventDispatcher.
"Session:StatePurged" is not used so it's removed. "Gecko:Ready" in
geckoview.js is not necessary because it's only used for GeckoApp, so
it's removed from geckoview.js.
Bug 1321418 - 3. Use GeckoBundle events in BrowserApp; r=snorp r=sebastian
Switch BrowserApp to using GeckoBundle events, in a similar vein as
GeckoApp. UI or Gecko events are used if the event handlers required UI
or Gecko thread, respectively, and background events are used for all
other events.
Some other Java classes also have to be modified as a result of
switching to GeckoBundle.
Bug 1321418 - 4. Use global EventDispatcher to send BrowserApp events; r=snorp r=sebastian
Change JS code that sends events to BrowserApp to use the global
EventDispatcher instead of "Messaging".
Bug 1321418 - 5. Update usages of events in tests; r=gbrown
Update cases where we use or wait for events in tests.
2016-12-09 20:32:45 +03:00
|
|
|
EventDispatcher.instance.sendRequest({
|
2015-09-16 11:48:57 +03:00
|
|
|
type: "Settings:Show",
|
2015-11-12 22:34:31 +03:00
|
|
|
resource: "preferences_privacy",
|
2015-09-16 11:48:57 +03:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
// Show the data choices preferences on desktop.
|
|
|
|
let mainWindow = getMainWindowWithPreferencesPane();
|
2017-06-21 18:17:00 +03:00
|
|
|
// The advanced subpanes are only supported in the old organization,
|
|
|
|
// which will be removed by bug 1349689.
|
|
|
|
if (Preferences.get("browser.preferences.useOldOrganization")) {
|
|
|
|
mainWindow.openAdvancedPreferences("dataChoicesTab", {origin: "aboutTelemetry"});
|
|
|
|
} else {
|
|
|
|
mainWindow.openPreferences("privacy-reports", {origin: "aboutTelemetry"});
|
|
|
|
}
|
2015-09-16 11:48:57 +03:00
|
|
|
}
|
2017-01-17 13:50:25 +03:00
|
|
|
});
|
2015-05-13 22:57:05 +03:00
|
|
|
}
|
2015-05-13 22:57:05 +03:00
|
|
|
},
|
2012-11-09 00:36:06 +04:00
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
detachObservers() {
|
2015-05-13 22:57:05 +03:00
|
|
|
for (let setting of this.SETTINGS) {
|
|
|
|
Preferences.ignore(setting.pref, this.render, this);
|
2012-11-09 00:36:06 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-06-12 19:52:17 +03:00
|
|
|
getStatusStringForSetting(setting) {
|
|
|
|
let enabled = Preferences.get(setting.pref, setting.defaultPrefValue);
|
2017-06-16 15:04:50 +03:00
|
|
|
let status = bundle.GetStringFromName(enabled ? "telemetryEnabled" : "telemetryDisabled");
|
2017-06-12 19:52:17 +03:00
|
|
|
return status;
|
|
|
|
},
|
|
|
|
|
2012-11-09 00:36:06 +04:00
|
|
|
/**
|
|
|
|
* Updates the button & text at the top of the page to reflect Telemetry state.
|
|
|
|
*/
|
2016-12-30 02:34:54 +03:00
|
|
|
render() {
|
2017-06-12 19:52:17 +03:00
|
|
|
let homeExplanation = document.getElementById("home-explanation");
|
2017-07-20 13:16:26 +03:00
|
|
|
let fhrEnabled = Preferences.get(this.SETTINGS[0].pref, this.SETTINGS[0].defaultPrefValue);
|
|
|
|
fhrEnabled = bundle.GetStringFromName(fhrEnabled ? "telemetryEnabled" : "telemetryDisabled");
|
|
|
|
let extendedEnabled = Preferences.get(this.SETTINGS[1].pref, this.SETTINGS[1].defaultPrefValue);
|
|
|
|
extendedEnabled = bundle.GetStringFromName(extendedEnabled ? "extendedTelemetryEnabled" : "extendedTelemetryDisabled");
|
2017-06-12 19:52:17 +03:00
|
|
|
let parameters = [fhrEnabled, extendedEnabled].map(this.convertStringToLink);
|
|
|
|
|
|
|
|
let explanation = bundle.formatStringFromName("homeExplanation", parameters, 2);
|
2017-06-28 22:50:38 +03:00
|
|
|
|
|
|
|
// eslint-disable-next-line no-unsanitized/property
|
2017-06-12 19:52:17 +03:00
|
|
|
homeExplanation.innerHTML = explanation;
|
|
|
|
this.attachObservers()
|
|
|
|
},
|
2015-05-13 22:57:05 +03:00
|
|
|
|
2017-06-12 19:52:17 +03:00
|
|
|
convertStringToLink(string) {
|
|
|
|
return "<a href=\"\" class=\"change-data-choices-link\">" + string + "</a>";
|
|
|
|
},
|
2012-11-09 00:36:06 +04:00
|
|
|
};
|
|
|
|
|
2015-09-15 21:19:45 +03:00
|
|
|
var PingPicker = {
|
2016-01-06 17:54:30 +03:00
|
|
|
viewCurrentPingData: null,
|
2015-05-13 22:57:05 +03:00
|
|
|
_archivedPings: null,
|
2017-06-26 16:17:06 +03:00
|
|
|
TYPE_ALL: bundle.GetStringFromName("telemetryPingTypeAll"),
|
2015-05-13 22:57:05 +03:00
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
attachObservers() {
|
2017-06-26 16:17:06 +03:00
|
|
|
let pingSourceElements = document.getElementsByName("choose-ping-source");
|
|
|
|
for (let el of pingSourceElements) {
|
2017-01-17 13:50:25 +03:00
|
|
|
el.addEventListener("change", () => this.onPingSourceChanged());
|
2015-05-13 22:57:05 +03:00
|
|
|
}
|
|
|
|
|
2015-12-19 20:11:07 +03:00
|
|
|
let displays = document.getElementsByName("choose-ping-display");
|
|
|
|
for (let el of displays) {
|
2017-01-17 13:50:25 +03:00
|
|
|
el.addEventListener("change", () => this.onPingDisplayChanged());
|
2015-12-19 20:11:07 +03:00
|
|
|
}
|
|
|
|
|
2015-05-13 22:57:06 +03:00
|
|
|
document.getElementById("show-subsession-data").addEventListener("change", () => {
|
|
|
|
this._updateCurrentPingData();
|
|
|
|
});
|
|
|
|
|
2015-05-13 22:57:05 +03:00
|
|
|
document.getElementById("choose-ping-id").addEventListener("change", () => {
|
2017-06-26 16:17:06 +03:00
|
|
|
this._updateArchivedPingData();
|
|
|
|
});
|
|
|
|
document.getElementById("choose-ping-type").addEventListener("change", () => {
|
|
|
|
this.filterDisplayedPings();
|
2017-01-17 13:50:25 +03:00
|
|
|
});
|
2015-05-13 22:57:05 +03:00
|
|
|
|
2017-06-29 15:13:44 +03:00
|
|
|
|
2015-05-18 20:20:01 +03:00
|
|
|
document.getElementById("newer-ping")
|
2017-01-17 13:50:25 +03:00
|
|
|
.addEventListener("click", () => this._movePingIndex(-1));
|
2015-05-18 20:20:01 +03:00
|
|
|
document.getElementById("older-ping")
|
2017-01-17 13:50:25 +03:00
|
|
|
.addEventListener("click", () => this._movePingIndex(1));
|
2017-06-29 15:13:44 +03:00
|
|
|
|
|
|
|
document.addEventListener("click", (ev) => {
|
|
|
|
if (ev.target.querySelector("#ping-picker")) {
|
|
|
|
document.getElementById("ping-picker").classList.add("hidden");
|
|
|
|
}
|
|
|
|
});
|
2015-10-29 09:36:00 +03:00
|
|
|
document.getElementById("choose-payload")
|
2017-01-17 13:50:25 +03:00
|
|
|
.addEventListener("change", () => displayPingData(gPingData));
|
2017-07-08 20:46:36 +03:00
|
|
|
document.getElementById("processes")
|
2017-03-06 18:12:52 +03:00
|
|
|
.addEventListener("change", () => displayPingData(gPingData));
|
2017-06-29 15:13:44 +03:00
|
|
|
Array.from(document.querySelectorAll(".change-ping")).forEach(el =>
|
|
|
|
el.addEventListener("click", () =>
|
|
|
|
document.getElementById("ping-picker").classList.remove("hidden"))
|
|
|
|
);
|
2015-05-13 22:57:05 +03:00
|
|
|
},
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
onPingSourceChanged() {
|
2015-05-13 22:57:05 +03:00
|
|
|
this.update();
|
|
|
|
},
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
onPingDisplayChanged() {
|
2015-12-19 20:11:07 +03:00
|
|
|
this.update();
|
|
|
|
},
|
|
|
|
|
2017-06-12 19:52:17 +03:00
|
|
|
render() {
|
2017-06-16 15:04:50 +03:00
|
|
|
let pings = bundle.GetStringFromName("pingExplanationLink");
|
2017-07-20 13:24:25 +03:00
|
|
|
let pingLink = "<a href=\"http://gecko.readthedocs.io/en/latest/toolkit/components/telemetry/telemetry/concepts/pings.html\">" + pings + "</a>";
|
2017-06-26 16:17:06 +03:00
|
|
|
let pingName = this._getSelectedPingName();
|
|
|
|
|
|
|
|
let pingDate = document.getElementById("ping-date");
|
|
|
|
pingDate.textContent = pingName;
|
|
|
|
pingDate.setAttribute("title", pingName);
|
|
|
|
|
2017-06-29 17:44:03 +03:00
|
|
|
// Display the type and controls if the ping is not current
|
2017-06-26 16:17:06 +03:00
|
|
|
let pingType = document.getElementById("ping-type");
|
|
|
|
let older = document.getElementById("older-ping");
|
|
|
|
let newer = document.getElementById("newer-ping");
|
2017-07-20 13:35:57 +03:00
|
|
|
let explanation;
|
|
|
|
if (!this.viewCurrentPingData) {
|
|
|
|
let pingTypeText = this._getSelectedPingType();
|
2017-06-26 16:17:06 +03:00
|
|
|
pingType.hidden = false;
|
|
|
|
older.hidden = false;
|
|
|
|
newer.hidden = false;
|
2017-07-20 13:35:57 +03:00
|
|
|
pingType.textContent = pingTypeText;
|
|
|
|
pingName = bundle.formatStringFromName("namedPing", [pingName, pingTypeText], 2);
|
|
|
|
let pingNameHtml = "<span class=\"change-ping\">" + pingName + "</span>";
|
|
|
|
let parameters = [pingLink, pingNameHtml, pingTypeText];
|
|
|
|
explanation = bundle.formatStringFromName("pingDetails", parameters, 3);
|
2017-06-26 16:17:06 +03:00
|
|
|
} else {
|
|
|
|
pingType.hidden = true;
|
|
|
|
older.hidden = true;
|
|
|
|
newer.hidden = true;
|
2017-07-20 13:35:57 +03:00
|
|
|
pingDate.textContent = bundle.GetStringFromName("currentPingSidebar");
|
|
|
|
let pingNameHtml = "<span class=\"change-ping\">" + pingName + "</span>";
|
|
|
|
explanation = bundle.formatStringFromName("pingDetailsCurrent", [pingLink, pingNameHtml], 2);
|
2017-06-26 16:17:06 +03:00
|
|
|
}
|
|
|
|
|
2017-06-12 19:52:17 +03:00
|
|
|
let pingExplanation = document.getElementById("ping-explanation");
|
2017-06-28 22:50:38 +03:00
|
|
|
|
|
|
|
// eslint-disable-next-line no-unsanitized/property
|
2017-06-12 19:52:17 +03:00
|
|
|
pingExplanation.innerHTML = explanation;
|
2017-06-29 15:13:44 +03:00
|
|
|
pingExplanation.querySelector(".change-ping").addEventListener("click", () =>
|
|
|
|
document.getElementById("ping-picker").classList.remove("hidden")
|
|
|
|
);
|
2017-06-26 16:17:06 +03:00
|
|
|
|
2017-06-16 15:04:50 +03:00
|
|
|
GenericSubsection.deleteAllSubSections();
|
2017-06-12 19:52:17 +03:00
|
|
|
},
|
|
|
|
|
2017-03-13 14:37:09 +03:00
|
|
|
async update() {
|
2016-01-06 17:54:30 +03:00
|
|
|
let viewCurrent = document.getElementById("ping-source-current").checked;
|
|
|
|
let currentChanged = viewCurrent !== this.viewCurrentPingData;
|
|
|
|
this.viewCurrentPingData = viewCurrent;
|
|
|
|
|
2016-03-03 04:04:10 +03:00
|
|
|
// If we have no archived pings, disable the ping archive selection.
|
|
|
|
// This can happen on new profiles or if the ping archive is disabled.
|
2017-03-13 14:37:09 +03:00
|
|
|
let archivedPingList = await TelemetryArchive.promiseArchivedPingList();
|
2016-03-03 04:04:10 +03:00
|
|
|
let sourceArchived = document.getElementById("ping-source-archive");
|
|
|
|
sourceArchived.disabled = (archivedPingList.length == 0);
|
|
|
|
|
2016-01-06 17:54:30 +03:00
|
|
|
if (currentChanged) {
|
|
|
|
if (this.viewCurrentPingData) {
|
2017-06-06 16:25:15 +03:00
|
|
|
document.getElementById("current-ping-picker").hidden = false;
|
|
|
|
document.getElementById("archived-ping-picker").hidden = true;
|
2016-01-06 17:54:30 +03:00
|
|
|
this._updateCurrentPingData();
|
|
|
|
} else {
|
2017-06-06 16:25:15 +03:00
|
|
|
document.getElementById("current-ping-picker").hidden = true;
|
2017-03-13 14:37:09 +03:00
|
|
|
await this._updateArchivedPingList(archivedPingList);
|
2017-06-06 16:25:15 +03:00
|
|
|
document.getElementById("archived-ping-picker").hidden = false;
|
2016-01-06 17:54:30 +03:00
|
|
|
}
|
2015-12-19 20:11:07 +03:00
|
|
|
}
|
2017-03-13 14:37:09 +03:00
|
|
|
},
|
2015-05-13 22:57:05 +03:00
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
_updateCurrentPingData() {
|
2015-05-13 22:57:06 +03:00
|
|
|
const subsession = document.getElementById("show-subsession-data").checked;
|
|
|
|
const ping = TelemetryController.getCurrentPingData(subsession);
|
2015-11-16 16:27:00 +03:00
|
|
|
if (!ping) {
|
|
|
|
return;
|
|
|
|
}
|
2015-10-29 09:36:00 +03:00
|
|
|
displayPingData(ping, true);
|
2015-05-13 22:57:06 +03:00
|
|
|
},
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
_updateArchivedPingData() {
|
2015-05-13 22:57:06 +03:00
|
|
|
let id = this._getSelectedPingId();
|
2017-06-29 17:44:03 +03:00
|
|
|
let res = Promise.resolve();
|
|
|
|
if (id) {
|
|
|
|
res = TelemetryArchive.promiseArchivedPingById(id)
|
|
|
|
.then((ping) => displayPingData(ping, true));
|
|
|
|
}
|
|
|
|
return res;
|
2015-05-13 22:57:06 +03:00
|
|
|
},
|
|
|
|
|
2017-03-13 14:37:09 +03:00
|
|
|
async _updateArchivedPingList(pingList) {
|
2016-02-28 21:09:35 +03:00
|
|
|
// The archived ping list is sorted in ascending timestamp order,
|
|
|
|
// but descending is more practical for the operations we do here.
|
|
|
|
pingList.reverse();
|
|
|
|
this._archivedPings = pingList;
|
|
|
|
// Render the archive data.
|
|
|
|
this._renderPingList();
|
|
|
|
// Update the displayed ping.
|
2017-03-13 14:37:09 +03:00
|
|
|
await this._updateArchivedPingData();
|
|
|
|
},
|
2015-05-13 22:57:05 +03:00
|
|
|
|
2017-06-29 17:44:03 +03:00
|
|
|
_renderPingList() {
|
2015-05-13 22:57:05 +03:00
|
|
|
let pingSelector = document.getElementById("choose-ping-id");
|
2017-06-29 17:44:03 +03:00
|
|
|
Array.from(pingSelector.children).forEach((child) => removeAllChildNodes(child));
|
2015-05-13 22:57:05 +03:00
|
|
|
|
2017-06-26 16:17:06 +03:00
|
|
|
let pingTypes = new Set();
|
|
|
|
pingTypes.add(this.TYPE_ALL);
|
2017-06-29 17:44:03 +03:00
|
|
|
let todayString = (new Date()).toDateString();
|
|
|
|
let yesterdayString = yesterday(new Date()).toDateString();
|
|
|
|
for (let p of this._archivedPings) {
|
2017-06-26 16:17:06 +03:00
|
|
|
pingTypes.add(p.type);
|
2015-05-13 22:57:05 +03:00
|
|
|
let date = new Date(p.timestampCreated);
|
2017-06-29 17:44:03 +03:00
|
|
|
let datetext = date.toLocaleDateString() + " " + shortTimeString(date);
|
|
|
|
let text = datetext + ", " + p.type;
|
2015-05-13 22:57:05 +03:00
|
|
|
|
|
|
|
let option = document.createElement("option");
|
|
|
|
let content = document.createTextNode(text);
|
|
|
|
option.appendChild(content);
|
|
|
|
option.setAttribute("value", p.id);
|
2017-06-26 16:17:06 +03:00
|
|
|
option.dataset.type = p.type;
|
2017-06-29 17:44:03 +03:00
|
|
|
option.dataset.date = datetext;
|
|
|
|
|
|
|
|
if (date.toDateString() == todayString) {
|
|
|
|
pingSelector.children[0].appendChild(option);
|
|
|
|
} else if (date.toDateString() == yesterdayString) {
|
|
|
|
pingSelector.children[1].appendChild(option);
|
|
|
|
} else {
|
|
|
|
pingSelector.children[2].appendChild(option);
|
2015-05-13 22:57:05 +03:00
|
|
|
}
|
|
|
|
}
|
2017-06-26 16:17:06 +03:00
|
|
|
this._renderPingTypes(pingTypes);
|
|
|
|
},
|
|
|
|
|
2017-06-29 17:44:03 +03:00
|
|
|
_renderPingTypes(pingTypes) {
|
|
|
|
let pingTypeSelector = document.getElementById("choose-ping-type");
|
|
|
|
removeAllChildNodes(pingTypeSelector);
|
|
|
|
pingTypes.forEach((type) => {
|
|
|
|
let option = document.createElement("option");
|
|
|
|
option.appendChild(document.createTextNode(type));
|
|
|
|
option.setAttribute("value", type);
|
|
|
|
pingTypeSelector.appendChild(option);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
_movePingIndex(offset) {
|
|
|
|
if (this.viewCurrentPingData) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let typeSelector = document.getElementById("choose-ping-type");
|
|
|
|
let type = typeSelector.selectedOptions.item(0).value;
|
|
|
|
|
|
|
|
let id = this._getSelectedPingId();
|
|
|
|
let index = this._archivedPings.findIndex((p) => p.id == id);
|
|
|
|
let newIndex = Math.min(Math.max(0, index + offset), this._archivedPings.length - 1);
|
|
|
|
|
|
|
|
let pingList;
|
|
|
|
if (offset > 0) {
|
|
|
|
pingList = this._archivedPings.slice(newIndex);
|
|
|
|
} else {
|
|
|
|
pingList = this._archivedPings.slice(0, newIndex);
|
|
|
|
pingList.reverse();
|
|
|
|
}
|
|
|
|
|
|
|
|
let ping = pingList.find((p) => {
|
|
|
|
return type == this.TYPE_ALL || p.type == type;
|
|
|
|
});
|
|
|
|
|
|
|
|
if (ping) {
|
|
|
|
this.selectPing(ping);
|
|
|
|
this._updateArchivedPingData();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
selectPing(ping) {
|
|
|
|
let pingSelector = document.getElementById("choose-ping-id");
|
|
|
|
// Use some() to break if we find the ping.
|
|
|
|
Array.from(pingSelector.children).some((group) => {
|
|
|
|
return Array.from(group.children).some((option) => {
|
|
|
|
if (option.value == ping.id) {
|
|
|
|
option.selected = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2017-06-26 16:17:06 +03:00
|
|
|
filterDisplayedPings() {
|
|
|
|
let pingSelector = document.getElementById("choose-ping-id");
|
|
|
|
let typeSelector = document.getElementById("choose-ping-type");
|
|
|
|
let type = typeSelector.selectedOptions.item(0).value;
|
2017-06-29 17:44:03 +03:00
|
|
|
let first = true;
|
|
|
|
Array.from(pingSelector.children).forEach((group) => {
|
|
|
|
Array.from(group.children).forEach((option) => {
|
2017-06-26 16:17:06 +03:00
|
|
|
if (first && option.dataset.type == type) {
|
|
|
|
option.selected = true;
|
|
|
|
first = false;
|
|
|
|
}
|
2017-06-29 17:44:03 +03:00
|
|
|
option.hidden = (type != this.TYPE_ALL) && (option.dataset.type != type);
|
2017-06-26 16:17:06 +03:00
|
|
|
});
|
|
|
|
});
|
2017-06-29 17:44:03 +03:00
|
|
|
this._updateArchivedPingData();
|
2015-05-13 22:57:05 +03:00
|
|
|
},
|
|
|
|
|
2017-06-12 19:52:17 +03:00
|
|
|
_getSelectedPingName() {
|
2017-07-20 13:35:57 +03:00
|
|
|
if (this.viewCurrentPingData) return bundle.GetStringFromName("currentPing");
|
2017-06-12 19:52:17 +03:00
|
|
|
|
|
|
|
let pingSelector = document.getElementById("choose-ping-id");
|
|
|
|
let selected = pingSelector.selectedOptions.item(0);
|
2017-06-29 17:44:03 +03:00
|
|
|
return selected.dataset.date;
|
2017-06-12 19:52:17 +03:00
|
|
|
},
|
|
|
|
|
2017-06-26 16:17:06 +03:00
|
|
|
_getSelectedPingType() {
|
|
|
|
let pingSelector = document.getElementById("choose-ping-id");
|
|
|
|
let selected = pingSelector.selectedOptions.item(0);
|
|
|
|
return selected.dataset.type;
|
|
|
|
},
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
_getSelectedPingId() {
|
2015-05-13 22:57:05 +03:00
|
|
|
let pingSelector = document.getElementById("choose-ping-id");
|
|
|
|
let selected = pingSelector.selectedOptions.item(0);
|
|
|
|
return selected.getAttribute("value");
|
|
|
|
},
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
_showRawPingData() {
|
2017-06-06 16:25:15 +03:00
|
|
|
show(document.getElementById("category-raw"));
|
2015-11-06 16:57:53 +03:00
|
|
|
},
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
_showStructuredPingData() {
|
2017-06-06 16:25:15 +03:00
|
|
|
show(document.getElementById("category-home"));
|
2015-11-06 16:57:53 +03:00
|
|
|
},
|
2015-05-13 22:57:05 +03:00
|
|
|
};
|
|
|
|
|
2015-09-15 21:19:45 +03:00
|
|
|
var GeneralData = {
|
2014-10-23 17:42:04 +04:00
|
|
|
/**
|
|
|
|
* Renders the general data
|
|
|
|
*/
|
2016-12-30 02:34:54 +03:00
|
|
|
render(aPing) {
|
2014-10-23 17:42:04 +04:00
|
|
|
setHasData("general-data-section", true);
|
2017-05-30 15:44:49 +03:00
|
|
|
let generalDataSection = document.getElementById("general-data");
|
|
|
|
removeAllChildNodes(generalDataSection);
|
2014-10-23 17:42:04 +04:00
|
|
|
|
2017-05-30 15:44:49 +03:00
|
|
|
const headings = [
|
2017-05-31 17:24:08 +03:00
|
|
|
"namesHeader",
|
|
|
|
"valuesHeader",
|
2017-05-30 15:44:49 +03:00
|
|
|
].map(h => bundle.GetStringFromName(h));
|
2014-10-23 17:42:04 +04:00
|
|
|
|
2015-05-13 22:57:05 +03:00
|
|
|
// The payload & environment parts are handled by other renderers.
|
|
|
|
let ignoreSections = ["payload", "environment"];
|
|
|
|
let data = explodeObject(filterObject(aPing, ignoreSections));
|
|
|
|
|
2017-05-30 15:44:49 +03:00
|
|
|
const table = GenericTable.render(data, headings);
|
|
|
|
generalDataSection.appendChild(table);
|
2014-10-23 17:42:04 +04:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2015-09-15 21:19:45 +03:00
|
|
|
var EnvironmentData = {
|
2015-05-13 22:57:05 +03:00
|
|
|
/**
|
|
|
|
* Renders the environment data
|
|
|
|
*/
|
2016-12-30 02:34:54 +03:00
|
|
|
render(ping) {
|
2015-05-13 22:57:05 +03:00
|
|
|
let dataDiv = document.getElementById("environment-data");
|
2015-05-13 22:57:06 +03:00
|
|
|
removeAllChildNodes(dataDiv);
|
2015-05-20 16:22:38 +03:00
|
|
|
const hasData = !!ping.environment;
|
|
|
|
setHasData("environment-data-section", hasData);
|
|
|
|
if (!hasData) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-06-01 17:37:33 +03:00
|
|
|
let ignore = ["addons"];
|
|
|
|
let env = filterObject(ping.environment, ignore);
|
|
|
|
let sections = sectionalizeObject(env);
|
2017-06-12 19:52:17 +03:00
|
|
|
GenericSubsection.render(sections, dataDiv, "environment-data-section");
|
2015-12-15 20:06:05 +03:00
|
|
|
|
|
|
|
// We use specialized rendering here to make the addon and plugin listings
|
|
|
|
// more readable.
|
2016-01-17 10:40:45 +03:00
|
|
|
this.createAddonSection(dataDiv, ping);
|
|
|
|
},
|
2015-12-15 20:06:05 +03:00
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
renderPersona(addonObj, addonSection, sectionTitle) {
|
2015-12-15 20:06:05 +03:00
|
|
|
let table = document.createElement("table");
|
|
|
|
table.setAttribute("id", sectionTitle);
|
|
|
|
this.appendAddonSubsectionTitle(sectionTitle, table);
|
|
|
|
this.appendRow(table, "persona", addonObj.persona);
|
|
|
|
addonSection.appendChild(table);
|
|
|
|
},
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
renderActivePlugins(addonObj, addonSection, sectionTitle) {
|
2015-12-15 20:06:05 +03:00
|
|
|
let table = document.createElement("table");
|
|
|
|
table.setAttribute("id", sectionTitle);
|
|
|
|
this.appendAddonSubsectionTitle(sectionTitle, table);
|
|
|
|
|
|
|
|
for (let plugin of addonObj) {
|
|
|
|
let data = explodeObject(plugin);
|
|
|
|
this.appendHeadingName(table, data.get("name"));
|
|
|
|
|
|
|
|
for (let [key, value] of data) {
|
|
|
|
this.appendRow(table, key, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
addonSection.appendChild(table);
|
|
|
|
},
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
renderAddonsObject(addonObj, addonSection, sectionTitle) {
|
2015-12-15 20:06:05 +03:00
|
|
|
let table = document.createElement("table");
|
|
|
|
table.setAttribute("id", sectionTitle);
|
|
|
|
this.appendAddonSubsectionTitle(sectionTitle, table);
|
|
|
|
|
|
|
|
for (let id of Object.keys(addonObj)) {
|
|
|
|
let addon = addonObj[id];
|
|
|
|
this.appendHeadingName(table, addon.name || id);
|
|
|
|
this.appendAddonID(table, id);
|
|
|
|
let data = explodeObject(addon);
|
|
|
|
|
|
|
|
for (let [key, value] of data) {
|
|
|
|
this.appendRow(table, key, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
addonSection.appendChild(table);
|
2015-05-13 22:57:05 +03:00
|
|
|
},
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
renderKeyValueObject(addonObj, addonSection, sectionTitle) {
|
2015-12-15 20:06:05 +03:00
|
|
|
let data = explodeObject(addonObj);
|
2017-06-01 17:37:33 +03:00
|
|
|
let table = GenericTable.render(data);
|
2015-12-15 20:06:05 +03:00
|
|
|
table.setAttribute("class", sectionTitle);
|
|
|
|
this.appendAddonSubsectionTitle(sectionTitle, table);
|
|
|
|
addonSection.appendChild(table);
|
|
|
|
},
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
appendAddonID(table, addonID) {
|
2015-12-15 20:06:05 +03:00
|
|
|
this.appendRow(table, "id", addonID);
|
|
|
|
},
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
appendHeadingName(table, name) {
|
2015-12-15 20:06:05 +03:00
|
|
|
let headings = document.createElement("tr");
|
|
|
|
this.appendColumn(headings, "th", name);
|
|
|
|
headings.cells[0].colSpan = 2;
|
|
|
|
table.appendChild(headings);
|
|
|
|
},
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
appendAddonSubsectionTitle(section, table) {
|
2015-12-15 20:06:05 +03:00
|
|
|
let caption = document.createElement("caption");
|
|
|
|
caption.setAttribute("class", "addon-caption");
|
|
|
|
caption.appendChild(document.createTextNode(section));
|
|
|
|
table.appendChild(caption);
|
|
|
|
},
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
createAddonSection(dataDiv, ping) {
|
2016-01-17 10:40:45 +03:00
|
|
|
let addonSection = document.createElement("div");
|
2017-06-01 17:37:33 +03:00
|
|
|
addonSection.setAttribute("class", "subsection-data subdata");
|
2016-01-17 10:40:45 +03:00
|
|
|
let addons = ping.environment.addons;
|
|
|
|
this.renderAddonsObject(addons.activeAddons, addonSection, "activeAddons");
|
|
|
|
this.renderActivePlugins(addons.activePlugins, addonSection, "activePlugins");
|
|
|
|
this.renderKeyValueObject(addons.theme, addonSection, "theme");
|
|
|
|
this.renderKeyValueObject(addons.activeExperiment, addonSection, "activeExperiment");
|
|
|
|
this.renderAddonsObject(addons.activeGMPlugins, addonSection, "activeGMPlugins");
|
|
|
|
this.renderPersona(addons, addonSection, "persona");
|
|
|
|
|
|
|
|
let hasAddonData = Object.keys(ping.environment.addons).length > 0;
|
2017-06-12 19:52:17 +03:00
|
|
|
let s = GenericSubsection.renderSubsectionHeader("addons", hasAddonData, "environment-data-section");
|
2017-06-01 17:37:33 +03:00
|
|
|
s.appendChild(addonSection);
|
|
|
|
dataDiv.appendChild(s);
|
2015-12-15 20:06:05 +03:00
|
|
|
},
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
appendRow(table, id, value) {
|
2015-12-15 20:06:05 +03:00
|
|
|
let row = document.createElement("tr");
|
2017-07-08 20:46:36 +03:00
|
|
|
row.id = id;
|
2015-12-15 20:06:05 +03:00
|
|
|
this.appendColumn(row, "td", id);
|
|
|
|
this.appendColumn(row, "td", value);
|
|
|
|
table.appendChild(row);
|
|
|
|
},
|
2015-05-13 22:57:05 +03:00
|
|
|
/**
|
|
|
|
* Helper function for appending a column to the data table.
|
|
|
|
*
|
|
|
|
* @param aRowElement Parent row element
|
|
|
|
* @param aColType Column's tag name
|
|
|
|
* @param aColText Column contents
|
|
|
|
*/
|
2016-12-30 02:34:54 +03:00
|
|
|
appendColumn(aRowElement, aColType, aColText) {
|
2015-05-13 22:57:05 +03:00
|
|
|
let colElement = document.createElement(aColType);
|
|
|
|
let colTextElement = document.createTextNode(aColText);
|
|
|
|
colElement.appendChild(colTextElement);
|
|
|
|
aRowElement.appendChild(colElement);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2015-09-15 21:19:45 +03:00
|
|
|
var TelLog = {
|
2015-03-20 02:23:56 +03:00
|
|
|
/**
|
|
|
|
* Renders the telemetry log
|
|
|
|
*/
|
2017-07-13 16:31:29 +03:00
|
|
|
render(payload) {
|
|
|
|
let entries = payload.log;
|
2015-05-20 16:22:38 +03:00
|
|
|
const hasData = entries && entries.length > 0;
|
|
|
|
setHasData("telemetry-log-section", hasData);
|
|
|
|
if (!hasData) {
|
|
|
|
return;
|
2015-03-20 02:23:56 +03:00
|
|
|
}
|
2015-05-20 16:22:38 +03:00
|
|
|
|
2015-03-20 02:23:56 +03:00
|
|
|
let table = document.createElement("table");
|
|
|
|
|
|
|
|
let caption = document.createElement("caption");
|
|
|
|
let captionString = bundle.GetStringFromName("telemetryLogTitle");
|
|
|
|
caption.appendChild(document.createTextNode(captionString + "\n"));
|
|
|
|
table.appendChild(caption);
|
|
|
|
|
|
|
|
let headings = document.createElement("tr");
|
|
|
|
this.appendColumn(headings, "th", bundle.GetStringFromName("telemetryLogHeadingId") + "\t");
|
|
|
|
this.appendColumn(headings, "th", bundle.GetStringFromName("telemetryLogHeadingTimestamp") + "\t");
|
|
|
|
this.appendColumn(headings, "th", bundle.GetStringFromName("telemetryLogHeadingData") + "\t");
|
|
|
|
table.appendChild(headings);
|
|
|
|
|
|
|
|
for (let entry of entries) {
|
|
|
|
let row = document.createElement("tr");
|
|
|
|
for (let elem of entry) {
|
|
|
|
this.appendColumn(row, "td", elem + "\t");
|
|
|
|
}
|
|
|
|
table.appendChild(row);
|
|
|
|
}
|
|
|
|
|
|
|
|
let dataDiv = document.getElementById("telemetry-log");
|
2015-05-13 22:57:06 +03:00
|
|
|
removeAllChildNodes(dataDiv);
|
2015-03-20 02:23:56 +03:00
|
|
|
dataDiv.appendChild(table);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper function for appending a column to the data table.
|
|
|
|
*
|
|
|
|
* @param aRowElement Parent row element
|
|
|
|
* @param aColType Column's tag name
|
|
|
|
* @param aColText Column contents
|
|
|
|
*/
|
2016-12-30 02:34:54 +03:00
|
|
|
appendColumn(aRowElement, aColType, aColText) {
|
2015-03-20 02:23:56 +03:00
|
|
|
let colElement = document.createElement(aColType);
|
|
|
|
let colTextElement = document.createTextNode(aColText);
|
|
|
|
colElement.appendChild(colTextElement);
|
|
|
|
aRowElement.appendChild(colElement);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2015-09-15 21:19:45 +03:00
|
|
|
var SlowSQL = {
|
2012-11-09 00:36:06 +04:00
|
|
|
|
|
|
|
slowSqlHits: bundle.GetStringFromName("slowSqlHits"),
|
|
|
|
|
|
|
|
slowSqlAverage: bundle.GetStringFromName("slowSqlAverage"),
|
|
|
|
|
|
|
|
slowSqlStatement: bundle.GetStringFromName("slowSqlStatement"),
|
|
|
|
|
|
|
|
mainThreadTitle: bundle.GetStringFromName("slowSqlMain"),
|
|
|
|
|
|
|
|
otherThreadTitle: bundle.GetStringFromName("slowSqlOther"),
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render slow SQL statistics
|
|
|
|
*/
|
2015-05-13 22:57:05 +03:00
|
|
|
render: function SlowSQL_render(aPing) {
|
|
|
|
// We can add the debug SQL data to the current ping later.
|
|
|
|
// However, we need to be careful to never send that debug data
|
|
|
|
// out due to privacy concerns.
|
2015-05-13 22:57:06 +03:00
|
|
|
// We want to show the actual ping data for archived pings,
|
|
|
|
// so skip this there.
|
|
|
|
let debugSlowSql = PingPicker.viewCurrentPingData && Preferences.get(PREF_DEBUG_SLOW_SQL, false);
|
2015-05-20 16:22:38 +03:00
|
|
|
let slowSql = debugSlowSql ? Telemetry.debugSlowSQL : aPing.payload.slowSQL;
|
|
|
|
if (!slowSql) {
|
|
|
|
setHasData("slow-sql-section", false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-11-09 00:36:06 +04:00
|
|
|
let {mainThread, otherThreads} =
|
2015-05-13 22:57:05 +03:00
|
|
|
debugSlowSql ? Telemetry.debugSlowSQL : aPing.payload.slowSQL;
|
2012-11-09 00:36:06 +04:00
|
|
|
|
|
|
|
let mainThreadCount = Object.keys(mainThread).length;
|
|
|
|
let otherThreadCount = Object.keys(otherThreads).length;
|
|
|
|
if (mainThreadCount == 0 && otherThreadCount == 0) {
|
2015-05-20 16:22:38 +03:00
|
|
|
setHasData("slow-sql-section", false);
|
2012-11-09 00:36:06 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-12-11 00:54:01 +04:00
|
|
|
setHasData("slow-sql-section", true);
|
2012-11-09 00:36:06 +04:00
|
|
|
if (debugSlowSql) {
|
2017-06-06 16:25:15 +03:00
|
|
|
document.getElementById("sql-warning").hidden = false;
|
2012-11-09 00:36:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
let slowSqlDiv = document.getElementById("slow-sql-tables");
|
2015-05-13 22:57:06 +03:00
|
|
|
removeAllChildNodes(slowSqlDiv);
|
2012-11-09 00:36:06 +04:00
|
|
|
|
|
|
|
// Main thread
|
|
|
|
if (mainThreadCount > 0) {
|
|
|
|
let table = document.createElement("table");
|
|
|
|
this.renderTableHeader(table, this.mainThreadTitle);
|
|
|
|
this.renderTable(table, mainThread);
|
|
|
|
|
|
|
|
slowSqlDiv.appendChild(table);
|
|
|
|
slowSqlDiv.appendChild(document.createElement("hr"));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Other threads
|
|
|
|
if (otherThreadCount > 0) {
|
|
|
|
let table = document.createElement("table");
|
|
|
|
this.renderTableHeader(table, this.otherThreadTitle);
|
|
|
|
this.renderTable(table, otherThreads);
|
|
|
|
|
|
|
|
slowSqlDiv.appendChild(table);
|
|
|
|
slowSqlDiv.appendChild(document.createElement("hr"));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a header row for a Slow SQL table
|
2013-01-03 06:46:33 +04:00
|
|
|
* Tabs & newlines added to cells to make it easier to copy-paste.
|
2012-11-09 00:36:06 +04:00
|
|
|
*
|
|
|
|
* @param aTable Parent table element
|
|
|
|
* @param aTitle Table's title
|
|
|
|
*/
|
|
|
|
renderTableHeader: function SlowSQL_renderTableHeader(aTable, aTitle) {
|
|
|
|
let caption = document.createElement("caption");
|
2013-01-03 06:46:33 +04:00
|
|
|
caption.appendChild(document.createTextNode(aTitle + "\n"));
|
2012-11-09 00:36:06 +04:00
|
|
|
aTable.appendChild(caption);
|
|
|
|
|
|
|
|
let headings = document.createElement("tr");
|
2013-01-03 06:46:33 +04:00
|
|
|
this.appendColumn(headings, "th", this.slowSqlHits + "\t");
|
|
|
|
this.appendColumn(headings, "th", this.slowSqlAverage + "\t");
|
|
|
|
this.appendColumn(headings, "th", this.slowSqlStatement + "\n");
|
2012-11-09 00:36:06 +04:00
|
|
|
aTable.appendChild(headings);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fills out the table body
|
2013-01-03 06:46:33 +04:00
|
|
|
* Tabs & newlines added to cells to make it easier to copy-paste.
|
2012-11-09 00:36:06 +04:00
|
|
|
*
|
|
|
|
* @param aTable Parent table element
|
|
|
|
* @param aSql SQL stats object
|
|
|
|
*/
|
|
|
|
renderTable: function SlowSQL_renderTable(aTable, aSql) {
|
2016-08-03 09:23:10 +03:00
|
|
|
for (let [sql, [hitCount, totalTime]] of Object.entries(aSql)) {
|
2012-11-09 00:36:06 +04:00
|
|
|
let averageTime = totalTime / hitCount;
|
|
|
|
|
|
|
|
let sqlRow = document.createElement("tr");
|
|
|
|
|
2013-01-03 06:46:33 +04:00
|
|
|
this.appendColumn(sqlRow, "td", hitCount + "\t");
|
|
|
|
this.appendColumn(sqlRow, "td", averageTime.toFixed(0) + "\t");
|
|
|
|
this.appendColumn(sqlRow, "td", sql + "\n");
|
2012-11-09 00:36:06 +04:00
|
|
|
|
|
|
|
aTable.appendChild(sqlRow);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper function for appending a column to a Slow SQL table.
|
|
|
|
*
|
|
|
|
* @param aRowElement Parent row element
|
|
|
|
* @param aColType Column's tag name
|
|
|
|
* @param aColText Column contents
|
|
|
|
*/
|
|
|
|
appendColumn: function SlowSQL_appendColumn(aRowElement, aColType, aColText) {
|
|
|
|
let colElement = document.createElement(aColType);
|
2013-01-03 06:46:33 +04:00
|
|
|
let colTextElement = document.createTextNode(aColText);
|
|
|
|
colElement.appendChild(colTextElement);
|
2012-11-09 00:36:06 +04:00
|
|
|
aRowElement.appendChild(colElement);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-09-15 21:19:45 +03:00
|
|
|
var StackRenderer = {
|
2012-11-09 00:36:06 +04:00
|
|
|
|
|
|
|
stackTitle: bundle.GetStringFromName("stackTitle"),
|
|
|
|
|
|
|
|
memoryMapTitle: bundle.GetStringFromName("memoryMapTitle"),
|
|
|
|
|
2012-12-25 03:07:17 +04:00
|
|
|
/**
|
|
|
|
* Outputs the memory map associated with this hang report
|
|
|
|
*
|
|
|
|
* @param aDiv Output div
|
|
|
|
*/
|
|
|
|
renderMemoryMap: function StackRenderer_renderMemoryMap(aDiv, memoryMap) {
|
|
|
|
aDiv.appendChild(document.createTextNode(this.memoryMapTitle));
|
|
|
|
aDiv.appendChild(document.createElement("br"));
|
|
|
|
|
|
|
|
for (let currentModule of memoryMap) {
|
|
|
|
aDiv.appendChild(document.createTextNode(currentModule.join(" ")));
|
|
|
|
aDiv.appendChild(document.createElement("br"));
|
|
|
|
}
|
|
|
|
|
|
|
|
aDiv.appendChild(document.createElement("br"));
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Outputs the raw PCs from the hang's stack
|
|
|
|
*
|
|
|
|
* @param aDiv Output div
|
|
|
|
* @param aStack Array of PCs from the hang stack
|
|
|
|
*/
|
|
|
|
renderStack: function StackRenderer_renderStack(aDiv, aStack) {
|
|
|
|
aDiv.appendChild(document.createTextNode(this.stackTitle));
|
|
|
|
let stackText = " " + aStack.join(" ");
|
|
|
|
aDiv.appendChild(document.createTextNode(stackText));
|
|
|
|
|
|
|
|
aDiv.appendChild(document.createElement("br"));
|
|
|
|
aDiv.appendChild(document.createElement("br"));
|
2013-01-17 19:25:44 +04:00
|
|
|
},
|
|
|
|
renderStacks: function StackRenderer_renderStacks(aPrefix, aStacks,
|
|
|
|
aMemoryMap, aRenderHeader) {
|
2017-01-17 18:48:17 +03:00
|
|
|
let div = document.getElementById(aPrefix + "-data");
|
2015-05-13 22:57:06 +03:00
|
|
|
removeAllChildNodes(div);
|
2013-01-17 19:25:44 +04:00
|
|
|
|
2017-01-17 18:48:17 +03:00
|
|
|
let fetchE = document.getElementById(aPrefix + "-fetch-symbols");
|
2013-01-17 19:25:44 +04:00
|
|
|
if (fetchE) {
|
2017-06-06 16:25:15 +03:00
|
|
|
fetchE.hidden = false;
|
2013-01-17 19:25:44 +04:00
|
|
|
}
|
2017-01-17 18:48:17 +03:00
|
|
|
let hideE = document.getElementById(aPrefix + "-hide-symbols");
|
2013-01-17 19:25:44 +04:00
|
|
|
if (hideE) {
|
2017-06-06 16:25:15 +03:00
|
|
|
hideE.hidden = true;
|
2013-01-17 19:25:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aStacks.length == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-01-17 18:48:17 +03:00
|
|
|
setHasData(aPrefix + "-section", true);
|
2013-12-11 00:54:01 +04:00
|
|
|
|
2013-01-17 19:25:44 +04:00
|
|
|
this.renderMemoryMap(div, aMemoryMap);
|
|
|
|
|
|
|
|
for (let i = 0; i < aStacks.length; ++i) {
|
|
|
|
let stack = aStacks[i];
|
|
|
|
aRenderHeader(i);
|
|
|
|
this.renderStack(div, stack)
|
|
|
|
}
|
2013-01-17 23:32:51 +04:00
|
|
|
},
|
2013-02-07 01:41:30 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the title of the stack: e.g. "Late Write #1" or
|
|
|
|
* "Hang Report #1 (6 seconds)".
|
|
|
|
*
|
|
|
|
* @param aFormatArgs formating args to be passed to formatStringFromName.
|
|
|
|
*/
|
|
|
|
renderHeader: function StackRenderer_renderHeader(aPrefix, aFormatArgs) {
|
|
|
|
let div = document.getElementById(aPrefix + "-data");
|
|
|
|
|
|
|
|
let titleElement = document.createElement("span");
|
|
|
|
titleElement.className = "stack-title";
|
|
|
|
|
|
|
|
let titleText = bundle.formatStringFromName(
|
|
|
|
aPrefix + "-title", aFormatArgs, aFormatArgs.length);
|
|
|
|
titleElement.appendChild(document.createTextNode(titleText));
|
|
|
|
|
|
|
|
div.appendChild(titleElement);
|
|
|
|
div.appendChild(document.createElement("br"));
|
|
|
|
}
|
2012-12-25 03:07:17 +04:00
|
|
|
};
|
|
|
|
|
2016-02-28 21:09:35 +03:00
|
|
|
var RawPayload = {
|
|
|
|
/**
|
|
|
|
* Renders the raw payload
|
|
|
|
*/
|
2016-12-30 02:34:54 +03:00
|
|
|
render(aPing) {
|
2017-06-16 15:04:50 +03:00
|
|
|
setHasData("raw-ping-data-section", true);
|
|
|
|
let pre = document.getElementById("raw-ping-data");
|
2017-07-17 23:11:03 +03:00
|
|
|
pre.textContent = JSON.stringify(aPing, null, 2);
|
2016-02-28 21:09:35 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-10-15 20:51:23 +03:00
|
|
|
function SymbolicationRequest(aPrefix, aRenderHeader,
|
|
|
|
aMemoryMap, aStacks, aDurations = null) {
|
2013-01-20 04:26:05 +04:00
|
|
|
this.prefix = aPrefix;
|
|
|
|
this.renderHeader = aRenderHeader;
|
|
|
|
this.memoryMap = aMemoryMap;
|
|
|
|
this.stacks = aStacks;
|
2015-10-15 20:51:23 +03:00
|
|
|
this.durations = aDurations;
|
2013-01-20 04:26:05 +04:00
|
|
|
}
|
2013-02-06 02:04:05 +04:00
|
|
|
/**
|
|
|
|
* A callback for onreadystatechange. It replaces the numeric stack with
|
|
|
|
* the symbolicated one returned by the symbolication server.
|
|
|
|
*/
|
|
|
|
SymbolicationRequest.prototype.handleSymbolResponse =
|
|
|
|
function SymbolicationRequest_handleSymbolResponse() {
|
2013-02-05 01:00:34 +04:00
|
|
|
if (this.symbolRequest.readyState != 4)
|
|
|
|
return;
|
|
|
|
|
|
|
|
let fetchElement = document.getElementById(this.prefix + "-fetch-symbols");
|
2017-06-06 16:25:15 +03:00
|
|
|
fetchElement.hidden = true;
|
2013-02-05 01:00:34 +04:00
|
|
|
let hideElement = document.getElementById(this.prefix + "-hide-symbols");
|
2017-06-06 16:25:15 +03:00
|
|
|
hideElement.hidden = false;
|
2013-02-05 01:00:34 +04:00
|
|
|
let div = document.getElementById(this.prefix + "-data");
|
2015-05-13 22:57:06 +03:00
|
|
|
removeAllChildNodes(div);
|
2013-02-05 01:00:34 +04:00
|
|
|
let errorMessage = bundle.GetStringFromName("errorFetchingSymbols");
|
|
|
|
|
|
|
|
if (this.symbolRequest.status != 200) {
|
|
|
|
div.appendChild(document.createTextNode(errorMessage));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let jsonResponse = {};
|
|
|
|
try {
|
|
|
|
jsonResponse = JSON.parse(this.symbolRequest.responseText);
|
|
|
|
} catch (e) {
|
|
|
|
div.appendChild(document.createTextNode(errorMessage));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let i = 0; i < jsonResponse.length; ++i) {
|
|
|
|
let stack = jsonResponse[i];
|
2015-10-15 20:51:23 +03:00
|
|
|
this.renderHeader(i, this.durations);
|
2013-02-05 01:00:34 +04:00
|
|
|
|
|
|
|
for (let symbol of stack) {
|
|
|
|
div.appendChild(document.createTextNode(symbol));
|
|
|
|
div.appendChild(document.createElement("br"));
|
|
|
|
}
|
|
|
|
div.appendChild(document.createElement("br"));
|
|
|
|
}
|
2013-01-20 04:26:05 +04:00
|
|
|
};
|
2013-02-06 02:04:05 +04:00
|
|
|
/**
|
|
|
|
* Send a request to the symbolication server to symbolicate this stack.
|
|
|
|
*/
|
|
|
|
SymbolicationRequest.prototype.fetchSymbols =
|
|
|
|
function SymbolicationRequest_fetchSymbols() {
|
2013-01-20 04:26:05 +04:00
|
|
|
let symbolServerURI =
|
2015-05-13 22:57:05 +03:00
|
|
|
Preferences.get(PREF_SYMBOL_SERVER_URI, DEFAULT_SYMBOL_SERVER_URI);
|
2017-03-21 21:29:43 +03:00
|
|
|
let request = {"memoryMap": this.memoryMap, "stacks": this.stacks,
|
|
|
|
"version": 3};
|
2013-01-20 04:26:05 +04:00
|
|
|
let requestJSON = JSON.stringify(request);
|
|
|
|
|
2014-03-11 01:38:14 +04:00
|
|
|
this.symbolRequest = new XMLHttpRequest();
|
2013-01-20 04:26:05 +04:00
|
|
|
this.symbolRequest.open("POST", symbolServerURI, true);
|
|
|
|
this.symbolRequest.setRequestHeader("Content-type", "application/json");
|
|
|
|
this.symbolRequest.setRequestHeader("Content-length",
|
|
|
|
requestJSON.length);
|
|
|
|
this.symbolRequest.setRequestHeader("Connection", "close");
|
|
|
|
this.symbolRequest.onreadystatechange = this.handleSymbolResponse.bind(this);
|
|
|
|
this.symbolRequest.send(requestJSON);
|
|
|
|
}
|
|
|
|
|
2015-09-15 21:19:45 +03:00
|
|
|
var ChromeHangs = {
|
2012-12-25 03:07:17 +04:00
|
|
|
|
|
|
|
symbolRequest: null,
|
|
|
|
|
2012-11-09 00:36:06 +04:00
|
|
|
/**
|
|
|
|
* Renders raw chrome hang data
|
|
|
|
*/
|
2017-07-13 16:31:29 +03:00
|
|
|
render: function ChromeHangs_render(payload) {
|
|
|
|
let hangs = payload.chromeHangs;
|
2015-05-20 16:22:38 +03:00
|
|
|
setHasData("chrome-hangs-section", !!hangs);
|
|
|
|
if (!hangs) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-11-20 18:45:14 +04:00
|
|
|
let stacks = hangs.stacks;
|
2012-12-25 03:07:17 +04:00
|
|
|
let memoryMap = hangs.memoryMap;
|
2015-10-15 20:51:23 +03:00
|
|
|
let durations = hangs.durations;
|
2013-01-17 19:25:44 +04:00
|
|
|
|
|
|
|
StackRenderer.renderStacks("chrome-hangs", stacks, memoryMap,
|
2015-10-15 20:51:23 +03:00
|
|
|
(index) => this.renderHangHeader(index, durations));
|
2012-11-09 00:36:06 +04:00
|
|
|
},
|
|
|
|
|
2015-10-15 20:51:23 +03:00
|
|
|
renderHangHeader: function ChromeHangs_renderHangHeader(aIndex, aDurations) {
|
|
|
|
StackRenderer.renderHeader("chrome-hangs", [aIndex + 1, aDurations[aIndex]]);
|
2012-11-09 00:36:06 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-11-17 22:52:53 +03:00
|
|
|
var CapturedStacks = {
|
|
|
|
symbolRequest: null,
|
|
|
|
|
|
|
|
render: function CapturedStacks_render(payload) {
|
|
|
|
// Retrieve captured stacks from telemetry payload.
|
|
|
|
let capturedStacks = "processes" in payload && "parent" in payload.processes
|
|
|
|
? payload.processes.parent.capturedStacks
|
|
|
|
: false;
|
|
|
|
let hasData = capturedStacks && capturedStacks.stacks &&
|
|
|
|
capturedStacks.stacks.length > 0;
|
|
|
|
setHasData("captured-stacks-section", hasData);
|
|
|
|
if (!hasData) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let stacks = capturedStacks.stacks;
|
|
|
|
let memoryMap = capturedStacks.memoryMap;
|
2017-01-30 20:49:04 +03:00
|
|
|
let captures = capturedStacks.captures;
|
2016-11-17 22:52:53 +03:00
|
|
|
|
2017-01-30 20:49:04 +03:00
|
|
|
StackRenderer.renderStacks("captured-stacks", stacks, memoryMap,
|
|
|
|
(index) => this.renderCaptureHeader(index, captures));
|
2016-11-17 22:52:53 +03:00
|
|
|
},
|
2017-01-30 20:49:04 +03:00
|
|
|
|
|
|
|
renderCaptureHeader: function CaptureStacks_renderCaptureHeader(index, captures) {
|
|
|
|
let key = captures[index][0];
|
|
|
|
let cardinality = captures[index][2];
|
|
|
|
StackRenderer.renderHeader("captured-stacks", [key, cardinality]);
|
|
|
|
}
|
2016-11-17 22:52:53 +03:00
|
|
|
};
|
|
|
|
|
2015-09-15 21:19:45 +03:00
|
|
|
var ThreadHangStats = {
|
2014-01-15 09:39:16 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders raw thread hang stats data
|
|
|
|
*/
|
2016-12-30 02:34:54 +03:00
|
|
|
render(aPayload) {
|
2014-01-15 09:39:16 +04:00
|
|
|
let div = document.getElementById("thread-hang-stats");
|
2015-05-13 22:57:06 +03:00
|
|
|
removeAllChildNodes(div);
|
2014-01-15 09:39:16 +04:00
|
|
|
|
2015-11-27 08:03:00 +03:00
|
|
|
let stats = aPayload.threadHangStats;
|
2015-05-20 16:22:38 +03:00
|
|
|
setHasData("thread-hang-stats-section", stats && (stats.length > 0));
|
|
|
|
if (!stats) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-01-15 09:39:16 +04:00
|
|
|
stats.forEach((thread) => {
|
|
|
|
div.appendChild(this.renderThread(thread));
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates and fills data corresponding to a thread
|
|
|
|
*/
|
2016-12-30 02:34:54 +03:00
|
|
|
renderThread(aThread) {
|
2014-01-15 09:39:16 +04:00
|
|
|
let div = document.createElement("div");
|
|
|
|
|
|
|
|
let title = document.createElement("h2");
|
|
|
|
title.textContent = aThread.name;
|
|
|
|
div.appendChild(title);
|
|
|
|
|
|
|
|
// Don't localize the histogram name, because the
|
|
|
|
// name is also used as the div element's ID
|
|
|
|
Histogram.render(div, aThread.name + "-Activity",
|
2016-01-25 21:43:09 +03:00
|
|
|
aThread.activity, {exponential: true}, true);
|
2014-01-15 09:39:16 +04:00
|
|
|
aThread.hangs.forEach((hang, index) => {
|
|
|
|
let hangName = aThread.name + "-Hang-" + (index + 1);
|
|
|
|
let hangDiv = Histogram.render(
|
2016-01-25 21:43:09 +03:00
|
|
|
div, hangName, hang.histogram, {exponential: true}, true);
|
2014-01-15 09:39:16 +04:00
|
|
|
let stackDiv = document.createElement("div");
|
2017-04-24 18:06:17 +03:00
|
|
|
hang.stack.forEach((frame) => {
|
2014-01-15 09:39:16 +04:00
|
|
|
stackDiv.appendChild(document.createTextNode(frame));
|
|
|
|
// Leave an extra <br> at the end of the stack listing
|
|
|
|
stackDiv.appendChild(document.createElement("br"));
|
|
|
|
});
|
|
|
|
// Insert stack after the histogram title
|
|
|
|
hangDiv.insertBefore(stackDiv, hangDiv.childNodes[1]);
|
|
|
|
});
|
|
|
|
return div;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2015-09-15 21:19:45 +03:00
|
|
|
var Histogram = {
|
2012-11-09 00:36:06 +04:00
|
|
|
|
|
|
|
hgramSamplesCaption: bundle.GetStringFromName("histogramSamples"),
|
|
|
|
|
|
|
|
hgramAverageCaption: bundle.GetStringFromName("histogramAverage"),
|
|
|
|
|
|
|
|
hgramSumCaption: bundle.GetStringFromName("histogramSum"),
|
|
|
|
|
2013-11-29 21:31:14 +04:00
|
|
|
hgramCopyCaption: bundle.GetStringFromName("histogramCopy"),
|
|
|
|
|
2012-11-09 00:36:06 +04:00
|
|
|
/**
|
|
|
|
* Renders a single Telemetry histogram
|
|
|
|
*
|
|
|
|
* @param aParent Parent element
|
|
|
|
* @param aName Histogram name
|
|
|
|
* @param aHgram Histogram information
|
2014-01-15 09:39:16 +04:00
|
|
|
* @param aOptions Object with render options
|
|
|
|
* * exponential: bars follow logarithmic scale
|
2016-01-25 21:43:09 +03:00
|
|
|
* @param aIsBHR whether or not requires fixing the labels for TimeHistogram
|
2012-11-09 00:36:06 +04:00
|
|
|
*/
|
2016-01-25 21:43:09 +03:00
|
|
|
render: function Histogram_render(aParent, aName, aHgram, aOptions, aIsBHR) {
|
2014-01-15 09:39:16 +04:00
|
|
|
let options = aOptions || {};
|
2016-01-25 21:43:09 +03:00
|
|
|
let hgram = this.processHistogram(aHgram, aName, aIsBHR);
|
2012-11-09 00:36:06 +04:00
|
|
|
|
|
|
|
let outerDiv = document.createElement("div");
|
|
|
|
outerDiv.className = "histogram";
|
|
|
|
outerDiv.id = aName;
|
|
|
|
|
|
|
|
let divTitle = document.createElement("div");
|
|
|
|
divTitle.className = "histogram-title";
|
|
|
|
divTitle.appendChild(document.createTextNode(aName));
|
|
|
|
outerDiv.appendChild(divTitle);
|
|
|
|
|
|
|
|
let stats = hgram.sample_count + " " + this.hgramSamplesCaption + ", " +
|
|
|
|
this.hgramAverageCaption + " = " + hgram.pretty_average + ", " +
|
|
|
|
this.hgramSumCaption + " = " + hgram.sum;
|
|
|
|
|
|
|
|
let divStats = document.createElement("div");
|
|
|
|
divStats.appendChild(document.createTextNode(stats));
|
|
|
|
outerDiv.appendChild(divStats);
|
|
|
|
|
2015-05-13 22:57:05 +03:00
|
|
|
if (isRTL()) {
|
|
|
|
hgram.buckets.reverse();
|
2012-11-09 00:36:06 +04:00
|
|
|
hgram.values.reverse();
|
2015-05-13 22:57:05 +03:00
|
|
|
}
|
2012-11-09 00:36:06 +04:00
|
|
|
|
2015-05-13 22:57:05 +03:00
|
|
|
let textData = this.renderValues(outerDiv, hgram, options);
|
2013-11-29 21:31:14 +04:00
|
|
|
|
|
|
|
// The 'Copy' button contains the textual data, copied to clipboard on click
|
|
|
|
let copyButton = document.createElement("button");
|
|
|
|
copyButton.className = "copy-node";
|
|
|
|
copyButton.appendChild(document.createTextNode(this.hgramCopyCaption));
|
|
|
|
copyButton.histogramText = aName + EOL + stats + EOL + EOL + textData;
|
2016-08-04 10:20:25 +03:00
|
|
|
copyButton.addEventListener("click", function() {
|
2013-11-29 21:31:14 +04:00
|
|
|
Cc["@mozilla.org/widget/clipboardhelper;1"].getService(Ci.nsIClipboardHelper)
|
|
|
|
.copyString(this.histogramText);
|
|
|
|
});
|
|
|
|
outerDiv.appendChild(copyButton);
|
2012-11-09 00:36:06 +04:00
|
|
|
|
|
|
|
aParent.appendChild(outerDiv);
|
2014-01-15 09:39:16 +04:00
|
|
|
return outerDiv;
|
2012-11-09 00:36:06 +04:00
|
|
|
},
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
processHistogram(aHgram, aName, aIsBHR) {
|
2015-12-03 21:02:22 +03:00
|
|
|
const values = Object.keys(aHgram.values).map(k => aHgram.values[k]);
|
2015-05-13 22:57:05 +03:00
|
|
|
if (!values.length) {
|
|
|
|
// If we have no values collected for this histogram, just return
|
|
|
|
// zero values so we still render it.
|
|
|
|
return {
|
|
|
|
values: [],
|
|
|
|
pretty_average: 0,
|
|
|
|
max: 0,
|
|
|
|
sample_count: 0,
|
|
|
|
sum: 0
|
|
|
|
};
|
2015-05-11 23:06:21 +03:00
|
|
|
}
|
2015-05-11 20:40:23 +03:00
|
|
|
|
2015-05-13 22:57:05 +03:00
|
|
|
const sample_count = values.reduceRight((a, b) => a + b);
|
|
|
|
const average = Math.round(aHgram.sum * 10 / sample_count) / 10;
|
|
|
|
const max_value = Math.max(...values);
|
|
|
|
|
2016-01-25 21:43:09 +03:00
|
|
|
function labelFunc(k) {
|
|
|
|
// - BHR histograms are TimeHistograms: Exactly power-of-two buckets (from 0)
|
|
|
|
// (buckets: [0..1], [2..3], [4..7], [8..15], ... note the 0..1 anomaly - same bucket)
|
|
|
|
// - TimeHistogram's JS representation adds a dummy (empty) "0" bucket, and
|
|
|
|
// the rest of the buckets have the label as the upper value of the
|
|
|
|
// bucket (non TimeHistograms have the lower value of the bucket as label).
|
|
|
|
// So JS TimeHistograms bucket labels are: 0 (dummy), 1, 3, 7, 15, ...
|
|
|
|
// - see toolkit/components/telemetry/Telemetry.cpp
|
|
|
|
// (CreateJSTimeHistogram, CreateJSThreadHangStats, CreateJSHangHistogram)
|
|
|
|
// - see toolkit/components/telemetry/ThreadHangStats.h
|
|
|
|
// Fix BHR labels to the "standard" format for about:telemetry as follows:
|
|
|
|
// - The dummy 0 label+bucket will be filtered before arriving here
|
|
|
|
// - If it's 1 -> manually correct it to 0 (the 0..1 anomaly)
|
|
|
|
// - For the rest, set the label as the bottom value instead of the upper.
|
|
|
|
// --> so we'll end with the following (non dummy) labels: 0, 2, 4, 8, 16, ...
|
2016-02-04 08:17:16 +03:00
|
|
|
if (!aIsBHR) {
|
|
|
|
return k;
|
|
|
|
}
|
|
|
|
return k == 1 ? 0 : (k + 1) / 2;
|
2016-01-25 21:43:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
const labelledValues = Object.keys(aHgram.values)
|
|
|
|
.filter(label => !aIsBHR || Number(label) != 0) // remove dummy 0 label for BHR
|
|
|
|
.map(k => [labelFunc(Number(k)), aHgram.values[k]]);
|
2012-11-09 00:36:06 +04:00
|
|
|
|
|
|
|
let result = {
|
2015-05-13 22:57:05 +03:00
|
|
|
values: labelledValues,
|
2012-11-09 00:36:06 +04:00
|
|
|
pretty_average: average,
|
|
|
|
max: max_value,
|
2016-12-30 02:34:54 +03:00
|
|
|
sample_count,
|
2012-11-09 00:36:06 +04:00
|
|
|
sum: aHgram.sum
|
|
|
|
};
|
|
|
|
|
|
|
|
return result;
|
|
|
|
},
|
|
|
|
|
2014-01-15 09:39:16 +04:00
|
|
|
/**
|
|
|
|
* Return a non-negative, logarithmic representation of a non-negative number.
|
|
|
|
* e.g. 0 => 0, 1 => 1, 10 => 2, 100 => 3
|
|
|
|
*
|
|
|
|
* @param aNumber Non-negative number
|
|
|
|
*/
|
2016-12-30 02:34:54 +03:00
|
|
|
getLogValue(aNumber) {
|
2014-01-15 09:39:16 +04:00
|
|
|
return Math.max(0, Math.log10(aNumber) + 1);
|
|
|
|
},
|
|
|
|
|
2012-11-09 00:36:06 +04:00
|
|
|
/**
|
2013-11-29 21:31:14 +04:00
|
|
|
* Create histogram HTML bars, also returns a textual representation
|
|
|
|
* Both aMaxValue and aSumValues must be positive.
|
|
|
|
* Values are assumed to use 0 as baseline.
|
2012-11-09 00:36:06 +04:00
|
|
|
*
|
|
|
|
* @param aDiv Outer parent div
|
2015-05-13 22:57:05 +03:00
|
|
|
* @param aHgram The histogram data
|
2014-01-15 09:39:16 +04:00
|
|
|
* @param aOptions Object with render options (@see #render)
|
2012-11-09 00:36:06 +04:00
|
|
|
*/
|
2015-05-13 22:57:05 +03:00
|
|
|
renderValues: function Histogram_renderValues(aDiv, aHgram, aOptions) {
|
2013-11-29 21:31:14 +04:00
|
|
|
let text = "";
|
|
|
|
// If the last label is not the longest string, alignment will break a little
|
2015-05-13 22:57:05 +03:00
|
|
|
let labelPadTo = 0;
|
|
|
|
if (aHgram.values.length) {
|
|
|
|
labelPadTo = String(aHgram.values[aHgram.values.length - 1][0]).length;
|
|
|
|
}
|
2015-08-04 12:49:42 +03:00
|
|
|
let maxBarValue = aOptions.exponential ? this.getLogValue(aHgram.max) : aHgram.max;
|
2013-11-29 21:31:14 +04:00
|
|
|
|
2015-05-13 22:57:05 +03:00
|
|
|
for (let [label, value] of aHgram.values) {
|
2017-07-19 22:28:07 +03:00
|
|
|
label = String(label);
|
2014-01-15 09:39:16 +04:00
|
|
|
let barValue = aOptions.exponential ? this.getLogValue(value) : value;
|
|
|
|
|
2013-11-29 21:31:14 +04:00
|
|
|
// Create a text representation: <right-aligned-label> |<bar-of-#><value> <percentage>
|
|
|
|
text += EOL
|
2017-07-19 22:28:07 +03:00
|
|
|
+ " ".repeat(Math.max(0, labelPadTo - label.length)) + label // Right-aligned label
|
2014-01-15 09:39:16 +04:00
|
|
|
+ " |" + "#".repeat(Math.round(MAX_BAR_CHARS * barValue / maxBarValue)) // Bar
|
|
|
|
+ " " + value // Value
|
2015-11-06 15:35:03 +03:00
|
|
|
+ " " + Math.round(100 * value / aHgram.sample_count) + "%"; // Percentage
|
2013-11-29 21:31:14 +04:00
|
|
|
|
|
|
|
// Construct the HTML labels + bars
|
2014-01-15 09:39:16 +04:00
|
|
|
let belowEm = Math.round(MAX_BAR_HEIGHT * (barValue / maxBarValue) * 10) / 10;
|
2012-11-09 00:36:06 +04:00
|
|
|
let aboveEm = MAX_BAR_HEIGHT - belowEm;
|
|
|
|
|
|
|
|
let barDiv = document.createElement("div");
|
|
|
|
barDiv.className = "bar";
|
|
|
|
barDiv.style.paddingTop = aboveEm + "em";
|
|
|
|
|
|
|
|
// Add value label or an nbsp if no value
|
2017-01-17 18:48:17 +03:00
|
|
|
barDiv.appendChild(document.createTextNode(value ? value : "\u00A0"));
|
2012-11-09 00:36:06 +04:00
|
|
|
|
|
|
|
// Create the blue bar
|
|
|
|
let bar = document.createElement("div");
|
|
|
|
bar.className = "bar-inner";
|
|
|
|
bar.style.height = belowEm + "em";
|
|
|
|
barDiv.appendChild(bar);
|
|
|
|
|
2017-07-19 22:28:07 +03:00
|
|
|
// Add a special class to move the text down to prevent text overlap
|
|
|
|
if (label.length > 3) {
|
|
|
|
bar.classList.add("long-label");
|
|
|
|
}
|
2012-11-09 00:36:06 +04:00
|
|
|
// Add bucket label
|
|
|
|
barDiv.appendChild(document.createTextNode(label));
|
|
|
|
|
|
|
|
aDiv.appendChild(barDiv);
|
|
|
|
}
|
2013-11-29 21:31:14 +04:00
|
|
|
|
|
|
|
return text.substr(EOL.length); // Trim the EOL before the first line
|
2013-12-11 00:54:01 +04:00
|
|
|
},
|
2017-07-08 20:46:36 +03:00
|
|
|
};
|
2013-12-11 00:54:01 +04:00
|
|
|
|
2017-07-08 20:46:36 +03:00
|
|
|
|
|
|
|
var Search = {
|
|
|
|
|
|
|
|
// Pass if: all non-empty array items match (case-sensitive)
|
|
|
|
isPassText(subject, filter) {
|
|
|
|
for (let item of filter) {
|
|
|
|
if (item.length && subject.indexOf(item) < 0) {
|
|
|
|
return false; // mismatch and not a spurious space
|
2013-12-11 00:54:01 +04:00
|
|
|
}
|
|
|
|
}
|
2017-07-08 20:46:36 +03:00
|
|
|
return true;
|
|
|
|
},
|
2013-12-11 00:54:01 +04:00
|
|
|
|
2017-07-08 20:46:36 +03:00
|
|
|
isPassRegex(subject, filter) {
|
|
|
|
return filter.test(subject);
|
|
|
|
},
|
2013-12-11 00:54:01 +04:00
|
|
|
|
2017-07-08 20:46:36 +03:00
|
|
|
chooseFilter(filterText) {
|
|
|
|
let filter = filterText.toString();
|
2013-12-11 00:54:01 +04:00
|
|
|
// Setup normalized filter string (trimmed, lower cased and split on spaces if not RegEx)
|
|
|
|
let isPassFunc; // filter function, set once, then applied to all elements
|
|
|
|
filter = filter.trim();
|
|
|
|
if (filter[0] != "/") { // Plain text: case insensitive, AND if multi-string
|
2017-07-08 20:46:36 +03:00
|
|
|
isPassFunc = this.isPassText;
|
2013-12-11 00:54:01 +04:00
|
|
|
filter = filter.toLowerCase().split(" ");
|
|
|
|
} else {
|
2017-07-08 20:46:36 +03:00
|
|
|
isPassFunc = this.isPassRegex;
|
2013-12-11 00:54:01 +04:00
|
|
|
var r = filter.match(/^\/(.*)\/(i?)$/);
|
|
|
|
try {
|
|
|
|
filter = RegExp(r[1], r[2]);
|
2016-12-31 05:47:25 +03:00
|
|
|
} catch (e) { // Incomplete or bad RegExp - always no match
|
2013-12-11 00:54:01 +04:00
|
|
|
isPassFunc = function() {
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2017-07-19 22:32:48 +03:00
|
|
|
return [isPassFunc, filter]
|
2017-07-08 20:46:36 +03:00
|
|
|
},
|
2013-12-11 00:54:01 +04:00
|
|
|
|
2017-07-08 20:46:36 +03:00
|
|
|
filterElements(elements, filterText) {
|
|
|
|
let [isPassFunc, filter] = this.chooseFilter(filterText);
|
2013-12-11 00:54:01 +04:00
|
|
|
|
2017-07-08 20:46:36 +03:00
|
|
|
let needLowerCase = (isPassFunc === this.isPassText);
|
|
|
|
for (let element of elements) {
|
|
|
|
let subject = needLowerCase ? element.id.toLowerCase() : element.id;
|
|
|
|
element.hidden = !isPassFunc(subject, filter);
|
2013-12-11 00:54:01 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-07-08 20:46:36 +03:00
|
|
|
filterKeyedElements(keyedElements, filterText) {
|
2017-07-19 22:32:48 +03:00
|
|
|
let [isPassFunc, filter] = this.chooseFilter(filterText);
|
2017-07-08 20:46:36 +03:00
|
|
|
|
|
|
|
let needLowerCase = (isPassFunc === this.isPassText);
|
|
|
|
keyedElements.forEach((keyedElement) => {
|
|
|
|
let subject = needLowerCase ? keyedElement.key.id.toLowerCase() : keyedElement.key.id;
|
|
|
|
if (!isPassFunc(subject, filter)) { // If the keyedHistogram's name is not matched
|
|
|
|
let allElementHidden = true;
|
|
|
|
for (let element of keyedElement.datas) {
|
|
|
|
let subject = needLowerCase ? element.id.toLowerCase() : element.id;
|
|
|
|
let match = isPassFunc(subject, filter);
|
|
|
|
element.hidden = !match;
|
|
|
|
if (match) {
|
|
|
|
allElementHidden = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
keyedElement.key.hidden = allElementHidden;
|
|
|
|
} else { // If the keyedHistogram's name is matched
|
|
|
|
keyedElement.key.hidden = false;
|
|
|
|
for (let element of keyedElement.datas) {
|
|
|
|
element.hidden = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
searchHandler(e) {
|
2013-12-11 00:54:01 +04:00
|
|
|
if (this.idleTimeout) {
|
|
|
|
clearTimeout(this.idleTimeout);
|
|
|
|
}
|
2017-07-08 20:46:36 +03:00
|
|
|
this.idleTimeout = setTimeout(() => Search.search(e.target.value), FILTER_IDLE_TIMEOUT);
|
|
|
|
},
|
2013-12-11 00:54:01 +04:00
|
|
|
|
2017-07-08 20:46:36 +03:00
|
|
|
search(text) {
|
|
|
|
let selectedSection = document.querySelector(".data-section.active");
|
|
|
|
if (selectedSection.id === "histograms-section") {
|
|
|
|
let histograms = selectedSection.getElementsByClassName("histogram");
|
|
|
|
this.filterElements(histograms, text);
|
|
|
|
} else if (selectedSection.id === "keyed-histograms-section") {
|
|
|
|
let keyedElements = [];
|
|
|
|
let keyedHistograms = selectedSection.getElementsByClassName("keyed-histogram");
|
|
|
|
for (let key of keyedHistograms) {
|
|
|
|
let datas = key.getElementsByClassName("histogram");
|
|
|
|
keyedElements.push({key, datas});
|
|
|
|
}
|
|
|
|
this.filterKeyedElements(keyedElements, text);
|
|
|
|
} else if (selectedSection.id === "keyed-scalars-section") {
|
|
|
|
let keyedElements = [];
|
|
|
|
let keyedScalars = selectedSection.getElementsByClassName("keyed-scalar");
|
|
|
|
for (let key of keyedScalars) {
|
|
|
|
let datas = key.querySelector("table").rows;
|
|
|
|
keyedElements.push({key, datas});
|
|
|
|
}
|
|
|
|
this.filterKeyedElements(keyedElements, text);
|
|
|
|
} else {
|
|
|
|
let tables = selectedSection.querySelectorAll("table");
|
|
|
|
for (let table of tables) {
|
|
|
|
this.filterElements(table.rows, text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
2012-11-09 00:36:06 +04:00
|
|
|
|
2013-10-11 21:13:31 +04:00
|
|
|
/*
|
|
|
|
* Helper function to render JS objects with white space between top level elements
|
|
|
|
* so that they look better in the browser
|
|
|
|
* @param aObject JavaScript object or array to render
|
|
|
|
* @return String
|
|
|
|
*/
|
|
|
|
function RenderObject(aObject) {
|
|
|
|
let output = "";
|
|
|
|
if (Array.isArray(aObject)) {
|
|
|
|
if (aObject.length == 0) {
|
|
|
|
return "[]";
|
|
|
|
}
|
|
|
|
output = "[" + JSON.stringify(aObject[0]);
|
|
|
|
for (let i = 1; i < aObject.length; i++) {
|
|
|
|
output += ", " + JSON.stringify(aObject[i]);
|
|
|
|
}
|
|
|
|
return output + "]";
|
|
|
|
}
|
|
|
|
let keys = Object.keys(aObject);
|
|
|
|
if (keys.length == 0) {
|
|
|
|
return "{}";
|
|
|
|
}
|
|
|
|
output = "{\"" + keys[0] + "\":\u00A0" + JSON.stringify(aObject[keys[0]]);
|
|
|
|
for (let i = 1; i < keys.length; i++) {
|
|
|
|
output += ", \"" + keys[i] + "\":\u00A0" + JSON.stringify(aObject[keys[i]]);
|
|
|
|
}
|
|
|
|
return output + "}";
|
2016-02-04 04:27:36 +03:00
|
|
|
}
|
2012-11-09 00:36:06 +04:00
|
|
|
|
2017-06-01 17:37:33 +03:00
|
|
|
var GenericSubsection = {
|
|
|
|
|
2017-06-12 19:52:17 +03:00
|
|
|
addSubSectionToSidebar(id, title) {
|
|
|
|
let category = document.querySelector("#categories > [value=" + id + "]");
|
2017-06-16 15:04:50 +03:00
|
|
|
category.classList.add("has-subsection");
|
2017-06-12 19:52:17 +03:00
|
|
|
let subCategory = document.createElement("div");
|
2017-06-16 15:04:50 +03:00
|
|
|
subCategory.classList.add("category-subsection");
|
|
|
|
subCategory.setAttribute("value", id + "-" + title);
|
|
|
|
subCategory.addEventListener("click", (ev) => {
|
|
|
|
let section = ev.target;
|
|
|
|
showSubSection(section);
|
|
|
|
});
|
2017-06-12 19:52:17 +03:00
|
|
|
subCategory.appendChild(document.createTextNode(title))
|
|
|
|
category.appendChild(subCategory);
|
|
|
|
},
|
|
|
|
|
|
|
|
render(data, dataDiv, sectionID) {
|
2017-06-01 17:37:33 +03:00
|
|
|
for (let [title, sectionData] of data) {
|
|
|
|
let hasData = sectionData.size > 0;
|
2017-06-12 19:52:17 +03:00
|
|
|
let s = this.renderSubsectionHeader(title, hasData, sectionID);
|
2017-06-16 15:04:50 +03:00
|
|
|
s.appendChild(this.renderSubsectionData(title, sectionData));
|
2017-06-01 17:37:33 +03:00
|
|
|
dataDiv.appendChild(s);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-06-12 19:52:17 +03:00
|
|
|
renderSubsectionHeader(title, hasData, sectionID) {
|
|
|
|
this.addSubSectionToSidebar(sectionID, title);
|
2017-06-01 17:37:33 +03:00
|
|
|
let section = document.createElement("section");
|
2017-06-16 15:04:50 +03:00
|
|
|
section.setAttribute("id", sectionID + "-" + title);
|
|
|
|
section.classList.add("data-subsection", "expanded");
|
2017-06-01 17:37:33 +03:00
|
|
|
if (hasData) {
|
|
|
|
section.classList.add("has-subdata");
|
|
|
|
}
|
|
|
|
return section;
|
|
|
|
},
|
|
|
|
|
2017-06-16 15:04:50 +03:00
|
|
|
renderSubsectionData(title, data) {
|
2017-06-01 17:37:33 +03:00
|
|
|
// Create data container
|
|
|
|
let dataDiv = document.createElement("div");
|
|
|
|
dataDiv.setAttribute("class", "subsection-data subdata");
|
|
|
|
// Instanciate the data
|
|
|
|
let table = GenericTable.render(data);
|
2017-06-16 15:04:50 +03:00
|
|
|
let caption = document.createElement("caption");
|
|
|
|
caption.textContent = title;
|
|
|
|
table.appendChild(caption);
|
2017-06-01 17:37:33 +03:00
|
|
|
dataDiv.appendChild(table);
|
|
|
|
|
|
|
|
return dataDiv;
|
|
|
|
},
|
|
|
|
|
2017-06-16 15:04:50 +03:00
|
|
|
deleteAllSubSections() {
|
|
|
|
let subsections = document.querySelectorAll(".category-subsection");
|
|
|
|
subsections.forEach((el) => {
|
|
|
|
el.parentElement.removeChild(el);
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2017-06-01 17:37:33 +03:00
|
|
|
}
|
|
|
|
|
2016-11-18 17:51:59 +03:00
|
|
|
var GenericTable = {
|
2017-05-31 15:38:11 +03:00
|
|
|
|
|
|
|
defaultHeadings: [
|
|
|
|
bundle.GetStringFromName("keysHeader"),
|
|
|
|
bundle.GetStringFromName("valuesHeader")
|
|
|
|
],
|
|
|
|
|
2016-11-18 17:51:59 +03:00
|
|
|
/**
|
|
|
|
* Returns a n-column table.
|
|
|
|
* @param rows An array of arrays, each containing data to render
|
|
|
|
* for one row.
|
|
|
|
* @param headings The column header strings.
|
|
|
|
*/
|
2017-05-31 15:38:11 +03:00
|
|
|
render(rows, headings = this.defaultHeadings) {
|
2016-11-18 17:51:59 +03:00
|
|
|
let table = document.createElement("table");
|
|
|
|
this.renderHeader(table, headings);
|
|
|
|
this.renderBody(table, rows);
|
|
|
|
return table;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create the table header.
|
|
|
|
* Tabs & newlines added to cells to make it easier to copy-paste.
|
|
|
|
*
|
|
|
|
* @param table Table element
|
|
|
|
* @param headings Array of column header strings.
|
|
|
|
*/
|
2016-12-30 02:34:54 +03:00
|
|
|
renderHeader(table, headings) {
|
2016-11-18 17:51:59 +03:00
|
|
|
let headerRow = document.createElement("tr");
|
|
|
|
table.appendChild(headerRow);
|
|
|
|
|
|
|
|
for (let i = 0; i < headings.length; ++i) {
|
|
|
|
let suffix = (i == (headings.length - 1)) ? "\n" : "\t";
|
|
|
|
let column = document.createElement("th");
|
|
|
|
column.appendChild(document.createTextNode(headings[i] + suffix));
|
|
|
|
headerRow.appendChild(column);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create the table body
|
|
|
|
* Tabs & newlines added to cells to make it easier to copy-paste.
|
|
|
|
*
|
|
|
|
* @param table Table element
|
|
|
|
* @param rows An array of arrays, each containing data to render
|
|
|
|
* for one row.
|
|
|
|
*/
|
2016-12-30 02:34:54 +03:00
|
|
|
renderBody(table, rows) {
|
2016-11-18 17:51:59 +03:00
|
|
|
for (let row of rows) {
|
|
|
|
row = row.map(value => {
|
|
|
|
// use .valueOf() to unbox Number, String, etc. objects
|
|
|
|
if (value &&
|
|
|
|
(typeof value == "object") &&
|
|
|
|
(typeof value.valueOf() == "object")) {
|
|
|
|
return RenderObject(value);
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
});
|
|
|
|
|
|
|
|
let newRow = document.createElement("tr");
|
2017-07-08 20:46:36 +03:00
|
|
|
newRow.id = row[0];
|
2016-11-18 17:51:59 +03:00
|
|
|
table.appendChild(newRow);
|
|
|
|
|
|
|
|
for (let i = 0; i < row.length; ++i) {
|
|
|
|
let suffix = (i == (row.length - 1)) ? "\n" : "\t";
|
|
|
|
let field = document.createElement("td");
|
|
|
|
field.appendChild(document.createTextNode(row[i] + suffix));
|
|
|
|
newRow.appendChild(field);
|
|
|
|
}
|
|
|
|
}
|
2017-05-31 15:38:11 +03:00
|
|
|
},
|
2016-11-18 17:51:59 +03:00
|
|
|
};
|
|
|
|
|
2015-09-15 21:19:45 +03:00
|
|
|
var KeyedHistogram = {
|
2016-12-30 02:34:54 +03:00
|
|
|
render(parent, id, keyedHistogram) {
|
2014-10-31 23:47:13 +03:00
|
|
|
let outerDiv = document.createElement("div");
|
|
|
|
outerDiv.className = "keyed-histogram";
|
|
|
|
outerDiv.id = id;
|
|
|
|
|
|
|
|
let divTitle = document.createElement("div");
|
|
|
|
divTitle.className = "keyed-histogram-title";
|
|
|
|
divTitle.appendChild(document.createTextNode(id));
|
|
|
|
outerDiv.appendChild(divTitle);
|
|
|
|
|
2016-08-03 09:23:10 +03:00
|
|
|
for (let [name, hgram] of Object.entries(keyedHistogram)) {
|
2014-10-31 23:47:13 +03:00
|
|
|
Histogram.render(outerDiv, name, hgram);
|
|
|
|
}
|
|
|
|
|
|
|
|
parent.appendChild(outerDiv);
|
|
|
|
return outerDiv;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2015-09-15 21:19:45 +03:00
|
|
|
var AddonDetails = {
|
2013-10-11 21:13:31 +04:00
|
|
|
tableIDTitle: bundle.GetStringFromName("addonTableID"),
|
|
|
|
tableDetailsTitle: bundle.GetStringFromName("addonTableDetails"),
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render the addon details section as a series of headers followed by key/value tables
|
2015-05-13 22:57:06 +03:00
|
|
|
* @param aPing A ping object to render the data from.
|
2013-10-11 21:13:31 +04:00
|
|
|
*/
|
2015-05-13 22:57:06 +03:00
|
|
|
render: function AddonDetails_render(aPing) {
|
2013-10-11 21:13:31 +04:00
|
|
|
let addonSection = document.getElementById("addon-details");
|
2015-05-13 22:57:06 +03:00
|
|
|
removeAllChildNodes(addonSection);
|
|
|
|
let addonDetails = aPing.payload.addonDetails;
|
2015-05-20 16:22:38 +03:00
|
|
|
const hasData = addonDetails && Object.keys(addonDetails).length > 0;
|
2015-05-13 22:57:06 +03:00
|
|
|
setHasData("addon-details-section", hasData);
|
|
|
|
if (!hasData) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let provider in addonDetails) {
|
2013-10-11 21:13:31 +04:00
|
|
|
let providerSection = document.createElement("h2");
|
|
|
|
let titleText = bundle.formatStringFromName("addonProvider", [provider], 1);
|
|
|
|
providerSection.appendChild(document.createTextNode(titleText));
|
|
|
|
addonSection.appendChild(providerSection);
|
2017-05-31 17:24:08 +03:00
|
|
|
|
|
|
|
let headingStrings = [this.tableIDTitle, this.tableDetailsTitle ]
|
|
|
|
let table = GenericTable.render(explodeObject(addonDetails[provider]),
|
|
|
|
headingStrings);
|
|
|
|
addonSection.appendChild(table);
|
2013-10-11 21:13:31 +04:00
|
|
|
}
|
2017-05-31 15:38:11 +03:00
|
|
|
},
|
2013-10-11 21:13:31 +04:00
|
|
|
};
|
|
|
|
|
2016-06-10 12:48:55 +03:00
|
|
|
var Scalars = {
|
|
|
|
/**
|
|
|
|
* Render the scalar data - if present - from the payload in a simple key-value table.
|
|
|
|
* @param aPayload A payload object to render the data from.
|
|
|
|
*/
|
2016-12-30 02:34:54 +03:00
|
|
|
render(aPayload) {
|
2016-06-10 12:48:55 +03:00
|
|
|
let scalarsSection = document.getElementById("scalars");
|
|
|
|
removeAllChildNodes(scalarsSection);
|
|
|
|
|
2017-07-08 20:46:36 +03:00
|
|
|
let processesSelect = document.getElementById("processes");
|
2017-01-10 11:06:00 +03:00
|
|
|
let selectedProcess = processesSelect.selectedOptions.item(0).getAttribute("value");
|
|
|
|
|
|
|
|
if (!aPayload.processes ||
|
|
|
|
!selectedProcess ||
|
|
|
|
!(selectedProcess in aPayload.processes)) {
|
2016-07-05 03:35:00 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-01-10 11:06:00 +03:00
|
|
|
let scalars = aPayload.processes[selectedProcess].scalars;
|
2016-06-10 12:48:55 +03:00
|
|
|
const hasData = scalars && Object.keys(scalars).length > 0;
|
2017-01-10 11:06:00 +03:00
|
|
|
setHasData("scalars-section", hasData || processesSelect.options.length);
|
2016-06-10 12:48:55 +03:00
|
|
|
if (!hasData) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-05-31 17:24:08 +03:00
|
|
|
const headings = [
|
|
|
|
"namesHeader",
|
|
|
|
"valuesHeader",
|
|
|
|
].map(h => bundle.GetStringFromName(h));
|
|
|
|
const table = GenericTable.render(explodeObject(scalars), headings);
|
2016-06-10 12:48:55 +03:00
|
|
|
scalarsSection.appendChild(table);
|
2017-05-31 15:38:11 +03:00
|
|
|
},
|
2016-06-10 12:48:55 +03:00
|
|
|
};
|
|
|
|
|
2016-10-07 10:35:00 +03:00
|
|
|
var KeyedScalars = {
|
|
|
|
/**
|
|
|
|
* Render the keyed scalar data - if present - from the payload in a simple key-value table.
|
|
|
|
* @param aPayload A payload object to render the data from.
|
|
|
|
*/
|
2016-12-30 02:34:54 +03:00
|
|
|
render(aPayload) {
|
2016-10-07 10:35:00 +03:00
|
|
|
let scalarsSection = document.getElementById("keyed-scalars");
|
|
|
|
removeAllChildNodes(scalarsSection);
|
|
|
|
|
2017-07-08 20:46:36 +03:00
|
|
|
let processesSelect = document.getElementById("processes");
|
2017-01-10 11:06:00 +03:00
|
|
|
let selectedProcess = processesSelect.selectedOptions.item(0).getAttribute("value");
|
|
|
|
|
|
|
|
if (!aPayload.processes ||
|
|
|
|
!selectedProcess ||
|
|
|
|
!(selectedProcess in aPayload.processes)) {
|
2016-10-07 10:35:00 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-01-10 11:06:00 +03:00
|
|
|
let keyedScalars = aPayload.processes[selectedProcess].keyedScalars;
|
2016-10-07 10:35:00 +03:00
|
|
|
const hasData = keyedScalars && Object.keys(keyedScalars).length > 0;
|
2017-01-10 11:06:00 +03:00
|
|
|
setHasData("keyed-scalars-section", hasData || processesSelect.options.length);
|
2016-10-07 10:35:00 +03:00
|
|
|
if (!hasData) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-05-31 17:24:08 +03:00
|
|
|
const headings = [
|
|
|
|
"namesHeader",
|
|
|
|
"valuesHeader",
|
|
|
|
].map(h => bundle.GetStringFromName(h));
|
2016-10-07 10:35:00 +03:00
|
|
|
for (let scalar in keyedScalars) {
|
|
|
|
// Add the name of the scalar.
|
2017-07-08 20:46:36 +03:00
|
|
|
let container = document.createElement("div");
|
|
|
|
container.classList.add("keyed-scalar");
|
|
|
|
container.id = scalar;
|
2016-10-07 10:35:00 +03:00
|
|
|
let scalarNameSection = document.createElement("h2");
|
|
|
|
scalarNameSection.appendChild(document.createTextNode(scalar));
|
2017-07-08 20:46:36 +03:00
|
|
|
container.appendChild(scalarNameSection);
|
2016-10-07 10:35:00 +03:00
|
|
|
// Populate the section with the key-value pairs from the scalar.
|
2017-05-31 17:24:08 +03:00
|
|
|
const table = GenericTable.render(explodeObject(keyedScalars[scalar]), headings);
|
2017-07-08 20:46:36 +03:00
|
|
|
container.appendChild(table);
|
|
|
|
scalarsSection.appendChild(container);
|
2016-10-07 10:35:00 +03:00
|
|
|
}
|
2017-05-31 15:38:11 +03:00
|
|
|
},
|
2016-10-07 10:35:00 +03:00
|
|
|
};
|
|
|
|
|
2016-11-18 17:51:59 +03:00
|
|
|
var Events = {
|
|
|
|
/**
|
|
|
|
* Render the event data - if present - from the payload in a simple table.
|
|
|
|
* @param aPayload A payload object to render the data from.
|
|
|
|
*/
|
2016-12-30 02:34:54 +03:00
|
|
|
render(aPayload) {
|
2016-11-18 17:51:59 +03:00
|
|
|
let eventsSection = document.getElementById("events");
|
|
|
|
removeAllChildNodes(eventsSection);
|
|
|
|
|
|
|
|
if (!aPayload.processes || !aPayload.processes.parent) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-07-08 20:46:36 +03:00
|
|
|
let processesSelect = document.getElementById("processes");
|
2017-03-06 18:12:52 +03:00
|
|
|
let selectedProcess = processesSelect.selectedOptions.item(0).getAttribute("value");
|
|
|
|
|
|
|
|
if (!aPayload.processes ||
|
|
|
|
!selectedProcess ||
|
|
|
|
!(selectedProcess in aPayload.processes)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let events = aPayload.processes[selectedProcess].events;
|
2016-11-18 17:51:59 +03:00
|
|
|
const hasData = events && Object.keys(events).length > 0;
|
|
|
|
setHasData("events-section", hasData);
|
|
|
|
if (!hasData) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const headings = [
|
|
|
|
"timestampHeader",
|
|
|
|
"categoryHeader",
|
|
|
|
"methodHeader",
|
|
|
|
"objectHeader",
|
|
|
|
"valuesHeader",
|
|
|
|
"extraHeader",
|
|
|
|
].map(h => bundle.GetStringFromName(h));
|
|
|
|
|
|
|
|
const table = GenericTable.render(events, headings);
|
|
|
|
eventsSection.appendChild(table);
|
2017-05-31 15:38:11 +03:00
|
|
|
},
|
2016-11-18 17:51:59 +03:00
|
|
|
};
|
|
|
|
|
2012-11-09 00:36:06 +04:00
|
|
|
/**
|
2013-12-11 00:54:01 +04:00
|
|
|
* Helper function for showing either the toggle element or "No data collected" message for a section
|
2012-11-09 00:36:06 +04:00
|
|
|
*
|
|
|
|
* @param aSectionID ID of the section element that needs to be changed
|
2013-12-11 00:54:01 +04:00
|
|
|
* @param aHasData true (default) indicates that toggle should be displayed
|
2012-11-09 00:36:06 +04:00
|
|
|
*/
|
2013-12-11 00:54:01 +04:00
|
|
|
function setHasData(aSectionID, aHasData) {
|
2012-11-09 00:36:06 +04:00
|
|
|
let sectionElement = document.getElementById(aSectionID);
|
2013-12-11 00:54:01 +04:00
|
|
|
sectionElement.classList[aHasData ? "add" : "remove"]("has-data");
|
2017-06-06 16:25:15 +03:00
|
|
|
|
|
|
|
// Display or Hide the section in the sidebar
|
|
|
|
let sectionCategory = document.querySelector(".category[value=" + aSectionID + "]");
|
|
|
|
sectionCategory.classList[aHasData ? "add" : "remove"]("has-data");
|
2012-11-09 00:36:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper function that expands and collapses sections +
|
|
|
|
* changes caption on the toggle text
|
|
|
|
*/
|
|
|
|
function toggleSection(aEvent) {
|
|
|
|
let parentElement = aEvent.target.parentElement;
|
2016-01-17 10:40:45 +03:00
|
|
|
if (!parentElement.classList.contains("has-data") &&
|
|
|
|
!parentElement.classList.contains("has-subdata")) {
|
2013-12-11 00:54:01 +04:00
|
|
|
return; // nothing to toggle
|
|
|
|
}
|
|
|
|
|
|
|
|
parentElement.classList.toggle("expanded");
|
2012-11-09 00:36:06 +04:00
|
|
|
}
|
|
|
|
|
2012-11-27 03:21:04 +04:00
|
|
|
/**
|
|
|
|
* Sets the text of the page header based on a config pref + bundle strings
|
|
|
|
*/
|
2016-12-31 05:47:25 +03:00
|
|
|
function setupPageHeader() {
|
2015-05-13 22:57:05 +03:00
|
|
|
let serverOwner = Preferences.get(PREF_TELEMETRY_SERVER_OWNER, "Mozilla");
|
2012-11-27 03:21:04 +04:00
|
|
|
let brandName = brandBundle.GetStringFromName("brandFullName");
|
|
|
|
let subtitleText = bundle.formatStringFromName(
|
|
|
|
"pageSubtitle", [serverOwner, brandName], 2);
|
|
|
|
|
|
|
|
let subtitleElement = document.getElementById("page-subtitle");
|
|
|
|
subtitleElement.appendChild(document.createTextNode(subtitleText));
|
|
|
|
}
|
2012-11-09 00:36:06 +04:00
|
|
|
|
2017-07-08 20:46:36 +03:00
|
|
|
function displayProcessesSelector(selectedSection) {
|
|
|
|
let whitelist = [
|
|
|
|
"scalars-section",
|
|
|
|
"keyed-scalars-section",
|
|
|
|
"histograms-section",
|
|
|
|
"keyed-histograms-section",
|
|
|
|
"events-section"
|
|
|
|
];
|
|
|
|
let processes = document.getElementById("processes");
|
|
|
|
processes.hidden = !whitelist.includes(selectedSection);
|
|
|
|
}
|
|
|
|
|
|
|
|
function displaySearch(selectedSection) {
|
|
|
|
let blacklist = [
|
|
|
|
"home",
|
|
|
|
];
|
|
|
|
// TODO: Implement global search for the Home section
|
|
|
|
let search = document.getElementById("search");
|
|
|
|
search.hidden = blacklist.includes(selectedSection);
|
|
|
|
}
|
|
|
|
|
2017-06-06 16:25:15 +03:00
|
|
|
/**
|
|
|
|
* Change the section displayed
|
|
|
|
*/
|
|
|
|
function show(selected) {
|
2017-06-16 15:04:50 +03:00
|
|
|
let current_button = document.querySelector(".category.selected");
|
|
|
|
current_button.classList.remove("selected");
|
|
|
|
selected.classList.add("selected");
|
|
|
|
// Hack because subsection text appear selected. See Bug 1375114.
|
|
|
|
document.getSelection().empty();
|
|
|
|
|
2017-07-08 20:46:36 +03:00
|
|
|
let selectedValue = selected.getAttribute("value");
|
2017-06-16 15:04:50 +03:00
|
|
|
let current_section = document.querySelector(".active");
|
2017-07-08 20:46:36 +03:00
|
|
|
let selected_section = document.getElementById(selectedValue);
|
2017-06-16 15:04:50 +03:00
|
|
|
if (current_section == selected_section)
|
|
|
|
return;
|
|
|
|
current_section.classList.remove("active");
|
|
|
|
current_section.hidden = true;
|
|
|
|
selected_section.classList.add("active");
|
|
|
|
selected_section.hidden = false;
|
|
|
|
|
2017-07-08 20:46:36 +03:00
|
|
|
let title = selected.querySelector(".category-name").textContent.trim();
|
2017-06-16 15:04:50 +03:00
|
|
|
document.getElementById("sectionTitle").textContent = title;
|
2017-07-08 20:46:36 +03:00
|
|
|
|
|
|
|
let search = document.getElementById("search");
|
|
|
|
let placeholder = bundle.formatStringFromName("filterPlaceholder", [ title ], 1);
|
|
|
|
search.setAttribute("placeholder", placeholder);
|
|
|
|
displayProcessesSelector(selectedValue);
|
|
|
|
displaySearch(selectedValue);
|
2017-06-16 15:04:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function showSubSection(selected) {
|
|
|
|
let current_selection = document.querySelector(".category-subsection.selected");
|
|
|
|
if (current_selection)
|
|
|
|
current_selection.classList.remove("selected");
|
|
|
|
selected.classList.add("selected");
|
|
|
|
|
|
|
|
let section = document.getElementById(selected.getAttribute("value"));
|
|
|
|
section.parentElement.childNodes.forEach((element) => {
|
|
|
|
element.classList.remove("expanded");
|
|
|
|
}, this);
|
|
|
|
section.classList.add("expanded");
|
|
|
|
|
|
|
|
let title = selected.parentElement.querySelector(".category-name").textContent;
|
|
|
|
document.getElementById("sectionTitle").textContent = title + " - " + selected.textContent;
|
|
|
|
document.getSelection().empty(); // prevent subsection text selection
|
2017-06-06 16:25:15 +03:00
|
|
|
}
|
|
|
|
|
2012-11-09 00:36:06 +04:00
|
|
|
/**
|
|
|
|
* Initializes load/unload, pref change and mouse-click listeners
|
|
|
|
*/
|
|
|
|
function setupListeners() {
|
2015-05-13 22:57:05 +03:00
|
|
|
Settings.attachObservers();
|
2015-05-13 22:57:05 +03:00
|
|
|
PingPicker.attachObservers();
|
2012-11-09 00:36:06 +04:00
|
|
|
|
2017-06-06 16:25:15 +03:00
|
|
|
let menu = document.getElementById("categories");
|
|
|
|
menu.addEventListener("click", (e) => {
|
|
|
|
if (e.target && e.target.parentNode == menu) {
|
|
|
|
show(e.target)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-07-08 20:46:36 +03:00
|
|
|
let search = document.getElementById("search");
|
|
|
|
search.addEventListener("input", Search.searchHandler);
|
|
|
|
|
2012-11-09 00:36:06 +04:00
|
|
|
// Clean up observers when page is closed
|
|
|
|
window.addEventListener("unload",
|
2017-01-25 09:01:52 +03:00
|
|
|
function(aEvent) {
|
2015-05-13 22:57:05 +03:00
|
|
|
Settings.detachObservers();
|
2017-01-25 09:01:52 +03:00
|
|
|
}, {once: true});
|
2015-05-11 20:40:23 +03:00
|
|
|
|
2015-05-11 23:06:21 +03:00
|
|
|
document.getElementById("chrome-hangs-fetch-symbols").addEventListener("click",
|
2016-11-12 02:22:34 +03:00
|
|
|
function() {
|
2015-05-13 22:57:05 +03:00
|
|
|
if (!gPingData) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let hangs = gPingData.payload.chromeHangs;
|
2013-01-20 04:26:05 +04:00
|
|
|
let req = new SymbolicationRequest("chrome-hangs",
|
|
|
|
ChromeHangs.renderHangHeader,
|
2015-10-15 20:51:23 +03:00
|
|
|
hangs.memoryMap,
|
|
|
|
hangs.stacks,
|
|
|
|
hangs.durations);
|
2013-01-20 04:26:05 +04:00
|
|
|
req.fetchSymbols();
|
2017-01-17 13:50:25 +03:00
|
|
|
});
|
2012-11-09 00:36:06 +04:00
|
|
|
|
2013-01-17 19:25:44 +04:00
|
|
|
document.getElementById("chrome-hangs-hide-symbols").addEventListener("click",
|
2016-11-12 02:22:34 +03:00
|
|
|
function() {
|
2015-05-13 22:57:05 +03:00
|
|
|
if (!gPingData) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ChromeHangs.render(gPingData);
|
2017-01-17 13:50:25 +03:00
|
|
|
});
|
2012-11-09 00:36:06 +04:00
|
|
|
|
2016-11-17 22:52:53 +03:00
|
|
|
document.getElementById("captured-stacks-fetch-symbols").addEventListener("click",
|
|
|
|
function() {
|
|
|
|
if (!gPingData) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let capturedStacks = gPingData.payload.processes.parent.capturedStacks;
|
|
|
|
let req = new SymbolicationRequest("captured-stacks",
|
2017-01-30 20:49:04 +03:00
|
|
|
CapturedStacks.renderCaptureHeader,
|
2016-11-17 22:52:53 +03:00
|
|
|
capturedStacks.memoryMap,
|
|
|
|
capturedStacks.stacks,
|
2017-01-30 20:49:04 +03:00
|
|
|
capturedStacks.captures);
|
2016-11-17 22:52:53 +03:00
|
|
|
req.fetchSymbols();
|
2017-01-17 13:50:25 +03:00
|
|
|
});
|
2016-11-17 22:52:53 +03:00
|
|
|
|
|
|
|
document.getElementById("captured-stacks-hide-symbols").addEventListener("click",
|
|
|
|
function() {
|
2017-01-30 20:49:04 +03:00
|
|
|
if (gPingData) {
|
|
|
|
CapturedStacks.render(gPingData.payload);
|
2016-11-17 22:52:53 +03:00
|
|
|
}
|
2017-01-17 13:50:25 +03:00
|
|
|
});
|
2016-11-17 22:52:53 +03:00
|
|
|
|
2013-01-20 04:26:05 +04:00
|
|
|
document.getElementById("late-writes-fetch-symbols").addEventListener("click",
|
2016-11-12 02:22:34 +03:00
|
|
|
function() {
|
2015-05-13 22:57:05 +03:00
|
|
|
if (!gPingData) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let lateWrites = gPingData.payload.lateWrites;
|
2013-02-07 01:41:30 +04:00
|
|
|
let req = new SymbolicationRequest("late-writes",
|
|
|
|
LateWritesSingleton.renderHeader,
|
2013-01-20 04:26:05 +04:00
|
|
|
lateWrites.memoryMap,
|
|
|
|
lateWrites.stacks);
|
|
|
|
req.fetchSymbols();
|
2017-01-17 13:50:25 +03:00
|
|
|
});
|
2013-01-20 04:26:05 +04:00
|
|
|
|
|
|
|
document.getElementById("late-writes-hide-symbols").addEventListener("click",
|
2016-11-12 02:22:34 +03:00
|
|
|
function() {
|
2015-05-13 22:57:05 +03:00
|
|
|
if (!gPingData) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
LateWritesSingleton.renderLateWrites(gPingData.payload.lateWrites);
|
2017-01-17 13:50:25 +03:00
|
|
|
});
|
2013-01-20 04:26:05 +04:00
|
|
|
|
2012-11-09 00:36:06 +04:00
|
|
|
// Clicking on the section name will toggle its state
|
|
|
|
let sectionHeaders = document.getElementsByClassName("section-name");
|
|
|
|
for (let sectionHeader of sectionHeaders) {
|
2017-01-17 13:50:25 +03:00
|
|
|
sectionHeader.addEventListener("click", toggleSection);
|
2012-11-09 00:36:06 +04:00
|
|
|
}
|
|
|
|
|
2013-12-11 00:54:01 +04:00
|
|
|
// Clicking on the "toggle" text will also toggle section's state
|
2012-11-09 00:36:06 +04:00
|
|
|
let toggleLinks = document.getElementsByClassName("toggle-caption");
|
|
|
|
for (let toggleLink of toggleLinks) {
|
2017-01-17 13:50:25 +03:00
|
|
|
toggleLink.addEventListener("click", toggleSection);
|
2012-11-09 00:36:06 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onLoad() {
|
|
|
|
window.removeEventListener("load", onLoad);
|
|
|
|
|
2012-11-27 03:21:04 +04:00
|
|
|
// Set the text in the page header
|
|
|
|
setupPageHeader();
|
|
|
|
|
2012-11-09 00:36:06 +04:00
|
|
|
// Set up event listeners
|
|
|
|
setupListeners();
|
|
|
|
|
2015-05-13 22:57:05 +03:00
|
|
|
// Render settings.
|
|
|
|
Settings.render();
|
|
|
|
|
2013-12-11 00:54:01 +04:00
|
|
|
// Restore sections states
|
2017-07-24 21:16:29 +03:00
|
|
|
// TODO
|
2016-01-06 17:54:30 +03:00
|
|
|
|
|
|
|
// Update ping data when async Telemetry init is finished.
|
|
|
|
Telemetry.asyncFetchTelemetryData(() => PingPicker.update());
|
2013-12-11 00:54:01 +04:00
|
|
|
}
|
2013-01-08 18:04:37 +04:00
|
|
|
|
2015-09-15 21:19:45 +03:00
|
|
|
var LateWritesSingleton = {
|
2013-02-07 01:41:30 +04:00
|
|
|
renderHeader: function LateWritesSingleton_renderHeader(aIndex) {
|
|
|
|
StackRenderer.renderHeader("late-writes", [aIndex + 1]);
|
|
|
|
},
|
|
|
|
|
2013-01-08 18:04:37 +04:00
|
|
|
renderLateWrites: function LateWritesSingleton_renderLateWrites(lateWrites) {
|
2015-05-20 16:22:38 +03:00
|
|
|
setHasData("late-writes-section", !!lateWrites);
|
|
|
|
if (!lateWrites) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-01-08 18:04:37 +04:00
|
|
|
let stacks = lateWrites.stacks;
|
|
|
|
let memoryMap = lateWrites.memoryMap;
|
2017-01-17 18:48:17 +03:00
|
|
|
StackRenderer.renderStacks("late-writes", stacks, memoryMap,
|
2013-02-07 01:41:30 +04:00
|
|
|
LateWritesSingleton.renderHeader);
|
2017-05-31 15:38:11 +03:00
|
|
|
},
|
2013-01-08 18:04:37 +04:00
|
|
|
};
|
2012-12-14 08:13:03 +04:00
|
|
|
|
2017-05-31 15:38:11 +03:00
|
|
|
var HistogramSection = {
|
|
|
|
render(aPayload) {
|
|
|
|
let hgramDiv = document.getElementById("histograms");
|
|
|
|
removeAllChildNodes(hgramDiv);
|
2013-06-26 17:45:45 +04:00
|
|
|
|
2017-05-31 15:38:11 +03:00
|
|
|
let histograms = aPayload.histograms;
|
2013-01-11 19:26:32 +04:00
|
|
|
|
2017-07-08 20:46:36 +03:00
|
|
|
let hgramsSelect = document.getElementById("processes");
|
2017-05-31 15:38:11 +03:00
|
|
|
let hgramsOption = hgramsSelect.selectedOptions.item(0);
|
|
|
|
let hgramsProcess = hgramsOption.getAttribute("value");
|
|
|
|
// "parent" histograms/keyedHistograms aren't under "parent". Fix that up.
|
|
|
|
if (hgramsProcess === "parent") {
|
|
|
|
hgramsProcess = "";
|
|
|
|
}
|
|
|
|
if (hgramsProcess &&
|
|
|
|
"processes" in aPayload &&
|
|
|
|
hgramsProcess in aPayload.processes) {
|
|
|
|
histograms = aPayload.processes[hgramsProcess].histograms;
|
|
|
|
}
|
2013-01-11 19:26:32 +04:00
|
|
|
|
2017-05-31 15:38:11 +03:00
|
|
|
let hasData = Object.keys(histograms).length > 0;
|
|
|
|
setHasData("histograms-section", hasData || hgramsSelect.options.length);
|
2013-01-11 19:26:32 +04:00
|
|
|
|
2017-05-31 15:38:11 +03:00
|
|
|
if (hasData) {
|
|
|
|
for (let [name, hgram] of Object.entries(histograms)) {
|
|
|
|
Histogram.render(hgramDiv, name, hgram, {unpacked: true});
|
|
|
|
}
|
2013-01-11 19:26:32 +04:00
|
|
|
|
2017-05-31 15:38:11 +03:00
|
|
|
setHasData("histograms-section", true);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
2013-01-11 19:26:32 +04:00
|
|
|
|
2017-05-31 15:38:11 +03:00
|
|
|
var KeyedHistogramSection = {
|
|
|
|
render(aPayload) {
|
|
|
|
let keyedDiv = document.getElementById("keyed-histograms");
|
|
|
|
removeAllChildNodes(keyedDiv);
|
|
|
|
|
|
|
|
let keyedHistograms = aPayload.keyedHistograms;
|
|
|
|
|
2017-07-08 20:46:36 +03:00
|
|
|
let keyedHgramsSelect = document.getElementById("processes");
|
2017-05-31 15:38:11 +03:00
|
|
|
let keyedHgramsOption = keyedHgramsSelect.selectedOptions.item(0);
|
|
|
|
let keyedHgramsProcess = keyedHgramsOption.getAttribute("value");
|
|
|
|
// "parent" histograms/keyedHistograms aren't under "parent". Fix that up.
|
|
|
|
if (keyedHgramsProcess === "parent") {
|
|
|
|
keyedHgramsProcess = "";
|
|
|
|
}
|
|
|
|
if (keyedHgramsProcess &&
|
|
|
|
"processes" in aPayload &&
|
|
|
|
keyedHgramsProcess in aPayload.processes) {
|
|
|
|
keyedHistograms = aPayload.processes[keyedHgramsProcess].keyedHistograms;
|
|
|
|
}
|
|
|
|
|
|
|
|
setHasData("keyed-histograms-section", keyedHgramsSelect.options.length);
|
|
|
|
if (keyedHistograms) {
|
|
|
|
let hasData = false;
|
|
|
|
for (let [id, keyed] of Object.entries(keyedHistograms)) {
|
|
|
|
if (Object.keys(keyed).length > 0) {
|
|
|
|
hasData = true;
|
|
|
|
KeyedHistogram.render(keyedDiv, id, keyed, {unpacked: true});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setHasData("keyed-histograms-section", hasData || keyedHgramsSelect.options.length);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
var SessionInformation = {
|
|
|
|
render(aPayload) {
|
|
|
|
let infoSection = document.getElementById("session-info");
|
|
|
|
removeAllChildNodes(infoSection);
|
|
|
|
|
|
|
|
let hasData = Object.keys(aPayload.info).length > 0;
|
|
|
|
setHasData("session-info-section", hasData);
|
|
|
|
|
|
|
|
if (hasData) {
|
|
|
|
const table = GenericTable.render(explodeObject(aPayload.info));
|
|
|
|
infoSection.appendChild(table);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
var SimpleMeasurements = {
|
|
|
|
render(aPayload) {
|
|
|
|
let simpleSection = document.getElementById("simple-measurements");
|
|
|
|
removeAllChildNodes(simpleSection);
|
|
|
|
|
|
|
|
let simpleMeasurements = this.sortStartupMilestones(aPayload.simpleMeasurements);
|
|
|
|
let hasData = Object.keys(simpleMeasurements).length > 0;
|
|
|
|
setHasData("simple-measurements-section", hasData);
|
|
|
|
|
|
|
|
if (hasData) {
|
|
|
|
const table = GenericTable.render(explodeObject(simpleMeasurements));
|
|
|
|
simpleSection.appendChild(table);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper function for sorting the startup milestones in the Simple Measurements
|
|
|
|
* section into temporal order.
|
|
|
|
*
|
|
|
|
* @param aSimpleMeasurements Telemetry ping's "Simple Measurements" data
|
|
|
|
* @return Sorted measurements
|
|
|
|
*/
|
|
|
|
sortStartupMilestones(aSimpleMeasurements) {
|
|
|
|
const telemetryTimestamps = TelemetryTimestamps.get();
|
|
|
|
let startupEvents = Services.startup.getStartupInfo();
|
|
|
|
delete startupEvents["process"];
|
|
|
|
|
|
|
|
function keyIsMilestone(k) {
|
|
|
|
return (k in startupEvents) || (k in telemetryTimestamps);
|
|
|
|
}
|
|
|
|
|
|
|
|
let sortedKeys = Object.keys(aSimpleMeasurements);
|
|
|
|
|
|
|
|
// Sort the measurements, with startup milestones at the front + ordered by time
|
|
|
|
sortedKeys.sort(function keyCompare(keyA, keyB) {
|
|
|
|
let isKeyAMilestone = keyIsMilestone(keyA);
|
|
|
|
let isKeyBMilestone = keyIsMilestone(keyB);
|
|
|
|
|
|
|
|
// First order by startup vs non-startup measurement
|
|
|
|
if (isKeyAMilestone && !isKeyBMilestone)
|
|
|
|
return -1;
|
|
|
|
if (!isKeyAMilestone && isKeyBMilestone)
|
|
|
|
return 1;
|
|
|
|
// Don't change order of non-startup measurements
|
|
|
|
if (!isKeyAMilestone && !isKeyBMilestone)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
// If both keys are startup measurements, order them by value
|
|
|
|
return aSimpleMeasurements[keyA] - aSimpleMeasurements[keyB];
|
|
|
|
});
|
|
|
|
|
|
|
|
// Insert measurements into a result object in sort-order
|
|
|
|
let result = {};
|
|
|
|
for (let key of sortedKeys) {
|
|
|
|
result[key] = aSimpleMeasurements[key];
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
},
|
2013-01-11 19:26:32 +04:00
|
|
|
}
|
|
|
|
|
2016-08-23 21:11:31 +03:00
|
|
|
function renderProcessList(ping, selectEl) {
|
|
|
|
removeAllChildNodes(selectEl);
|
|
|
|
let option = document.createElement("option");
|
|
|
|
option.appendChild(document.createTextNode("parent"));
|
2017-01-10 11:06:00 +03:00
|
|
|
option.setAttribute("value", "parent");
|
2016-08-23 21:11:31 +03:00
|
|
|
option.selected = true;
|
|
|
|
selectEl.appendChild(option);
|
|
|
|
|
|
|
|
if (!("processes" in ping.payload)) {
|
|
|
|
selectEl.disabled = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
selectEl.disabled = false;
|
|
|
|
|
|
|
|
for (let process of Object.keys(ping.payload.processes)) {
|
|
|
|
// TODO: parent hgrams are on root payload, not in payload.processes.parent
|
2017-01-10 11:06:00 +03:00
|
|
|
// When/If that gets moved, you'll need to remove this
|
2016-08-23 21:11:31 +03:00
|
|
|
if (process === "parent") {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
option = document.createElement("option");
|
|
|
|
option.appendChild(document.createTextNode(process));
|
|
|
|
option.setAttribute("value", process);
|
|
|
|
selectEl.appendChild(option);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-29 09:36:00 +03:00
|
|
|
function renderPayloadList(ping) {
|
|
|
|
// Rebuild the payload select with options:
|
|
|
|
// Parent Payload (selected)
|
|
|
|
// Child Payload 1..ping.payload.childPayloads.length
|
|
|
|
let listEl = document.getElementById("choose-payload");
|
|
|
|
removeAllChildNodes(listEl);
|
|
|
|
|
|
|
|
let option = document.createElement("option");
|
|
|
|
let text = bundle.GetStringFromName("parentPayload");
|
|
|
|
let content = document.createTextNode(text);
|
|
|
|
let payloadIndex = 0;
|
|
|
|
option.appendChild(content);
|
|
|
|
option.setAttribute("value", payloadIndex++);
|
|
|
|
option.selected = true;
|
|
|
|
listEl.appendChild(option);
|
|
|
|
|
|
|
|
if (!ping.payload.childPayloads) {
|
|
|
|
listEl.disabled = true;
|
|
|
|
return
|
|
|
|
}
|
|
|
|
listEl.disabled = false;
|
|
|
|
|
|
|
|
for (; payloadIndex <= ping.payload.childPayloads.length; ++payloadIndex) {
|
|
|
|
option = document.createElement("option");
|
2015-11-02 17:37:00 +03:00
|
|
|
text = bundle.formatStringFromName("childPayloadN", [payloadIndex], 1);
|
2015-10-29 09:36:00 +03:00
|
|
|
content = document.createTextNode(text);
|
|
|
|
option.appendChild(content);
|
|
|
|
option.setAttribute("value", payloadIndex);
|
|
|
|
listEl.appendChild(option);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-28 21:09:35 +03:00
|
|
|
function togglePingSections(isMainPing) {
|
|
|
|
// We always show the sections that are "common" to all pings.
|
2017-06-16 15:04:50 +03:00
|
|
|
let commonSections = new Set(["heading",
|
|
|
|
"home",
|
|
|
|
"general-data-section",
|
|
|
|
"environment-data-section",
|
|
|
|
"raw-ping-data-section"]);
|
2016-02-28 21:09:35 +03:00
|
|
|
|
2017-06-16 15:04:50 +03:00
|
|
|
let elements = document.querySelectorAll(".category");
|
2016-02-28 21:09:35 +03:00
|
|
|
for (let section of elements) {
|
2017-06-16 15:04:50 +03:00
|
|
|
if (commonSections.has(section.getAttribute("value"))) {
|
2016-02-28 21:09:35 +03:00
|
|
|
continue;
|
|
|
|
}
|
2017-06-16 15:04:50 +03:00
|
|
|
section.classList.toggle("has-data", isMainPing);
|
2016-02-28 21:09:35 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-29 09:36:00 +03:00
|
|
|
function displayPingData(ping, updatePayloadList = false) {
|
2015-05-13 22:57:05 +03:00
|
|
|
gPingData = ping;
|
2016-01-06 17:54:30 +03:00
|
|
|
// Render raw ping data.
|
2017-06-16 15:04:50 +03:00
|
|
|
RawPayload.render(ping);
|
2017-06-06 16:25:15 +03:00
|
|
|
|
2017-05-26 19:15:22 +03:00
|
|
|
try {
|
2017-06-16 15:04:50 +03:00
|
|
|
PingPicker.render();
|
2017-05-26 19:15:22 +03:00
|
|
|
displayRichPingData(ping, updatePayloadList);
|
|
|
|
} catch (err) {
|
2017-06-06 16:25:15 +03:00
|
|
|
console.log(err);
|
2017-05-26 19:15:22 +03:00
|
|
|
PingPicker._showRawPingData();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function displayRichPingData(ping, updatePayloadList) {
|
2016-08-23 21:11:31 +03:00
|
|
|
// Update the payload list and process lists
|
2015-10-29 09:36:00 +03:00
|
|
|
if (updatePayloadList) {
|
|
|
|
renderPayloadList(ping);
|
2017-07-08 20:46:36 +03:00
|
|
|
renderProcessList(ping, document.getElementById("processes"));
|
2015-10-29 09:36:00 +03:00
|
|
|
}
|
|
|
|
|
2015-05-13 22:57:05 +03:00
|
|
|
// Show general data.
|
|
|
|
GeneralData.render(ping);
|
|
|
|
|
2015-05-13 22:57:05 +03:00
|
|
|
// Show environment data.
|
|
|
|
EnvironmentData.render(ping);
|
|
|
|
|
2016-02-28 21:09:35 +03:00
|
|
|
// We only have special rendering code for the payloads from "main" pings.
|
|
|
|
// For any other pings we just render the raw JSON payload.
|
|
|
|
let isMainPing = (ping.type == "main" || ping.type == "saved-session");
|
|
|
|
togglePingSections(isMainPing);
|
|
|
|
|
|
|
|
if (!isMainPing) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-05-13 22:57:05 +03:00
|
|
|
// Show slow SQL stats
|
|
|
|
SlowSQL.render(ping);
|
|
|
|
|
2015-05-13 22:57:06 +03:00
|
|
|
// Render Addon details.
|
|
|
|
AddonDetails.render(ping);
|
|
|
|
|
2015-05-13 22:57:05 +03:00
|
|
|
let payload = ping.payload;
|
2015-11-17 18:07:25 +03:00
|
|
|
// Show basic session info gathered
|
2017-05-31 15:38:11 +03:00
|
|
|
SessionInformation.render(payload);
|
2015-05-13 22:57:05 +03:00
|
|
|
|
2016-06-10 12:48:55 +03:00
|
|
|
// Show scalar data.
|
|
|
|
Scalars.render(payload);
|
2016-10-07 10:35:00 +03:00
|
|
|
KeyedScalars.render(payload);
|
2016-06-10 12:48:55 +03:00
|
|
|
|
2015-05-13 22:57:05 +03:00
|
|
|
// Show histogram data
|
2017-05-31 15:38:11 +03:00
|
|
|
HistogramSection.render(payload);
|
2015-05-13 22:57:05 +03:00
|
|
|
|
|
|
|
// Show keyed histogram data
|
2017-05-31 15:38:11 +03:00
|
|
|
KeyedHistogramSection.render(payload);
|
2015-05-13 22:57:05 +03:00
|
|
|
|
2016-11-18 17:51:59 +03:00
|
|
|
// Show event data.
|
|
|
|
Events.render(payload);
|
2017-07-13 16:31:29 +03:00
|
|
|
|
|
|
|
// Show captured stacks.
|
|
|
|
CapturedStacks.render(payload);
|
|
|
|
|
|
|
|
LateWritesSingleton.renderLateWrites(payload.lateWrites);
|
|
|
|
|
|
|
|
// Select payload to render
|
|
|
|
let payloadSelect = document.getElementById("choose-payload");
|
|
|
|
let payloadOption = payloadSelect.selectedOptions.item(0);
|
|
|
|
let payloadIndex = payloadOption.getAttribute("value");
|
|
|
|
|
|
|
|
if (payloadIndex > 0) {
|
|
|
|
payload = ping.payload.childPayloads[payloadIndex - 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Show chrome hang stacks
|
|
|
|
ChromeHangs.render(payload);
|
|
|
|
|
|
|
|
// Show telemetry log.
|
|
|
|
TelLog.render(payload);
|
|
|
|
|
|
|
|
// Show thread hang stats
|
|
|
|
ThreadHangStats.render(payload);
|
|
|
|
|
|
|
|
// Show simple measurements
|
|
|
|
SimpleMeasurements.render(payload);
|
|
|
|
|
2012-11-09 00:36:06 +04:00
|
|
|
}
|
|
|
|
|
2017-01-17 13:50:25 +03:00
|
|
|
window.addEventListener("load", onLoad);
|