From 40a355a42d4a9444dc753c04c6608dade2f06a23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:27 +0200 Subject: Adding upstream version 125.0.1. Signed-off-by: Daniel Baumann --- .../reportbrokensite/ReportBrokenSiteChild.sys.mjs | 118 ++------ .../ReportBrokenSiteParent.sys.mjs | 310 ++++++++++----------- 2 files changed, 175 insertions(+), 253 deletions(-) (limited to 'toolkit/components/reportbrokensite') diff --git a/toolkit/components/reportbrokensite/ReportBrokenSiteChild.sys.mjs b/toolkit/components/reportbrokensite/ReportBrokenSiteChild.sys.mjs index 8220f5b4b6..291b1defc8 100644 --- a/toolkit/components/reportbrokensite/ReportBrokenSiteChild.sys.mjs +++ b/toolkit/components/reportbrokensite/ReportBrokenSiteChild.sys.mjs @@ -2,8 +2,6 @@ * 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/. */ -import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs"; - const SCREENSHOT_FORMAT = { format: "jpeg", quality: 75 }; function RunScriptInFrame(win, script) { @@ -206,95 +204,21 @@ const FrameworkDetector = { }, }; -function getSysinfoProperty(propertyName, defaultValue) { - try { - return Services.sysinfo.getProperty(propertyName); - } catch (e) {} - return defaultValue; -} - -const BrowserInfo = { - getAppInfo() { - const { userAgent } = Cc[ - "@mozilla.org/network/protocol;1?name=http" - ].getService(Ci.nsIHttpProtocolHandler); - return { - applicationName: Services.appinfo.name, - buildId: Services.appinfo.appBuildID, - defaultUserAgent: userAgent, - updateChannel: AppConstants.MOZ_UPDATE_CHANNEL, - version: AppConstants.MOZ_APP_VERSION_DISPLAY, - }; - }, - - getPrefs() { - const prefs = {}; - for (const [name, dflt] of Object.entries({ - "layers.acceleration.force-enabled": undefined, - "gfx.webrender.software": undefined, - "browser.opaqueResponseBlocking": undefined, - "extensions.InstallTrigger.enabled": undefined, - "privacy.resistFingerprinting": undefined, - "privacy.globalprivacycontrol.enabled": undefined, - })) { - prefs[name] = Services.prefs.getBoolPref(name, dflt); - } - const cookieBehavior = "network.cookie.cookieBehavior"; - prefs[cookieBehavior] = Services.prefs.getIntPref(cookieBehavior); - return prefs; - }, - - getPlatformInfo() { - let memoryMB = getSysinfoProperty("memsize", null); - if (memoryMB) { - memoryMB = Math.round(memoryMB / 1024 / 1024); - } - - const info = { - fissionEnabled: Services.appinfo.fissionAutostart, - memoryMB, - osArchitecture: getSysinfoProperty("arch", null), - osName: getSysinfoProperty("name", null), - osVersion: getSysinfoProperty("version", null), - os: AppConstants.platform, - }; - if (AppConstants.platform === "android") { - info.device = getSysinfoProperty("device", null); - info.isTablet = getSysinfoProperty("tablet", false); - } - return info; - }, - - getAllData() { - return { - app: BrowserInfo.getAppInfo(), - prefs: BrowserInfo.getPrefs(), - platform: BrowserInfo.getPlatformInfo(), - }; - }, -}; - export class ReportBrokenSiteChild extends JSWindowActorChild { #getWebCompatInfo(docShell) { return Promise.all([ this.#getConsoleLogs(docShell), - this.sendQuery( - "GetWebcompatInfoOnlyAvailableInParentProcess", - SCREENSHOT_FORMAT - ), + this.sendQuery("GetWebcompatInfoFromParentProcess", SCREENSHOT_FORMAT), ]).then(([consoleLog, infoFromParent]) => { - const { antitracking, graphics, locales, screenshot, security } = - infoFromParent; - - const browser = BrowserInfo.getAllData(); - browser.graphics = graphics; - browser.locales = locales; - browser.security = security; + const { antitracking, browser, screenshot } = infoFromParent; const win = docShell.domWindow; + + const devicePixelRatio = win.devicePixelRatio; const frameworks = FrameworkDetector.checkWindow(win); + const { languages, userAgent } = win.navigator; - if (browser.platform.os !== "linux") { + if (browser.platform.name !== "linux") { delete browser.prefs["layers.acceleration.force-enabled"]; } @@ -302,12 +226,12 @@ export class ReportBrokenSiteChild extends JSWindowActorChild { antitracking, browser, consoleLog, - devicePixelRatio: win.devicePixelRatio, + devicePixelRatio, frameworks, - languages: win.navigator.languages, + languages, screenshot, url: win.location.href, - userAgent: win.navigator.userAgent, + userAgent, }; }); } @@ -369,13 +293,19 @@ export class ReportBrokenSiteChild extends JSWindowActorChild { message.blockList = blockList; - const { app, graphics, prefs, platform, security } = browser; + const { app, graphics, locales, prefs, platform, security } = browser; - const { applicationName, version, updateChannel, defaultUserAgent } = app; + const { + applicationName, + buildId, + defaultUserAgent, + updateChannel, + version, + } = app; const { fissionEnabled, - memoryMb, + memoryMB, osArchitecture, osName, osVersion, @@ -386,6 +316,7 @@ export class ReportBrokenSiteChild extends JSWindowActorChild { const additionalData = { applicationName, blockList, + buildId, devicePixelRatio, finalUserAgent: userAgent, fissionEnabled, @@ -395,16 +326,15 @@ export class ReportBrokenSiteChild extends JSWindowActorChild { hasTrackingContentBlocked, isPB: isPrivateBrowsing, languages, - memoryMb, + locales, + memoryMB, osArchitecture, osName, osVersion, prefs, - updateChannel, - userAgent: defaultUserAgent, version, }; - if (security !== undefined) { + if (security !== undefined && Object.keys(security).length) { additionalData.sec = security; } if (device !== undefined) { @@ -424,9 +354,9 @@ export class ReportBrokenSiteChild extends JSWindowActorChild { const details = Object.assign(message.details, specialPrefs, { additionalData, - buildId: browser.buildId, blockList, - channel: browser.updateChannel, + channel: updateChannel, + defaultUserAgent, hasTouchScreen: browser.graphics.hasTouchScreen, }); diff --git a/toolkit/components/reportbrokensite/ReportBrokenSiteParent.sys.mjs b/toolkit/components/reportbrokensite/ReportBrokenSiteParent.sys.mjs index d6363a4ee1..c9b38b233f 100644 --- a/toolkit/components/reportbrokensite/ReportBrokenSiteParent.sys.mjs +++ b/toolkit/components/reportbrokensite/ReportBrokenSiteParent.sys.mjs @@ -3,118 +3,9 @@ * 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/. */ -import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs"; - -function getSysinfoProperty(propertyName, defaultValue) { - try { - return Services.sysinfo.getProperty(propertyName); - } catch (e) {} - return defaultValue; -} - -function getSecurityInfo() { - const keys = [ - ["registeredAntiVirus", "antivirus"], - ["registeredAntiSpyware", "antispyware"], - ["registeredFirewall", "firewall"], - ]; - - let result = {}; - - for (let [inKey, outKey] of keys) { - const str = getSysinfoProperty(inKey, null); - result[outKey] = !str ? null : str.split(";"); - } - - // Right now, security data is only available for Windows builds, and - // we might as well not return anything at all if no data is available. - if (!Object.values(result).filter(e => e).length) { - return undefined; - } - - return result; -} - -class DriverInfo { - constructor(gl, ext) { - try { - this.extensions = ext.getParameter(ext.EXTENSIONS); - } catch (e) {} - - try { - this.renderer = ext.getParameter(gl.RENDERER); - } catch (e) {} - - try { - this.vendor = ext.getParameter(gl.VENDOR); - } catch (e) {} - - try { - this.version = ext.getParameter(gl.VERSION); - } catch (e) {} - - try { - this.wsiInfo = ext.getParameter(ext.WSI_INFO); - } catch (e) {} - } - - equals(info2) { - return this.renderer == info2.renderer && this.version == info2.version; - } - - static getByType(driver) { - const doc = new DOMParser().parseFromString("", "text/html"); - const canvas = doc.createElement("canvas"); - canvas.width = 1; - canvas.height = 1; - let error; - canvas.addEventListener("webglcontextcreationerror", function (e) { - error = true; - }); - let gl = null; - try { - gl = canvas.getContext(driver); - } catch (e) { - error = true; - } - if (error || !gl?.getExtension) { - return undefined; - } - - let ext = null; - try { - ext = gl.getExtension("MOZ_debug"); - } catch (e) {} - if (!ext) { - return undefined; - } - - const data = new DriverInfo(gl, ext); - - try { - gl.getExtension("WEBGL_lose_context").loseContext(); - } catch (e) {} - - return data; - } - - static getAll() { - const drivers = []; - - function tryDriver(type) { - const driver = DriverInfo.getByType(type); - if (driver) { - drivers.push(driver); - } - } - - tryDriver("webgl"); - tryDriver("webgl2"); - tryDriver("webgpu"); +import { Troubleshoot } from "resource://gre/modules/Troubleshoot.sys.mjs"; - return drivers; - } -} +import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs"; export class ReportBrokenSiteParent extends JSWindowActorParent { #getAntitrackingBlockList() { @@ -145,10 +36,10 @@ export class ReportBrokenSiteParent extends JSWindowActorParent { }; } - #getBasicGraphicsInfo(gfxInfo) { + #parseGfxInfo(info) { const get = name => { try { - return gfxInfo[name]; + return info[name]; } catch (e) {} return undefined; }; @@ -183,63 +74,165 @@ export class ReportBrokenSiteParent extends JSWindowActorParent { direct2DEnabled: get("direct2DEnabled"), directWriteEnabled: get("directWriteEnabled"), directWriteVersion: get("directWriteVersion"), - hasTouchScreen: gfxInfo.getInfo().ApzTouchInput == 1, - cleartypeParameters: get("clearTypeParameters"), + hasTouchScreen: info.ApzTouchInput == 1, + clearTypeParameters: get("clearTypeParameters"), targetFrameRate: get("targetFrameRate"), devices, }); } - #getGraphicsInfo() { - const gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo); + #parseCodecSupportInfo(codecSupportInfo) { + if (!codecSupportInfo) { + return undefined; + } - const data = this.#getBasicGraphicsInfo(gfxInfo); + const codecs = {}; + for (const item of codecSupportInfo.split("\n")) { + const [codec, ...types] = item.split(" "); + if (!codecs[codec]) { + codecs[codec] = { hardware: false, software: false }; + } + codecs[codec].software ||= types.includes("SW"); + codecs[codec].hardware ||= types.includes("HW"); + } + return codecs; + } - data.drivers = DriverInfo.getAll().map(({ renderer, vendor, version }) => { - return { renderer: `${vendor} -- ${renderer}`, version }; - }); + #parseFeatureLog(featureLog = {}) { + const { features } = featureLog; + if (!features) { + return undefined; + } - try { - const info = gfxInfo.CodecSupportInfo; - if (info) { - const codecs = {}; - for (const item of gfxInfo.CodecSupportInfo.split("\n")) { - const [codec, ...types] = item.split(" "); - if (!codecs[codec]) { - codecs[codec] = { software: false, hardware: false }; - } - if (types.includes("SW")) { - codecs[codec].software = true; - } - if (types.includes("HW")) { - codecs[codec].hardware = true; - } + const parsedFeatures = {}; + for (let { name, log, status } of features) { + for (const item of log.reverse()) { + if (!item.failureId || item.status != status) { + continue; } - data.codecSupport = codecs; + status = `${status} (${item.message || item.failureId})`; } - } catch (e) {} + parsedFeatures[name] = status; + } + return parsedFeatures; + } - try { - const { features } = gfxInfo.getFeatureLog(); - data.features = {}; - for (let { name, log, status } of features) { - for (const item of log.reverse()) { - if (!item.failureId || item.status != status) { - continue; - } - status = `${status} (${item.message || item.failureId})`; - } - data.features[name] = status; - } - } catch (e) {} + #getGraphicsInfo(troubleshoot) { + const { graphics, media } = troubleshoot; + const { featureLog } = graphics; + const data = this.#parseGfxInfo(graphics); + data.drivers = [ + { + renderer: graphics.webgl1Renderer, + version: graphics.webgl1Version, + }, + { + renderer: graphics.webgl2Renderer, + version: graphics.webgl2Version, + }, + ].filter(({ version }) => version && version != "-"); + + data.codecSupport = this.#parseCodecSupportInfo(media.codecSupportInfo); + data.features = this.#parseFeatureLog(featureLog); + const gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo); + data.monitors = gfxInfo.getMonitors(); + + return data; + } + + #getAppInfo(troubleshootingInfo) { + const { application } = troubleshootingInfo; + return { + applicationName: application.name, + buildId: application.buildID, + defaultUserAgent: application.userAgent, + updateChannel: application.updateChannel, + version: application.version, + }; + } + + #getSysinfoProperty(propertyName, defaultValue) { try { - if (AppConstants.platform !== "android") { - data.monitors = gfxInfo.getMonitors(); - } + return Services.sysinfo.getProperty(propertyName); } catch (e) {} + return defaultValue; + } - return data; + #getPrefs() { + const prefs = {}; + for (const name of [ + "layers.acceleration.force-enabled", + "gfx.webrender.software", + "browser.opaqueResponseBlocking", + "extensions.InstallTrigger.enabled", + "privacy.resistFingerprinting", + "privacy.globalprivacycontrol.enabled", + ]) { + prefs[name] = Services.prefs.getBoolPref(name, undefined); + } + const cookieBehavior = "network.cookie.cookieBehavior"; + prefs[cookieBehavior] = Services.prefs.getIntPref(cookieBehavior, -1); + return prefs; + } + + async #getPlatformInfo(troubleshootingInfo) { + const { application } = troubleshootingInfo; + const { memorySizeBytes, fissionAutoStart } = application; + + let memoryMB = memorySizeBytes; + if (memoryMB) { + memoryMB = Math.round(memoryMB / 1024 / 1024); + } + + const info = { + fissionEnabled: fissionAutoStart, + memoryMB, + osArchitecture: this.#getSysinfoProperty("arch", null), + osName: this.#getSysinfoProperty("name", null), + osVersion: this.#getSysinfoProperty("version", null), + name: AppConstants.platform, + }; + if (info.os === "android") { + info.device = this.#getSysinfoProperty("device", null); + info.isTablet = this.#getSysinfoProperty("tablet", false); + } + if ( + info.osName == "Windows_NT" && + (await Services.sysinfo.processInfo).isWindowsSMode + ) { + info.osVersion += " S"; + } + return info; + } + + #getSecurityInfo(troubleshootingInfo) { + const result = {}; + for (const [k, v] of Object.entries(troubleshootingInfo.securitySoftware)) { + result[k.replace("registered", "").toLowerCase()] = v + ? v.split(";") + : null; + } + + // Right now, security data is only available for Windows builds, and + // we might as well not return anything at all if no data is available. + if (!Object.values(result).filter(e => e).length) { + return undefined; + } + + return result; + } + + async #getBrowserInfo() { + const troubleshootingInfo = await Troubleshoot.snapshot(); + return { + app: this.#getAppInfo(troubleshootingInfo), + graphics: this.#getGraphicsInfo(troubleshootingInfo), + locales: troubleshootingInfo.intl.localeService.available, + prefs: this.#getPrefs(), + platform: await this.#getPlatformInfo(troubleshootingInfo), + security: this.#getSecurityInfo(troubleshootingInfo), + }; } async #getScreenshot(browsingContext, format, quality) { @@ -268,7 +261,7 @@ export class ReportBrokenSiteParent extends JSWindowActorParent { async receiveMessage(msg) { switch (msg.name) { - case "GetWebcompatInfoOnlyAvailableInParentProcess": { + case "GetWebcompatInfoFromParentProcess": { const { format, quality } = msg.data; const screenshot = await this.#getScreenshot( msg.target.browsingContext, @@ -278,12 +271,11 @@ export class ReportBrokenSiteParent extends JSWindowActorParent { console.error("Report Broken Site: getting a screenshot failed", e); return Promise.resolve(undefined); }); + return { antitracking: this.#getAntitrackingInfo(msg.target.browsingContext), - graphics: this.#getGraphicsInfo(), - locales: Services.locale.availableLocales, + browser: await this.#getBrowserInfo(), screenshot, - security: getSecurityInfo(), }; } } -- cgit v1.2.3