1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 const { Troubleshoot } = ChromeUtils.importESModule(
8 "resource://gre/modules/Troubleshoot.sys.mjs"
10 const { ResetProfile } = ChromeUtils.importESModule(
11 "resource://gre/modules/ResetProfile.sys.mjs"
13 const { AppConstants } = ChromeUtils.importESModule(
14 "resource://gre/modules/AppConstants.sys.mjs"
17 ChromeUtils.defineESModuleGetters(this, {
18 DownloadUtils: "resource://gre/modules/DownloadUtils.sys.mjs",
19 PlacesDBUtils: "resource://gre/modules/PlacesDBUtils.sys.mjs",
20 ProcessType: "resource://gre/modules/ProcessType.sys.mjs",
23 window.addEventListener("load", function onload() {
25 window.removeEventListener("load", onload);
26 Troubleshoot.snapshot().then(async snapshot => {
27 for (let prop in snapshotFormatters) {
29 await snapshotFormatters[prop](snapshot[prop]);
32 "stack of snapshot error for about:support: ",
44 setupEventListeners();
46 if (Services.sysinfo.getProperty("isPackagedApp")) {
47 $("update-dir-row").hidden = true;
48 $("update-history-row").hidden = true;
51 console.error("stack of load error for about:support: ", e, ": ", e.stack);
55 function prefsTable(data) {
56 return sortedArrayFromObject(data).map(function ([name, value]) {
58 $.new("td", name, "pref-name"),
59 // Very long preference values can cause users problems when they
60 // copy and paste them into some text editors. Long values generally
61 // aren't useful anyway, so truncate them to a reasonable length.
62 $.new("td", String(value).substr(0, 120), "pref-value"),
67 // Fluent uses lisp-case IDs so this converts
68 // the SentenceCase info IDs to lisp-case.
69 const FLUENT_IDENT_REGEX = /^[a-zA-Z][a-zA-Z0-9_-]*$/;
70 function toFluentID(str) {
71 if (!FLUENT_IDENT_REGEX.test(str)) {
76 .replace(/([a-z0-9])([A-Z])/g, "$1-$2")
80 // Each property in this object corresponds to a property in Troubleshoot.sys.mjs's
81 // snapshot data. Each function is passed its property's corresponding data,
82 // and it's the function's job to update the page with it.
83 var snapshotFormatters = {
84 async application(data) {
85 $("application-box").textContent = data.name;
86 $("useragent-box").textContent = data.userAgent;
87 $("os-box").textContent = data.osVersion;
89 $("os-theme-box").textContent = data.osTheme;
91 $("os-theme-row").hidden = true;
93 if (AppConstants.platform == "macosx") {
94 $("rosetta-box").textContent = data.rosetta;
96 if (AppConstants.platform == "win") {
97 const translatedList = await Promise.all(
98 data.pointingDevices.map(deviceName => {
99 return document.l10n.formatValue(deviceName);
103 const formatter = new Intl.ListFormat();
105 $("pointing-devices-box").textContent = formatter.format(translatedList);
107 $("binary-box").textContent = Services.dirsvc.get(
111 $("supportLink").href = data.supportURL;
112 let version = AppConstants.MOZ_APP_VERSION_DISPLAY;
114 version += " (" + data.vendor + ")";
116 $("version-box").textContent = version;
117 $("buildid-box").textContent = data.buildID;
118 $("distributionid-box").textContent = data.distributionID;
119 if (data.updateChannel) {
120 $("updatechannel-box").textContent = data.updateChannel;
122 if (AppConstants.MOZ_UPDATER && AppConstants.platform != "android") {
123 $("update-dir-box").textContent = Services.dirsvc.get(
128 $("profile-dir-box").textContent = Services.dirsvc.get(
134 let launcherStatusTextId = "launcher-process-status-unknown";
135 switch (data.launcherProcessState) {
139 launcherStatusTextId =
140 "launcher-process-status-" + data.launcherProcessState;
144 document.l10n.setAttributes(
145 $("launcher-process-box"),
150 const STATUS_STRINGS = {
151 experimentControl: "fission-status-experiment-control",
152 experimentTreatment: "fission-status-experiment-treatment",
153 disabledByE10sEnv: "fission-status-disabled-by-e10s-env",
154 enabledByEnv: "fission-status-enabled-by-env",
155 disabledByEnv: "fission-status-disabled-by-env",
156 enabledByDefault: "fission-status-enabled-by-default",
157 disabledByDefault: "fission-status-disabled-by-default",
158 enabledByUserPref: "fission-status-enabled-by-user-pref",
159 disabledByUserPref: "fission-status-disabled-by-user-pref",
160 disabledByE10sOther: "fission-status-disabled-by-e10s-other",
161 enabledByRollout: "fission-status-enabled-by-rollout",
164 let statusTextId = STATUS_STRINGS[data.fissionDecisionStatus];
166 document.l10n.setAttributes(
167 $("multiprocess-box-process-count"),
168 "multi-process-windows",
170 remoteWindows: data.numRemoteWindows,
171 totalWindows: data.numTotalWindows,
174 document.l10n.setAttributes(
175 $("fission-box-process-count"),
178 fissionWindows: data.numFissionWindows,
179 totalWindows: data.numTotalWindows,
182 document.l10n.setAttributes($("fission-box-status"), statusTextId);
184 if (Services.policies) {
185 let policiesStrId = "";
186 let aboutPolicies = "about:policies";
187 switch (data.policiesStatus) {
188 case Services.policies.INACTIVE:
189 policiesStrId = "policies-inactive";
192 case Services.policies.ACTIVE:
193 policiesStrId = "policies-active";
194 aboutPolicies += "#active";
198 policiesStrId = "policies-error";
199 aboutPolicies += "#errors";
203 if (data.policiesStatus != Services.policies.INACTIVE) {
204 let activePolicies = $.new("a", null, null, {
207 document.l10n.setAttributes(activePolicies, policiesStrId);
208 $("policies-status").appendChild(activePolicies);
210 document.l10n.setAttributes($("policies-status"), policiesStrId);
213 $("policies-status-row").hidden = true;
216 let keyLocationServiceGoogleFound = data.keyLocationServiceGoogleFound
219 document.l10n.setAttributes(
220 $("key-location-service-google-box"),
221 keyLocationServiceGoogleFound
224 let keySafebrowsingGoogleFound = data.keySafebrowsingGoogleFound
227 document.l10n.setAttributes(
228 $("key-safebrowsing-google-box"),
229 keySafebrowsingGoogleFound
232 let keyMozillaFound = data.keyMozillaFound ? "found" : "missing";
233 document.l10n.setAttributes($("key-mozilla-box"), keyMozillaFound);
235 $("safemode-box").textContent = data.safeMode;
237 const formatHumanReadableBytes = (elem, bytes) => {
238 let size = DownloadUtils.convertByteUnits(bytes);
239 document.l10n.setAttributes(elem, "app-basics-data-size", {
245 formatHumanReadableBytes($("memory-size-box"), data.memorySizeBytes);
246 formatHumanReadableBytes($("disk-available-box"), data.diskAvailableBytes);
249 async legacyUserStylesheets(legacyUserStylesheets) {
250 $("legacyUserStylesheets-enabled").textContent =
251 legacyUserStylesheets.active;
252 $("legacyUserStylesheets-types").textContent =
253 new Intl.ListFormat(undefined, { style: "short", type: "unit" }).format(
254 legacyUserStylesheets.types
256 document.l10n.setAttributes(
257 $("legacyUserStylesheets-types"),
258 "legacy-user-stylesheets-no-stylesheets-found"
263 if (!AppConstants.MOZ_CRASHREPORTER) {
267 let daysRange = Troubleshoot.kMaxCrashAge / (24 * 60 * 60 * 1000);
268 document.l10n.setAttributes($("crashes"), "report-crash-for-days", {
273 reportURL = Services.prefs.getCharPref("breakpad.reportURL");
274 // Ignore any non http/https urls
275 if (!/^https?:/i.test(reportURL)) {
280 $("crashes-noConfig").style.display = "block";
281 $("crashes-noConfig").classList.remove("no-copy");
284 $("crashes-allReports").style.display = "block";
286 if (data.pending > 0) {
287 document.l10n.setAttributes(
288 $("crashes-allReportsWithPending"),
290 { reports: data.pending }
294 let dateNow = new Date();
297 data.submitted.map(function (crash) {
298 let date = new Date(crash.date);
299 let timePassed = dateNow - date;
300 let formattedDateStrId;
301 let formattedDateStrArgs;
302 if (timePassed >= 24 * 60 * 60 * 1000) {
303 let daysPassed = Math.round(timePassed / (24 * 60 * 60 * 1000));
304 formattedDateStrId = "crashes-time-days";
305 formattedDateStrArgs = { days: daysPassed };
306 } else if (timePassed >= 60 * 60 * 1000) {
307 let hoursPassed = Math.round(timePassed / (60 * 60 * 1000));
308 formattedDateStrId = "crashes-time-hours";
309 formattedDateStrArgs = { hours: hoursPassed };
311 let minutesPassed = Math.max(Math.round(timePassed / (60 * 1000)), 1);
312 formattedDateStrId = "crashes-time-minutes";
313 formattedDateStrArgs = { minutes: minutesPassed };
317 $.new("a", crash.id, null, { href: reportURL + crash.id }),
319 $.new("td", null, null, {
320 "data-l10n-id": formattedDateStrId,
321 "data-l10n-args": formattedDateStrArgs,
331 data.map(function (addon) {
333 $.new("td", addon.name),
334 $.new("td", addon.type),
335 $.new("td", addon.version),
336 $.new("td", addon.isActive),
337 $.new("td", addon.id),
343 securitySoftware(data) {
344 if (AppConstants.platform !== "win") {
345 $("security-software").hidden = true;
346 $("security-software-table").hidden = true;
350 $("security-software-antivirus").textContent = data.registeredAntiVirus;
351 $("security-software-antispyware").textContent = data.registeredAntiSpyware;
352 $("security-software-firewall").textContent = data.registeredFirewall;
358 data.map(function (feature) {
360 $.new("td", feature.name),
361 $.new("td", feature.version),
362 $.new("td", feature.id),
368 async processes(data) {
369 async function buildEntry(name, value) {
370 const fluentName = ProcessType.fluentNameFromProcessTypeString(name);
371 let entryName = (await document.l10n.formatValue(fluentName)) || name;
372 $("processes-tbody").appendChild(
373 $.new("tr", [$.new("td", entryName), $.new("td", value)])
377 let remoteProcessesCount = Object.values(data.remoteTypes).reduce(
381 document.querySelector("#remoteprocesses-row a").textContent =
382 remoteProcessesCount;
384 // Display the regular "web" process type first in the list,
385 // and with special formatting.
386 if (data.remoteTypes.web) {
389 `${data.remoteTypes.web} / ${data.maxWebContentProcesses}`
391 delete data.remoteTypes.web;
394 for (let remoteProcessType in data.remoteTypes) {
395 await buildEntry(remoteProcessType, data.remoteTypes[remoteProcessType]);
399 async experimentalFeatures(data) {
403 let titleL10nIds = data.map(([titleL10nId]) => titleL10nId);
404 let titleL10nObjects = await document.l10n.formatMessages(titleL10nIds);
405 if (titleL10nObjects.length != data.length) {
406 throw Error("Missing localized title strings in experimental features");
408 for (let i = 0; i < titleL10nObjects.length; i++) {
409 let localizedTitle = titleL10nObjects[i].attributes.find(
410 a => a.name == "label"
412 data[i] = [localizedTitle, data[i][1], data[i][2]];
416 $("experimental-features-tbody"),
417 data.map(function ([title, pref, value]) {
419 $.new("td", `${title} (${pref})`, "pref-name"),
420 $.new("td", value, "pref-value"),
426 environmentVariables(data) {
431 $("environment-variables-tbody"),
432 Object.entries(data).map(([name, value]) => {
434 $.new("td", name, "pref-name"),
435 $.new("td", value, "pref-value"),
441 modifiedPreferences(data) {
442 $.append($("prefs-tbody"), prefsTable(data));
445 lockedPreferences(data) {
446 $.append($("locked-prefs-tbody"), prefsTable(data));
450 if (!AppConstants.MOZ_PLACES) {
453 const statsBody = $("place-database-stats-tbody");
456 data.map(function (entry) {
458 $.new("td", entry.entity),
459 $.new("td", entry.count),
460 $.new("td", entry.sizeBytes / 1024),
461 $.new("td", entry.sizePerc),
462 $.new("td", entry.efficiencyPerc),
463 $.new("td", entry.sequentialityPerc),
467 statsBody.style.display = "none";
468 $("place-database-stats-toggle").addEventListener(
471 if (statsBody.style.display === "none") {
472 document.l10n.setAttributes(
474 "place-database-stats-hide"
476 statsBody.style.display = "";
478 document.l10n.setAttributes(
480 "place-database-stats-show"
482 statsBody.style.display = "none";
488 printingPreferences(data) {
489 if (AppConstants.platform == "android") {
492 const tbody = $("support-printing-prefs-tbody");
493 $.append(tbody, prefsTable(data));
494 $("support-printing-clear-settings-button").addEventListener(
497 for (let name in data) {
498 Services.prefs.clearUserPref(name);
500 tbody.textContent = "";
505 async graphics(data) {
506 function localizedMsg(msg) {
507 if (typeof msg == "object" && msg.key) {
508 return document.l10n.formatValue(msg.key, msg.args);
510 let msgId = toFluentID(msg);
512 return document.l10n.formatValue(msgId);
517 // Read APZ info out of data.info, stripping it out in the process.
519 let formatApzInfo = function (info) {
529 let key = "Apz" + type + "Input";
531 if (!(key in info)) {
537 out.push(toFluentID(type.toLowerCase() + "Enabled"));
543 // Create a <tr> element with key and value columns.
545 // @key Text in the key column. Localized automatically, unless starts with "#".
546 // @value Fluent ID for text in the value column, or array of children.
547 function buildRow(key, value) {
548 let title = key[0] == "#" ? key.substr(1) : key;
549 let keyStrId = toFluentID(key);
550 let valueStrId = Array.isArray(value) ? null : toFluentID(value);
551 let td = $.new("td", value);
552 td.style["white-space"] = "pre-wrap";
554 document.l10n.setAttributes(td, valueStrId);
557 let th = $.new("th", title, "column");
558 if (!key.startsWith("#")) {
559 document.l10n.setAttributes(th, keyStrId);
561 return $.new("tr", [th, td]);
564 // @where The name in "graphics-<name>-tbody", of the element to append to.
565 // @trs Array of row elements.
566 function addRows(where, trs) {
567 $.append($("graphics-" + where + "-tbody"), trs);
570 // Build and append a row.
572 // @where The name in "graphics-<name>-tbody", of the element to append to.
573 function addRow(where, key, value) {
574 addRows(where, [buildRow(key, value)]);
576 if ("info" in data) {
577 apzInfo = formatApzInfo(data.info);
579 let trs = sortedArrayFromObject(data.info).map(function ([prop, val]) {
580 let td = $.new("td", String(val));
581 td.style["word-break"] = "break-all";
582 return $.new("tr", [$.new("th", prop, "column"), td]);
584 addRows("diagnostics", trs);
589 let windowUtils = window.windowUtils;
590 let gpuProcessPid = windowUtils.gpuProcessPid;
592 if (gpuProcessPid != -1) {
593 let gpuProcessKillButton = null;
594 if (AppConstants.NIGHTLY_BUILD || AppConstants.MOZ_DEV_EDITION) {
595 gpuProcessKillButton = $.new("button");
597 gpuProcessKillButton.addEventListener("click", function () {
598 windowUtils.terminateGPUProcess();
601 document.l10n.setAttributes(
602 gpuProcessKillButton,
603 "gpu-process-kill-button"
607 addRow("diagnostics", "gpu-process-pid", [new Text(gpuProcessPid)]);
608 if (gpuProcessKillButton) {
609 addRow("diagnostics", "gpu-process", [gpuProcessKillButton]);
614 (AppConstants.NIGHTLY_BUILD || AppConstants.MOZ_DEV_EDITION) &&
615 AppConstants.platform != "macosx"
617 let gpuDeviceResetButton = $.new("button");
619 gpuDeviceResetButton.addEventListener("click", function () {
620 windowUtils.triggerDeviceReset();
623 document.l10n.setAttributes(
624 gpuDeviceResetButton,
625 "gpu-device-reset-button"
627 addRow("diagnostics", "gpu-device-reset", [gpuDeviceResetButton]);
630 // graphics-failures-tbody tbody
631 if ("failures" in data) {
632 // If indices is there, it should be the same length as failures,
633 // (see Troubleshoot.sys.mjs) but we check anyway:
634 if ("indices" in data && data.failures.length == data.indices.length) {
636 for (let i = 0; i < data.failures.length; i++) {
637 let assembled = assembleFromGraphicsFailure(i, data);
638 combined.push(assembled);
640 combined.sort(function (a, b) {
641 if (a.index < b.index) {
644 if (a.index > b.index) {
650 $("graphics-failures-tbody"),
651 combined.map(function (val) {
653 $.new("th", val.header, "column"),
654 $.new("td", val.message),
660 $.append($("graphics-failures-tbody"), [
662 $.new("th", "LogFailure", "column"),
665 data.failures.map(function (val) {
666 return $.new("p", val);
672 delete data.failures;
674 $("graphics-failures-tbody").style.display = "none";
677 // Add a new row to the table, and take the key (or keys) out of data.
679 // @where Table section to add to.
680 // @key Data key to use.
681 // @colKey The localization key to use, if different from key.
682 async function addRowFromKey(where, key, colKey) {
683 if (!(key in data)) {
686 colKey = colKey || key;
689 let messageKey = key + "Message";
690 if (messageKey in data) {
691 value = await localizedMsg(data[messageKey]);
692 delete data[messageKey];
699 addRow(where, colKey, [new Text(value)]);
703 // graphics-features-tbody
704 let devicePixelRatios = data.graphicsDevicePixelRatios;
705 addRow("features", "graphicsDevicePixelRatios", [
706 new Text(devicePixelRatios),
710 if (data.windowLayerManagerRemote) {
711 compositor = data.windowLayerManagerType;
713 let noOMTCString = await document.l10n.formatValue("main-thread-no-omtc");
714 compositor = "BasicLayers (" + noOMTCString + ")";
716 addRow("features", "compositing", [new Text(compositor)]);
717 addRow("features", "supportFontDetermination", [
718 new Text(data.supportFontDetermination),
720 delete data.windowLayerManagerRemote;
721 delete data.windowLayerManagerType;
722 delete data.numTotalWindows;
723 delete data.numAcceleratedWindows;
724 delete data.numAcceleratedWindowsMessage;
725 delete data.graphicsDevicePixelRatios;
734 await document.l10n.formatValues(
748 "webgl1DriverExtensions",
753 "webgl2DriverExtensions",
755 ["supportsHardwareH264", "hardware-h264"],
756 ["direct2DEnabled", "#Direct2D"],
757 ["windowProtocol", "graphics-window-protocol"],
758 ["desktopEnvironment", "graphics-desktop-environment"],
761 for (let feature of featureKeys) {
762 if (Array.isArray(feature)) {
763 await addRowFromKey("features", feature[0], feature[1]);
766 await addRowFromKey("features", feature);
769 featureKeys = ["webgpuDefaultAdapter", "webgpuFallbackAdapter"];
770 for (let feature of featureKeys) {
771 const obj = data[feature];
773 const str = JSON.stringify(obj, null, " ");
774 await addRow("features", feature, [new Text(str)]);
775 delete data[feature];
779 if ("directWriteEnabled" in data) {
780 let message = data.directWriteEnabled;
781 if ("directWriteVersion" in data) {
782 message += " (" + data.directWriteVersion + ")";
784 await addRow("features", "#DirectWrite", [new Text(message)]);
785 delete data.directWriteEnabled;
786 delete data.directWriteVersion;
791 ["adapterDescription", "gpu-description"],
792 ["adapterVendorID", "gpu-vendor-id"],
793 ["adapterDeviceID", "gpu-device-id"],
794 ["driverVendor", "gpu-driver-vendor"],
795 ["driverVersion", "gpu-driver-version"],
796 ["driverDate", "gpu-driver-date"],
797 ["adapterDrivers", "gpu-drivers"],
798 ["adapterSubsysID", "gpu-subsys-id"],
799 ["adapterRAM", "gpu-ram"],
802 function showGpu(id, suffix) {
804 return data[prop + suffix];
808 for (let [prop, key] of adapterKeys) {
809 let value = get(prop);
810 if (value === undefined || value === "") {
813 trs.push(buildRow(key, [new Text(value)]));
817 $("graphics-" + id + "-tbody").style.display = "none";
822 if ("isGPU2Active" in data && (suffix == "2") != data.isGPU2Active) {
826 addRow(id, "gpu-active", active);
829 showGpu("gpu-1", "");
830 showGpu("gpu-2", "2");
832 // Remove adapter keys.
833 for (let [prop /* key */] of adapterKeys) {
835 delete data[prop + "2"];
837 delete data.isGPU2Active;
839 let featureLog = data.featureLog;
840 delete data.featureLog;
842 if (featureLog.features.length) {
843 for (let feature of featureLog.features) {
845 for (let entry of feature.log) {
847 if (entry.hasOwnProperty("failureId")) {
848 // This is a failure ID. See nsIGfxInfo.idl.
849 let m = /BUG_(\d+)/.exec(entry.failureId);
855 let failureIdSpan = $.new("span", "");
857 let bugHref = $.new("a");
859 "https://bugzilla.mozilla.org/show_bug.cgi?id=" + bugNumber;
860 bugHref.setAttribute("data-l10n-name", "bug-link");
861 failureIdSpan.append(bugHref);
862 document.l10n.setAttributes(
864 "support-blocklisted-bug",
870 entry.hasOwnProperty("failureId") &&
871 entry.failureId.length
873 document.l10n.setAttributes(failureIdSpan, "unknown-failure", {
874 failureCode: entry.failureId,
878 let messageSpan = $.new("span", "");
879 if (entry.hasOwnProperty("message") && entry.message.length) {
880 messageSpan.innerText = entry.message;
883 let typeCol = $.new("td", entry.type);
884 let statusCol = $.new("td", entry.status);
885 let messageCol = $.new("td", "");
886 let failureIdCol = $.new("td", "");
887 typeCol.style.width = "10%";
888 statusCol.style.width = "10%";
889 messageCol.style.width = "30%";
890 messageCol.appendChild(messageSpan);
891 failureIdCol.style.width = "50%";
892 failureIdCol.appendChild(failureIdSpan);
894 trs.push($.new("tr", [typeCol, statusCol, messageCol, failureIdCol]));
896 addRow("decisions", "#" + feature.name, [$.new("table", trs)]);
899 $("graphics-decisions-tbody").style.display = "none";
902 if (featureLog.fallbacks.length) {
903 for (let fallback of featureLog.fallbacks) {
904 addRow("workarounds", "#" + fallback.name, [
905 new Text(fallback.message),
909 $("graphics-workarounds-tbody").style.display = "none";
912 let crashGuards = data.crashGuards;
913 delete data.crashGuards;
915 if (crashGuards.length) {
916 for (let guard of crashGuards) {
917 let resetButton = $.new("button");
918 let onClickReset = function () {
919 Services.prefs.setIntPref(guard.prefName, 0);
920 resetButton.removeEventListener("click", onClickReset);
921 resetButton.disabled = true;
924 document.l10n.setAttributes(resetButton, "reset-on-next-restart");
925 resetButton.addEventListener("click", onClickReset);
927 addRow("crashguards", guard.type + "CrashGuard", [resetButton]);
930 $("graphics-crashguards-tbody").style.display = "none";
933 // Now that we're done, grab any remaining keys in data and drop them into
934 // the diagnostics section.
935 for (let key in data) {
936 let value = data[key];
937 addRow("diagnostics", key, [new Text(value)]);
942 function insertBasicInfo(key, value) {
943 function createRow(key, value) {
944 let th = $.new("th", null, "column");
945 document.l10n.setAttributes(th, key);
946 let td = $.new("td", value);
947 td.style["white-space"] = "pre-wrap";
949 return $.new("tr", [th, td]);
951 $.append($("media-info-tbody"), [createRow(key, value)]);
954 function createDeviceInfoRow(device) {
955 let deviceInfo = Ci.nsIAudioDeviceInfo;
958 states[deviceInfo.STATE_DISABLED] = "Disabled";
959 states[deviceInfo.STATE_UNPLUGGED] = "Unplugged";
960 states[deviceInfo.STATE_ENABLED] = "Enabled";
963 preferreds[deviceInfo.PREF_NONE] = "None";
964 preferreds[deviceInfo.PREF_MULTIMEDIA] = "Multimedia";
965 preferreds[deviceInfo.PREF_VOICE] = "Voice";
966 preferreds[deviceInfo.PREF_NOTIFICATION] = "Notification";
967 preferreds[deviceInfo.PREF_ALL] = "All";
970 formats[deviceInfo.FMT_S16LE] = "S16LE";
971 formats[deviceInfo.FMT_S16BE] = "S16BE";
972 formats[deviceInfo.FMT_F32LE] = "F32LE";
973 formats[deviceInfo.FMT_F32BE] = "F32BE";
975 function toPreferredString(preferred) {
976 if (preferred == deviceInfo.PREF_NONE) {
977 return preferreds[deviceInfo.PREF_NONE];
978 } else if (preferred & deviceInfo.PREF_ALL) {
979 return preferreds[deviceInfo.PREF_ALL];
983 deviceInfo.PREF_MULTIMEDIA,
984 deviceInfo.PREF_VOICE,
985 deviceInfo.PREF_NOTIFICATION,
987 if (preferred & pref) {
988 str += " " + preferreds[pref];
994 function toFromatString(dev) {
995 let str = "default: " + formats[dev.defaultFormat] + ", support:";
997 deviceInfo.FMT_S16LE,
998 deviceInfo.FMT_S16BE,
999 deviceInfo.FMT_F32LE,
1000 deviceInfo.FMT_F32BE,
1002 if (dev.supportedFormat & fmt) {
1003 str += " " + formats[fmt];
1009 function toRateString(dev) {
1020 function toLatencyString(dev) {
1021 return dev.minLatency + " - " + dev.maxLatency;
1024 return $.new("tr", [
1025 $.new("td", device.name),
1026 $.new("td", device.groupId),
1027 $.new("td", device.vendor),
1028 $.new("td", states[device.state]),
1029 $.new("td", toPreferredString(device.preferred)),
1030 $.new("td", toFromatString(device)),
1031 $.new("td", device.maxChannels),
1032 $.new("td", toRateString(device)),
1033 $.new("td", toLatencyString(device)),
1037 function insertDeviceInfo(side, devices) {
1039 for (let dev of devices) {
1040 rows.push(createDeviceInfoRow(dev));
1042 $.append($("media-" + side + "-devices-tbody"), rows);
1045 function insertEnumerateDatabase() {
1047 !Services.prefs.getBoolPref("media.mediacapabilities.from-database")
1049 $("media-capabilities-tbody").style.display = "none";
1052 let button = $("enumerate-database-button");
1054 button.addEventListener("click", function () {
1055 let { KeyValueService } = ChromeUtils.importESModule(
1056 "resource://gre/modules/kvstore.sys.mjs"
1058 let currProfDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
1059 currProfDir.append("mediacapabilities");
1060 let path = currProfDir.path;
1062 function enumerateDatabase(name) {
1063 KeyValueService.getOrCreate(path, name)
1065 return database.enumerate();
1067 .then(enumerator => {
1069 logs.push(`${name}:`);
1070 while (enumerator.hasMoreElements()) {
1071 const { key, value } = enumerator.getNext();
1072 logs.push(`${key}: ${value}`);
1074 $("enumerate-database-result").textContent +=
1075 logs.join("\n") + "\n";
1078 $("enumerate-database-result").textContent += `${name}:\n`;
1082 $("enumerate-database-result").style.display = "block";
1083 $("enumerate-database-result").classList.remove("no-copy");
1084 $("enumerate-database-result").textContent = "";
1086 enumerateDatabase("video/av1");
1087 enumerateDatabase("video/vp8");
1088 enumerateDatabase("video/vp9");
1089 enumerateDatabase("video/avc");
1090 enumerateDatabase("video/theora");
1095 function roundtripAudioLatency() {
1096 insertBasicInfo("roundtrip-latency", "...");
1098 .defaultDevicesRoundTripLatency()
1100 var latencyString = `${(latency[0] * 1000).toFixed(2)}ms (${(
1103 data.defaultDevicesRoundTripLatency = latencyString;
1104 document.querySelector(
1105 'th[data-l10n-id="roundtrip-latency"]'
1106 ).nextSibling.textContent = latencyString;
1111 function createCDMInfoRow(cdmInfo) {
1112 function findElementInArray(array, name) {
1113 const rv = array.find(element => element.includes(name));
1114 return rv ? rv.split("=")[1] : "Unknown";
1117 function getAudioRobustness(array) {
1118 return findElementInArray(array, "audio-robustness");
1121 function getVideoRobustness(array) {
1122 return findElementInArray(array, "video-robustness");
1125 function getSupportedCodecs(array) {
1126 const mp4Content = findElementInArray(array, "MP4");
1127 const webContent = findElementInArray(array, "WEBM");
1129 const mp4DecodingAndDecryptingCodecs = mp4Content
1130 .match(/decoding-and-decrypting:\[([^\]]*)\]/)[1]
1132 const webmDecodingAndDecryptingCodecs = webContent
1133 .match(/decoding-and-decrypting:\[([^\]]*)\]/)[1]
1136 const mp4DecryptingOnlyCodecs = mp4Content
1137 .match(/decrypting-only:\[([^\]]*)\]/)[1]
1139 const webmDecryptingOnlyCodecs = webContent
1140 .match(/decrypting-only:\[([^\]]*)\]/)[1]
1143 // Combine and get unique codecs for decoding-and-decrypting (always)
1144 // and decrypting-only (only set when it's not empty)
1146 rv.decodingAndDecrypting = [
1149 ...mp4DecodingAndDecryptingCodecs,
1150 ...webmDecodingAndDecryptingCodecs,
1156 [...mp4DecryptingOnlyCodecs, ...webmDecryptingOnlyCodecs].filter(
1162 rv.decryptingOnly = temp;
1167 function getCapabilities(array) {
1168 let capabilities = {};
1169 capabilities.persistent = findElementInArray(array, "persistent");
1170 capabilities.distinctive = findElementInArray(array, "distinctive");
1171 capabilities.sessionType = findElementInArray(array, "sessionType");
1172 capabilities.scheme = findElementInArray(array, "scheme");
1173 capabilities.codec = getSupportedCodecs(array);
1174 return JSON.stringify(capabilities);
1177 const rvArray = cdmInfo.capabilities.split(" ");
1178 return $.new("tr", [
1179 $.new("td", cdmInfo.keySystemName),
1180 $.new("td", getVideoRobustness(rvArray)),
1181 $.new("td", getAudioRobustness(rvArray)),
1182 $.new("td", getCapabilities(rvArray), null, { colspan: "4" }),
1183 $.new("td", cdmInfo.clearlead ? "Yes" : "No"),
1184 $.new("td", cdmInfo.isHDCP22Compatible ? "Yes" : "No"),
1188 async function insertContentDecryptionModuleInfo() {
1190 // Retrieve information from GMPCDM
1192 await ChromeUtils.getGMPContentDecryptionModuleInformation();
1193 for (let info of cdmInfo) {
1194 rows.push(createCDMInfoRow(info));
1196 // Retrieve information from WMFCDM, only works when MOZ_WMF_CDM is true
1197 if (ChromeUtils.getWMFContentDecryptionModuleInformation !== undefined) {
1198 cdmInfo = await ChromeUtils.getWMFContentDecryptionModuleInformation();
1199 for (let info of cdmInfo) {
1200 rows.push(createCDMInfoRow(info));
1203 $.append($("media-content-decryption-modules-tbody"), rows);
1206 // Basic information
1207 insertBasicInfo("audio-backend", data.currentAudioBackend);
1208 insertBasicInfo("max-audio-channels", data.currentMaxAudioChannels);
1209 insertBasicInfo("sample-rate", data.currentPreferredSampleRate);
1211 if (AppConstants.platform == "macosx") {
1213 let permission = Cc["@mozilla.org/ospermissionrequest;1"].getService(
1214 Ci.nsIOSPermissionRequest
1216 permission.getAudioCapturePermissionState(micStatus);
1217 if (micStatus.value == permission.PERMISSION_STATE_AUTHORIZED) {
1218 roundtripAudioLatency();
1221 roundtripAudioLatency();
1224 // Output devices information
1225 insertDeviceInfo("output", data.audioOutputDevices);
1227 // Input devices information
1228 insertDeviceInfo("input", data.audioInputDevices);
1230 // Media Capabilitites
1231 insertEnumerateDatabase();
1233 // Create codec support matrix if possible
1234 let supportInfo = null;
1235 if (data.codecSupportInfo.length) {
1239 codecNameHeaderText,
1242 lackOfExtensionText,
1243 ] = await document.l10n.formatValues([
1244 "media-codec-support-supported",
1245 "media-codec-support-unsupported",
1246 "media-codec-support-codec-name",
1247 "media-codec-support-sw-decoding",
1248 "media-codec-support-hw-decoding",
1249 "media-codec-support-lack-of-extension",
1252 function formatCodecRowHeader(a, b, c) {
1253 let h1 = $.new("th", a);
1254 let h2 = $.new("th", b);
1255 let h3 = $.new("th", c);
1256 h1.classList.add("codec-table-name");
1257 h2.classList.add("codec-table-sw");
1258 h3.classList.add("codec-table-hw");
1259 return $.new("tr", [h1, h2, h3]);
1262 function formatCodecRow(codec, sw, hw) {
1263 let swCell = $.new("td", sw ? supportText : unsupportedText);
1264 let hwCell = $.new("td", hw ? supportText : unsupportedText);
1266 swCell.classList.add("supported");
1268 swCell.classList.add("unsupported");
1271 hwCell.classList.add("supported");
1273 hwCell.classList.add("unsupported");
1275 return $.new("tr", [$.new("td", codec), swCell, hwCell]);
1278 function formatCodecRowForLackOfExtension(codec, sw) {
1279 let swCell = $.new("td", sw ? supportText : unsupportedText);
1280 // Link to AV1 extension on MS store.
1281 let hwCell = $.new("td", [
1282 $.new("a", lackOfExtensionText, null, {
1283 href: "ms-windows-store://pdp/?ProductId=9MVZQVXJBQ9V",
1287 swCell.classList.add("supported");
1289 swCell.classList.add("unsupported");
1291 hwCell.classList.add("lack-of-extension");
1292 return $.new("tr", [$.new("td", codec), swCell, hwCell]);
1295 // Parse codec support string and create dictionary containing
1296 // SW/HW support information for each codec found
1298 for (const codec_string of data.codecSupportInfo.split("\n")) {
1299 const s = codec_string.split(" ");
1300 const codec_name = s[0];
1301 const codec_support = s.slice(1);
1303 if (!(codec_name in codecs)) {
1304 codecs[codec_name] = {
1308 lackOfExtension: false,
1312 if (codec_support.includes("SW")) {
1313 codecs[codec_name].sw = true;
1315 if (codec_support.includes("HW")) {
1316 codecs[codec_name].hw = true;
1318 if (codec_support.includes("LACK_OF_EXTENSION")) {
1319 codecs[codec_name].lackOfExtension = true;
1323 // Create row in support table for each codec
1324 let codecSupportRows = [];
1325 for (const c in codecs) {
1326 if (!codecs.hasOwnProperty(c)) {
1329 if (codecs[c].lackOfExtension) {
1330 codecSupportRows.push(
1331 formatCodecRowForLackOfExtension(codecs[c].name, codecs[c].sw)
1334 codecSupportRows.push(
1335 formatCodecRow(codecs[c].name, codecs[c].sw, codecs[c].hw)
1340 let codecSupportTable = $.new("table", [
1341 formatCodecRowHeader(
1342 codecNameHeaderText,
1346 $.new("tbody", codecSupportRows),
1348 codecSupportTable.id = "codec-table";
1349 supportInfo = [codecSupportTable];
1351 // Don't have access to codec support information
1352 supportInfo = await document.l10n.formatValue(
1353 "media-codec-support-error"
1356 if (["win", "macosx", "linux", "android"].includes(AppConstants.platform)) {
1357 insertBasicInfo("media-codec-support-info", supportInfo);
1361 insertContentDecryptionModuleInfo();
1365 if (!AppConstants.ENABLE_WEBDRIVER) {
1368 $("remote-debugging-accepting-connections").textContent = data.running;
1369 $("remote-debugging-url").textContent = data.url;
1372 contentAnalysis(data) {
1373 $("content-analysis-active").textContent = data.active;
1375 $("content-analysis-connected-to-agent").textContent = data.connected;
1376 $("content-analysis-agent-path").textContent = data.agentPath;
1377 $("content-analysis-agent-failed-signature-verification").textContent =
1378 data.failedSignatureVerification;
1379 $("content-analysis-request-count").textContent = data.requestCount;
1383 accessibility(data) {
1384 $("a11y-activated").textContent = data.isActive;
1385 $("a11y-force-disabled").textContent = data.forceDisabled || 0;
1387 let a11yInstantiator = $("a11y-instantiator");
1388 if (a11yInstantiator) {
1389 a11yInstantiator.textContent = data.instantiator;
1393 startupCache(data) {
1394 $("startup-cache-disk-cache-path").textContent = data.DiskCachePath;
1395 $("startup-cache-ignore-disk-cache").textContent = data.IgnoreDiskCache;
1396 $("startup-cache-found-disk-cache-on-init").textContent =
1397 data.FoundDiskCacheOnInit;
1398 $("startup-cache-wrote-to-disk-cache").textContent = data.WroteToDiskCache;
1401 libraryVersions(data) {
1405 $.new("th", null, null, { "data-l10n-id": "min-lib-versions" }),
1406 $.new("th", null, null, { "data-l10n-id": "loaded-lib-versions" }),
1409 sortedArrayFromObject(data).forEach(function ([name, val]) {
1413 $.new("td", val.minVersion),
1414 $.new("td", val.version),
1418 $.append($("libversions-tbody"), trs);
1425 let userJSFile = Services.dirsvc.get("PrefD", Ci.nsIFile);
1426 userJSFile.append("user.js");
1427 $("prefs-user-js-link").href = Services.io.newFileURI(userJSFile).spec;
1428 $("prefs-user-js-section").style.display = "";
1429 // Clear the no-copy class
1430 $("prefs-user-js-section").className = "";
1434 if (!AppConstants.MOZ_SANDBOX) {
1438 let tbody = $("sandbox-tbody");
1439 for (let key in data) {
1440 // Simplify the display a little in the common case.
1442 key === "hasPrivilegedUserNamespaces" &&
1443 data[key] === data.hasUserNamespaces
1447 if (key === "syscallLog") {
1448 // Not in this table.
1451 let keyStrId = toFluentID(key);
1452 let th = $.new("th", null, "column");
1453 document.l10n.setAttributes(th, keyStrId);
1454 tbody.appendChild($.new("tr", [th, $.new("td", data[key])]));
1457 if ("syscallLog" in data) {
1458 let syscallBody = $("sandbox-syscalls-tbody");
1459 let argsHead = $("sandbox-syscalls-argshead");
1460 for (let syscall of data.syscallLog) {
1461 if (argsHead.colSpan < syscall.args.length) {
1462 argsHead.colSpan = syscall.args.length;
1464 let procTypeStrId = toFluentID(syscall.procType);
1466 $.new("td", syscall.index, "integer"),
1467 $.new("td", syscall.msecAgo / 1000),
1468 $.new("td", syscall.pid, "integer"),
1469 $.new("td", syscall.tid, "integer"),
1470 $.new("td", null, null, {
1471 "data-l10n-id": "sandbox-proc-type-" + procTypeStrId,
1473 $.new("td", syscall.syscall, "integer"),
1475 for (let arg of syscall.args) {
1476 cells.push($.new("td", arg, "integer"));
1478 syscallBody.appendChild($.new("tr", cells));
1484 $("intl-locale-requested").textContent = JSON.stringify(
1485 data.localeService.requested
1487 $("intl-locale-available").textContent = JSON.stringify(
1488 data.localeService.available
1490 $("intl-locale-supported").textContent = JSON.stringify(
1491 data.localeService.supported
1493 $("intl-locale-regionalprefs").textContent = JSON.stringify(
1494 data.localeService.regionalPrefs
1496 $("intl-locale-default").textContent = JSON.stringify(
1497 data.localeService.defaultLocale
1500 $("intl-osprefs-systemlocales").textContent = JSON.stringify(
1501 data.osPrefs.systemLocales
1503 $("intl-osprefs-regionalprefs").textContent = JSON.stringify(
1504 data.osPrefs.regionalPrefsLocales
1521 $("remote-features-tbody"),
1522 prefRollouts.map(({ slug, state }) =>
1524 $.new("td", [document.createTextNode(slug)]),
1525 $.new("td", [document.createTextNode(state)]),
1531 $("remote-features-tbody"),
1532 nimbusRollouts.map(({ userFacingName, branch }) =>
1534 $.new("td", [document.createTextNode(userFacingName)]),
1535 $.new("td", [document.createTextNode(`(${branch.slug})`)]),
1540 $("remote-experiments-tbody"),
1541 [addonStudies, prefStudies, nimbusExperiments]
1543 .map(({ userFacingName, branch }) =>
1545 $.new("td", [document.createTextNode(userFacingName)]),
1546 $.new("td", [document.createTextNode(branch?.slug || branch)]),
1553 var $ = document.getElementById.bind(document);
1555 $.new = function $_new(tag, textContentOrChildren, className, attributes) {
1556 let elt = document.createElement(tag);
1558 elt.className = className;
1561 if (attributes["data-l10n-id"]) {
1562 let args = attributes.hasOwnProperty("data-l10n-args")
1563 ? attributes["data-l10n-args"]
1565 document.l10n.setAttributes(elt, attributes["data-l10n-id"], args);
1566 delete attributes["data-l10n-id"];
1568 delete attributes["data-l10n-args"];
1572 for (let attrName in attributes) {
1573 elt.setAttribute(attrName, attributes[attrName]);
1576 if (Array.isArray(textContentOrChildren)) {
1577 this.append(elt, textContentOrChildren);
1578 } else if (!attributes || !attributes["data-l10n-id"]) {
1579 elt.textContent = String(textContentOrChildren);
1584 $.append = function $_append(parent, children) {
1585 children.forEach(c => parent.appendChild(c));
1588 function assembleFromGraphicsFailure(i, data) {
1589 // Only cover the cases we have today; for example, we do not have
1590 // log failures that assert and we assume the log level is 1/error.
1591 let message = data.failures[i];
1592 let index = data.indices[i];
1594 if (message.search(/\[GFX1-\]: \(LF\)/) == 0) {
1595 // Non-asserting log failure - the message is substring(14)
1596 what = "LogFailure";
1597 message = message.substring(14);
1598 } else if (message.search(/\[GFX1-\]: /) == 0) {
1599 // Non-asserting - the message is substring(9)
1601 message = message.substring(9);
1602 } else if (message.search(/\[GFX1\]: /) == 0) {
1603 // Asserting - the message is substring(8)
1605 message = message.substring(8);
1609 header: "(#" + index + ") " + what,
1615 function sortedArrayFromObject(obj) {
1617 for (let prop in obj) {
1618 tuples.push([prop, obj[prop]]);
1620 tuples.sort(([prop1], [prop2]) => prop1.localeCompare(prop2));
1624 function copyRawDataToClipboard(button) {
1626 button.disabled = true;
1628 Troubleshoot.snapshot().then(
1631 button.disabled = false;
1633 let str = Cc["@mozilla.org/supports-string;1"].createInstance(
1634 Ci.nsISupportsString
1636 str.data = JSON.stringify(snapshot, undefined, 2);
1637 let transferable = Cc[
1638 "@mozilla.org/widget/transferable;1"
1639 ].createInstance(Ci.nsITransferable);
1640 transferable.init(getLoadContext());
1641 transferable.addDataFlavor("text/plain");
1642 transferable.setTransferData("text/plain", str);
1643 Services.clipboard.setData(
1646 Ci.nsIClipboard.kGlobalClipboard
1651 button.disabled = false;
1658 function getLoadContext() {
1659 return window.docShell.QueryInterface(Ci.nsILoadContext);
1662 async function copyContentsToClipboard() {
1663 // Get the HTML and text representations for the important part of the page.
1664 let contentsDiv = $("contents").cloneNode(true);
1665 // Remove the items we don't want to copy from the clone:
1666 contentsDiv.querySelectorAll(".no-copy, [hidden]").forEach(n => n.remove());
1667 let dataHtml = contentsDiv.innerHTML;
1668 let dataText = createTextForElement(contentsDiv);
1670 // We can't use plain strings, we have to use nsSupportsString.
1671 let supportsStringClass = Cc["@mozilla.org/supports-string;1"];
1672 let ssHtml = supportsStringClass.createInstance(Ci.nsISupportsString);
1673 let ssText = supportsStringClass.createInstance(Ci.nsISupportsString);
1675 let transferable = Cc["@mozilla.org/widget/transferable;1"].createInstance(
1678 transferable.init(getLoadContext());
1680 // Add the HTML flavor.
1681 transferable.addDataFlavor("text/html");
1682 ssHtml.data = dataHtml;
1683 transferable.setTransferData("text/html", ssHtml);
1685 // Add the plain text flavor.
1686 transferable.addDataFlavor("text/plain");
1687 ssText.data = dataText;
1688 transferable.setTransferData("text/plain", ssText);
1690 // Store the data into the clipboard.
1691 Services.clipboard.setData(
1694 Services.clipboard.kGlobalClipboard
1698 // Return the plain text representation of an element. Do a little bit
1699 // of pretty-printing to make it human-readable.
1700 function createTextForElement(elem) {
1701 let serializer = new Serializer();
1702 let text = serializer.serialize(elem);
1704 // Actual CR/LF pairs are needed for some Windows text editors.
1705 if (AppConstants.platform == "win") {
1706 text = text.replace(/\n/g, "\r\n");
1712 function Serializer() {}
1714 Serializer.prototype = {
1715 serialize(rootElem) {
1717 this._startNewLine();
1718 this._serializeElement(rootElem);
1719 this._startNewLine();
1720 return this._lines.join("\n").trim() + "\n";
1723 // The current line is always the line that writing will start at next. When
1724 // an element is serialized, the current line is updated to be the line at
1725 // which the next element should be written.
1726 get _currentLine() {
1727 return this._lines.length ? this._lines[this._lines.length - 1] : null;
1730 set _currentLine(val) {
1731 this._lines[this._lines.length - 1] = val;
1734 _serializeElement(elem) {
1736 if (elem.localName == "table") {
1737 this._serializeTable(elem);
1741 // all other elements
1743 let hasText = false;
1744 for (let child of elem.childNodes) {
1745 if (child.nodeType == Node.TEXT_NODE) {
1746 let text = this._nodeText(child);
1747 this._appendText(text);
1748 hasText = hasText || !!text.trim();
1749 } else if (child.nodeType == Node.ELEMENT_NODE) {
1750 this._serializeElement(child);
1754 // For headings, draw a "line" underneath them so they stand out.
1755 let isHeader = /^h[0-9]+$/.test(elem.localName);
1757 let headerText = (this._currentLine || "").trim();
1759 this._startNewLine();
1760 this._appendText("-".repeat(headerText.length));
1764 // Add a blank line underneath elements but only if they contain text.
1765 if (hasText && (isHeader || "p" == elem.localName)) {
1766 this._startNewLine();
1767 this._startNewLine();
1772 let currLine = this._currentLine;
1774 // The current line is not empty. Trim it.
1775 this._currentLine = currLine.trim();
1776 if (!this._currentLine) {
1777 // The current line became empty. Discard it.
1781 this._lines.push("");
1785 this._currentLine += text;
1788 _isHiddenSubHeading(th) {
1789 return th.parentNode.parentNode.style.display == "none";
1792 _serializeTable(table) {
1793 // Collect the table's column headings if in fact there are any. First
1794 // check thead. If there's no thead, check the first tr.
1795 let colHeadings = {};
1796 let tableHeadingElem = table.querySelector("thead");
1797 if (!tableHeadingElem) {
1798 tableHeadingElem = table.querySelector("tr");
1800 if (tableHeadingElem) {
1801 let tableHeadingCols = tableHeadingElem.querySelectorAll("th,td");
1802 // If there's a contiguous run of th's in the children starting from the
1803 // rightmost child, then consider them to be column headings.
1804 for (let i = tableHeadingCols.length - 1; i >= 0; i--) {
1805 let col = tableHeadingCols[i];
1806 if (col.localName != "th" || col.classList.contains("title-column")) {
1809 colHeadings[i] = this._nodeText(col).trim();
1812 let hasColHeadings = !!Object.keys(colHeadings).length;
1813 if (!hasColHeadings) {
1814 tableHeadingElem = null;
1817 let trs = table.querySelectorAll("table > tr, tbody > tr");
1819 tableHeadingElem && tableHeadingElem.localName == "tr" ? 1 : 0;
1821 if (startRow >= trs.length) {
1822 // The table's empty.
1826 if (hasColHeadings) {
1827 // Use column headings. Print each tr as a multi-line chunk like:
1828 // Heading 1: Column 1 value
1829 // Heading 2: Column 2 value
1830 for (let i = startRow; i < trs.length; i++) {
1831 let children = trs[i].querySelectorAll("td");
1832 for (let j = 0; j < children.length; j++) {
1834 if (colHeadings[j]) {
1835 text += colHeadings[j] + ": ";
1837 text += this._nodeText(children[j]).trim();
1838 this._appendText(text);
1839 this._startNewLine();
1841 this._startNewLine();
1846 // Don't use column headings. Assume the table has only two columns and
1847 // print each tr in a single line like:
1848 // Column 1 value: Column 2 value
1849 for (let i = startRow; i < trs.length; i++) {
1850 let children = trs[i].querySelectorAll("th,td");
1851 let rowHeading = this._nodeText(children[0]).trim();
1852 if (children[0].classList.contains("title-column")) {
1853 if (!this._isHiddenSubHeading(children[0])) {
1854 this._appendText(rowHeading);
1856 } else if (children.length == 1) {
1857 // This is a single-cell row.
1858 this._appendText(rowHeading);
1860 let childTables = trs[i].querySelectorAll("table");
1861 if (childTables.length) {
1862 // If we have child tables, don't use nodeText - its trs are already
1863 // queued up from querySelectorAll earlier.
1864 this._appendText(rowHeading + ": ");
1866 this._appendText(rowHeading + ": ");
1867 for (let k = 1; k < children.length; k++) {
1868 let l = this._nodeText(children[k]).trim();
1872 if (k < children.length - 1) {
1875 this._appendText(l);
1879 this._startNewLine();
1881 this._startNewLine();
1885 return node.textContent.replace(/\s+/g, " ");
1889 function openProfileDirectory() {
1890 // Get the profile directory.
1891 let currProfD = Services.dirsvc.get("ProfD", Ci.nsIFile);
1892 let profileDir = currProfD.path;
1894 // Show the profile directory.
1895 let nsLocalFile = Components.Constructor(
1896 "@mozilla.org/file/local;1",
1900 new nsLocalFile(profileDir).reveal();
1904 * Profile reset is only supported for the default profile if the appropriate migrator exists.
1906 function populateActionBox() {
1907 if (ResetProfile.resetSupported()) {
1908 $("reset-box").style.display = "block";
1910 if (!Services.appinfo.inSafeMode && AppConstants.platform !== "android") {
1911 $("safe-mode-box").style.display = "block";
1913 if (Services.policies && !Services.policies.isAllowed("safeMode")) {
1914 $("restart-in-safe-mode-button").setAttribute("disabled", "true");
1919 // Prompt user to restart the browser in safe mode
1920 function safeModeRestart() {
1921 let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(
1922 Ci.nsISupportsPRBool
1924 Services.obs.notifyObservers(
1926 "quit-application-requested",
1930 if (!cancelQuit.data) {
1931 Services.startup.restartInSafeMode(Ci.nsIAppStartup.eAttemptQuit);
1935 * Set up event listeners for buttons.
1937 function setupEventListeners() {
1938 let button = $("reset-box-button");
1940 button.addEventListener("click", function () {
1941 ResetProfile.openConfirmationDialog(window);
1944 button = $("clear-startup-cache-button");
1946 button.addEventListener("click", async function () {
1947 const [promptTitle, promptBody, restartButtonLabel] =
1948 await document.l10n.formatValues([
1949 { id: "startup-cache-dialog-title2" },
1950 { id: "startup-cache-dialog-body2" },
1951 { id: "restart-button-label" },
1954 Services.prompt.BUTTON_POS_0 * Services.prompt.BUTTON_TITLE_IS_STRING +
1955 Services.prompt.BUTTON_POS_1 * Services.prompt.BUTTON_TITLE_CANCEL +
1956 Services.prompt.BUTTON_POS_0_DEFAULT;
1957 const result = Services.prompt.confirmEx(
1958 window.docShell.chromeEventHandler.ownerGlobal,
1971 Services.appinfo.invalidateCachesOnRestart();
1972 Services.startup.quit(
1973 Ci.nsIAppStartup.eRestart | Ci.nsIAppStartup.eAttemptQuit
1977 button = $("restart-in-safe-mode-button");
1979 button.addEventListener("click", function () {
1982 .enumerateObservers("restart-in-safe-mode")
1985 Services.obs.notifyObservers(
1986 window.docShell.chromeEventHandler.ownerGlobal,
1987 "restart-in-safe-mode"
1994 if (AppConstants.MOZ_UPDATER) {
1995 button = $("update-dir-button");
1997 button.addEventListener("click", function () {
1998 // Get the update directory.
1999 let updateDir = Services.dirsvc.get("UpdRootD", Ci.nsIFile);
2000 if (!updateDir.exists()) {
2001 updateDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755);
2003 let updateDirPath = updateDir.path;
2004 // Show the update directory.
2005 let nsLocalFile = Components.Constructor(
2006 "@mozilla.org/file/local;1",
2010 new nsLocalFile(updateDirPath).reveal();
2013 button = $("show-update-history-button");
2015 button.addEventListener("click", function () {
2016 window.browsingContext.topChromeWindow.openDialog(
2017 "chrome://mozapps/content/update/history.xhtml",
2019 "centerscreen,resizable=no,titlebar,modal"
2024 button = $("verify-place-integrity-button");
2026 button.addEventListener("click", function () {
2027 PlacesDBUtils.checkAndFixDatabase().then(tasksStatusMap => {
2029 for (let [key, value] of tasksStatusMap) {
2030 logs.push(`> Task: ${key}`);
2031 let prefix = value.succeeded ? "+ " : "- ";
2032 logs = logs.concat(value.logs.map(m => `${prefix}${m}`));
2034 $("verify-place-result").style.display = "block";
2035 $("verify-place-result").classList.remove("no-copy");
2036 $("verify-place-result").textContent = logs.join("\n");
2041 $("copy-raw-data-to-clipboard").addEventListener("click", function () {
2042 copyRawDataToClipboard(this);
2044 $("copy-to-clipboard").addEventListener("click", function () {
2045 copyContentsToClipboard();
2047 $("profile-dir-button").addEventListener("click", function () {
2048 openProfileDirectory();
2053 * Scroll to section specified by location.hash
2055 function scrollToSection() {
2056 const id = location.hash.substr(1);
2060 elem.scrollIntoView();