2012-09-19 00:30:41 +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/. */
|
2010-02-21 07:42:25 +03:00
|
|
|
|
2015-01-10 22:40:03 +03:00
|
|
|
"use strict";
|
|
|
|
|
2019-01-17 21:18:31 +03:00
|
|
|
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
|
|
|
const {Troubleshoot} = ChromeUtils.import("resource://gre/modules/Troubleshoot.jsm");
|
|
|
|
const {ResetProfile} = ChromeUtils.import("resource://gre/modules/ResetProfile.jsm");
|
|
|
|
const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
|
2014-04-23 07:19:12 +04:00
|
|
|
|
2018-01-30 02:20:18 +03:00
|
|
|
ChromeUtils.defineModuleGetter(this, "PluralForm",
|
|
|
|
"resource://gre/modules/PluralForm.jsm");
|
|
|
|
ChromeUtils.defineModuleGetter(this, "PlacesDBUtils",
|
|
|
|
"resource://gre/modules/PlacesDBUtils.jsm");
|
2010-02-21 07:42:25 +03:00
|
|
|
|
2012-09-19 00:30:41 +04:00
|
|
|
window.addEventListener("load", function onload(event) {
|
2014-05-05 18:31:26 +04:00
|
|
|
try {
|
2018-12-28 22:40:17 +03:00
|
|
|
window.removeEventListener("load", onload);
|
|
|
|
Troubleshoot.snapshot(async function(snapshot) {
|
|
|
|
for (let prop in snapshotFormatters)
|
|
|
|
await snapshotFormatters[prop](snapshot[prop]);
|
|
|
|
});
|
|
|
|
populateActionBox();
|
|
|
|
setupEventListeners();
|
2014-05-05 18:31:26 +04:00
|
|
|
} catch (e) {
|
|
|
|
Cu.reportError("stack of load error for about:support: " + e + ": " + e.stack);
|
|
|
|
}
|
2017-01-17 13:50:25 +03:00
|
|
|
});
|
2012-09-19 00:30:41 +04:00
|
|
|
|
2018-12-28 22:40:17 +03:00
|
|
|
// Fluent uses lisp-case IDs so this converts
|
|
|
|
// the SentenceCase info IDs to lisp-case.
|
2018-12-28 22:40:33 +03:00
|
|
|
const FLUENT_IDENT_REGEX = /^[a-zA-Z][a-zA-Z0-9_-]*$/;
|
2018-12-28 22:40:17 +03:00
|
|
|
function toFluentID(str) {
|
2018-12-28 22:40:33 +03:00
|
|
|
if (!FLUENT_IDENT_REGEX.test(str)) {
|
|
|
|
return null;
|
|
|
|
}
|
2018-12-28 22:40:17 +03:00
|
|
|
return str.toString().replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
|
|
}
|
|
|
|
|
2012-09-19 00:30:41 +04:00
|
|
|
// Each property in this object corresponds to a property in Troubleshoot.jsm's
|
|
|
|
// snapshot data. Each function is passed its property's corresponding data,
|
|
|
|
// and it's the function's job to update the page with it.
|
2015-09-15 21:19:45 +03:00
|
|
|
var snapshotFormatters = {
|
2012-09-19 00:30:41 +04:00
|
|
|
|
2018-12-28 22:40:17 +03:00
|
|
|
async application(data) {
|
2012-09-19 00:30:41 +04:00
|
|
|
$("application-box").textContent = data.name;
|
|
|
|
$("useragent-box").textContent = data.userAgent;
|
2016-04-28 23:57:25 +03:00
|
|
|
$("os-box").textContent = data.osVersion;
|
2019-06-03 22:06:21 +03:00
|
|
|
$("binary-box").textContent = Services.dirsvc.get("XREExeF", Ci.nsIFile).path;
|
2012-09-19 00:30:41 +04:00
|
|
|
$("supportLink").href = data.supportURL;
|
2015-07-12 04:37:54 +03:00
|
|
|
let version = AppConstants.MOZ_APP_VERSION_DISPLAY;
|
2012-09-19 00:30:41 +04:00
|
|
|
if (data.vendor)
|
|
|
|
version += " (" + data.vendor + ")";
|
|
|
|
$("version-box").textContent = version;
|
2015-01-28 05:01:26 +03:00
|
|
|
$("buildid-box").textContent = data.buildID;
|
|
|
|
if (data.updateChannel)
|
|
|
|
$("updatechannel-box").textContent = data.updateChannel;
|
2019-06-07 20:01:56 +03:00
|
|
|
if (AppConstants.MOZ_UPDATER) {
|
|
|
|
$("update-dir-box").textContent = Services.dirsvc.get("UpdRootD", Ci.nsIFile).path;
|
|
|
|
}
|
2017-09-21 16:31:12 +03:00
|
|
|
$("profile-dir-box").textContent = Services.dirsvc.get("ProfD", Ci.nsIFile).path;
|
2015-01-28 20:13:42 +03:00
|
|
|
|
2019-01-16 03:22:19 +03:00
|
|
|
try {
|
|
|
|
let launcherStatusTextId = "launcher-process-status-unknown";
|
|
|
|
switch (data.launcherProcessState) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
launcherStatusTextId = "launcher-process-status-" + data.launcherProcessState;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
document.l10n.setAttributes($("launcher-process-box"), launcherStatusTextId);
|
|
|
|
} catch (e) {}
|
|
|
|
|
2018-12-28 22:40:17 +03:00
|
|
|
let statusTextId = "multi-process-status-unknown";
|
2016-01-23 01:42:30 +03:00
|
|
|
|
|
|
|
// Whitelist of known values with string descriptions:
|
|
|
|
switch (data.autoStartStatus) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
case 4:
|
|
|
|
case 6:
|
|
|
|
case 7:
|
2016-04-06 20:30:46 +03:00
|
|
|
case 8:
|
2018-12-28 22:40:17 +03:00
|
|
|
statusTextId = "multi-process-status-" + data.autoStartStatus;
|
2016-05-26 00:51:48 +03:00
|
|
|
break;
|
2016-01-23 01:42:30 +03:00
|
|
|
}
|
|
|
|
|
2018-12-28 22:40:17 +03:00
|
|
|
document.l10n.setAttributes($("multiprocess-box-process-count"),
|
|
|
|
"multi-process-windows",
|
|
|
|
{
|
|
|
|
remoteWindows: data.numRemoteWindows,
|
|
|
|
totalWindows: data.numTotalWindows,
|
|
|
|
});
|
|
|
|
document.l10n.setAttributes($("multiprocess-box-status"), statusTextId);
|
2015-06-27 00:21:46 +03:00
|
|
|
|
2018-03-02 21:28:14 +03:00
|
|
|
if (Services.policies) {
|
2018-12-28 22:40:20 +03:00
|
|
|
let policiesStrId = "";
|
2018-09-22 18:19:08 +03:00
|
|
|
let aboutPolicies = "about:policies";
|
2018-03-02 21:28:14 +03:00
|
|
|
switch (data.policiesStatus) {
|
|
|
|
case Services.policies.INACTIVE:
|
2018-12-28 22:40:20 +03:00
|
|
|
policiesStrId = "policies-inactive";
|
2018-03-02 21:28:14 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Services.policies.ACTIVE:
|
2018-12-28 22:40:20 +03:00
|
|
|
policiesStrId = "policies-active";
|
2018-09-22 18:19:08 +03:00
|
|
|
aboutPolicies += "#active";
|
2018-03-02 21:28:14 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2018-12-28 22:40:20 +03:00
|
|
|
policiesStrId = "policies-error";
|
2018-09-22 18:19:08 +03:00
|
|
|
aboutPolicies += "#errors";
|
2018-03-02 21:28:14 +03:00
|
|
|
break;
|
|
|
|
}
|
2018-06-25 17:15:16 +03:00
|
|
|
|
2018-07-02 10:25:31 +03:00
|
|
|
if (data.policiesStatus != Services.policies.INACTIVE) {
|
2018-12-28 22:40:20 +03:00
|
|
|
let activePolicies = $.new("a", null, null, {
|
|
|
|
href: aboutPolicies,
|
|
|
|
});
|
2018-12-28 22:40:33 +03:00
|
|
|
document.l10n.setAttributes(activePolicies, policiesStrId);
|
2018-06-25 17:15:16 +03:00
|
|
|
$("policies-status").appendChild(activePolicies);
|
|
|
|
} else {
|
2018-12-28 22:40:20 +03:00
|
|
|
document.l10n.setAttributes($("policies-status"), policiesStrId);
|
2018-06-25 17:15:16 +03:00
|
|
|
}
|
2018-03-02 21:28:14 +03:00
|
|
|
} else {
|
|
|
|
$("policies-status-row").hidden = true;
|
|
|
|
}
|
|
|
|
|
2019-03-10 18:29:41 +03:00
|
|
|
let keyLocationServiceGoogleFound = data.keyLocationServiceGoogleFound ? "found" : "missing";
|
|
|
|
document.l10n.setAttributes($("key-location-service-google-box"), keyLocationServiceGoogleFound);
|
|
|
|
|
|
|
|
let keySafebrowsingGoogleFound = data.keySafebrowsingGoogleFound ? "found" : "missing";
|
|
|
|
document.l10n.setAttributes($("key-safebrowsing-google-box"), keySafebrowsingGoogleFound);
|
2017-02-16 15:01:21 +03:00
|
|
|
|
|
|
|
let keyMozillaFound = data.keyMozillaFound ? "found" : "missing";
|
2018-12-28 22:40:17 +03:00
|
|
|
document.l10n.setAttributes($("key-mozilla-box"), keyMozillaFound);
|
2017-02-16 15:01:21 +03:00
|
|
|
|
2015-06-27 00:21:46 +03:00
|
|
|
$("safemode-box").textContent = data.safeMode;
|
2012-09-19 00:30:41 +04:00
|
|
|
},
|
|
|
|
|
2018-12-28 22:40:17 +03:00
|
|
|
crashes(data) {
|
2015-12-03 21:02:22 +03:00
|
|
|
if (!AppConstants.MOZ_CRASHREPORTER)
|
|
|
|
return;
|
|
|
|
|
2013-10-28 03:18:14 +04:00
|
|
|
let daysRange = Troubleshoot.kMaxCrashAge / (24 * 60 * 60 * 1000);
|
2018-12-28 22:40:17 +03:00
|
|
|
document.l10n.setAttributes($("crashes-title"), "report-crash-for-days", { days: daysRange });
|
2013-10-28 03:18:14 +04:00
|
|
|
let reportURL;
|
|
|
|
try {
|
|
|
|
reportURL = Services.prefs.getCharPref("breakpad.reportURL");
|
|
|
|
// Ignore any non http/https urls
|
|
|
|
if (!/^https?:/i.test(reportURL))
|
|
|
|
reportURL = null;
|
2016-12-31 05:47:25 +03:00
|
|
|
} catch (e) { }
|
2013-10-28 03:18:14 +04:00
|
|
|
if (!reportURL) {
|
|
|
|
$("crashes-noConfig").style.display = "block";
|
|
|
|
$("crashes-noConfig").classList.remove("no-copy");
|
|
|
|
return;
|
|
|
|
}
|
2016-08-04 01:54:59 +03:00
|
|
|
$("crashes-allReports").style.display = "block";
|
2013-10-28 03:18:14 +04:00
|
|
|
|
|
|
|
if (data.pending > 0) {
|
2018-12-28 22:40:17 +03:00
|
|
|
document.l10n.setAttributes($("crashes-allReportsWithPending"), "pending-reports", { reports: data.pending });
|
2013-10-28 03:18:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
let dateNow = new Date();
|
2016-11-12 02:22:34 +03:00
|
|
|
$.append($("crashes-tbody"), data.submitted.map(function(crash) {
|
2013-10-28 03:18:14 +04:00
|
|
|
let date = new Date(crash.date);
|
|
|
|
let timePassed = dateNow - date;
|
2018-12-28 22:40:17 +03:00
|
|
|
let formattedDateStrId;
|
|
|
|
let formattedDateStrArgs;
|
2016-12-31 05:47:25 +03:00
|
|
|
if (timePassed >= 24 * 60 * 60 * 1000) {
|
2013-10-28 03:18:14 +04:00
|
|
|
let daysPassed = Math.round(timePassed / (24 * 60 * 60 * 1000));
|
2018-12-28 22:40:17 +03:00
|
|
|
formattedDateStrId = "crashes-time-days";
|
|
|
|
formattedDateStrArgs = { days: daysPassed };
|
2016-12-31 05:47:25 +03:00
|
|
|
} else if (timePassed >= 60 * 60 * 1000) {
|
2013-10-28 03:18:14 +04:00
|
|
|
let hoursPassed = Math.round(timePassed / (60 * 60 * 1000));
|
2018-12-28 22:40:17 +03:00
|
|
|
formattedDateStrId = "crashes-time-hours";
|
|
|
|
formattedDateStrArgs = { hours: hoursPassed };
|
2016-12-31 05:47:25 +03:00
|
|
|
} else {
|
2013-10-28 03:18:14 +04:00
|
|
|
let minutesPassed = Math.max(Math.round(timePassed / (60 * 1000)), 1);
|
2018-12-28 22:40:17 +03:00
|
|
|
formattedDateStrId = "crashes-time-minutes";
|
|
|
|
formattedDateStrArgs = { minutes: minutesPassed };
|
2013-10-28 03:18:14 +04:00
|
|
|
}
|
|
|
|
return $.new("tr", [
|
|
|
|
$.new("td", [
|
2018-08-31 08:59:17 +03:00
|
|
|
$.new("a", crash.id, null, {href: reportURL + crash.id}),
|
2013-10-28 03:18:14 +04:00
|
|
|
]),
|
2018-12-28 22:40:17 +03:00
|
|
|
$.new("td", null, null, {"data-l10n-id": formattedDateStrId, "data-l10n-args": formattedDateStrArgs}),
|
2013-10-28 03:18:14 +04:00
|
|
|
]);
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
|
2018-12-28 22:40:17 +03:00
|
|
|
extensions(data) {
|
2016-11-12 02:22:34 +03:00
|
|
|
$.append($("extensions-tbody"), data.map(function(extension) {
|
2012-09-19 00:30:41 +04:00
|
|
|
return $.new("tr", [
|
|
|
|
$.new("td", extension.name),
|
|
|
|
$.new("td", extension.version),
|
|
|
|
$.new("td", extension.isActive),
|
|
|
|
$.new("td", extension.id),
|
2010-04-21 02:14:15 +04:00
|
|
|
]);
|
2012-09-19 00:30:41 +04:00
|
|
|
}));
|
|
|
|
},
|
|
|
|
|
2018-12-28 22:40:17 +03:00
|
|
|
securitySoftware(data) {
|
2017-11-18 23:59:45 +03:00
|
|
|
if (!AppConstants.isPlatformAndVersionAtLeast("win", "6.2")) {
|
|
|
|
$("security-software-title").hidden = true;
|
|
|
|
$("security-software-table").hidden = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$("security-software-antivirus").textContent = data.registeredAntiVirus;
|
|
|
|
$("security-software-antispyware").textContent = data.registeredAntiSpyware;
|
|
|
|
$("security-software-firewall").textContent = data.registeredFirewall;
|
|
|
|
},
|
|
|
|
|
2018-12-28 22:40:17 +03:00
|
|
|
features(data) {
|
2017-03-10 02:44:40 +03:00
|
|
|
$.append($("features-tbody"), data.map(function(feature) {
|
|
|
|
return $.new("tr", [
|
|
|
|
$.new("td", feature.name),
|
|
|
|
$.new("td", feature.version),
|
|
|
|
$.new("td", feature.id),
|
|
|
|
]);
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
|
2019-04-06 08:49:47 +03:00
|
|
|
async processes(data) {
|
|
|
|
async function buildEntry(name, value) {
|
|
|
|
let entryName = (await document.l10n.formatValue(`process-type-${name.toLowerCase()}`))
|
|
|
|
|| name;
|
|
|
|
|
|
|
|
$("processes-tbody").appendChild($.new("tr", [
|
|
|
|
$.new("td", entryName),
|
|
|
|
$.new("td", value),
|
|
|
|
]));
|
|
|
|
}
|
|
|
|
|
|
|
|
let remoteProcessesCount = Object.values(data.remoteTypes).reduce((a, b) => a + b, 0);
|
|
|
|
document.querySelector("#remoteprocesses-row a").textContent = remoteProcessesCount;
|
|
|
|
|
|
|
|
// Display the regular "web" process type first in the list,
|
|
|
|
// and with special formatting.
|
|
|
|
if (data.remoteTypes.web) {
|
|
|
|
await buildEntry("web", `${data.remoteTypes.web} / ${data.maxWebContentProcesses}`);
|
|
|
|
delete data.remoteTypes.web;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let remoteProcessType in data.remoteTypes) {
|
|
|
|
await buildEntry(remoteProcessType, data.remoteTypes[remoteProcessType]);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-12-28 22:40:17 +03:00
|
|
|
modifiedPreferences(data) {
|
2012-09-19 00:30:41 +04:00
|
|
|
$.append($("prefs-tbody"), sortedArrayFromObject(data).map(
|
2016-11-12 02:22:34 +03:00
|
|
|
function([name, value]) {
|
2012-09-19 00:30:41 +04:00
|
|
|
return $.new("tr", [
|
|
|
|
$.new("td", name, "pref-name"),
|
|
|
|
// Very long preference values can cause users problems when they
|
|
|
|
// copy and paste them into some text editors. Long values generally
|
|
|
|
// aren't useful anyway, so truncate them to a reasonable length.
|
|
|
|
$.new("td", String(value).substr(0, 120), "pref-value"),
|
2014-06-10 18:49:00 +04:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
));
|
|
|
|
},
|
|
|
|
|
2018-12-28 22:40:17 +03:00
|
|
|
lockedPreferences(data) {
|
2014-06-10 18:49:00 +04:00
|
|
|
$.append($("locked-prefs-tbody"), sortedArrayFromObject(data).map(
|
2016-11-12 02:22:34 +03:00
|
|
|
function([name, value]) {
|
2014-06-10 18:49:00 +04:00
|
|
|
return $.new("tr", [
|
|
|
|
$.new("td", name, "pref-name"),
|
|
|
|
$.new("td", String(value).substr(0, 120), "pref-value"),
|
2012-09-19 00:30:41 +04:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
));
|
|
|
|
},
|
|
|
|
|
2018-12-28 22:40:17 +03:00
|
|
|
async graphics(data) {
|
|
|
|
function localizedMsg(msg) {
|
2018-12-28 22:40:33 +03:00
|
|
|
if (typeof msg == "object" && msg.key) {
|
|
|
|
return document.l10n.formatValue(msg.key, msg.args);
|
|
|
|
}
|
2018-12-28 22:40:17 +03:00
|
|
|
let msgId = toFluentID(msg);
|
2018-12-28 22:40:33 +03:00
|
|
|
if (msgId) {
|
|
|
|
return document.l10n.formatValue(msgId);
|
|
|
|
}
|
|
|
|
return "";
|
2015-03-25 01:04:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Read APZ info out of data.info, stripping it out in the process.
|
|
|
|
let apzInfo = [];
|
2016-11-12 02:22:34 +03:00
|
|
|
let formatApzInfo = function(info) {
|
2015-03-25 01:04:44 +03:00
|
|
|
let out = [];
|
2017-08-29 23:27:19 +03:00
|
|
|
for (let type of ["Wheel", "Touch", "Drag", "Keyboard", "Autoscroll"]) {
|
2017-01-17 18:48:17 +03:00
|
|
|
let key = "Apz" + type + "Input";
|
2015-03-25 01:04:44 +03:00
|
|
|
|
|
|
|
if (!(key in info))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
delete info[key];
|
2015-12-02 00:49:01 +03:00
|
|
|
|
2018-12-28 22:40:17 +03:00
|
|
|
out.push(toFluentID(type.toLowerCase() + "Enabled"));
|
2015-03-25 01:04:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return out;
|
|
|
|
};
|
|
|
|
|
2016-04-14 21:54:33 +03:00
|
|
|
// Create a <tr> element with key and value columns.
|
|
|
|
//
|
|
|
|
// @key Text in the key column. Localized automatically, unless starts with "#".
|
2019-03-13 08:13:58 +03:00
|
|
|
// @value Fluent ID for text in the value column, or array of children.
|
2016-04-14 21:54:33 +03:00
|
|
|
function buildRow(key, value) {
|
2018-12-28 22:40:17 +03:00
|
|
|
let title = key[0] == "#" ? key.substr(1) : key;
|
|
|
|
let keyStrId = toFluentID(key);
|
|
|
|
let valueStrId = Array.isArray(value) ? null : toFluentID(value);
|
2018-12-28 22:40:33 +03:00
|
|
|
let td = $.new("td", value);
|
2017-01-31 05:58:52 +03:00
|
|
|
td.style["white-space"] = "pre-wrap";
|
2018-12-28 22:40:33 +03:00
|
|
|
if (valueStrId) {
|
|
|
|
document.l10n.setAttributes(td, valueStrId);
|
|
|
|
}
|
2017-01-31 05:58:52 +03:00
|
|
|
|
2018-12-28 22:40:33 +03:00
|
|
|
let th = $.new("th", title, "column");
|
|
|
|
if (!key.startsWith("#")) {
|
|
|
|
document.l10n.setAttributes(th, keyStrId);
|
|
|
|
}
|
2016-04-14 21:54:33 +03:00
|
|
|
return $.new("tr", [
|
2018-12-28 22:40:33 +03:00
|
|
|
th,
|
2017-01-31 05:58:52 +03:00
|
|
|
td,
|
2016-04-14 21:54:33 +03:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// @where The name in "graphics-<name>-tbody", of the element to append to.
|
|
|
|
// @trs Array of row elements.
|
|
|
|
function addRows(where, trs) {
|
2016-04-14 22:16:33 +03:00
|
|
|
$.append($("graphics-" + where + "-tbody"), trs);
|
2016-04-14 21:54:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Build and append a row.
|
|
|
|
//
|
|
|
|
// @where The name in "graphics-<name>-tbody", of the element to append to.
|
|
|
|
function addRow(where, key, value) {
|
|
|
|
addRows(where, [buildRow(key, value)]);
|
|
|
|
}
|
2012-09-19 00:30:41 +04:00
|
|
|
if ("info" in data) {
|
2015-03-25 01:04:44 +03:00
|
|
|
apzInfo = formatApzInfo(data.info);
|
|
|
|
|
2016-11-12 02:22:34 +03:00
|
|
|
let trs = sortedArrayFromObject(data.info).map(function([prop, val]) {
|
2019-06-05 01:50:47 +03:00
|
|
|
let td = $.new("td", String(val));
|
|
|
|
td.style["word-break"] = "break-all";
|
2012-09-19 00:30:41 +04:00
|
|
|
return $.new("tr", [
|
|
|
|
$.new("th", prop, "column"),
|
2019-06-05 01:50:47 +03:00
|
|
|
td,
|
2012-09-19 00:30:41 +04:00
|
|
|
]);
|
|
|
|
});
|
2016-04-14 21:54:33 +03:00
|
|
|
addRows("diagnostics", trs);
|
|
|
|
|
2012-09-19 00:30:41 +04:00
|
|
|
delete data.info;
|
2010-04-21 02:14:15 +04:00
|
|
|
}
|
2010-02-21 07:42:25 +03:00
|
|
|
|
2018-07-25 02:47:42 +03:00
|
|
|
let windowUtils = window.windowUtils;
|
2017-04-21 22:07:14 +03:00
|
|
|
let gpuProcessPid = windowUtils.gpuProcessPid;
|
2016-11-01 23:46:48 +03:00
|
|
|
|
2017-04-21 22:07:14 +03:00
|
|
|
if (gpuProcessPid != -1) {
|
|
|
|
let gpuProcessKillButton = null;
|
|
|
|
if (AppConstants.NIGHTLY_BUILD || AppConstants.MOZ_DEV_EDITION) {
|
|
|
|
gpuProcessKillButton = $.new("button");
|
2016-11-01 23:46:48 +03:00
|
|
|
|
|
|
|
gpuProcessKillButton.addEventListener("click", function() {
|
|
|
|
windowUtils.terminateGPUProcess();
|
|
|
|
});
|
|
|
|
|
2018-12-28 22:40:17 +03:00
|
|
|
document.l10n.setAttributes(gpuProcessKillButton, "gpu-process-kill-button");
|
2017-04-21 22:07:14 +03:00
|
|
|
}
|
|
|
|
|
2018-12-28 22:40:33 +03:00
|
|
|
addRow("diagnostics", "gpu-process-pid", [new Text(gpuProcessPid)]);
|
2017-04-21 22:07:14 +03:00
|
|
|
if (gpuProcessKillButton) {
|
2018-12-28 22:40:33 +03:00
|
|
|
addRow("diagnostics", "gpu-process", [gpuProcessKillButton]);
|
2016-11-01 23:46:48 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-15 21:35:00 +03:00
|
|
|
if ((AppConstants.NIGHTLY_BUILD || AppConstants.MOZ_DEV_EDITION) && AppConstants.platform != "macosx") {
|
|
|
|
let gpuDeviceResetButton = $.new("button");
|
|
|
|
|
|
|
|
gpuDeviceResetButton.addEventListener("click", function() {
|
|
|
|
windowUtils.triggerDeviceReset();
|
|
|
|
});
|
|
|
|
|
2018-12-28 22:40:17 +03:00
|
|
|
document.l10n.setAttributes(gpuDeviceResetButton, "gpu-device-reset-button");
|
2018-12-28 22:40:33 +03:00
|
|
|
addRow("diagnostics", "gpu-device-reset", [gpuDeviceResetButton]);
|
2017-06-15 21:35:00 +03:00
|
|
|
}
|
|
|
|
|
2012-09-19 00:30:41 +04:00
|
|
|
// graphics-failures-tbody tbody
|
|
|
|
if ("failures" in data) {
|
2015-01-14 05:19:25 +03:00
|
|
|
// If indices is there, it should be the same length as failures,
|
|
|
|
// (see Troubleshoot.jsm) but we check anyway:
|
|
|
|
if ("indices" in data && data.failures.length == data.indices.length) {
|
|
|
|
let combined = [];
|
|
|
|
for (let i = 0; i < data.failures.length; i++) {
|
|
|
|
let assembled = assembleFromGraphicsFailure(i, data);
|
|
|
|
combined.push(assembled);
|
|
|
|
}
|
2016-08-16 22:44:15 +03:00
|
|
|
combined.sort(function(a, b) {
|
2016-08-17 02:24:58 +03:00
|
|
|
if (a.index < b.index) return -1;
|
|
|
|
if (a.index > b.index) return 1;
|
|
|
|
return 0;
|
2016-08-16 22:44:13 +03:00
|
|
|
});
|
2015-01-14 05:19:25 +03:00
|
|
|
$.append($("graphics-failures-tbody"),
|
|
|
|
combined.map(function(val) {
|
|
|
|
return $.new("tr", [$.new("th", val.header, "column"),
|
|
|
|
$.new("td", val.message)]);
|
|
|
|
}));
|
2015-04-09 17:44:17 +03:00
|
|
|
delete data.indices;
|
2015-01-14 05:19:25 +03:00
|
|
|
} else {
|
|
|
|
$.append($("graphics-failures-tbody"),
|
|
|
|
[$.new("tr", [$.new("th", "LogFailure", "column"),
|
2016-11-12 02:22:34 +03:00
|
|
|
$.new("td", data.failures.map(function(val) {
|
2015-01-14 05:19:25 +03:00
|
|
|
return $.new("p", val);
|
|
|
|
}))])]);
|
|
|
|
}
|
2019-02-01 02:40:33 +03:00
|
|
|
delete data.failures;
|
2016-04-14 21:54:33 +03:00
|
|
|
} else {
|
|
|
|
$("graphics-failures-tbody").style.display = "none";
|
2012-09-19 00:30:41 +04:00
|
|
|
}
|
2010-02-21 07:42:25 +03:00
|
|
|
|
2016-04-14 21:54:33 +03:00
|
|
|
// Add a new row to the table, and take the key (or keys) out of data.
|
|
|
|
//
|
|
|
|
// @where Table section to add to.
|
|
|
|
// @key Data key to use.
|
|
|
|
// @colKey The localization key to use, if different from key.
|
2018-12-28 22:40:17 +03:00
|
|
|
async function addRowFromKey(where, key, colKey) {
|
2016-04-14 21:54:33 +03:00
|
|
|
if (!(key in data))
|
|
|
|
return;
|
|
|
|
colKey = colKey || key;
|
|
|
|
|
|
|
|
let value;
|
|
|
|
let messageKey = key + "Message";
|
|
|
|
if (messageKey in data) {
|
2018-12-28 22:40:17 +03:00
|
|
|
value = await localizedMsg(data[messageKey]);
|
2016-04-14 21:54:33 +03:00
|
|
|
delete data[messageKey];
|
|
|
|
} else {
|
|
|
|
value = data[key];
|
|
|
|
}
|
|
|
|
delete data[key];
|
2012-03-13 03:04:37 +04:00
|
|
|
|
2016-04-14 21:54:33 +03:00
|
|
|
if (value) {
|
2018-12-28 22:40:33 +03:00
|
|
|
addRow(where, colKey, [new Text(value)]);
|
2016-04-14 21:54:33 +03:00
|
|
|
}
|
|
|
|
}
|
2015-03-25 01:04:44 +03:00
|
|
|
|
2016-04-14 21:54:33 +03:00
|
|
|
// graphics-features-tbody
|
2017-06-24 00:23:13 +03:00
|
|
|
let compositor = "";
|
|
|
|
if (data.windowLayerManagerRemote) {
|
|
|
|
compositor = data.windowLayerManagerType;
|
|
|
|
if (data.windowUsingAdvancedLayers) {
|
|
|
|
compositor += " (Advanced Layers)";
|
|
|
|
}
|
|
|
|
} else {
|
2018-12-28 22:40:17 +03:00
|
|
|
let noOMTCString = await document.l10n.formatValue("main-thread-no-omtc");
|
|
|
|
compositor = "BasicLayers (" + noOMTCString + ")";
|
2017-06-24 00:23:13 +03:00
|
|
|
}
|
2018-12-28 22:40:33 +03:00
|
|
|
addRow("features", "compositing", [new Text(compositor)]);
|
2016-04-14 21:54:33 +03:00
|
|
|
delete data.windowLayerManagerRemote;
|
2012-09-19 00:30:41 +04:00
|
|
|
delete data.windowLayerManagerType;
|
2016-04-14 21:54:33 +03:00
|
|
|
delete data.numTotalWindows;
|
|
|
|
delete data.numAcceleratedWindows;
|
2016-05-20 01:07:13 +03:00
|
|
|
delete data.numAcceleratedWindowsMessage;
|
2017-06-24 00:23:13 +03:00
|
|
|
delete data.windowUsingAdvancedLayers;
|
2012-09-19 00:30:41 +04:00
|
|
|
|
2016-04-14 21:54:33 +03:00
|
|
|
addRow("features", "asyncPanZoom",
|
|
|
|
apzInfo.length
|
2019-03-13 08:13:58 +03:00
|
|
|
? [new Text((await document.l10n.formatValues(apzInfo.map(id => { return {id}; }))).join("; "))]
|
|
|
|
: "apz-none");
|
2018-12-28 22:40:17 +03:00
|
|
|
let featureKeys = [
|
|
|
|
"webgl1WSIInfo",
|
|
|
|
"webgl1Renderer",
|
|
|
|
"webgl1Version",
|
|
|
|
"webgl1DriverExtensions",
|
|
|
|
"webgl1Extensions",
|
|
|
|
"webgl2WSIInfo",
|
|
|
|
"webgl2Renderer",
|
|
|
|
"webgl2Version",
|
|
|
|
"webgl2DriverExtensions",
|
|
|
|
"webgl2Extensions",
|
|
|
|
["supportsHardwareH264", "hardware-h264"],
|
|
|
|
["direct2DEnabled", "#Direct2D"],
|
2019-05-27 03:02:32 +03:00
|
|
|
["windowProtocol", "graphics-window-protocol"],
|
2018-12-28 22:40:17 +03:00
|
|
|
"usesTiling",
|
|
|
|
"contentUsesTiling",
|
|
|
|
"offMainThreadPaintEnabled",
|
|
|
|
"offMainThreadPaintWorkerCount",
|
2019-01-08 18:48:24 +03:00
|
|
|
"targetFrameRate",
|
2018-12-28 22:40:17 +03:00
|
|
|
];
|
|
|
|
for (let feature of featureKeys) {
|
|
|
|
if (Array.isArray(feature)) {
|
|
|
|
await addRowFromKey("features", feature[0], feature[1]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
await addRowFromKey("features", feature);
|
|
|
|
}
|
2011-05-04 00:07:17 +04:00
|
|
|
|
2012-09-19 00:30:41 +04:00
|
|
|
if ("directWriteEnabled" in data) {
|
2016-04-14 21:54:33 +03:00
|
|
|
let message = data.directWriteEnabled;
|
2012-09-19 00:30:41 +04:00
|
|
|
if ("directWriteVersion" in data)
|
2016-04-14 21:54:33 +03:00
|
|
|
message += " (" + data.directWriteVersion + ")";
|
2018-12-28 22:40:33 +03:00
|
|
|
await addRow("features", "#DirectWrite", [new Text(message)]);
|
2012-09-19 00:30:41 +04:00
|
|
|
delete data.directWriteEnabled;
|
|
|
|
delete data.directWriteVersion;
|
2011-05-04 00:07:17 +04:00
|
|
|
}
|
2011-05-04 00:07:17 +04:00
|
|
|
|
2016-04-14 21:54:33 +03:00
|
|
|
// Adapter tbodies.
|
|
|
|
let adapterKeys = [
|
2018-12-28 22:40:17 +03:00
|
|
|
["adapterDescription", "gpu-description"],
|
|
|
|
["adapterVendorID", "gpu-vendor-id"],
|
|
|
|
["adapterDeviceID", "gpu-device-id"],
|
2019-04-30 23:29:48 +03:00
|
|
|
["driverVendor", "gpu-driver-vendor"],
|
2018-12-28 22:40:17 +03:00
|
|
|
["driverVersion", "gpu-driver-version"],
|
|
|
|
["driverDate", "gpu-driver-date"],
|
|
|
|
["adapterDrivers", "gpu-drivers"],
|
|
|
|
["adapterSubsysID", "gpu-subsys-id"],
|
|
|
|
["adapterRAM", "gpu-ram"],
|
2016-04-14 21:54:33 +03:00
|
|
|
];
|
2011-05-11 04:30:20 +04:00
|
|
|
|
2016-04-14 21:54:33 +03:00
|
|
|
function showGpu(id, suffix) {
|
|
|
|
function get(prop) {
|
|
|
|
return data[prop + suffix];
|
2011-05-11 04:30:20 +04:00
|
|
|
}
|
2016-04-14 21:54:33 +03:00
|
|
|
|
|
|
|
let trs = [];
|
2016-04-20 01:21:33 +03:00
|
|
|
for (let [prop, key] of adapterKeys) {
|
|
|
|
let value = get(prop);
|
2016-04-14 21:54:33 +03:00
|
|
|
if (value === undefined || value === "")
|
|
|
|
continue;
|
|
|
|
trs.push(buildRow(key, value));
|
2012-09-19 00:30:41 +04:00
|
|
|
}
|
2016-04-14 21:54:33 +03:00
|
|
|
|
|
|
|
if (trs.length == 0) {
|
|
|
|
$("graphics-" + id + "-tbody").style.display = "none";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let active = "yes";
|
|
|
|
if ("isGPU2Active" in data && ((suffix == "2") != data.isGPU2Active)) {
|
|
|
|
active = "no";
|
|
|
|
}
|
2018-12-28 22:40:17 +03:00
|
|
|
|
|
|
|
addRow(id, "gpu-active", active);
|
2016-04-14 21:54:33 +03:00
|
|
|
addRows(id, trs);
|
2016-04-14 22:16:33 +03:00
|
|
|
}
|
2016-04-14 21:54:33 +03:00
|
|
|
showGpu("gpu-1", "");
|
|
|
|
showGpu("gpu-2", "2");
|
|
|
|
|
|
|
|
// Remove adapter keys.
|
2018-08-31 08:59:17 +03:00
|
|
|
for (let [prop /* key */] of adapterKeys) {
|
2016-04-20 01:21:33 +03:00
|
|
|
delete data[prop];
|
|
|
|
delete data[prop + "2"];
|
2016-04-14 21:54:33 +03:00
|
|
|
}
|
|
|
|
delete data.isGPU2Active;
|
|
|
|
|
2016-04-29 07:52:56 +03:00
|
|
|
let featureLog = data.featureLog;
|
|
|
|
delete data.featureLog;
|
|
|
|
|
|
|
|
let features = [];
|
|
|
|
for (let feature of featureLog.features) {
|
|
|
|
// Only add interesting decisions - ones that were not automatic based on
|
2019-05-26 17:31:53 +03:00
|
|
|
// all.js/StaticPrefs defaults.
|
2016-04-29 07:52:56 +03:00
|
|
|
if (feature.log.length > 1 || feature.log[0].status != "available") {
|
|
|
|
features.push(feature);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (features.length) {
|
|
|
|
for (let feature of features) {
|
|
|
|
let trs = [];
|
|
|
|
for (let entry of feature.log) {
|
|
|
|
if (entry.type == "default" && entry.status == "available")
|
|
|
|
continue;
|
|
|
|
|
2016-05-05 21:42:12 +03:00
|
|
|
let contents;
|
|
|
|
if (entry.message.length > 0 && entry.message[0] == "#") {
|
|
|
|
// This is a failure ID. See nsIGfxInfo.idl.
|
2017-01-05 09:03:08 +03:00
|
|
|
let m = /#BLOCKLIST_FEATURE_FAILURE_BUG_(\d+)/.exec(entry.message);
|
|
|
|
if (m) {
|
2016-05-05 21:42:12 +03:00
|
|
|
let bugSpan = $.new("span");
|
2018-12-28 22:40:17 +03:00
|
|
|
document.l10n.setAttributes(bugSpan, "blocklisted-bug");
|
2016-05-05 21:42:12 +03:00
|
|
|
|
|
|
|
let bugHref = $.new("a");
|
|
|
|
bugHref.href = "https://bugzilla.mozilla.org/show_bug.cgi?id=" + m[1];
|
2018-12-28 22:40:17 +03:00
|
|
|
document.l10n.setAttributes(bugHref, "bug-link", { bugNumber: m[1]});
|
2016-05-05 21:42:12 +03:00
|
|
|
|
|
|
|
contents = [bugSpan, bugHref];
|
|
|
|
} else {
|
2018-12-28 22:40:17 +03:00
|
|
|
let unknownFailure = $.new("span");
|
|
|
|
document.l10n.setAttributes(unknownFailure, "unknown-failure", { failureCode: entry.message.substr(1) });
|
|
|
|
contents = [unknownFailure];
|
2016-05-05 21:42:12 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
contents = entry.status + " by " + entry.type + ": " + entry.message;
|
|
|
|
}
|
|
|
|
|
2016-04-29 07:52:56 +03:00
|
|
|
trs.push($.new("tr", [
|
2016-05-05 21:42:12 +03:00
|
|
|
$.new("td", contents),
|
2016-04-29 07:52:56 +03:00
|
|
|
]));
|
|
|
|
}
|
2018-12-28 22:40:33 +03:00
|
|
|
addRow("decisions", "#" + feature.name, [$.new("table", trs)]);
|
2016-04-29 07:52:56 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$("graphics-decisions-tbody").style.display = "none";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (featureLog.fallbacks.length) {
|
|
|
|
for (let fallback of featureLog.fallbacks) {
|
2019-06-21 00:24:25 +03:00
|
|
|
addRow("workarounds", "#" + fallback.name, [new Text(fallback.message)]);
|
2016-04-29 07:52:56 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$("graphics-workarounds-tbody").style.display = "none";
|
2016-05-10 21:49:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
let crashGuards = data.crashGuards;
|
|
|
|
delete data.crashGuards;
|
|
|
|
|
|
|
|
if (crashGuards.length) {
|
|
|
|
for (let guard of crashGuards) {
|
|
|
|
let resetButton = $.new("button");
|
2017-02-20 14:45:58 +03:00
|
|
|
let onClickReset = function() {
|
2016-12-22 14:03:28 +03:00
|
|
|
Services.prefs.setIntPref(guard.prefName, 0);
|
|
|
|
resetButton.removeEventListener("click", onClickReset);
|
|
|
|
resetButton.disabled = true;
|
|
|
|
};
|
2016-05-10 21:49:38 +03:00
|
|
|
|
2018-12-28 22:40:17 +03:00
|
|
|
document.l10n.setAttributes(resetButton, "reset-on-next-restart");
|
2016-05-10 21:49:38 +03:00
|
|
|
resetButton.addEventListener("click", onClickReset);
|
|
|
|
|
|
|
|
addRow("crashguards", guard.type + "CrashGuard", [resetButton]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$("graphics-crashguards-tbody").style.display = "none";
|
2016-04-29 07:52:56 +03:00
|
|
|
}
|
|
|
|
|
2016-04-14 21:54:33 +03:00
|
|
|
// Now that we're done, grab any remaining keys in data and drop them into
|
|
|
|
// the diagnostics section.
|
|
|
|
for (let key in data) {
|
2016-05-20 01:07:13 +03:00
|
|
|
let value = data[key];
|
2019-03-13 08:13:58 +03:00
|
|
|
addRow("diagnostics", key, [new Text(value)]);
|
2011-11-18 08:00:37 +04:00
|
|
|
}
|
2012-09-19 00:30:41 +04:00
|
|
|
},
|
|
|
|
|
2018-12-28 22:40:20 +03:00
|
|
|
media(data) {
|
|
|
|
function insertBasicInfo(key, value) {
|
|
|
|
function createRow(key, value) {
|
2018-12-28 22:40:33 +03:00
|
|
|
let th = $.new("th", null, "column");
|
|
|
|
document.l10n.setAttributes(th, key);
|
2017-07-25 05:46:39 +03:00
|
|
|
let td = $.new("td", value);
|
|
|
|
td.style["white-space"] = "pre-wrap";
|
2017-09-18 06:44:23 +03:00
|
|
|
td.colSpan = 8;
|
2017-07-25 05:46:39 +03:00
|
|
|
return $.new("tr", [th, td]);
|
|
|
|
}
|
2018-12-28 22:40:20 +03:00
|
|
|
$.append($("media-info-tbody"), [createRow(key, value)]);
|
2017-07-25 05:46:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function createDeviceInfoRow(device) {
|
|
|
|
let deviceInfo = Ci.nsIAudioDeviceInfo;
|
|
|
|
|
|
|
|
let states = {};
|
|
|
|
states[deviceInfo.STATE_DISABLED] = "Disabled";
|
|
|
|
states[deviceInfo.STATE_UNPLUGGED] = "Unplugged";
|
|
|
|
states[deviceInfo.STATE_ENABLED] = "Enabled";
|
|
|
|
|
|
|
|
let preferreds = {};
|
|
|
|
preferreds[deviceInfo.PREF_NONE] = "None";
|
|
|
|
preferreds[deviceInfo.PREF_MULTIMEDIA] = "Multimedia";
|
|
|
|
preferreds[deviceInfo.PREF_VOICE] = "Voice";
|
|
|
|
preferreds[deviceInfo.PREF_NOTIFICATION] = "Notification";
|
|
|
|
preferreds[deviceInfo.PREF_ALL] = "All";
|
|
|
|
|
|
|
|
let formats = {};
|
|
|
|
formats[deviceInfo.FMT_S16LE] = "S16LE";
|
|
|
|
formats[deviceInfo.FMT_S16BE] = "S16BE";
|
|
|
|
formats[deviceInfo.FMT_F32LE] = "F32LE";
|
|
|
|
formats[deviceInfo.FMT_F32BE] = "F32BE";
|
|
|
|
|
|
|
|
function toPreferredString(preferred) {
|
|
|
|
if (preferred == deviceInfo.PREF_NONE) {
|
|
|
|
return preferreds[deviceInfo.PREF_NONE];
|
|
|
|
} else if (preferred & deviceInfo.PREF_ALL) {
|
|
|
|
return preferreds[deviceInfo.PREF_ALL];
|
|
|
|
}
|
|
|
|
let str = "";
|
|
|
|
for (let pref of [deviceInfo.PREF_MULTIMEDIA,
|
|
|
|
deviceInfo.PREF_VOICE,
|
|
|
|
deviceInfo.PREF_NOTIFICATION]) {
|
|
|
|
if (preferred & pref) {
|
|
|
|
str += " " + preferreds[pref];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
function toFromatString(dev) {
|
|
|
|
let str = "default: " + formats[dev.defaultFormat] + ", support:";
|
|
|
|
for (let fmt of [deviceInfo.FMT_S16LE,
|
|
|
|
deviceInfo.FMT_S16BE,
|
|
|
|
deviceInfo.FMT_F32LE,
|
|
|
|
deviceInfo.FMT_F32BE]) {
|
|
|
|
if (dev.supportedFormat & fmt) {
|
|
|
|
str += " " + formats[fmt];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
function toRateString(dev) {
|
|
|
|
return "default: " + dev.defaultRate +
|
|
|
|
", support: " + dev.minRate + " - " + dev.maxRate;
|
|
|
|
}
|
|
|
|
|
|
|
|
function toLatencyString(dev) {
|
|
|
|
return dev.minLatency + " - " + dev.maxLatency;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $.new("tr", [$.new("td", device.name),
|
|
|
|
$.new("td", device.groupId),
|
|
|
|
$.new("td", device.vendor),
|
|
|
|
$.new("td", states[device.state]),
|
|
|
|
$.new("td", toPreferredString(device.preferred)),
|
|
|
|
$.new("td", toFromatString(device)),
|
|
|
|
$.new("td", device.maxChannels),
|
|
|
|
$.new("td", toRateString(device)),
|
|
|
|
$.new("td", toLatencyString(device))]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function insertDeviceInfo(side, devices) {
|
|
|
|
let rows = [];
|
|
|
|
for (let dev of devices) {
|
|
|
|
rows.push(createDeviceInfoRow(dev));
|
|
|
|
}
|
|
|
|
$.append($("media-" + side + "-devices-tbody"), rows);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Basic information
|
2018-12-28 22:40:20 +03:00
|
|
|
insertBasicInfo("audio-backend", data.currentAudioBackend);
|
|
|
|
insertBasicInfo("max-audio-channels", data.currentMaxAudioChannels);
|
|
|
|
insertBasicInfo("sample-rate", data.currentPreferredSampleRate);
|
2017-07-25 05:46:39 +03:00
|
|
|
|
|
|
|
// Output devices information
|
|
|
|
insertDeviceInfo("output", data.audioOutputDevices);
|
|
|
|
|
|
|
|
// Input devices information
|
|
|
|
insertDeviceInfo("input", data.audioInputDevices);
|
|
|
|
},
|
|
|
|
|
2018-12-28 22:40:17 +03:00
|
|
|
javaScript(data) {
|
2012-09-19 00:30:41 +04:00
|
|
|
$("javascript-incremental-gc").textContent = data.incrementalGCEnabled;
|
|
|
|
},
|
|
|
|
|
2018-12-28 22:40:17 +03:00
|
|
|
accessibility(data) {
|
2012-09-19 00:30:41 +04:00
|
|
|
$("a11y-activated").textContent = data.isActive;
|
|
|
|
$("a11y-force-disabled").textContent = data.forceDisabled || 0;
|
2017-08-10 23:30:23 +03:00
|
|
|
|
2017-06-19 19:13:58 +03:00
|
|
|
let a11yHandlerUsed = $("a11y-handler-used");
|
|
|
|
if (a11yHandlerUsed) {
|
|
|
|
a11yHandlerUsed.textContent = data.handlerUsed;
|
|
|
|
}
|
2017-08-10 23:30:23 +03:00
|
|
|
|
|
|
|
let a11yInstantiator = $("a11y-instantiator");
|
|
|
|
if (a11yInstantiator) {
|
|
|
|
a11yInstantiator.textContent = data.instantiator;
|
|
|
|
}
|
2012-09-19 00:30:41 +04:00
|
|
|
},
|
|
|
|
|
2018-12-28 22:40:20 +03:00
|
|
|
libraryVersions(data) {
|
2012-09-19 00:30:41 +04:00
|
|
|
let trs = [
|
|
|
|
$.new("tr", [
|
|
|
|
$.new("th", ""),
|
2018-12-28 22:40:20 +03:00
|
|
|
$.new("th", null, null, {"data-l10n-id": "min-lib-versions"}),
|
|
|
|
$.new("th", null, null, {"data-l10n-id": "loaded-lib-versions"}),
|
2018-08-31 08:59:17 +03:00
|
|
|
]),
|
2012-09-19 00:30:41 +04:00
|
|
|
];
|
|
|
|
sortedArrayFromObject(data).forEach(
|
2016-11-12 02:22:34 +03:00
|
|
|
function([name, val]) {
|
2012-09-19 00:30:41 +04:00
|
|
|
trs.push($.new("tr", [
|
|
|
|
$.new("td", name),
|
|
|
|
$.new("td", val.minVersion),
|
|
|
|
$.new("td", val.version),
|
|
|
|
]));
|
|
|
|
}
|
2011-02-08 00:11:57 +03:00
|
|
|
);
|
2012-09-19 00:30:41 +04:00
|
|
|
$.append($("libversions-tbody"), trs);
|
|
|
|
},
|
2012-09-27 03:03:00 +04:00
|
|
|
|
2018-12-28 22:40:17 +03:00
|
|
|
userJS(data) {
|
2012-09-27 03:03:00 +04:00
|
|
|
if (!data.exists)
|
|
|
|
return;
|
|
|
|
let userJSFile = Services.dirsvc.get("PrefD", Ci.nsIFile);
|
|
|
|
userJSFile.append("user.js");
|
|
|
|
$("prefs-user-js-link").href = Services.io.newFileURI(userJSFile).spec;
|
|
|
|
$("prefs-user-js-section").style.display = "";
|
2012-11-01 03:10:46 +04:00
|
|
|
// Clear the no-copy class
|
|
|
|
$("prefs-user-js-section").className = "";
|
2012-09-27 03:03:00 +04:00
|
|
|
},
|
2014-11-06 14:40:00 +03:00
|
|
|
|
2018-12-28 22:40:20 +03:00
|
|
|
sandbox(data) {
|
2016-08-16 09:40:43 +03:00
|
|
|
if (!AppConstants.MOZ_SANDBOX)
|
2015-12-03 21:02:22 +03:00
|
|
|
return;
|
|
|
|
|
2014-11-06 14:40:00 +03:00
|
|
|
let tbody = $("sandbox-tbody");
|
2015-03-06 21:59:00 +03:00
|
|
|
for (let key in data) {
|
|
|
|
// Simplify the display a little in the common case.
|
|
|
|
if (key === "hasPrivilegedUserNamespaces" &&
|
2017-07-25 21:15:41 +03:00
|
|
|
data[key] === data.hasUserNamespaces) {
|
2015-03-06 21:59:00 +03:00
|
|
|
continue;
|
2014-11-06 14:40:00 +03:00
|
|
|
}
|
2017-01-31 04:51:13 +03:00
|
|
|
if (key === "syscallLog") {
|
2017-05-31 01:44:43 +03:00
|
|
|
// Not in this table.
|
|
|
|
continue;
|
2017-01-31 04:51:13 +03:00
|
|
|
}
|
2018-12-28 22:40:17 +03:00
|
|
|
let keyStrId = toFluentID(key);
|
2018-12-28 22:40:33 +03:00
|
|
|
let th = $.new("th", null, "column");
|
|
|
|
document.l10n.setAttributes(th, keyStrId);
|
2015-03-06 21:59:00 +03:00
|
|
|
tbody.appendChild($.new("tr", [
|
2018-12-28 22:40:33 +03:00
|
|
|
th,
|
2017-01-31 04:51:13 +03:00
|
|
|
$.new("td", data[key]),
|
2015-03-06 21:59:00 +03:00
|
|
|
]));
|
2014-11-06 14:40:00 +03:00
|
|
|
}
|
2017-01-31 04:51:13 +03:00
|
|
|
|
2017-05-31 01:44:43 +03:00
|
|
|
if ("syscallLog" in data) {
|
|
|
|
let syscallBody = $("sandbox-syscalls-tbody");
|
|
|
|
let argsHead = $("sandbox-syscalls-argshead");
|
|
|
|
for (let syscall of data.syscallLog) {
|
|
|
|
if (argsHead.colSpan < syscall.args.length) {
|
|
|
|
argsHead.colSpan = syscall.args.length;
|
|
|
|
}
|
2018-12-28 22:40:17 +03:00
|
|
|
let procTypeStrId = toFluentID(syscall.procType);
|
2017-05-31 01:44:43 +03:00
|
|
|
let cells = [
|
|
|
|
$.new("td", syscall.index, "integer"),
|
|
|
|
$.new("td", syscall.msecAgo / 1000),
|
|
|
|
$.new("td", syscall.pid, "integer"),
|
|
|
|
$.new("td", syscall.tid, "integer"),
|
2018-12-28 22:40:20 +03:00
|
|
|
$.new("td", null, null, {"data-l10n-id": "sandbox-proc-type-" + procTypeStrId}),
|
2017-05-31 01:44:43 +03:00
|
|
|
$.new("td", syscall.syscall, "integer"),
|
|
|
|
];
|
|
|
|
for (let arg of syscall.args) {
|
|
|
|
cells.push($.new("td", arg, "integer"));
|
|
|
|
}
|
|
|
|
syscallBody.appendChild($.new("tr", cells));
|
2017-01-31 04:51:13 +03:00
|
|
|
}
|
|
|
|
}
|
2014-11-06 14:40:00 +03:00
|
|
|
},
|
2017-11-07 02:42:32 +03:00
|
|
|
|
2018-12-28 22:40:17 +03:00
|
|
|
intl(data) {
|
2017-11-07 02:42:32 +03:00
|
|
|
$("intl-locale-requested").textContent =
|
|
|
|
JSON.stringify(data.localeService.requested);
|
|
|
|
$("intl-locale-available").textContent =
|
|
|
|
JSON.stringify(data.localeService.available);
|
|
|
|
$("intl-locale-supported").textContent =
|
|
|
|
JSON.stringify(data.localeService.supported);
|
|
|
|
$("intl-locale-regionalprefs").textContent =
|
|
|
|
JSON.stringify(data.localeService.regionalPrefs);
|
|
|
|
$("intl-locale-default").textContent =
|
|
|
|
JSON.stringify(data.localeService.defaultLocale);
|
|
|
|
|
|
|
|
$("intl-osprefs-systemlocales").textContent =
|
|
|
|
JSON.stringify(data.osPrefs.systemLocales);
|
|
|
|
$("intl-osprefs-regionalprefs").textContent =
|
|
|
|
JSON.stringify(data.osPrefs.regionalPrefsLocales);
|
2018-08-31 08:59:17 +03:00
|
|
|
},
|
2012-09-19 00:30:41 +04:00
|
|
|
};
|
|
|
|
|
2015-09-15 21:19:45 +03:00
|
|
|
var $ = document.getElementById.bind(document);
|
2012-09-19 00:30:41 +04:00
|
|
|
|
2013-10-28 03:18:14 +04:00
|
|
|
$.new = function $_new(tag, textContentOrChildren, className, attributes) {
|
2012-09-19 00:30:41 +04:00
|
|
|
let elt = document.createElement(tag);
|
2018-12-28 22:40:17 +03:00
|
|
|
if (className) {
|
2012-09-19 00:30:41 +04:00
|
|
|
elt.className = className;
|
2018-12-28 22:40:17 +03:00
|
|
|
}
|
2013-10-28 03:18:14 +04:00
|
|
|
if (attributes) {
|
2018-12-28 22:40:17 +03:00
|
|
|
if (attributes["data-l10n-id"]) {
|
2018-12-28 22:40:33 +03:00
|
|
|
let args = attributes.hasOwnProperty("data-l10n-args") ?
|
|
|
|
attributes["data-l10n-args"] :
|
|
|
|
undefined;
|
2018-12-28 22:40:17 +03:00
|
|
|
document.l10n.setAttributes(elt,
|
|
|
|
attributes["data-l10n-id"],
|
2018-12-28 22:40:33 +03:00
|
|
|
args);
|
2018-12-28 22:40:17 +03:00
|
|
|
delete attributes["data-l10n-id"];
|
2018-12-28 22:40:33 +03:00
|
|
|
if (args) {
|
2018-12-28 22:40:17 +03:00
|
|
|
delete attributes["data-l10n-args"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let attrName in attributes) {
|
2013-10-28 03:18:14 +04:00
|
|
|
elt.setAttribute(attrName, attributes[attrName]);
|
2018-12-28 22:40:17 +03:00
|
|
|
}
|
2013-10-28 03:18:14 +04:00
|
|
|
}
|
2018-12-28 22:40:17 +03:00
|
|
|
if (Array.isArray(textContentOrChildren)) {
|
2012-09-19 00:30:41 +04:00
|
|
|
this.append(elt, textContentOrChildren);
|
2019-01-24 19:05:39 +03:00
|
|
|
} else if (!attributes || !attributes["data-l10n-id"]) {
|
2012-09-19 00:30:41 +04:00
|
|
|
elt.textContent = String(textContentOrChildren);
|
2018-12-28 22:40:17 +03:00
|
|
|
}
|
2012-09-19 00:30:41 +04:00
|
|
|
return elt;
|
|
|
|
};
|
|
|
|
|
|
|
|
$.append = function $_append(parent, children) {
|
2015-01-10 22:40:03 +03:00
|
|
|
children.forEach(c => parent.appendChild(c));
|
2012-09-19 00:30:41 +04:00
|
|
|
};
|
|
|
|
|
2016-12-31 05:47:25 +03:00
|
|
|
function assembleFromGraphicsFailure(i, data) {
|
2015-01-14 05:19:25 +03:00
|
|
|
// Only cover the cases we have today; for example, we do not have
|
|
|
|
// log failures that assert and we assume the log level is 1/error.
|
|
|
|
let message = data.failures[i];
|
|
|
|
let index = data.indices[i];
|
|
|
|
let what = "";
|
|
|
|
if (message.search(/\[GFX1-\]: \(LF\)/) == 0) {
|
|
|
|
// Non-asserting log failure - the message is substring(14)
|
|
|
|
what = "LogFailure";
|
|
|
|
message = message.substring(14);
|
|
|
|
} else if (message.search(/\[GFX1-\]: /) == 0) {
|
|
|
|
// Non-asserting - the message is substring(9)
|
|
|
|
what = "Error";
|
|
|
|
message = message.substring(9);
|
|
|
|
} else if (message.search(/\[GFX1\]: /) == 0) {
|
|
|
|
// Asserting - the message is substring(8)
|
|
|
|
what = "Assert";
|
|
|
|
message = message.substring(8);
|
|
|
|
}
|
2017-03-21 21:29:43 +03:00
|
|
|
let assembled = {"index": index,
|
|
|
|
"header": ("(#" + index + ") " + what),
|
|
|
|
"message": message};
|
2015-01-14 05:19:25 +03:00
|
|
|
return assembled;
|
|
|
|
}
|
|
|
|
|
2012-09-19 00:30:41 +04:00
|
|
|
function sortedArrayFromObject(obj) {
|
|
|
|
let tuples = [];
|
|
|
|
for (let prop in obj)
|
|
|
|
tuples.push([prop, obj[prop]]);
|
2015-01-10 22:40:03 +03:00
|
|
|
tuples.sort(([prop1, v1], [prop2, v2]) => prop1.localeCompare(prop2));
|
2012-09-19 00:30:41 +04:00
|
|
|
return tuples;
|
2012-02-18 02:35:20 +04:00
|
|
|
}
|
|
|
|
|
2012-09-19 00:30:41 +04:00
|
|
|
function copyRawDataToClipboard(button) {
|
|
|
|
if (button)
|
|
|
|
button.disabled = true;
|
2012-06-27 19:47:27 +04:00
|
|
|
try {
|
2018-12-28 22:40:17 +03:00
|
|
|
Troubleshoot.snapshot(async function(snapshot) {
|
2012-09-19 00:30:41 +04:00
|
|
|
if (button)
|
|
|
|
button.disabled = false;
|
|
|
|
let str = Cc["@mozilla.org/supports-string;1"].
|
|
|
|
createInstance(Ci.nsISupportsString);
|
|
|
|
str.data = JSON.stringify(snapshot, undefined, 2);
|
|
|
|
let transferable = Cc["@mozilla.org/widget/transferable;1"].
|
|
|
|
createInstance(Ci.nsITransferable);
|
|
|
|
transferable.init(getLoadContext());
|
|
|
|
transferable.addDataFlavor("text/unicode");
|
|
|
|
transferable.setTransferData("text/unicode", str, str.data.length * 2);
|
2017-11-09 19:36:57 +03:00
|
|
|
Services.clipboard.setData(transferable, null, Ci.nsIClipboard.kGlobalClipboard);
|
2015-12-03 21:02:22 +03:00
|
|
|
if (AppConstants.platform == "android") {
|
2018-04-06 01:50:11 +03:00
|
|
|
// Present a snackbar notification.
|
2019-01-17 21:18:31 +03:00
|
|
|
var {Snackbars} = ChromeUtils.import("resource://gre/modules/Snackbars.jsm");
|
2018-12-28 22:40:17 +03:00
|
|
|
let rawDataCopiedString = await document.l10n.formatValue("raw-data-copied");
|
|
|
|
Snackbars.show(rawDataCopiedString, Snackbars.LENGTH_SHORT);
|
2015-12-03 21:02:22 +03:00
|
|
|
}
|
2012-09-19 00:30:41 +04:00
|
|
|
});
|
2016-12-31 05:47:25 +03:00
|
|
|
} catch (err) {
|
2012-09-19 00:30:41 +04:00
|
|
|
if (button)
|
|
|
|
button.disabled = false;
|
|
|
|
throw err;
|
2010-09-11 13:16:00 +04:00
|
|
|
}
|
2010-02-21 07:42:25 +03:00
|
|
|
}
|
|
|
|
|
2012-04-17 06:14:01 +04:00
|
|
|
function getLoadContext() {
|
2018-08-01 20:07:09 +03:00
|
|
|
return window.docShell.QueryInterface(Ci.nsILoadContext);
|
2012-04-17 06:14:01 +04:00
|
|
|
}
|
|
|
|
|
2018-12-28 22:40:17 +03:00
|
|
|
async function copyContentsToClipboard() {
|
2010-02-21 07:42:25 +03:00
|
|
|
// Get the HTML and text representations for the important part of the page.
|
2019-04-16 23:33:01 +03:00
|
|
|
let contentsDiv = $("contents").cloneNode(true);
|
|
|
|
// Remove the items we don't want to copy from the clone:
|
|
|
|
contentsDiv.querySelectorAll(".no-copy, [hidden]").forEach(n => n.remove());
|
2010-02-21 07:42:25 +03:00
|
|
|
let dataHtml = contentsDiv.innerHTML;
|
|
|
|
let dataText = createTextForElement(contentsDiv);
|
|
|
|
|
|
|
|
// We can't use plain strings, we have to use nsSupportsString.
|
|
|
|
let supportsStringClass = Cc["@mozilla.org/supports-string;1"];
|
|
|
|
let ssHtml = supportsStringClass.createInstance(Ci.nsISupportsString);
|
|
|
|
let ssText = supportsStringClass.createInstance(Ci.nsISupportsString);
|
|
|
|
|
|
|
|
let transferable = Cc["@mozilla.org/widget/transferable;1"]
|
|
|
|
.createInstance(Ci.nsITransferable);
|
2012-04-17 06:14:01 +04:00
|
|
|
transferable.init(getLoadContext());
|
2010-02-21 07:42:25 +03:00
|
|
|
|
|
|
|
// Add the HTML flavor.
|
|
|
|
transferable.addDataFlavor("text/html");
|
|
|
|
ssHtml.data = dataHtml;
|
|
|
|
transferable.setTransferData("text/html", ssHtml, dataHtml.length * 2);
|
|
|
|
|
|
|
|
// Add the plain text flavor.
|
|
|
|
transferable.addDataFlavor("text/unicode");
|
|
|
|
ssText.data = dataText;
|
|
|
|
transferable.setTransferData("text/unicode", ssText, dataText.length * 2);
|
|
|
|
|
|
|
|
// Store the data into the clipboard.
|
2017-11-09 19:36:57 +03:00
|
|
|
Services.clipboard.setData(transferable, null, Services.clipboard.kGlobalClipboard);
|
2012-09-22 21:12:30 +04:00
|
|
|
|
2015-12-03 21:02:22 +03:00
|
|
|
if (AppConstants.platform == "android") {
|
2018-04-06 01:50:11 +03:00
|
|
|
// Present a snackbar notification.
|
2019-01-17 21:18:31 +03:00
|
|
|
var {Snackbars} = ChromeUtils.import("resource://gre/modules/Snackbars.jsm");
|
2018-12-28 22:40:17 +03:00
|
|
|
let textCopiedString = await document.l10n.formatValue("text-copied");
|
|
|
|
Snackbars.show(textCopiedString, Snackbars.LENGTH_SHORT);
|
2015-12-03 21:02:22 +03:00
|
|
|
}
|
2010-02-21 07:42:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Return the plain text representation of an element. Do a little bit
|
|
|
|
// of pretty-printing to make it human-readable.
|
|
|
|
function createTextForElement(elem) {
|
2013-05-21 07:05:53 +04:00
|
|
|
let serializer = new Serializer();
|
|
|
|
let text = serializer.serialize(elem);
|
2010-02-21 07:42:25 +03:00
|
|
|
|
|
|
|
// Actual CR/LF pairs are needed for some Windows text editors.
|
2015-12-03 21:02:22 +03:00
|
|
|
if (AppConstants.platform == "win") {
|
|
|
|
text = text.replace(/\n/g, "\r\n");
|
|
|
|
}
|
2010-02-21 07:42:25 +03:00
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2013-05-21 07:05:53 +04:00
|
|
|
function Serializer() {
|
|
|
|
}
|
|
|
|
|
|
|
|
Serializer.prototype = {
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
serialize(rootElem) {
|
2013-05-21 07:05:53 +04:00
|
|
|
this._lines = [];
|
|
|
|
this._startNewLine();
|
|
|
|
this._serializeElement(rootElem);
|
|
|
|
this._startNewLine();
|
|
|
|
return this._lines.join("\n").trim() + "\n";
|
|
|
|
},
|
|
|
|
|
|
|
|
// The current line is always the line that writing will start at next. When
|
|
|
|
// an element is serialized, the current line is updated to be the line at
|
|
|
|
// which the next element should be written.
|
|
|
|
get _currentLine() {
|
|
|
|
return this._lines.length ? this._lines[this._lines.length - 1] : null;
|
|
|
|
},
|
2012-09-29 20:32:56 +04:00
|
|
|
|
2013-05-21 07:05:53 +04:00
|
|
|
set _currentLine(val) {
|
|
|
|
return this._lines[this._lines.length - 1] = val;
|
|
|
|
},
|
2010-02-21 07:42:25 +03:00
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
_serializeElement(elem) {
|
2013-05-21 07:05:53 +04:00
|
|
|
// table
|
|
|
|
if (elem.localName == "table") {
|
|
|
|
this._serializeTable(elem);
|
|
|
|
return;
|
2010-02-21 07:42:25 +03:00
|
|
|
}
|
2013-05-21 07:05:53 +04:00
|
|
|
|
|
|
|
// all other elements
|
|
|
|
|
|
|
|
let hasText = false;
|
|
|
|
for (let child of elem.childNodes) {
|
|
|
|
if (child.nodeType == Node.TEXT_NODE) {
|
|
|
|
let text = this._nodeText(child);
|
|
|
|
this._appendText(text);
|
|
|
|
hasText = hasText || !!text.trim();
|
2019-02-28 11:39:33 +03:00
|
|
|
} else if (child.nodeType == Node.ELEMENT_NODE) {
|
2013-05-21 07:05:53 +04:00
|
|
|
this._serializeElement(child);
|
2019-02-28 11:39:33 +03:00
|
|
|
}
|
2010-02-21 07:42:25 +03:00
|
|
|
}
|
|
|
|
|
2013-05-21 07:05:53 +04:00
|
|
|
// For headings, draw a "line" underneath them so they stand out.
|
2019-04-16 23:33:01 +03:00
|
|
|
let isHeader = /^h[0-9]+$/.test(elem.localName);
|
|
|
|
if (isHeader) {
|
2013-05-21 07:05:53 +04:00
|
|
|
let headerText = (this._currentLine || "").trim();
|
|
|
|
if (headerText) {
|
|
|
|
this._startNewLine();
|
|
|
|
this._appendText("-".repeat(headerText.length));
|
|
|
|
}
|
|
|
|
}
|
2010-02-21 07:42:25 +03:00
|
|
|
|
2019-04-16 23:33:01 +03:00
|
|
|
// Add a blank line underneath elements but only if they contain text.
|
|
|
|
if (hasText && (isHeader || "p" == elem.localName)) {
|
|
|
|
this._startNewLine();
|
|
|
|
this._startNewLine();
|
2013-05-21 07:05:53 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
_startNewLine(lines) {
|
2013-05-21 07:05:53 +04:00
|
|
|
let currLine = this._currentLine;
|
|
|
|
if (currLine) {
|
|
|
|
// The current line is not empty. Trim it.
|
|
|
|
this._currentLine = currLine.trim();
|
|
|
|
if (!this._currentLine)
|
|
|
|
// The current line became empty. Discard it.
|
|
|
|
this._lines.pop();
|
|
|
|
}
|
|
|
|
this._lines.push("");
|
|
|
|
},
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
_appendText(text, lines) {
|
2013-05-21 07:05:53 +04:00
|
|
|
this._currentLine += text;
|
|
|
|
},
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
_isHiddenSubHeading(th) {
|
2016-04-18 18:57:32 +03:00
|
|
|
return th.parentNode.parentNode.style.display == "none";
|
|
|
|
},
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
_serializeTable(table) {
|
2013-05-21 07:05:53 +04:00
|
|
|
// Collect the table's column headings if in fact there are any. First
|
|
|
|
// check thead. If there's no thead, check the first tr.
|
|
|
|
let colHeadings = {};
|
|
|
|
let tableHeadingElem = table.querySelector("thead");
|
|
|
|
if (!tableHeadingElem)
|
|
|
|
tableHeadingElem = table.querySelector("tr");
|
|
|
|
if (tableHeadingElem) {
|
|
|
|
let tableHeadingCols = tableHeadingElem.querySelectorAll("th,td");
|
|
|
|
// If there's a contiguous run of th's in the children starting from the
|
|
|
|
// rightmost child, then consider them to be column headings.
|
|
|
|
for (let i = tableHeadingCols.length - 1; i >= 0; i--) {
|
2016-04-18 18:57:32 +03:00
|
|
|
let col = tableHeadingCols[i];
|
|
|
|
if (col.localName != "th" || col.classList.contains("title-column"))
|
2013-05-21 07:05:53 +04:00
|
|
|
break;
|
2016-04-18 18:57:32 +03:00
|
|
|
colHeadings[i] = this._nodeText(col).trim();
|
2013-05-21 07:05:53 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
let hasColHeadings = Object.keys(colHeadings).length > 0;
|
|
|
|
if (!hasColHeadings)
|
|
|
|
tableHeadingElem = null;
|
|
|
|
|
|
|
|
let trs = table.querySelectorAll("table > tr, tbody > tr");
|
|
|
|
let startRow =
|
|
|
|
tableHeadingElem && tableHeadingElem.localName == "tr" ? 1 : 0;
|
|
|
|
|
|
|
|
if (startRow >= trs.length)
|
|
|
|
// The table's empty.
|
|
|
|
return;
|
|
|
|
|
2019-04-16 23:33:01 +03:00
|
|
|
if (hasColHeadings) {
|
2013-05-21 07:05:53 +04:00
|
|
|
// Use column headings. Print each tr as a multi-line chunk like:
|
|
|
|
// Heading 1: Column 1 value
|
|
|
|
// Heading 2: Column 2 value
|
|
|
|
for (let i = startRow; i < trs.length; i++) {
|
|
|
|
let children = trs[i].querySelectorAll("td");
|
|
|
|
for (let j = 0; j < children.length; j++) {
|
|
|
|
let text = "";
|
|
|
|
if (colHeadings[j])
|
|
|
|
text += colHeadings[j] + ": ";
|
|
|
|
text += this._nodeText(children[j]).trim();
|
|
|
|
this._appendText(text);
|
|
|
|
this._startNewLine();
|
|
|
|
}
|
|
|
|
this._startNewLine();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Don't use column headings. Assume the table has only two columns and
|
|
|
|
// print each tr in a single line like:
|
|
|
|
// Column 1 value: Column 2 value
|
|
|
|
for (let i = startRow; i < trs.length; i++) {
|
|
|
|
let children = trs[i].querySelectorAll("th,td");
|
|
|
|
let rowHeading = this._nodeText(children[0]).trim();
|
2016-04-18 18:57:32 +03:00
|
|
|
if (children[0].classList.contains("title-column")) {
|
|
|
|
if (!this._isHiddenSubHeading(children[0]))
|
|
|
|
this._appendText(rowHeading);
|
2016-04-29 07:52:56 +03:00
|
|
|
} else if (children.length == 1) {
|
|
|
|
// This is a single-cell row.
|
|
|
|
this._appendText(rowHeading);
|
2016-04-18 18:57:32 +03:00
|
|
|
} else {
|
2016-04-29 07:52:56 +03:00
|
|
|
let childTables = trs[i].querySelectorAll("table");
|
|
|
|
if (childTables.length) {
|
|
|
|
// If we have child tables, don't use nodeText - its trs are already
|
|
|
|
// queued up from querySelectorAll earlier.
|
|
|
|
this._appendText(rowHeading + ": ");
|
|
|
|
} else {
|
|
|
|
this._appendText(rowHeading + ": " + this._nodeText(children[1]).trim());
|
|
|
|
}
|
2016-04-18 18:57:32 +03:00
|
|
|
}
|
2013-05-21 07:05:53 +04:00
|
|
|
this._startNewLine();
|
|
|
|
}
|
|
|
|
this._startNewLine();
|
|
|
|
},
|
|
|
|
|
2016-12-30 02:34:54 +03:00
|
|
|
_nodeText(node) {
|
2013-05-21 07:05:53 +04:00
|
|
|
return node.textContent.replace(/\s+/g, " ");
|
|
|
|
},
|
|
|
|
};
|
2010-02-21 07:42:25 +03:00
|
|
|
|
|
|
|
function openProfileDirectory() {
|
|
|
|
// Get the profile directory.
|
2010-09-11 13:16:00 +04:00
|
|
|
let currProfD = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
2010-02-21 07:42:25 +03:00
|
|
|
let profileDir = currProfD.path;
|
|
|
|
|
|
|
|
// Show the profile directory.
|
|
|
|
let nsLocalFile = Components.Constructor("@mozilla.org/file/local;1",
|
2017-08-04 11:49:22 +03:00
|
|
|
"nsIFile", "initWithPath");
|
2010-02-21 07:42:25 +03:00
|
|
|
new nsLocalFile(profileDir).reveal();
|
|
|
|
}
|
2012-02-24 07:34:18 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Profile reset is only supported for the default profile if the appropriate migrator exists.
|
|
|
|
*/
|
2015-02-20 03:53:00 +03:00
|
|
|
function populateActionBox() {
|
|
|
|
if (ResetProfile.resetSupported()) {
|
|
|
|
$("reset-box").style.display = "block";
|
|
|
|
$("action-box").style.display = "block";
|
|
|
|
}
|
2017-06-13 05:17:50 +03:00
|
|
|
if (!Services.appinfo.inSafeMode && AppConstants.platform !== "android") {
|
2015-02-20 03:53:00 +03:00
|
|
|
$("safe-mode-box").style.display = "block";
|
|
|
|
$("action-box").style.display = "block";
|
2018-03-16 05:06:22 +03:00
|
|
|
|
|
|
|
if (Services.policies && !Services.policies.isAllowed("safeMode")) {
|
|
|
|
$("restart-in-safe-mode-button").setAttribute("disabled", "true");
|
|
|
|
}
|
2015-02-20 03:53:00 +03:00
|
|
|
}
|
2012-02-24 07:34:18 +04:00
|
|
|
}
|
2014-03-24 17:11:21 +04:00
|
|
|
|
2015-02-20 03:53:00 +03:00
|
|
|
// Prompt user to restart the browser in safe mode
|
|
|
|
function safeModeRestart() {
|
|
|
|
let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"]
|
|
|
|
.createInstance(Ci.nsISupportsPRBool);
|
|
|
|
Services.obs.notifyObservers(cancelQuit, "quit-application-requested", "restart");
|
|
|
|
|
|
|
|
if (!cancelQuit.data) {
|
|
|
|
Services.startup.restartInSafeMode(Ci.nsIAppStartup.eAttemptQuit);
|
|
|
|
}
|
|
|
|
}
|
2014-03-24 17:11:21 +04:00
|
|
|
/**
|
|
|
|
* Set up event listeners for buttons.
|
|
|
|
*/
|
2016-08-04 10:20:25 +03:00
|
|
|
function setupEventListeners() {
|
2019-06-07 20:01:56 +03:00
|
|
|
let button = $("reset-box-button");
|
2018-11-16 03:08:37 +03:00
|
|
|
if (button) {
|
|
|
|
button.addEventListener("click", function(event) {
|
2017-06-13 05:17:50 +03:00
|
|
|
ResetProfile.openConfirmationDialog(window);
|
|
|
|
});
|
2018-11-16 03:08:37 +03:00
|
|
|
}
|
|
|
|
button = $("restart-in-safe-mode-button");
|
|
|
|
if (button) {
|
|
|
|
button.addEventListener("click", function(event) {
|
2017-06-13 05:17:50 +03:00
|
|
|
if (Services.obs.enumerateObservers("restart-in-safe-mode").hasMoreElements()) {
|
|
|
|
Services.obs.notifyObservers(null, "restart-in-safe-mode");
|
|
|
|
} else {
|
|
|
|
safeModeRestart();
|
|
|
|
}
|
|
|
|
});
|
2018-11-16 03:08:37 +03:00
|
|
|
}
|
2019-06-07 20:01:56 +03:00
|
|
|
if (AppConstants.MOZ_UPDATER) {
|
|
|
|
button = $("update-dir-button");
|
|
|
|
if (button) {
|
|
|
|
button.addEventListener("click", function(event) {
|
|
|
|
// Get the update directory.
|
|
|
|
let updateDir = Services.dirsvc.get("UpdRootD", Ci.nsIFile);
|
|
|
|
if (!updateDir.exists()) {
|
|
|
|
updateDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755);
|
|
|
|
}
|
|
|
|
let updateDirPath = updateDir.path;
|
|
|
|
// Show the update directory.
|
|
|
|
let nsLocalFile = Components.Constructor("@mozilla.org/file/local;1",
|
|
|
|
"nsIFile", "initWithPath");
|
|
|
|
new nsLocalFile(updateDirPath).reveal();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
button = $("show-update-history-button");
|
|
|
|
if (button) {
|
|
|
|
button.addEventListener("click", function(event) {
|
|
|
|
let uri = "chrome://mozapps/content/update/history.xul";
|
|
|
|
let features = "chrome,centerscreen,resizable=no,titlebar,toolbar=no," +
|
|
|
|
"dialog=yes,modal";
|
|
|
|
Services.ww.openWindow(window, uri, "Update:History", features, null);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2018-11-16 03:08:37 +03:00
|
|
|
button = $("verify-place-integrity-button");
|
|
|
|
if (button) {
|
|
|
|
button.addEventListener("click", function(event) {
|
2017-06-13 05:17:50 +03:00
|
|
|
PlacesDBUtils.checkAndFixDatabase().then((tasksStatusMap) => {
|
2017-11-30 20:16:02 +03:00
|
|
|
let logs = [];
|
|
|
|
for (let [key, value] of tasksStatusMap) {
|
|
|
|
logs.push(`> Task: ${key}`);
|
|
|
|
let prefix = value.succeeded ? "+ " : "- ";
|
|
|
|
logs = logs.concat(value.logs.map(m => `${prefix}${m}`));
|
|
|
|
}
|
2017-06-13 05:17:50 +03:00
|
|
|
$("verify-place-result").style.display = "block";
|
|
|
|
$("verify-place-result").classList.remove("no-copy");
|
2017-11-30 20:16:02 +03:00
|
|
|
$("verify-place-result").textContent = logs.join("\n");
|
2017-06-13 05:17:50 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-11-12 02:22:34 +03:00
|
|
|
$("copy-raw-data-to-clipboard").addEventListener("click", function(event) {
|
2014-03-24 17:11:21 +04:00
|
|
|
copyRawDataToClipboard(this);
|
|
|
|
});
|
2016-11-12 02:22:34 +03:00
|
|
|
$("copy-to-clipboard").addEventListener("click", function(event) {
|
2014-03-24 17:11:21 +04:00
|
|
|
copyContentsToClipboard();
|
|
|
|
});
|
2016-11-12 02:22:34 +03:00
|
|
|
$("profile-dir-button").addEventListener("click", function(event) {
|
2014-03-24 17:11:21 +04:00
|
|
|
openProfileDirectory();
|
|
|
|
});
|
|
|
|
}
|