diff options
Diffstat (limited to '')
-rw-r--r-- | comm/mail/components/about-support/content/aboutSupport.js | 1729 | ||||
-rw-r--r-- | comm/mail/components/about-support/content/aboutSupport.xhtml | 956 | ||||
-rw-r--r-- | comm/mail/components/about-support/content/accounts.js | 339 | ||||
-rw-r--r-- | comm/mail/components/about-support/content/calendars.js | 77 | ||||
-rw-r--r-- | comm/mail/components/about-support/content/chat.js | 73 | ||||
-rw-r--r-- | comm/mail/components/about-support/content/export.js | 288 | ||||
-rw-r--r-- | comm/mail/components/about-support/content/libs.js | 24 |
7 files changed, 3486 insertions, 0 deletions
diff --git a/comm/mail/components/about-support/content/aboutSupport.js b/comm/mail/components/about-support/content/aboutSupport.js new file mode 100644 index 0000000000..fc73b59029 --- /dev/null +++ b/comm/mail/components/about-support/content/aboutSupport.js @@ -0,0 +1,1729 @@ +/* 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/. */ + +/* This file is a copy of mozilla/toolkit/content/aboutSupport.js with + modifications for TB. */ + +/* globals AboutSupportPlatform, populateAccountsSection, sendViaEmail + populateCalendarsSection, populateChatSection, populateLibrarySection */ + +"use strict"; + +var { XPCOMUtils } = ChromeUtils.importESModule( + "resource://gre/modules/XPCOMUtils.sys.mjs" +); +var { Troubleshoot } = ChromeUtils.importESModule( + "resource://gre/modules/Troubleshoot.sys.mjs" +); +var { ResetProfile } = ChromeUtils.importESModule( + "resource://gre/modules/ResetProfile.sys.mjs" +); +var { AppConstants } = ChromeUtils.importESModule( + "resource://gre/modules/AppConstants.sys.mjs" +); + +ChromeUtils.defineESModuleGetters(this, { + DownloadUtils: "resource://gre/modules/DownloadUtils.sys.mjs", + PlacesDBUtils: "resource://gre/modules/PlacesDBUtils.sys.mjs", + PluralForm: "resource://gre/modules/PluralForm.sys.mjs", + ProcessType: "resource://gre/modules/ProcessType.sys.mjs", +}); + +// added for TB +/* Node classes. All of these are mutually exclusive. */ + +// Any nodes marked with this class will be considered part of the UI only, +// and therefore will not be copied. +var CLASS_DATA_UIONLY = "data-uionly"; + +// Any nodes marked with this class will be considered private and will be +// hidden if the user requests only public data to be shown or copied. +var CLASS_DATA_PRIVATE = "data-private"; + +// Any nodes marked with this class will only be displayed when the user chooses +// to not display private data. +var CLASS_DATA_PUBLIC = "data-public"; +// end of TB addition +window.addEventListener("load", function onload(event) { + try { + window.removeEventListener("load", onload); + Troubleshoot.snapshot().then(async snapshot => { + for (let prop in snapshotFormatters) { + try { + await snapshotFormatters[prop](snapshot[prop]); + } catch (e) { + console.error( + "stack of snapshot error for about:support: ", + e, + ": ", + e.stack + ); + } + } + }, console.error); + populateActionBox(); + setupEventListeners(); + + let hasWinPackageId = false; + try { + hasWinPackageId = Services.sysinfo.getProperty("hasWinPackageId"); + } catch (_ex) { + // The hasWinPackageId property doesn't exist; assume it would be false. + } + if (hasWinPackageId) { + $("update-dir-row").hidden = true; + $("update-history-row").hidden = true; + } + } catch (e) { + console.error( + "stack of load error for about:support: " + e + ": " + e.stack + ); + } + // added for TB + populateAccountsSection(); + populateCalendarsSection(); + populateChatSection(); + populateLibrarySection(); + document + .getElementById("check-show-private-data") + .addEventListener("change", () => onShowPrivateDataChange()); +}); + +function prefsTable(data) { + return sortedArrayFromObject(data).map(function ([name, value]) { + 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"), + ]); + }); +} + +// Fluent uses lisp-case IDs so this converts +// the SentenceCase info IDs to lisp-case. +const FLUENT_IDENT_REGEX = /^[a-zA-Z][a-zA-Z0-9_-]*$/; +function toFluentID(str) { + if (!FLUENT_IDENT_REGEX.test(str)) { + return null; + } + return str + .toString() + .replace(/([a-z0-9])([A-Z])/g, "$1-$2") + .toLowerCase(); +} + +// 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. +var snapshotFormatters = { + async application(data) { + $("application-box").textContent = data.name; + $("useragent-box").textContent = data.userAgent; + $("os-box").textContent = data.osVersion; + if (data.osTheme) { + $("os-theme-box").textContent = data.osTheme; + } else { + $("os-theme-row").hidden = true; + } + if (AppConstants.platform == "macosx") { + $("rosetta-box").textContent = data.rosetta; + } + $("binary-box").textContent = Services.dirsvc.get( + "XREExeF", + Ci.nsIFile + ).path; + $("supportLink").href = data.supportURL; + let version = AppConstants.MOZ_APP_VERSION_DISPLAY; + if (data.vendor) { + version += " (" + data.vendor + ")"; + } + $("version-box").textContent = version; + $("buildid-box").textContent = data.buildID; + $("distributionid-box").textContent = data.distributionID; + if (data.updateChannel) { + $("updatechannel-box").textContent = data.updateChannel; + } + if (AppConstants.MOZ_UPDATER) { + $("update-dir-box").textContent = Services.dirsvc.get( + "UpdRootD", + Ci.nsIFile + ).path; + } + + 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) {} + + const STATUS_STRINGS = { + experimentControl: "fission-status-experiment-control", + experimentTreatment: "fission-status-experiment-treatment", + disabledByE10sEnv: "fission-status-disabled-by-e10s-env", + enabledByEnv: "fission-status-enabled-by-env", + enabledByDefault: "fission-status-enabled-by-default", + disabledByDefault: "fission-status-disabled-by-default", + enabledByUserPref: "fission-status-enabled-by-user-pref", + disabledByUserPref: "fission-status-disabled-by-user-pref", + disabledByE10sOther: "fission-status-disabled-by-e10s-other", + }; + + let statusTextId = STATUS_STRINGS[data.fissionDecisionStatus]; + + document.l10n.setAttributes( + $("multiprocess-box-process-count"), + "multi-process-windows", + { + remoteWindows: data.numRemoteWindows, + totalWindows: data.numTotalWindows, + } + ); + document.l10n.setAttributes( + $("fission-box-process-count"), + "fission-windows", + { + fissionWindows: data.numFissionWindows, + totalWindows: data.numTotalWindows, + } + ); + document.l10n.setAttributes($("fission-box-status"), statusTextId); + + if (Services.policies) { + let policiesStrId = ""; + let aboutPolicies = "about:policies"; + switch (data.policiesStatus) { + case Services.policies.INACTIVE: + policiesStrId = "policies-inactive"; + break; + + case Services.policies.ACTIVE: + policiesStrId = "policies-active"; + aboutPolicies += "#active"; + break; + + default: + policiesStrId = "policies-error"; + aboutPolicies += "#errors"; + break; + } + + if (data.policiesStatus != Services.policies.INACTIVE) { + let activePolicies = $.new("a", null, null, { + href: aboutPolicies, + }); + document.l10n.setAttributes(activePolicies, policiesStrId); + $("policies-status").appendChild(activePolicies); + } else { + document.l10n.setAttributes($("policies-status"), policiesStrId); + } + } else { + $("policies-status-row").hidden = true; + } + + 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 + ); + + let keyMozillaFound = data.keyMozillaFound ? "found" : "missing"; + document.l10n.setAttributes($("key-mozilla-box"), keyMozillaFound); + + $("safemode-box").textContent = data.safeMode; + + const formatHumanReadableBytes = (elem, bytes) => { + let size = DownloadUtils.convertByteUnits(bytes); + document.l10n.setAttributes(elem, "app-basics-data-size", { + value: size[0], + unit: size[1], + }); + }; + + formatHumanReadableBytes($("memory-size-box"), data.memorySizeBytes); + formatHumanReadableBytes($("disk-available-box"), data.diskAvailableBytes); + + // added for TB + // Add profile path as private info into the page. + let currProfD = Services.dirsvc.get("ProfD", Ci.nsIFile); + let profElem = document.getElementById("profile-dir-button").parentNode; + let profDirNode = document.getElementById("profile-dir-box"); + profDirNode.setAttribute("class", CLASS_DATA_PRIVATE); + let profLinkNode = document.createElement("a"); + profLinkNode.setAttribute("href", Services.io.newFileURI(currProfD).spec); + profLinkNode.addEventListener("click", function (event) { + openProfileDirectory(); + event.preventDefault(); + }); + let profPathNode = document.createTextNode(currProfD.path); + profLinkNode.appendChild(profPathNode); + profDirNode.appendChild(profLinkNode); + profElem.appendChild(document.createTextNode(" ")); + + // Show type of filesystem detected. + let fsType; + try { + fsType = AboutSupportPlatform.getFileSystemType(currProfD); + if (fsType) { + let bundle = Services.strings.createBundle( + "chrome://messenger/locale/aboutSupportMail.properties" + ); + let fsText = bundle.GetStringFromName("fsType." + fsType); + let fsTextNode = document.createElement("span"); + fsTextNode.textContent = fsText; + profElem.appendChild(fsTextNode); + } + } catch (x) { + console.error(x); + } + // end of TB addition + }, + + crashes(data) { + if (!AppConstants.MOZ_CRASHREPORTER) { + return; + } + + let daysRange = Troubleshoot.kMaxCrashAge / (24 * 60 * 60 * 1000); + document.l10n.setAttributes($("crashes-title"), "report-crash-for-days", { + days: daysRange, + }); + let reportURL; + try { + reportURL = Services.prefs.getCharPref("breakpad.reportURL"); + // Ignore any non http/https urls + if (!/^https?:/i.test(reportURL)) { + reportURL = null; + } + } catch (e) {} + if (!reportURL) { + $("crashes-noConfig").style.display = "block"; + $("crashes-noConfig").classList.remove("no-copy"); + return; + } + $("crashes-allReports").style.display = "block"; + + if (data.pending > 0) { + document.l10n.setAttributes( + $("crashes-allReportsWithPending"), + "pending-reports", + { reports: data.pending } + ); + } + + let dateNow = new Date(); + $.append( + $("crashes-tbody"), + data.submitted.map(function (crash) { + let date = new Date(crash.date); + let timePassed = dateNow - date; + let formattedDateStrId; + let formattedDateStrArgs; + if (timePassed >= 24 * 60 * 60 * 1000) { + let daysPassed = Math.round(timePassed / (24 * 60 * 60 * 1000)); + formattedDateStrId = "crashes-time-days"; + formattedDateStrArgs = { days: daysPassed }; + } else if (timePassed >= 60 * 60 * 1000) { + let hoursPassed = Math.round(timePassed / (60 * 60 * 1000)); + formattedDateStrId = "crashes-time-hours"; + formattedDateStrArgs = { hours: hoursPassed }; + } else { + let minutesPassed = Math.max(Math.round(timePassed / (60 * 1000)), 1); + formattedDateStrId = "crashes-time-minutes"; + formattedDateStrArgs = { minutes: minutesPassed }; + } + return $.new("tr", [ + $.new("td", [ + $.new("a", crash.id, null, { href: reportURL + crash.id }), + ]), + $.new("td", null, null, { + "data-l10n-id": formattedDateStrId, + "data-l10n-args": formattedDateStrArgs, + }), + ]); + }) + ); + }, + + addons(data) { + $.append( + $("addons-tbody"), + data.map(function (addon) { + return $.new("tr", [ + $.new("td", addon.name), + $.new("td", addon.type), + $.new("td", addon.version), + $.new("td", addon.isActive), + $.new("td", addon.id), + ]); + }) + ); + }, + + securitySoftware(data) { + 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; + }, + + /* Not used by TB + features(data) { + $.append($("features-tbody"), data.map(function(feature) { + return $.new("tr", [ + $.new("td", feature.name), + $.new("td", feature.version), + $.new("td", feature.id), + ]); + })); + }, +*/ + + async processes(data) { + async function buildEntry(name, value) { + const fluentName = ProcessType.fluentNameFromProcessTypeString(name); + let entryName = (await document.l10n.formatValue(fluentName)) || 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]); + } + }, + + environmentVariables(data) { + if (!data) { + return; + } + $.append( + $("environment-variables-tbody"), + Object.entries(data).map(([name, value]) => { + return $.new("tr", [ + $.new("td", name, "pref-name"), + $.new("td", value, "pref-value"), + ]); + }) + ); + }, + + modifiedPreferences(data) { + $.append($("prefs-tbody"), prefsTable(data)); + }, + + lockedPreferences(data) { + $.append($("locked-prefs-tbody"), prefsTable(data)); + }, + + printingPreferences(data) { + if (AppConstants.platform == "android") { + return; + } + const tbody = $("support-printing-prefs-tbody"); + $.append(tbody, prefsTable(data)); + $("support-printing-clear-settings-button").addEventListener( + "click", + function () { + for (let name in data) { + Services.prefs.clearUserPref(name); + } + tbody.textContent = ""; + } + ); + }, + + /* eslint-disable complexity */ + async graphics(data) { + function localizedMsg(msg) { + if (typeof msg == "object" && msg.key) { + return document.l10n.formatValue(msg.key, msg.args); + } + let msgId = toFluentID(msg); + if (msgId) { + return document.l10n.formatValue(msgId); + } + return ""; + } + + // Read APZ info out of data.info, stripping it out in the process. + let apzInfo = []; + let formatApzInfo = function (info) { + let out = []; + for (let type of [ + "Wheel", + "Touch", + "Drag", + "Keyboard", + "Autoscroll", + "Zooming", + ]) { + let key = "Apz" + type + "Input"; + + if (!(key in info)) { + continue; + } + + delete info[key]; + + out.push(toFluentID(type.toLowerCase() + "Enabled")); + } + + return out; + }; + + // Create a <tr> element with key and value columns. + // + // @key Text in the key column. Localized automatically, unless starts with "#". + // @value Fluent ID for text in the value column, or array of children. + function buildRow(key, value) { + let title = key[0] == "#" ? key.substr(1) : key; + let keyStrId = toFluentID(key); + let valueStrId = Array.isArray(value) ? null : toFluentID(value); + let td = $.new("td", value); + td.style["white-space"] = "pre-wrap"; + if (valueStrId) { + document.l10n.setAttributes(td, valueStrId); + } + + let th = $.new("th", title, "column"); + if (!key.startsWith("#")) { + document.l10n.setAttributes(th, keyStrId); + } + return $.new("tr", [th, td]); + } + + // @where The name in "graphics-<name>-tbody", of the element to append to. + // @trs Array of row elements. + function addRows(where, trs) { + $.append($("graphics-" + where + "-tbody"), trs); + } + + // 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)]); + } + if ("info" in data) { + apzInfo = formatApzInfo(data.info); + + let trs = sortedArrayFromObject(data.info).map(function ([prop, val]) { + let td = $.new("td", String(val)); + td.style["word-break"] = "break-all"; + return $.new("tr", [$.new("th", prop, "column"), td]); + }); + addRows("diagnostics", trs); + + delete data.info; + } + + let windowUtils = window.windowUtils; + let gpuProcessPid = windowUtils.gpuProcessPid; + + if (gpuProcessPid != -1) { + let gpuProcessKillButton = null; + if (AppConstants.NIGHTLY_BUILD || AppConstants.MOZ_DEV_EDITION) { + gpuProcessKillButton = $.new("button"); + + gpuProcessKillButton.addEventListener("click", function () { + windowUtils.terminateGPUProcess(); + }); + + document.l10n.setAttributes( + gpuProcessKillButton, + "gpu-process-kill-button" + ); + } + + addRow("diagnostics", "gpu-process-pid", [new Text(gpuProcessPid)]); + if (gpuProcessKillButton) { + addRow("diagnostics", "gpu-process", [gpuProcessKillButton]); + } + } + + if ( + (AppConstants.NIGHTLY_BUILD || AppConstants.MOZ_DEV_EDITION) && + AppConstants.platform != "macosx" + ) { + let gpuDeviceResetButton = $.new("button"); + + gpuDeviceResetButton.addEventListener("click", function () { + windowUtils.triggerDeviceReset(); + }); + + document.l10n.setAttributes( + gpuDeviceResetButton, + "gpu-device-reset-button" + ); + addRow("diagnostics", "gpu-device-reset", [gpuDeviceResetButton]); + } + + // graphics-failures-tbody tbody + if ("failures" in data) { + // 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); + } + combined.sort(function (a, b) { + if (a.index < b.index) { + return -1; + } + if (a.index > b.index) { + return 1; + } + return 0; + }); + $.append( + $("graphics-failures-tbody"), + combined.map(function (val) { + return $.new("tr", [ + $.new("th", val.header, "column"), + $.new("td", val.message), + ]); + }) + ); + delete data.indices; + } else { + $.append($("graphics-failures-tbody"), [ + $.new("tr", [ + $.new("th", "LogFailure", "column"), + $.new( + "td", + data.failures.map(function (val) { + return $.new("p", val); + }) + ), + ]), + ]); + } + delete data.failures; + } else { + $("graphics-failures-tbody").style.display = "none"; + } + + // 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. + async function addRowFromKey(where, key, colKey) { + if (!(key in data)) { + return; + } + colKey = colKey || key; + + let value; + let messageKey = key + "Message"; + if (messageKey in data) { + value = await localizedMsg(data[messageKey]); + delete data[messageKey]; + } else { + value = data[key]; + } + delete data[key]; + + if (value) { + addRow(where, colKey, [new Text(value)]); + } + } + + // graphics-features-tbody + let compositor = ""; + if (data.windowLayerManagerRemote) { + compositor = data.windowLayerManagerType; + } else { + let noOMTCString = await document.l10n.formatValue("main-thread-no-omtc"); + compositor = "BasicLayers (" + noOMTCString + ")"; + } + addRow("features", "compositing", [new Text(compositor)]); + delete data.windowLayerManagerRemote; + delete data.windowLayerManagerType; + delete data.numTotalWindows; + delete data.numAcceleratedWindows; + delete data.numAcceleratedWindowsMessage; + + addRow( + "features", + "asyncPanZoom", + apzInfo.length + ? [ + new Text( + ( + await document.l10n.formatValues( + apzInfo.map(id => { + return { id }; + }) + ) + ).join("; ") + ), + ] + : "apz-none" + ); + let featureKeys = [ + "webgl1WSIInfo", + "webgl1Renderer", + "webgl1Version", + "webgl1DriverExtensions", + "webgl1Extensions", + "webgl2WSIInfo", + "webgl2Renderer", + "webgl2Version", + "webgl2DriverExtensions", + "webgl2Extensions", + ["supportsHardwareH264", "hardware-h264"], + ["direct2DEnabled", "#Direct2D"], + ["windowProtocol", "graphics-window-protocol"], + ["desktopEnvironment", "graphics-desktop-environment"], + "usesTiling", + "targetFrameRate", + ]; + for (let feature of featureKeys) { + if (Array.isArray(feature)) { + await addRowFromKey("features", feature[0], feature[1]); + continue; + } + await addRowFromKey("features", feature); + } + + if ("directWriteEnabled" in data) { + let message = data.directWriteEnabled; + if ("directWriteVersion" in data) { + message += " (" + data.directWriteVersion + ")"; + } + await addRow("features", "#DirectWrite", [new Text(message)]); + delete data.directWriteEnabled; + delete data.directWriteVersion; + } + + // Adapter tbodies. + let adapterKeys = [ + ["adapterDescription", "gpu-description"], + ["adapterVendorID", "gpu-vendor-id"], + ["adapterDeviceID", "gpu-device-id"], + ["driverVendor", "gpu-driver-vendor"], + ["driverVersion", "gpu-driver-version"], + ["driverDate", "gpu-driver-date"], + ["adapterDrivers", "gpu-drivers"], + ["adapterSubsysID", "gpu-subsys-id"], + ["adapterRAM", "gpu-ram"], + ]; + + function showGpu(id, suffix) { + function get(prop) { + return data[prop + suffix]; + } + + let trs = []; + for (let [prop, key] of adapterKeys) { + let value = get(prop); + if (value === undefined || value === "") { + continue; + } + trs.push(buildRow(key, [new Text(value)])); + } + + if (trs.length == 0) { + $("graphics-" + id + "-tbody").style.display = "none"; + return; + } + + let active = "yes"; + if ("isGPU2Active" in data && (suffix == "2") != data.isGPU2Active) { + active = "no"; + } + + addRow(id, "gpu-active", active); + addRows(id, trs); + } + showGpu("gpu-1", ""); + showGpu("gpu-2", "2"); + + // Remove adapter keys. + for (let [prop /* key */] of adapterKeys) { + delete data[prop]; + delete data[prop + "2"]; + } + delete data.isGPU2Active; + + let featureLog = data.featureLog; + delete data.featureLog; + + if (featureLog.features.length) { + for (let feature of featureLog.features) { + let trs = []; + for (let entry of feature.log) { + let contents; + if (!entry.hasOwnProperty("message")) { + // This is a default entry. + contents = entry.status + " by " + entry.type; + } else if (entry.message.length && entry.message[0] == "#") { + // This is a failure ID. See nsIGfxInfo.idl. + let m = /#BLOCKLIST_FEATURE_FAILURE_BUG_(\d+)/.exec(entry.message); + if (m) { + let bugSpan = $.new("span"); + + let bugHref = $.new("a"); + bugHref.href = + "https://bugzilla.mozilla.org/show_bug.cgi?id=" + m[1]; + bugHref.setAttribute("data-l10n-name", "bug-link"); + bugSpan.append(bugHref); + document.l10n.setAttributes(bugSpan, "support-blocklisted-bug", { + bugNumber: m[1], + }); + + contents = [bugSpan]; + } else { + let unknownFailure = $.new("span"); + document.l10n.setAttributes(unknownFailure, "unknown-failure", { + failureCode: entry.message.substr(1), + }); + contents = [unknownFailure]; + } + } else { + contents = + entry.status + " by " + entry.type + ": " + entry.message; + } + + trs.push($.new("tr", [$.new("td", contents)])); + } + addRow("decisions", "#" + feature.name, [$.new("table", trs)]); + } + } else { + $("graphics-decisions-tbody").style.display = "none"; + } + + if (featureLog.fallbacks.length) { + for (let fallback of featureLog.fallbacks) { + addRow("workarounds", "#" + fallback.name, [ + new Text(fallback.message), + ]); + } + } else { + $("graphics-workarounds-tbody").style.display = "none"; + } + + let crashGuards = data.crashGuards; + delete data.crashGuards; + + if (crashGuards.length) { + for (let guard of crashGuards) { + let resetButton = $.new("button"); + let onClickReset = function () { + Services.prefs.setIntPref(guard.prefName, 0); + resetButton.removeEventListener("click", onClickReset); + resetButton.disabled = true; + }; + + document.l10n.setAttributes(resetButton, "reset-on-next-restart"); + resetButton.addEventListener("click", onClickReset); + + addRow("crashguards", guard.type + "CrashGuard", [resetButton]); + } + } else { + $("graphics-crashguards-tbody").style.display = "none"; + } + + // Now that we're done, grab any remaining keys in data and drop them into + // the diagnostics section. + for (let key in data) { + let value = data[key]; + addRow("diagnostics", key, [new Text(value)]); + } + }, + /* eslint-enable complexity */ + + media(data) { + function insertBasicInfo(key, value) { + function createRow(key, value) { + let th = $.new("th", null, "column"); + document.l10n.setAttributes(th, key); + let td = $.new("td", value); + td.style["white-space"] = "pre-wrap"; + td.colSpan = 8; + return $.new("tr", [th, td]); + } + $.append($("media-info-tbody"), [createRow(key, value)]); + } + + 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); + } + + function insertEnumerateDatabase() { + if ( + !Services.prefs.getBoolPref("media.mediacapabilities.from-database") + ) { + $("media-capabilities-tbody").style.display = "none"; + return; + } + let button = $("enumerate-database-button"); + if (button) { + button.addEventListener("click", function (event) { + let { KeyValueService } = ChromeUtils.importESModule( + "resource://gre/modules/kvstore.sys.mjs" + ); + let currProfDir = Services.dirsvc.get("ProfD", Ci.nsIFile); + currProfDir.append("mediacapabilities"); + let path = currProfDir.path; + + function enumerateDatabase(name) { + KeyValueService.getOrCreate(path, name) + .then(database => { + return database.enumerate(); + }) + .then(enumerator => { + var logs = []; + logs.push(`${name}:`); + for (let { key, value } of enumerator) { + logs.push(`${key}: ${value}`); + } + $("enumerate-database-result").textContent += + logs.join("\n") + "\n"; + }) + .catch(err => { + $("enumerate-database-result").textContent += `${name}:\n`; + }); + } + + $("enumerate-database-result").style.display = "block"; + $("enumerate-database-result").classList.remove("no-copy"); + $("enumerate-database-result").textContent = ""; + + enumerateDatabase("video/av1"); + enumerateDatabase("video/vp8"); + enumerateDatabase("video/vp9"); + enumerateDatabase("video/avc"); + enumerateDatabase("video/theora"); + }); + } + } + + function roundtripAudioLatency() { + insertBasicInfo("roundtrip-latency", "..."); + window.windowUtils + .defaultDevicesRoundTripLatency() + .then(latency => { + var latencyString = `${(latency[0] * 1000).toFixed(2)}ms (${( + latency[1] * 1000 + ).toFixed(2)})`; + data.defaultDevicesRoundTripLatency = latencyString; + document.querySelector( + 'th[data-l10n-id="roundtrip-latency"]' + ).nextSibling.textContent = latencyString; + }) + .catch(e => {}); + } + + // Basic information + insertBasicInfo("audio-backend", data.currentAudioBackend); + insertBasicInfo("max-audio-channels", data.currentMaxAudioChannels); + insertBasicInfo("sample-rate", data.currentPreferredSampleRate); + + if (AppConstants.platform == "macosx") { + var micStatus = {}; + let permission = Cc["@mozilla.org/ospermissionrequest;1"].getService( + Ci.nsIOSPermissionRequest + ); + permission.getAudioCapturePermissionState(micStatus); + if (micStatus.value == permission.PERMISSION_STATE_AUTHORIZED) { + roundtripAudioLatency(); + } + } else { + roundtripAudioLatency(); + } + + // Output devices information + insertDeviceInfo("output", data.audioOutputDevices); + + // Input devices information + insertDeviceInfo("input", data.audioInputDevices); + + // Media Capabilitites + insertEnumerateDatabase(); + }, + + remoteAgent(data) { + if (!AppConstants.ENABLE_WEBDRIVER) { + return; + } + $("remote-debugging-accepting-connections").textContent = data.listening; + $("remote-debugging-url").textContent = data.url; + }, + + accessibility(data) { + $("a11y-activated").textContent = data.isActive; + $("a11y-force-disabled").textContent = data.forceDisabled || 0; + + let a11yHandlerUsed = $("a11y-handler-used"); + if (a11yHandlerUsed) { + a11yHandlerUsed.textContent = data.handlerUsed; + } + + let a11yInstantiator = $("a11y-instantiator"); + if (a11yInstantiator) { + a11yInstantiator.textContent = data.instantiator; + } + }, + + startupCache(data) { + $("startup-cache-disk-cache-path").textContent = data.DiskCachePath; + $("startup-cache-ignore-disk-cache").textContent = data.IgnoreDiskCache; + $("startup-cache-found-disk-cache-on-init").textContent = + data.FoundDiskCacheOnInit; + $("startup-cache-wrote-to-disk-cache").textContent = data.WroteToDiskCache; + }, + + libraryVersions(data) { + let trs = [ + $.new("tr", [ + $.new("th", ""), + $.new("th", null, null, { "data-l10n-id": "min-lib-versions" }), + $.new("th", null, null, { "data-l10n-id": "loaded-lib-versions" }), + ]), + ]; + sortedArrayFromObject(data).forEach(function ([name, val]) { + trs.push( + $.new("tr", [ + $.new("td", name), + $.new("td", val.minVersion), + $.new("td", val.version), + ]) + ); + }); + $.append($("libversions-tbody"), trs); + }, + + userJS(data) { + 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 = ""; + // Clear the no-copy class + $("prefs-user-js-section").className = ""; + }, + + sandbox(data) { + if (!AppConstants.MOZ_SANDBOX) { + return; + } + + let tbody = $("sandbox-tbody"); + for (let key in data) { + // Simplify the display a little in the common case. + if ( + key === "hasPrivilegedUserNamespaces" && + data[key] === data.hasUserNamespaces + ) { + continue; + } + if (key === "syscallLog") { + // Not in this table. + continue; + } + let keyStrId = toFluentID(key); + let th = $.new("th", null, "column"); + document.l10n.setAttributes(th, keyStrId); + tbody.appendChild($.new("tr", [th, $.new("td", data[key])])); + } + + 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; + } + let procTypeStrId = toFluentID(syscall.procType); + let cells = [ + $.new("td", syscall.index, "integer"), + $.new("td", syscall.msecAgo / 1000), + $.new("td", syscall.pid, "integer"), + $.new("td", syscall.tid, "integer"), + $.new("td", null, null, { + "data-l10n-id": "sandbox-proc-type-" + procTypeStrId, + }), + $.new("td", syscall.syscall, "integer"), + ]; + for (let arg of syscall.args) { + cells.push($.new("td", arg, "integer")); + } + syscallBody.appendChild($.new("tr", cells)); + } + } + }, + + intl(data) { + $("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 + ); + }, +}; + +var $ = document.getElementById.bind(document); + +// eslint-disable-next-line func-names +$.new = function $_new(tag, textContentOrChildren, className, attributes) { + let elt = document.createElement(tag); + if (className) { + elt.className = className; + } + if (attributes) { + if (attributes["data-l10n-id"]) { + let args = attributes.hasOwnProperty("data-l10n-args") + ? attributes["data-l10n-args"] + : undefined; + document.l10n.setAttributes(elt, attributes["data-l10n-id"], args); + delete attributes["data-l10n-id"]; + if (args) { + delete attributes["data-l10n-args"]; + } + } + + for (let attrName in attributes) { + elt.setAttribute(attrName, attributes[attrName]); + } + } + if (Array.isArray(textContentOrChildren)) { + this.append(elt, textContentOrChildren); + } else if (!attributes || !attributes["data-l10n-id"]) { + elt.textContent = String(textContentOrChildren); + } + return elt; +}; + +// eslint-disable-next-line func-names +$.append = function $_append(parent, children) { + children.forEach(c => parent.appendChild(c)); +}; + +function assembleFromGraphicsFailure(i, data) { + // 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); + } + let assembled = { + index, + header: "(#" + index + ") " + what, + message, + }; + return assembled; +} + +function sortedArrayFromObject(obj) { + let tuples = []; + for (let prop in obj) { + tuples.push([prop, obj[prop]]); + } + tuples.sort(([prop1, v1], [prop2, v2]) => prop1.localeCompare(prop2)); + return tuples; +} + +function copyRawDataToClipboard(button) { + if (button) { + button.disabled = true; + } + Troubleshoot.snapshot().then( + async snapshot => { + 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/plain"); + transferable.setTransferData("text/plain", str); + Services.clipboard.setData( + transferable, + null, + Ci.nsIClipboard.kGlobalClipboard + ); + }, + err => { + if (button) { + button.disabled = false; + } + console.error(err); + } + ); +} + +function getLoadContext() { + return window.docShell.QueryInterface(Ci.nsILoadContext); +} + +async function copyContentsToClipboard() { + // Get the HTML and text representations for the important part of the page. + 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()); + 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 + ); + transferable.init(getLoadContext()); + + // Add the HTML flavor. + transferable.addDataFlavor("text/html"); + ssHtml.data = dataHtml; + transferable.setTransferData("text/html", ssHtml); + + // Add the plain text flavor. + transferable.addDataFlavor("text/plain"); + ssText.data = dataText; + transferable.setTransferData("text/plain", ssText); + + // Store the data into the clipboard. + Services.clipboard.setData( + transferable, + null, + Services.clipboard.kGlobalClipboard + ); +} + +// Return the plain text representation of an element. Do a little bit +// of pretty-printing to make it human-readable. +function createTextForElement(elem) { + let serializer = new Serializer(); + let text = serializer.serialize(elem); + + // Actual CR/LF pairs are needed for some Windows text editors. + if (AppConstants.platform == "win") { + text = text.replace(/\n/g, "\r\n"); + } + + return text; +} + +function Serializer() {} + +Serializer.prototype = { + serialize(rootElem) { + 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; + }, + + set _currentLine(val) { + this._lines[this._lines.length - 1] = val; + }, + + _serializeElement(elem) { + // table + if (elem.localName == "table") { + this._serializeTable(elem); + return; + } + + // 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(); + } else if (child.nodeType == Node.ELEMENT_NODE) { + this._serializeElement(child); + } + } + + // For headings, draw a "line" underneath them so they stand out. + let isHeader = /^h[0-9]+$/.test(elem.localName); + if (isHeader) { + let headerText = (this._currentLine || "").trim(); + if (headerText) { + this._startNewLine(); + this._appendText("-".repeat(headerText.length)); + } + } + + // Add a blank line underneath elements but only if they contain text. + if (hasText && (isHeader || "p" == elem.localName)) { + this._startNewLine(); + this._startNewLine(); + } + }, + + _startNewLine(lines) { + 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(""); + }, + + _appendText(text, lines) { + this._currentLine += text; + }, + + _isHiddenSubHeading(th) { + return th.parentNode.parentNode.style.display == "none"; + }, + + _serializeTable(table) { + // 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--) { + let col = tableHeadingCols[i]; + if (col.localName != "th" || col.classList.contains("title-column")) { + break; + } + colHeadings[i] = this._nodeText(col).trim(); + } + } + 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; + } + + if (hasColHeadings) { + // 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(); + if (children[0].classList.contains("title-column")) { + if (!this._isHiddenSubHeading(children[0])) { + this._appendText(rowHeading); + } + } else if (children.length == 1) { + // This is a single-cell row. + this._appendText(rowHeading); + } else { + 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() + ); + } + } + this._startNewLine(); + } + this._startNewLine(); + }, + + _nodeText(node) { + return node.textContent.replace(/\s+/g, " "); + }, +}; + +function openProfileDirectory() { + // Get the profile directory. + let currProfD = Services.dirsvc.get("ProfD", Ci.nsIFile); + let profileDir = currProfD.path; + + // Show the profile directory. + let nsLocalFile = Components.Constructor( + "@mozilla.org/file/local;1", + "nsIFile", + "initWithPath" + ); + new nsLocalFile(profileDir).reveal(); +} + +/** + * Profile reset is only supported for the default profile if the appropriate migrator exists. + */ +function populateActionBox() { + if (ResetProfile.resetSupported()) { + $("reset-box").style.display = "block"; + } + if (!Services.appinfo.inSafeMode && AppConstants.platform !== "android") { + $("safe-mode-box").style.display = "block"; + + if (Services.policies && !Services.policies.isAllowed("safeMode")) { + $("restart-in-safe-mode-button").setAttribute("disabled", "true"); + } + } +} + +// 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); + } +} + +// Added for TB. +function onShowPrivateDataChange() { + document + .getElementById("contents") + .classList.toggle( + "show-private-data", + document.getElementById("check-show-private-data").checked + ); +} + +/** + * Set up event listeners for buttons. + */ +function setupEventListeners() { + /* not used by TB + let button = $("reset-box-button"); + if (button) { + button.addEventListener("click", function(event) { + ResetProfile.openConfirmationDialog(window); + }); + } +*/ + let button = $("clear-startup-cache-button"); + if (button) { + button.addEventListener("click", async function (event) { + const [promptTitle, promptBody, restartButtonLabel] = + await document.l10n.formatValues([ + { id: "startup-cache-dialog-title2" }, + { id: "startup-cache-dialog-body2" }, + { id: "restart-button-label" }, + ]); + const buttonFlags = + Services.prompt.BUTTON_POS_0 * Services.prompt.BUTTON_TITLE_IS_STRING + + Services.prompt.BUTTON_POS_1 * Services.prompt.BUTTON_TITLE_CANCEL + + Services.prompt.BUTTON_POS_0_DEFAULT; + const result = Services.prompt.confirmEx( + window.docShell.chromeEventHandler.ownerGlobal, + promptTitle, + promptBody, + buttonFlags, + restartButtonLabel, + null, + null, + null, + {} + ); + if (result !== 0) { + return; + } + Services.appinfo.invalidateCachesOnRestart(); + Services.startup.quit( + Ci.nsIAppStartup.eRestart | Ci.nsIAppStartup.eAttemptQuit + ); + }); + } + button = $("restart-in-safe-mode-button"); + if (button) { + button.addEventListener("click", function (event) { + if ( + Services.obs + .enumerateObservers("restart-in-safe-mode") + .hasMoreElements() + ) { + Services.obs.notifyObservers(null, "restart-in-safe-mode"); + } else { + safeModeRestart(); + } + }); + } + 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) { + window.browsingContext.topChromeWindow.openDialog( + "chrome://mozapps/content/update/history.xhtml", + "Update:History", + "centerscreen,resizable=no,titlebar,modal" + ); + }); + } + } + button = $("verify-place-integrity-button"); + if (button) { + button.addEventListener("click", function (event) { + PlacesDBUtils.checkAndFixDatabase().then(tasksStatusMap => { + 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}`)); + } + $("verify-place-result").style.display = "block"; + $("verify-place-result").classList.remove("no-copy"); + $("verify-place-result").textContent = logs.join("\n"); + }); + }); + } + + // added for TB + $("send-via-email").addEventListener("click", function (event) { + sendViaEmail(); + }); + // end of TB addition + /* not used by TB + $("copy-raw-data-to-clipboard").addEventListener("click", function(event) { + copyRawDataToClipboard(this); + }); +*/ + $("copy-to-clipboard").addEventListener("click", function (event) { + copyContentsToClipboard(); + }); + $("profile-dir-button").addEventListener("click", function (event) { + openProfileDirectory(); + }); +} diff --git a/comm/mail/components/about-support/content/aboutSupport.xhtml b/comm/mail/components/about-support/content/aboutSupport.xhtml new file mode 100644 index 0000000000..8b3f5df2f6 --- /dev/null +++ b/comm/mail/components/about-support/content/aboutSupport.xhtml @@ -0,0 +1,956 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- 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/. --> + +<!-- This file is a copy of mozilla/toolkit/content/aboutSupport.xhtml with + modifications for TB. --> + +<!DOCTYPE html [ + <!ENTITY % htmlDTD PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> %htmlDTD; + <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd"> %brandDTD; +]> + +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <meta http-equiv="Content-Security-Policy" content="default-src chrome:; object-src 'none'" /> + <meta name="color-scheme" content="light dark" /> + <title data-l10n-id="page-title"/> + + <link rel="icon" type="image/png" id="favicon" + href="chrome://branding/content/icon48.png"/> + <link rel="stylesheet" href="chrome://global/skin/aboutSupport.css" + type="text/css"/> +<!-- Added for TB --> + <link rel="stylesheet" href="chrome://messenger/skin/aboutSupport.css" + type="text/css"/> +<!-- End of TB addition --> + <script src="chrome://messenger/content/about-support/aboutSupport.js"/> + <link rel="localization" href="branding/brand.ftl"/> + <link rel="localization" href="toolkit/about/aboutSupport.ftl"/> + <link rel="localization" href="toolkit/global/resetProfile.ftl"/> + <link rel="localization" href="toolkit/global/processTypes.ftl"/> +<!-- Added for TB --> + <link rel="localization" href="messenger/aboutSupportMail.ftl"/> + <link rel="localization" href="messenger/aboutSupportCalendar.ftl"/> + <link rel="localization" href="messenger/aboutSupportChat.ftl"/> + <script src="chrome://messenger/content/about-support/accounts.js"/> + <script src="chrome://messenger/content/about-support/calendars.js"/> + <script src="chrome://messenger/content/about-support/chat.js"/> + <script src="chrome://messenger/content/about-support/libs.js"/> + <script src="chrome://messenger/content/about-support/export.js"/> +<!-- End of TB addition --> + </head> + + <body class="wide-container"> + <h1 data-l10n-id="page-title"/> + <div class="header-flex"> + <div class="content-flex"> + <div class="page-subtitle" data-l10n-id="page-subtitle"> + <a id="supportLink" data-l10n-name="support-link"></a> + </div> + <div id="support-buttons"> + <!-- Not used on TB + <button id="copy-raw-data-to-clipboard" data-l10n-id="copy-raw-data-to-clipboard-label"/> + --> + <button id="copy-to-clipboard" data-l10n-id="copy-text-to-clipboard-label"/> + <!-- Added for TB --> + <button id="send-via-email" data-l10n-id="send-via-email"/> + <div> + <input type="checkbox" + id="check-show-private-data" + class="data-uionly" + role="checkbox"/> + <span> + <label for="check-show-private-data" data-l10n-id="show-private-data-main-text"/> + <span class="gray-text" data-l10n-id="show-private-data-explanation-text"></span> + </span> + </div> + <!-- End of TB addition --> + </div> + </div> + +#ifndef ANDROID + <div class="action-box"> + <div id="reset-box"> + <h3 data-l10n-id="refresh-profile"/> + <button id="reset-box-button" data-l10n-id="refresh-profile-button"/> + </div> + <div id="safe-mode-box"> + <h3 data-l10n-id="troubleshoot-mode-title"/> + <button id="restart-in-safe-mode-button" data-l10n-id="restart-in-troubleshoot-mode-label"/> + </div> + <div id="clear-startup-cache-box"> + <h3 data-l10n-id="clear-startup-cache-title"/> + <button id="clear-startup-cache-button" data-l10n-id="clear-startup-cache-label"/> + </div> + </div> +#endif + </div> + <div id="contents"> + + <!-- - - - - - - - - - - - - - - - - - - - - --> + + <h2 class="major-section" data-l10n-id="app-basics-title"/> + + <table> + <tbody> + <tr> + <th class="column" data-l10n-id="app-basics-name"/> + + <td id="application-box"> + </td> + </tr> + + <tr> + <th class="column" data-l10n-id="app-basics-version"/> + + <td id="version-box"> + </td> + </tr> + + <tr> + <th class="column" data-l10n-id="app-basics-build-id"/> + <td id="buildid-box"></td> + </tr> + + <tr> + <th class="column" data-l10n-id="app-basics-distribution-id"/> + <td id="distributionid-box"></td> + </tr> + +#ifndef ANDROID +#ifdef MOZ_UPDATER + <tr id="update-dir-row" class="no-copy"> + <th class="column" data-l10n-id="app-basics-update-dir"/> + + <td> + <button id="update-dir-button" data-l10n-id="show-dir-label"/> + <span id="update-dir-box" dir="ltr"> + </span> + </td> + </tr> + + <tr id="update-history-row" class="no-copy"> + <th class="column" data-l10n-id="app-basics-update-history"/> + + <td> + <button id="show-update-history-button" data-l10n-id="app-basics-show-update-history"/> + </td> + </tr> +#endif +#endif + +#ifdef MOZ_UPDATER + <tr> + <th class="column" data-l10n-id="app-basics-update-channel"/> + <td id="updatechannel-box"></td> + </tr> +#endif + + <tr> + <th class="column" data-l10n-id="app-basics-user-agent"/> + + <td id="useragent-box"> + </td> + </tr> + + <tr> + <th class="column" data-l10n-id="app-basics-os"/> + + <td id="os-box"> + </td> + </tr> + + <tr id="os-theme-row"> + <th class="column" data-l10n-id="app-basics-os-theme"/> + + <td id="os-theme-box"> + </td> + </tr> + +#ifdef XP_MACOSX + <tr> + <th class="column" data-l10n-id="app-basics-rosetta"/> + + <td id="rosetta-box"> + </td> + </tr> +#endif + + <tr class="no-copy"> + <th class="column" data-l10n-id="app-basics-binary"/> + + <td id="binary-box" dir="ltr"> + </td> + </tr> + + <tr id="profile-row" class="no-copy" dir="ltr"> + <th class="column" data-l10n-id="app-basics-profile-dir"/> + + <td> + <button id="profile-dir-button" data-l10n-id="show-dir-label"/> + <span id="profile-dir-box"> + </span> + </td> + </tr> + + <tr class="no-copy"> + <th class="column" data-l10n-id="app-basics-build-config"/> + + <td> + <a href="about:buildconfig" target="_blank">about:buildconfig</a> + </td> + </tr> + + <tr class="no-copy"> + <th class="column" data-l10n-id="app-basics-memory-use"/> + + <td> + <a href="about:memory" target="_blank">about:memory</a> + </td> + </tr> + + <tr class="no-copy"> + <th class="column" data-l10n-id="app-basics-cache-use"/> + + <td> + <a href="about:cache" target="_blank">about:cache</a> + </td> + </tr> + + <tr class="no-copy"> + <th class="column" data-l10n-id="app-basics-performance"/> + + <td> + <a href="about:processes" target="_blank">about:processes</a> + </td> + </tr> + + <tr class="no-copy"> + <th class="column" data-l10n-id="app-basics-service-workers"/> + + <td> + <a href="about:serviceworkers" target="_blank">about:serviceworkers</a> + </td> + </tr> + +#if defined(XP_WIN) + <tr class="no-copy"> + <th class="column" data-l10n-id="app-basics-third-party"/> + + <td> + <a href="about:third-party" target="_blank">about:third-party</a> + </td> + </tr> +#endif + +#if defined(XP_WIN) && defined(MOZ_LAUNCHER_PROCESS) + <tr> + <th class="column" data-l10n-id="app-basics-launcher-process-status"/> + + <td id="launcher-process-box"> + </td> + </tr> +#endif + + <tr> + <th class="column" data-l10n-id="app-basics-multi-process-support"/> + + <td id="multiprocess-box"> + <span id="multiprocess-box-process-count"/> + </td> + </tr> + + <tr> + <th class="column" data-l10n-id="app-basics-fission-support"/> + + <td id="fission-box"> + <span id="fission-box-process-count"/> + <span id="fission-box-status"/> + </td> + </tr> + + <tr id="remoteprocesses-row"> + <th class="column" data-l10n-id="app-basics-remote-processes-count"/> + + <td> + <a href="#remote-processes"></a> + </td> + </tr> + + <tr id="policies-status-row"> + <th class="column" data-l10n-id="app-basics-enterprise-policies"/> + + <td id="policies-status"> + </td> + </tr> + + <tr> + <th class="column" data-l10n-id="app-basics-location-service-key-google"/> + + <td id="key-location-service-google-box"> + </td> + </tr> + + <tr> + <th class="column" data-l10n-id="app-basics-safebrowsing-key-google"/> + + <td id="key-safebrowsing-google-box"> + </td> + </tr> + + <tr> + <th class="column" data-l10n-id="app-basics-key-mozilla"/> + + <td id="key-mozilla-box"> + </td> + </tr> + + <tr> + <th class="column" data-l10n-id="app-basics-safe-mode"/> + + <td id="safemode-box"> + </td> + </tr> + + <tr> + <th class="column" data-l10n-id="app-basics-memory-size"/> + + <td id="memory-size-box"> + </td> + </tr> + + <tr> + <th class="column" data-l10n-id="app-basics-disk-available"/> + + <td id="disk-available-box"> + </td> + </tr> + +#ifndef ANDROID + <tr class="no-copy"> + <th class="column" data-l10n-id="app-basics-profiles"/> + + <td> + <a href="about:profiles" target="_blank">about:profiles</a> + </td> + </tr> +#endif + + <tr class="no-copy"> + <th class="column" data-l10n-id="app-basics-telemetry"/> + + <td> + <a href="about:telemetry" target="_blank">about:telemetry</a> + </td> + </tr> + + </tbody> + </table> + + <!-- - - - - - - - - - - - - - - - - - - - - --> +<!-- Added for TB --> + <h2 class="major-section" data-l10n-id="accounts-title"/> + + <table id="accounts-table"> + <thead> + <tr> + <th rowspan="2" data-l10n-id="accounts-ID"/> + + <th rowspan="2" class="data-private" data-l10n-id="accounts-name"/> + + <th colspan="3" data-l10n-id="accounts-incoming-server"/> + + <th colspan="5" data-l10n-id="accounts-outgoing-servers"/> + </tr> + <tr class="thead-level2"> + <!-- Incoming server --> + <th data-l10n-id="accounts-server-name"/> + + <th data-l10n-id="accounts-conn-security"/> + + <th data-l10n-id="accounts-auth-method"/> + + <!-- Outgoing servers --> + <th class="data-private" data-l10n-id="identity-name"/> + + <th data-l10n-id="accounts-server-name"/> + + <th data-l10n-id="accounts-conn-security"/> + + <th data-l10n-id="accounts-auth-method"/> + + <th data-l10n-id="accounts-default"/> + </tr> + </thead> + + <tbody id="accounts-tbody"> + </tbody> + </table> + + <h2 class="major-section" data-l10n-id="mail-libs-title"></h2> + <table class="mail-libs-table"> + <caption></caption> + <thead> + <th data-l10n-id="libs-table-heading-library"></th> + <th data-l10n-id="libs-table-heading-status"></th> + <th data-l10n-id="libs-table-heading-expected-version"></th> + <th data-l10n-id="libs-table-heading-loaded-version"></th> + <th data-l10n-id="libs-table-heading-path"></th> + </thead> + + <tbody> + <tr> + <td>RNP (OpenPGP)</td> + <td id="rnp-status"> + </td> + <td id="rnp-expected-version"> + </td> + <td id="rnp-loaded-version"> + </td> + <td id="rnp-path"> + </td> + </tr> + </tbody> + </table> + + <h2 class="major-section" data-l10n-id="calendars-title"></h2> + + <div id="calendar-tables"></div> + + <template id="calendars-table-template"> + <table class="calendar-table"> + <caption></caption> + <thead> + <th data-l10n-id="calendars-table-heading-property"></th> + <th data-l10n-id="calendars-table-heading-value"></th> + </thead> + <tbody> + </tbody> + </table> + </template> + + <template id="calendars-table-row-template"> + <tr> + <td></td> + <td></td> + </tr> + </template> + + <h2 class="major-section no-copy" data-l10n-id="chat-title"></h2> + + <table class="no-copy" id="chat-table"> + <thead> + <tr> + <th data-l10n-id="chat-table-heading-account"></th> + <th data-l10n-id="chat-table-heading-protocol"></th> + <th data-l10n-id="chat-table-heading-name" class="data-private"></th> + <th data-l10n-id="chat-table-heading-actions"></th> + </tr> + </thead> + <tbody id="chat-tbody"> + </tbody> + </table> + + <template id="chat-table-row-template"> + <tr> + <td></td> + <td></td> + <td class="data-private"></td> + <td><button class="button" type="button" data-l10n-id="chat-table-copy-debug-log"></button></td> + </tr> + </template> + +<!-- End of TB addition --> + + <!-- - - - - - - - - - - - - - - - - - - - - --> +#ifdef MOZ_CRASHREPORTER + + <h2 class="major-section" id="crashes-title" data-l10n-id="crashes-title"/> + + <table id="crashes-table"> + <thead> + <tr> + <th data-l10n-id="crashes-id"/> + <th data-l10n-id="crashes-send-date"/> + </tr> + </thead> + <tbody id="crashes-tbody"> + </tbody> + </table> + <p id="crashes-allReports" class="hidden no-copy"> + <a href="about:crashes" id="crashes-allReportsWithPending" + class="block" data-l10n-id="crashes-all-reports" target="_blank"/> + </p> + <p id="crashes-noConfig" class="hidden no-copy" data-l10n-id="crashes-no-config"/> + +#endif + <!-- - - - - - - - - - - - - - - - - - - - - --> + <!-- Not used by TB + <h2 class="major-section" data-l10n-id="features-title"/> + + <table id="features-table"> + <thead> + <tr> + <th data-l10n-id="features-name"/> + <th data-l10n-id="features-version"/> + <th data-l10n-id="features-id"/> + </tr> + </thead> + <tbody id="features-tbody"> + </tbody> + </table> + --> + + <!-- - - - - - - - - - - - - - - - - - - - - --> + + <h2 class="major-section" data-l10n-id="processes-title" id="remote-processes"/> + + <table id="remote-processes-table"> + <thead> + <tr> + <th data-l10n-id="processes-type"/> + <th data-l10n-id="processes-count"/> + </tr> + </thead> + <tbody id="processes-tbody"> + </tbody> + </table> + + <!-- - - - - - - - - - - - - - - - - - - - - --> + + <h2 class="major-section" data-l10n-id="support-addons-title"/> + + <table> + <thead> + <tr> + <th data-l10n-id="support-addons-name"/> + <th data-l10n-id="support-addons-type"/> + <th data-l10n-id="support-addons-version"/> + <th data-l10n-id="support-addons-enabled"/> + <th data-l10n-id="support-addons-id"/> + </tr> + </thead> + <tbody id="addons-tbody"> + </tbody> + </table> + + <!-- - - - - - - - - - - - - - - - - - - - - --> + + <h2 class="major-section" id="security-software-title" data-l10n-id="security-software-title"/> + + <table id="security-software-table"> + <thead> + <tr> + <th data-l10n-id="security-software-type"/> + <th data-l10n-id="security-software-name"/> + </tr> + </thead> + <tbody> + <tr> + <th class="column" data-l10n-id="security-software-antivirus"/> + + <td id="security-software-antivirus"> + </td> + </tr> + + <tr> + <th class="column" data-l10n-id="security-software-antispyware"/> + + <td id="security-software-antispyware"> + </td> + </tr> + + <tr> + <th class="column" data-l10n-id="security-software-firewall"/> + + <td id="security-software-firewall"> + </td> + </tr> + </tbody> + </table> + + <!-- - - - - - - - - - - - - - - - - - - - - --> + + <h2 class="major-section" data-l10n-id="graphics-title"/> + + <table> + <tbody id="graphics-features-tbody"> + <tr> + <th colspan="2" class="title-column" data-l10n-id="graphics-features-title"/> + </tr> + </tbody> + + <tbody id="graphics-gpu-1-tbody"> + <tr> + <th colspan="2" class="title-column" data-l10n-id="graphics-gpu1-title"/> + </tr> + </tbody> + + <tbody id="graphics-gpu-2-tbody"> + <tr> + <th colspan="2" class="title-column" data-l10n-id="graphics-gpu2-title"/> + </tr> + </tbody> + + <tbody id="graphics-diagnostics-tbody"> + <tr> + <th colspan="2" class="title-column" data-l10n-id="graphics-diagnostics-title"/> + </tr> + </tbody> + + <tbody id="graphics-decisions-tbody"> + <tr> + <th colspan="2" class="title-column" data-l10n-id="graphics-decision-log-title"/> + </tr> + </tbody> + + <tbody id="graphics-crashguards-tbody"> + <tr> + <th colspan="2" class="title-column" data-l10n-id="graphics-crash-guards-title"/> + </tr> + </tbody> + + <tbody id="graphics-workarounds-tbody"> + <tr> + <th colspan="2" class="title-column" data-l10n-id="graphics-workarounds-title"/> + </tr> + </tbody> + + <tbody id="graphics-failures-tbody"> + <tr> + <th colspan="2" class="title-column" data-l10n-id="graphics-failure-log-title"/> + </tr> + </tbody> + </table> + + <!-- - - - - - - - - - - - - - - - - - - - - --> + + <h2 class="major-section" data-l10n-id="media-title"/> + <table> + <tbody id="media-info-tbody"> + </tbody> + + <tbody id="media-output-devices-tbody"> + <tr> + <th colspan="9" class="title-column" data-l10n-id="media-output-devices-title"/> + </tr> + <tr> + <th data-l10n-id="media-device-name"/> + <th data-l10n-id="media-device-group"/> + <th data-l10n-id="media-device-vendor"/> + <th data-l10n-id="media-device-state"/> + <th data-l10n-id="media-device-preferred"/> + <th data-l10n-id="media-device-format"/> + <th data-l10n-id="media-device-channels"/> + <th data-l10n-id="media-device-rate"/> + <th data-l10n-id="media-device-latency"/> + </tr> + </tbody> + + <tbody id="media-input-devices-tbody"> + <tr> + <th colspan="9" class="title-column" data-l10n-id="media-input-devices-title"/> + </tr> + <tr> + <th data-l10n-id="media-device-name"/> + <th data-l10n-id="media-device-group"/> + <th data-l10n-id="media-device-vendor"/> + <th data-l10n-id="media-device-state"/> + <th data-l10n-id="media-device-preferred"/> + <th data-l10n-id="media-device-format"/> + <th data-l10n-id="media-device-channels"/> + <th data-l10n-id="media-device-rate"/> + <th data-l10n-id="media-device-latency"/> + </tr> + </tbody> + + <tbody id="media-capabilities-tbody"> + <tr> + <th colspan="9" class="title-column" data-l10n-id="media-capabilities-title"/> + </tr> + <tr> + <td colspan="9"> + <button id="enumerate-database-button" data-l10n-id="media-capabilities-enumerate"/> + <pre id="enumerate-database-result" class="hidden no-copy"></pre> + </td> + </tr> + </tbody> + + </table> + + <!-- - - - - - - - - - - - - - - - - - - - - --> + + <h2 class="major-section" data-l10n-id="environment-variables-title"/> + + <table class="prefs-table"> + <thead class="no-copy"> + <th class="name" data-l10n-id="environment-variables-name"/> + + <th class="value" data-l10n-id="environment-variables-value"/> + </thead> + + <tbody id="environment-variables-tbody"> + </tbody> + </table> + + <!-- - - - - - - - - - - - - - - - - - - - - --> + + <h2 class="major-section" data-l10n-id="modified-key-prefs-title"/> + + <table class="prefs-table"> + <thead class="no-copy"> + <th class="name" data-l10n-id="modified-prefs-name"/> + + <th class="value" data-l10n-id="modified-prefs-value"/> + </thead> + + <tbody id="prefs-tbody"> + </tbody> + </table> + + <section id="prefs-user-js-section" class="hidden no-copy"> + <h3 data-l10n-id="user-js-title"/> + <p data-l10n-id="user-js-description"> + <a id="prefs-user-js-link" data-l10n-name="user-js-link"></a> + </p> + </section> + + <!-- - - - - - - - - - - - - - - - - - - - - --> + + <h2 class="major-section" data-l10n-id="locked-key-prefs-title"/> + + <table class="prefs-table"> + <thead class="no-copy"> + <th class="name" data-l10n-id="locked-prefs-name"/> + + <th class="value" data-l10n-id="locked-prefs-value"/> + </thead> + + <tbody id="locked-prefs-tbody"> + </tbody> + </table> + +#ifndef ANDROID + <!-- - - - - - - - - - - - - - - - - - - - - --> + + <h2 class="major-section" data-l10n-id="place-database-title"/> + + <table> + <tr class="no-copy"> + <th class="column" data-l10n-id="place-database-integrity"/> + + <td> + <button id="verify-place-integrity-button" data-l10n-id="place-database-verify-integrity"/> + <pre id="verify-place-result" class="hidden no-copy"></pre> + </td> + </tr> + </table> +#endif + + <!-- - - - - - - - - - - - - - - - - - - - - --> + <h2 class="major-section" data-l10n-id="a11y-title"/> + + <table> + <tbody> + <tr> + <th class="column" data-l10n-id="a11y-activated"/> + + <td id="a11y-activated"> + </td> + </tr> + <tr> + <th class="column" data-l10n-id="a11y-force-disabled"/> + + <td id="a11y-force-disabled"> + </td> + </tr> +#if defined(XP_WIN) + <tr> + <th class="column" data-l10n-id="a11y-handler-used"/> + + <td id="a11y-handler-used"> + </td> + </tr> + + <tr> + <th class="column" data-l10n-id="a11y-instantiator"/> + + <td id="a11y-instantiator"> + </td> + </tr> +#endif + </tbody> + </table> + + <!-- - - - - - - - - - - - - - - - - - - - - --> + <h2 class="major-section" data-l10n-id="library-version-title"/> + + <table> + <tbody id="libversions-tbody"> + </tbody> + </table> + + <!-- - - - - - - - - - - - - - - - - - - - - --> + +#if defined(MOZ_SANDBOX) + <h2 class="major-section" id="sandbox" data-l10n-id="sandbox-title"/> + + <table> + <tbody id="sandbox-tbody"> + </tbody> + </table> + +#if defined(XP_LINUX) + <h4 data-l10n-id="sandbox-sys-call-log-title"/> + <table> + <thead> + <tr> + <th data-l10n-id="sandbox-sys-call-index"/> + <th data-l10n-id="sandbox-sys-call-age"/> + <th data-l10n-id="sandbox-sys-call-pid"/> + <th data-l10n-id="sandbox-sys-call-tid"/> + <th data-l10n-id="sandbox-sys-call-proc-type"/> + <th data-l10n-id="sandbox-sys-call-number"/> + <th id="sandbox-syscalls-argshead" data-l10n-id="sandbox-sys-call-args"/> + </tr> + </thead> + <tbody id="sandbox-syscalls-tbody"> + </tbody> + </table> +#endif +#endif + + <h2 class="major-section" data-l10n-id="startup-cache-title"/> + + <table> + <tbody> + <tr> + <th class="column" data-l10n-id="startup-cache-disk-cache-path"/> + + <td id="startup-cache-disk-cache-path"> + </td> + </tr> + <tr> + <th class="column" data-l10n-id="startup-cache-ignore-disk-cache"/> + + <td id="startup-cache-ignore-disk-cache"> + </td> + </tr> + <tr> + <th class="column" data-l10n-id="startup-cache-found-disk-cache-on-init"/> + + <td id="startup-cache-found-disk-cache-on-init"> + </td> + </tr> + <tr> + <th class="column" data-l10n-id="startup-cache-wrote-to-disk-cache"/> + + <td id="startup-cache-wrote-to-disk-cache"> + </td> + </tr> + </tbody> + </table> + + <h2 class="major-section" data-l10n-id="intl-title"/> + + <table> + <tbody id="intl-localeservice-tbody"> + <tr> + <th colspan="2" class="title-column" data-l10n-id="intl-app-title"/> + </tr> + <tr> + <th class="column" data-l10n-id="intl-locales-requested"/> + <td id="intl-locale-requested"> + </td> + </tr> + <tr> + <th class="column" data-l10n-id="intl-locales-available"/> + <td id="intl-locale-available"> + </td> + </tr> + <tr> + <th class="column" data-l10n-id="intl-locales-supported"/> + <td id="intl-locale-supported"> + </td> + </tr> + <tr> + <th class="column" data-l10n-id="intl-regional-prefs"/> + <td id="intl-locale-regionalprefs"> + </td> + </tr> + <tr> + <th class="column" data-l10n-id="intl-locales-default"/> + <td id="intl-locale-default"> + </td> + </tr> + </tbody> + <tbody id="intl-ospreferences-tbody"> + <tr> + <th colspan="2" class="title-column" data-l10n-id="intl-os-title"/> + </tr> + <tr> + <th class="column" data-l10n-id="intl-os-prefs-system-locales"/> + <td id="intl-osprefs-systemlocales"> + </td> + </tr> + <tr> + <th class="column" data-l10n-id="intl-regional-prefs"/> + <td id="intl-osprefs-regionalprefs"> + </td> + </tr> + </tbody> + </table> + <!-- - - - - - - - - - - - - - - - - - - - - --> + +#if defined(ENABLE_WEBDRIVER) + <h2 class="major-section" data-l10n-id="remote-debugging-title"/> + + <table> + <tbody> + <tr> + <th class="column" data-l10n-id="remote-debugging-accepting-connections"/> + <td id="remote-debugging-accepting-connections"></td> + </tr> + <tr> + <th class="column" data-l10n-id="remote-debugging-url"/> + <td id="remote-debugging-url"></td> + </tr> + </tbody> + </table> +#endif + +#ifndef ANDROID + <!-- - - - - - - - - - - - - - - - - - - - - --> + + <h2 class="major-section" data-l10n-id="support-printing-title"/> + + <table> + <tr class="no-copy"> + <th class="column" data-l10n-id="support-printing-troubleshoot"/> + <td> + <button id="support-printing-clear-settings-button" data-l10n-id="support-printing-clear-settings-button"/> + </td> + </tr> + </table> + + <h3 data-l10n-id="support-printing-modified-settings"/> + + <table class="prefs-table"> + <thead class="no-copy"> + <th class="name" data-l10n-id="support-printing-prefs-name"/> + + <th class="value" data-l10n-id="support-printing-prefs-value"/> + </thead> + + <tbody id="support-printing-prefs-tbody"> + </tbody> + </table> +#endif + + </div> + + </body> + +</html> diff --git a/comm/mail/components/about-support/content/accounts.js b/comm/mail/components/about-support/content/accounts.js new file mode 100644 index 0000000000..33633f4a15 --- /dev/null +++ b/comm/mail/components/about-support/content/accounts.js @@ -0,0 +1,339 @@ +/* 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/. */ + +/* globals CLASS_DATA_PRIVATE, CLASS_DATA_PUBLIC */ + +"use strict"; + +var { MailServices } = ChromeUtils.import( + "resource:///modules/MailServices.jsm" +); + +// Platform-specific includes +var AboutSupportPlatform; +if ("@mozilla.org/windows-registry-key;1" in Cc) { + let temp = ChromeUtils.import("resource:///modules/AboutSupportWin32.jsm"); + AboutSupportPlatform = temp.AboutSupportPlatform; +} else if ("nsILocalFileMac" in Ci) { + let temp = ChromeUtils.import("resource:///modules/AboutSupportMac.jsm"); + AboutSupportPlatform = temp.AboutSupportPlatform; +} else { + let temp = ChromeUtils.import("resource:///modules/AboutSupportUnix.jsm"); + AboutSupportPlatform = temp.AboutSupportPlatform; +} + +var gMessengerBundle = Services.strings.createBundle( + "chrome://messenger/locale/messenger.properties" +); + +var gSocketTypes = {}; +for (let [str, index] of Object.entries(Ci.nsMsgSocketType)) { + gSocketTypes[index] = str; +} + +var gAuthMethods = {}; +for (let [str, index] of Object.entries(Ci.nsMsgAuthMethod)) { + gAuthMethods[index] = str; +} + +// l10n properties in messenger.properties corresponding to each auth method +var gAuthMethodProperties = new Map([ + [0, "authNo"], // Special value defined to be invalid. + // Some accounts without auth report this. + [Ci.nsMsgAuthMethod.none, "authNo"], + [Ci.nsMsgAuthMethod.old, "authOld"], + [Ci.nsMsgAuthMethod.passwordCleartext, "authPasswordCleartextViaSSL"], + [Ci.nsMsgAuthMethod.passwordEncrypted, "authPasswordEncrypted"], + [Ci.nsMsgAuthMethod.GSSAPI, "authKerberos"], + [Ci.nsMsgAuthMethod.NTLM, "authNTLM"], + [Ci.nsMsgAuthMethod.External, "authExternal"], + [Ci.nsMsgAuthMethod.secure, "authAnySecure"], + [Ci.nsMsgAuthMethod.anything, "authAny"], + [Ci.nsMsgAuthMethod.OAuth2, "authOAuth2"], +]); + +var AboutSupport = { + /** + * Gets details about SMTP servers for a given nsIMsgAccount. + * + * @returns An array of records, each record containing the name and other details + * about one SMTP server. + */ + _getSMTPDetails(aAccount) { + let defaultIdentity = aAccount.defaultIdentity; + let smtpDetails = []; + + for (let identity of aAccount.identities) { + let isDefault = identity == defaultIdentity; + let smtpServer = MailServices.smtp.getServerByIdentity(identity); + if (!smtpServer) { + continue; + } + smtpDetails.push({ + identityName: identity.identityName, + name: smtpServer.displayname, + authMethod: smtpServer.authMethod, + socketType: smtpServer.socketType, + isDefault, + }); + } + + return smtpDetails; + }, + + /** + * Returns account details as an array of records. + */ + getAccountDetails() { + let accountDetails = []; + + for (let account of MailServices.accounts.accounts) { + let server = account.incomingServer; + accountDetails.push({ + key: account.key, + name: server.prettyName, + hostDetails: + "(" + + server.type + + ") " + + server.hostName + + (server.port != -1 ? ":" + server.port : ""), + socketType: server.socketType, + authMethod: server.authMethod, + smtpServers: this._getSMTPDetails(account), + }); + } + + function idCompare(accountA, accountB) { + let regex = /^account([0-9]+)$/; + let regexA = regex.exec(accountA.key); + let regexB = regex.exec(accountB.key); + // There's an off chance that the account ID isn't in the standard + // accountN form. If so, use the standard string compare against a fixed + // string ("account") to avoid correctness issues. + if (!regexA || !regexB) { + let keyA = regexA ? "account" : accountA.key; + let keyB = regexB ? "account" : accountB.key; + return keyA.localeCompare(keyB); + } + let idA = parseInt(regexA[1]); + let idB = parseInt(regexB[1]); + return idA - idB; + } + + // Sort accountDetails by account ID. + accountDetails.sort(idCompare); + return accountDetails; + }, + + /** + * Returns the corresponding text for a given socket type index. The text is + * returned as a record with "localized" and "neutral" entries. + */ + getSocketTypeText(aIndex) { + let plainSocketType = + aIndex in gSocketTypes ? gSocketTypes[aIndex] : aIndex; + let prettySocketType; + try { + prettySocketType = gMessengerBundle.GetStringFromName( + "smtpServer-ConnectionSecurityType-" + aIndex + ); + } catch (e) { + if (e.result == Cr.NS_ERROR_FAILURE) { + // The string wasn't found in the bundle. Make do without it. + prettySocketType = plainSocketType; + } else { + throw e; + } + } + return { localized: prettySocketType, neutral: plainSocketType }; + }, + + /** + * Returns the corresponding text for a given authentication method index. The + * text is returned as a record with "localized" and "neutral" entries. + */ + getAuthMethodText(aIndex) { + let prettyAuthMethod; + let plainAuthMethod = + aIndex in gAuthMethods ? gAuthMethods[aIndex] : aIndex; + if (gAuthMethodProperties.has(parseInt(aIndex))) { + prettyAuthMethod = gMessengerBundle.GetStringFromName( + gAuthMethodProperties.get(parseInt(aIndex)) + ); + } else { + prettyAuthMethod = plainAuthMethod; + } + return { localized: prettyAuthMethod, neutral: plainAuthMethod }; + }, +}; + +function createParentElement(tagName, childElems) { + let elem = document.createElement(tagName); + appendChildren(elem, childElems); + return elem; +} + +function createElement(tagName, textContent, opt_attributes, opt_copyData) { + if (opt_attributes == null) { + opt_attributes = {}; + } + let elem = document.createElement(tagName); + elem.textContent = textContent; + for (let key in opt_attributes) { + elem.setAttribute(key, "" + opt_attributes[key]); + } + + if (opt_copyData != null) { + elem.dataset.copyData = opt_copyData; + } + + return elem; +} + +function appendChildren(parentElem, children) { + for (let i = 0; i < children.length; i++) { + parentElem.appendChild(children[i]); + } +} + +/** + * Coerces x into a string. + */ +function toStr(x) { + return "" + x; +} + +/** + * Marks x as private (see below). + */ +function toPrivate(x) { + return { localized: x, neutral: x, isPrivate: true }; +} + +/** + * A list of fields for the incoming server of an account. Each element of the + * list is a pair of [property name, transforming function]. The transforming + * function should take the property and return either a string or an object + * with the following properties: + * - localized: the data in (possibly) localized form + * - neutral: the data in language-neutral form + * - isPrivate (optional): true if the data is private-only, false if public-only, + * not stated otherwise + */ +var gIncomingDetails = [ + ["key", toStr], + ["name", toPrivate], + ["hostDetails", toStr], + ["socketType", AboutSupport.getSocketTypeText.bind(AboutSupport)], + ["authMethod", AboutSupport.getAuthMethodText.bind(AboutSupport)], +]; + +/** + * A list of fields for the outgoing servers associated with an account. This is + * similar to gIncomingDetails above. + */ +var gOutgoingDetails = [ + ["identityName", toPrivate], + ["name", toStr], + ["socketType", AboutSupport.getSocketTypeText.bind(AboutSupport)], + ["authMethod", AboutSupport.getAuthMethodText.bind(AboutSupport)], + ["isDefault", toStr], +]; + +/** + * A list of account details. + */ +var gAccountDetails = AboutSupport.getAccountDetails(); + +function populateAccountsSection() { + let trAccounts = []; + + function createTD(data, rowSpan) { + let text = typeof data == "string" ? data : data.localized; + let copyData = typeof data == "string" ? null : data.neutral; + let attributes = { rowspan: rowSpan }; + if (typeof data == "object" && "isPrivate" in data) { + attributes.class = data.isPrivate + ? CLASS_DATA_PRIVATE + : CLASS_DATA_PUBLIC; + } + + return createElement("td", text, attributes, copyData); + } + + for (let account of gAccountDetails) { + // We want a minimum rowspan of 1 + let rowSpan = account.smtpServers.length || 1; + // incomingTDs is an array of TDs + let incomingTDs = gIncomingDetails.map(([prop, fn]) => + createTD(fn(account[prop]), rowSpan) + ); + // outgoingTDs is an array of arrays of TDs + let outgoingTDs = []; + for (let smtp of account.smtpServers) { + outgoingTDs.push( + gOutgoingDetails.map(([prop, fn]) => createTD(fn(smtp[prop]), 1)) + ); + } + + // If there are no SMTP servers, add a dummy element to make life easier below + if (outgoingTDs.length == 0) { + outgoingTDs = [[]]; + } + + // Add the first SMTP server to this tr. + let tr = createParentElement("tr", incomingTDs.concat(outgoingTDs[0])); + trAccounts.push(tr); + // Add the remaining SMTP servers as separate trs + for (let tds of outgoingTDs.slice(1)) { + trAccounts.push(createParentElement("tr", tds)); + } + } + + appendChildren(document.getElementById("accounts-tbody"), trAccounts); +} + +/** + * Returns a plaintext representation of the accounts data. + */ +function getAccountsText(aHidePrivateData, aIndent) { + let accumulator = []; + + // Given a string or object, converts it into a language-neutral form + function neutralizer(data) { + if (typeof data == "string") { + return data; + } + if ("isPrivate" in data && aHidePrivateData == data.isPrivate) { + return ""; + } + return data.neutral; + } + + for (let account of gAccountDetails) { + accumulator.push(aIndent + account.key + ":"); + // incomingData is an array of strings + let incomingData = gIncomingDetails.map(([prop, fn]) => + neutralizer(fn(account[prop])) + ); + accumulator.push(aIndent + " INCOMING: " + incomingData.join(", ")); + + // outgoingData is an array of arrays of strings + let outgoingData = []; + for (let smtp of account.smtpServers) { + outgoingData.push( + gOutgoingDetails.map(([prop, fn]) => neutralizer(fn(smtp[prop]))) + ); + } + + for (let data of outgoingData) { + accumulator.push(aIndent + " OUTGOING: " + data.join(", ")); + } + + accumulator.push(""); + } + + return accumulator.join("\n"); +} diff --git a/comm/mail/components/about-support/content/calendars.js b/comm/mail/components/about-support/content/calendars.js new file mode 100644 index 0000000000..a55b59572c --- /dev/null +++ b/comm/mail/components/about-support/content/calendars.js @@ -0,0 +1,77 @@ +/* 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/. */ + +/* globals CLASS_DATA_PRIVATE */ + +var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm"); + +let boolean = val => (!val && val !== false ? "" : val); +let string = val => (val ? String(val) : ""); + +/** + * A list of tuples for each calendar property displayed where each tuple + * contains the following elements: + * 0 - The name of the property passed to getProperty(). + * 1 - A function that accepts the property value and attempts it into a string. + * 2 - Boolean indicating whether the property is private data (optional). + */ +let gCalendarProperties = [ + ["name", string, true], + ["type", string], + ["disabled", boolean], + ["username", string, true], + ["uri", string, true], + ["refreshInterval", string], + ["readOnly", boolean], + ["suppressAlarms", boolean], + ["cache.enabled", boolean], + ["imip.identity", identity => string(identity && identity.key)], + ["imip.identity.disabled", boolean], + ["imip.identity.account", account => string(account && account.key)], + ["organizerId", string, true], + ["forceEmailScheduling", boolean], + ["capabilities.alarms.popup.supported", boolean], + ["capabilities.alarms.oninviations.supported", boolean], + ["capabilities.alarms.maxCount", string], + ["capabilities.attachments.supported", boolean], + ["capabilities.categories.maxCount", string], + ["capabilities.privacy.supported", boolean], + ["capabilities.priority.supported", boolean], + ["capabilities.events.supported", boolean], + ["capabilities.tasks.supported", boolean], + ["capabilities.timezones.floating.supported", boolean], + ["capabilities.timezones.UTC.supported", boolean], + ["capabilities.autoschedule.supported", boolean], +]; + +/** + * Populates the "Calendars" section of the troubleshooting information page + * with the properties of each configured calendar. + */ +function populateCalendarsSection() { + let container = document.getElementById("calendar-tables"); + let tableTmpl = document.getElementById("calendars-table-template"); + let rowTmpl = document.getElementById("calendars-table-row-template"); + + for (let calendar of cal.manager.getCalendars()) { + let table = tableTmpl.content.cloneNode(true).querySelector("table"); + table.firstElementChild.textContent = calendar.name; + + let tbody = table.querySelector("tbody"); + for (let [prop, transform, isPrivate] of gCalendarProperties) { + let tr = rowTmpl.content.cloneNode(true).querySelector("tr"); + let l10nKey = `calendars-table-${prop + .toLowerCase() + .replaceAll(".", "-")}`; + + tr.cells[0].setAttribute("data-l10n-id", l10nKey); + tr.cells[1].textContent = transform(calendar.getProperty(prop)); + if (isPrivate) { + tr.cells[1].setAttribute("class", CLASS_DATA_PRIVATE); + } + tbody.appendChild(tr); + } + container.appendChild(table); + } +} diff --git a/comm/mail/components/about-support/content/chat.js b/comm/mail/components/about-support/content/chat.js new file mode 100644 index 0000000000..50c34b9ba0 --- /dev/null +++ b/comm/mail/components/about-support/content/chat.js @@ -0,0 +1,73 @@ +/* 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/. */ + +var { IMServices } = ChromeUtils.importESModule( + "resource:///modules/IMServices.sys.mjs" +); + +/** + * Populates the "Chat" section of the troubleshooting information page with + * the chat accounts. + */ +function populateChatSection() { + let table = document.getElementById("chat-table"); + let rowTmpl = document.getElementById("chat-table-row-template"); + let dateTimeFormatter = new Services.intl.DateTimeFormat(undefined, { + dateStyle: "short", + timeStyle: "long", + }); + let formatDebugMessage = dbgMsg => { + let m = dbgMsg.message; + let time = new Date(m.timeStamp); + time = dateTimeFormatter.format(time); + let level = dbgMsg.logLevel; + if (!level) { + return "(" + m.errorMessage + ")"; + } + if (level == dbgMsg.LEVEL_ERROR) { + level = "ERROR"; + } else if (level == dbgMsg.LEVEL_WARNING) { + level = "WARN."; + } else if (level == dbgMsg.LEVEL_LOG) { + level = "LOG "; + } else { + level = "DEBUG"; + } + return ( + "[" + + time + + "] " + + level + + " (@ " + + m.sourceLine + + " " + + m.sourceName + + ":" + + m.lineNumber + + ")\n" + + m.errorMessage + ); + }; + + let chatAccounts = IMServices.accounts.getAccounts(); + if (!chatAccounts.length) { + return; + } + table.querySelector("tbody").append( + ...chatAccounts.map(account => { + const row = rowTmpl.content.cloneNode(true).querySelector("tr"); + row.cells[0].textContent = account.id; + row.cells[1].textContent = account.protocol.id; + row.cells[2].textContent = account.name; + row.cells[3].addEventListener("click", () => { + const text = account + .getDebugMessages() + .map(formatDebugMessage) + .join("\n"); + navigator.clipboard.writeText(text); + }); + return row; + }) + ); +} diff --git a/comm/mail/components/about-support/content/export.js b/comm/mail/components/about-support/content/export.js new file mode 100644 index 0000000000..46eb0c6497 --- /dev/null +++ b/comm/mail/components/about-support/content/export.js @@ -0,0 +1,288 @@ +/* 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/. */ + +/* globals CLASS_DATA_PRIVATE, CLASS_DATA_PUBLIC, CLASS_DATA_UIONLY, createElement, +createParentElement, getAccountsText, getLoadContext, MailServices, Services */ + +"use strict"; + +var { AppConstants } = ChromeUtils.importESModule( + "resource://gre/modules/AppConstants.sys.mjs" +); + +/** + * Create warning text to add to any private data. + * + * @returns A HTML paragraph node containing the warning. + */ +function createWarning() { + let bundle = Services.strings.createBundle( + "chrome://messenger/locale/aboutSupportMail.properties" + ); + return createParentElement("p", [ + createElement("strong", bundle.GetStringFromName("warningLabel")), + // Add some whitespace between the label and the text + document.createTextNode(" "), + document.createTextNode(bundle.GetStringFromName("warningText")), + ]); +} + +function getClipboardTransferable() { + // Get the HTML and text representations for the important part of the page. + let hidePrivateData = !document.getElementById("check-show-private-data") + .checked; + let contentsDiv = createCleanedUpContents(hidePrivateData); + let dataHtml = contentsDiv.innerHTML; + let dataText = createTextForElement(contentsDiv, hidePrivateData); + + // 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 + ); + transferable.init(getLoadContext()); + + // Add the HTML flavor. + transferable.addDataFlavor("text/html"); + ssHtml.data = dataHtml; + transferable.setTransferData("text/html", ssHtml); + + // Add the plain text flavor. + transferable.addDataFlavor("text/plain"); + ssText.data = dataText; + transferable.setTransferData("text/plain", ssText); + + return transferable; +} + +// This function intentionally has the same name as the one in aboutSupport.js +// so that the one here is called. +function copyContentsToClipboard() { + let transferable = getClipboardTransferable(); + // Store the data into the clipboard. + Services.clipboard.setData( + transferable, + null, + Services.clipboard.kGlobalClipboard + ); +} + +function sendViaEmail() { + // Get the HTML representation for the important part of the page. + let hidePrivateData = !document.getElementById("check-show-private-data") + .checked; + let contentsDiv = createCleanedUpContents(hidePrivateData); + let dataHtml = contentsDiv.innerHTML; + // The editor considers whitespace to be significant, so replace all + // whitespace with a single space. + dataHtml = dataHtml.replace(/\s+/g, " "); + + // Set up parameters and fields to use for the compose window. + let params = Cc[ + "@mozilla.org/messengercompose/composeparams;1" + ].createInstance(Ci.nsIMsgComposeParams); + params.type = Ci.nsIMsgCompType.New; + params.format = Ci.nsIMsgCompFormat.HTML; + + let fields = Cc[ + "@mozilla.org/messengercompose/composefields;1" + ].createInstance(Ci.nsIMsgCompFields); + fields.forcePlainText = false; + fields.body = dataHtml; + // In general we can have non-ASCII characters, and compose's charset + // detection doesn't seem to work when the HTML part is pure ASCII but the + // text isn't. So take the easy way out and force UTF-8. + fields.bodyIsAsciiOnly = false; + params.composeFields = fields; + + // Our params are set up. Now open a compose window. + MailServices.compose.OpenComposeWindowWithParams(null, params); +} + +function createCleanedUpContents(aHidePrivateData) { + // Get the important part of the page. + let contentsDiv = document.getElementById("contents"); + // Deep-clone the entire div. + let clonedDiv = contentsDiv.cloneNode(true); + // Go in and replace text with the text we actually want to copy. + // (this mutates the cloned node) + cleanUpText(clonedDiv, aHidePrivateData); + // Insert a warning if we need to + if (!aHidePrivateData) { + clonedDiv.insertBefore(createWarning(), clonedDiv.firstChild); + } + return clonedDiv; +} + +function cleanUpText(aElem, aHidePrivateData) { + let node = aElem.firstChild; + let copyData = aElem.dataset.copyData; + delete aElem.dataset.copyData; + while (node) { + let classList = "classList" in node && node.classList; + // Delete uionly and no-copy nodes. + if ( + classList && + (classList.contains(CLASS_DATA_UIONLY) || classList.contains("no-copy")) + ) { + // Advance to the next node before removing the current node, since + // node.nextElementSibling is null after remove() + let nextNode = node.nextElementSibling; + node.remove(); + node = nextNode; + continue; + } else if ( + aHidePrivateData && + classList && + classList.contains(CLASS_DATA_PRIVATE) + ) { + // Replace private data with a blank string. + node.textContent = ""; + } else if ( + !aHidePrivateData && + classList && + classList.contains(CLASS_DATA_PUBLIC) + ) { + // Replace public data with a blank string. + node.textContent = ""; + } else if (copyData != null) { + // Replace localized text with non-localized text. + node.textContent = copyData; + copyData = null; + } + + if (node.nodeType == Node.ELEMENT_NODE) { + cleanUpText(node, aHidePrivateData); + } + + // Advance! + node = node.nextSibling; + } +} + +// Return the plain text representation of an element. Do a little bit +// of pretty-printing to make it human-readable. +function createTextForElement(elem, aHidePrivateData) { + // Generate the initial text. + let textFragmentAccumulator = []; + generateTextForElement(elem, aHidePrivateData, "", textFragmentAccumulator); + let text = textFragmentAccumulator.join(""); + + // Trim extraneous whitespace before newlines, then squash extraneous + // blank lines. + text = text.replace(/[ \t]+\n/g, "\n"); + text = text.replace(/\n{3,}/g, "\n\n"); + + // Actual CR/LF pairs are needed for some Windows text editors. + if ("@mozilla.org/windows-registry-key;1" in Cc) { + text = text.replace(/\n/g, "\r\n"); + } + + return text; +} + +/** + * Elements to replace entirely with custom text. Keys are element ids, values + * are functions that return the text. The functions themselves are defined in + * the files for their respective sections. + */ +var gElementsToReplace = { + "accounts-table": getAccountsText, +}; + +function generateTextForElement( + elem, + aHidePrivateData, + indent, + textFragmentAccumulator +) { + // Add a little extra spacing around most elements. + if (!["td", "th", "span", "a"].includes(elem.tagName)) { + textFragmentAccumulator.push("\n"); + } + + // If this element is one of our elements to replace with text, do it. + if (elem.id in gElementsToReplace) { + let replaceFn = gElementsToReplace[elem.id]; + textFragmentAccumulator.push(replaceFn(aHidePrivateData, indent + " ")); + return; + } + + if (AppConstants.MOZ_CRASHREPORTER) { + if (elem.id == "crashes-table") { + textFragmentAccumulator.push(getCrashesText(indent)); + return; + } + } + + let childCount = elem.childElementCount; + + // We're not going to spread a two-column <tr> across multiple lines, so + // handle that separately. + if (elem.tagName == "tr" && childCount == 2) { + textFragmentAccumulator.push(indent); + textFragmentAccumulator.push( + elem.children[0].textContent.trim() + + ": " + + elem.children[1].textContent.trim() + ); + return; + } + + // Generate the text representation for each child node. + let node = elem.firstChild; + while (node) { + if (node.nodeType == Node.TEXT_NODE) { + // Text belonging to this element uses its indentation level. + generateTextForTextNode(node, indent, textFragmentAccumulator); + } else if (node.nodeType == Node.ELEMENT_NODE) { + // Recurse on the child element with an extra level of indentation (but + // only if there's more than one child). + generateTextForElement( + node, + aHidePrivateData, + indent + (childCount > 1 ? " " : ""), + textFragmentAccumulator + ); + } + // Advance! + node = node.nextSibling; + } +} + +function generateTextForTextNode(node, indent, textFragmentAccumulator) { + // If the text node is the first of a run of text nodes, then start + // a new line and add the initial indentation. + let prevNode = node.previousSibling; + if (!prevNode || prevNode.nodeType == Node.TEXT_NODE) { + textFragmentAccumulator.push("\n" + indent); + } + + // Trim the text node's text content and add proper indentation after + // any internal line breaks. + let text = node.textContent.trim().replace(/\n/g, "\n" + indent); + textFragmentAccumulator.push(text); +} + +/** + * Returns a plaintext representation of crashes data. + */ + +function getCrashesText(aIndent) { + let crashesData = ""; + let recentCrashesSubmitted = document.querySelectorAll("#crashes-tbody > tr"); + for (let i = 0; i < recentCrashesSubmitted.length; i++) { + let tds = recentCrashesSubmitted.item(i).querySelectorAll("td"); + crashesData += + aIndent.repeat(2) + + tds.item(0).firstElementChild.href + + " (" + + tds.item(1).textContent + + ")\n"; + } + return crashesData; +} diff --git a/comm/mail/components/about-support/content/libs.js b/comm/mail/components/about-support/content/libs.js new file mode 100644 index 0000000000..1c431596ae --- /dev/null +++ b/comm/mail/components/about-support/content/libs.js @@ -0,0 +1,24 @@ +/* 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/. */ + +var { XPCOMUtils } = ChromeUtils.importESModule( + "resource://gre/modules/XPCOMUtils.sys.mjs" +); + +XPCOMUtils.defineLazyModuleGetters(this, { + BondOpenPGP: "chrome://openpgp/content/BondOpenPGP.jsm", +}); + +/** + * Populates the "Mail Libraries" section of the troubleshooting information page. + */ +function populateLibrarySection() { + let { min_version, loaded_version, status, path } = + BondOpenPGP.getRNPLibStatus(); + + document.getElementById("rnp-expected-version").textContent = min_version; + document.getElementById("rnp-loaded-version").textContent = loaded_version; + document.getElementById("rnp-path").textContent = path; + document.l10n.setAttributes(document.getElementById("rnp-status"), status); +} |