Bug 1955086 - better-handle various broken site report information-gathering exception cases, to make automated tests more reliable; r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D242263
This commit is contained in:
@@ -575,6 +575,7 @@ export var ReportBrokenSite = new (class ReportBrokenSite {
|
||||
selectedBrowser
|
||||
).catch(err => {
|
||||
console.error("Report Broken Site: unexpected error", err);
|
||||
state.currentTabWebcompatDetailsPromise = undefined;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -836,6 +836,18 @@ async function tabTo(match, win = window) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function filterFrameworkDetectorFails(ping, expected) {
|
||||
// the framework detector's frame-script may fail to run in low memory or other
|
||||
// weird corner-cases, so we ignore the results in that case if they don't match.
|
||||
if (!areObjectsEqual(ping.frameworks, expected.frameworks)) {
|
||||
const { fastclick, mobify, marfeel } = ping.frameworks;
|
||||
if (!fastclick && !mobify && !marfeel) {
|
||||
console.info("Ignoring failure to get framework data");
|
||||
expected.frameworks = ping.frameworks;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function setupStrictETP() {
|
||||
await UrlClassifierTestUtils.addTestTrackers();
|
||||
registerCleanupFunction(() => {
|
||||
|
||||
@@ -317,6 +317,8 @@ async function testSend(tab, menu, expectedOverrides = {}) {
|
||||
"Got a default UA string"
|
||||
);
|
||||
|
||||
filterFrameworkDetectorFails(ping.tabInfo, expected.tabInfo);
|
||||
|
||||
ok(areObjectsEqual(ping, expected), "ping matches expectations");
|
||||
resolve();
|
||||
});
|
||||
|
||||
@@ -261,6 +261,8 @@ async function testSendMoreInfo(tab, menu, expectedOverrides = {}) {
|
||||
ok(isScreenshotValid, "Got a valid screenshot");
|
||||
}
|
||||
|
||||
filterFrameworkDetectorFails(message.details, expected.details);
|
||||
|
||||
ok(areObjectsEqual(message, expected), "sent info matches expectations");
|
||||
|
||||
// re-opening the panel, the url and description should be reset
|
||||
|
||||
@@ -187,20 +187,32 @@ const FrameworkDetector = {
|
||||
},
|
||||
|
||||
checkWindow(window) {
|
||||
const script = `
|
||||
(function() {
|
||||
function ${FrameworkDetector.hasFastClickPageScript};
|
||||
function ${FrameworkDetector.hasMobifyPageScript};
|
||||
function ${FrameworkDetector.hasMarfeelPageScript};
|
||||
const win = window.wrappedJSObject || window;
|
||||
return {
|
||||
fastclick: hasFastClickPageScript(win),
|
||||
mobify: hasMobifyPageScript(win),
|
||||
marfeel: hasMarfeelPageScript(win),
|
||||
}
|
||||
})();
|
||||
`;
|
||||
return RunScriptInFrame(window, script);
|
||||
try {
|
||||
const script = `
|
||||
(function() {
|
||||
function ${FrameworkDetector.hasFastClickPageScript};
|
||||
function ${FrameworkDetector.hasMobifyPageScript};
|
||||
function ${FrameworkDetector.hasMarfeelPageScript};
|
||||
const win = window.wrappedJSObject || window;
|
||||
return {
|
||||
fastclick: hasFastClickPageScript(win),
|
||||
mobify: hasMobifyPageScript(win),
|
||||
marfeel: hasMarfeelPageScript(win),
|
||||
}
|
||||
})();
|
||||
`;
|
||||
return RunScriptInFrame(window, script);
|
||||
} catch (e) {
|
||||
console.error(
|
||||
"GetWebcompatInfoFromParentProcess: Error detecting JS frameworks",
|
||||
e
|
||||
);
|
||||
return {
|
||||
fastclick: false,
|
||||
mobify: false,
|
||||
marfeel: false,
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -209,31 +221,40 @@ export class ReportBrokenSiteChild extends JSWindowActorChild {
|
||||
return Promise.all([
|
||||
this.#getConsoleLogs(docShell),
|
||||
this.sendQuery("GetWebcompatInfoFromParentProcess", SCREENSHOT_FORMAT),
|
||||
]).then(([consoleLog, infoFromParent]) => {
|
||||
const { antitracking, browser, screenshot } = infoFromParent;
|
||||
])
|
||||
.then(([consoleLog, infoFromParent]) => {
|
||||
const { antitracking, browser, devicePixelRatio, screenshot } =
|
||||
infoFromParent;
|
||||
|
||||
const win = docShell.domWindow;
|
||||
const win = docShell.domWindow;
|
||||
|
||||
const devicePixelRatio = win.devicePixelRatio;
|
||||
const frameworks = FrameworkDetector.checkWindow(win);
|
||||
const { languages, userAgent } = win.navigator;
|
||||
const frameworks = FrameworkDetector.checkWindow(win);
|
||||
const { languages, userAgent } = win.navigator;
|
||||
|
||||
if (browser.platform.name !== "linux") {
|
||||
delete browser.prefs["layers.acceleration.force-enabled"];
|
||||
}
|
||||
if (browser.platform.name !== "linux") {
|
||||
delete browser.prefs["layers.acceleration.force-enabled"];
|
||||
}
|
||||
|
||||
return {
|
||||
antitracking,
|
||||
browser,
|
||||
consoleLog,
|
||||
devicePixelRatio,
|
||||
frameworks,
|
||||
languages,
|
||||
screenshot,
|
||||
url: win.location.href,
|
||||
userAgent,
|
||||
};
|
||||
});
|
||||
return {
|
||||
antitracking,
|
||||
browser,
|
||||
consoleLog,
|
||||
devicePixelRatio,
|
||||
frameworks,
|
||||
languages,
|
||||
screenshot,
|
||||
url: win.location.href,
|
||||
userAgent,
|
||||
};
|
||||
})
|
||||
.catch(err => {
|
||||
// Log more output if the actor wasn't just being destroyed.
|
||||
if (err.name !== "AbortError") {
|
||||
// eslint-disable-next-line no-console
|
||||
console.trace("#getWebCompatInfo error", err);
|
||||
}
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
|
||||
async #getConsoleLogs() {
|
||||
|
||||
@@ -347,9 +347,10 @@ export class ReportBrokenSiteParent extends JSWindowActorParent {
|
||||
async receiveMessage(msg) {
|
||||
switch (msg.name) {
|
||||
case "GetWebcompatInfoFromParentProcess": {
|
||||
const { browsingContext } = msg.target;
|
||||
const { format, quality } = msg.data;
|
||||
const screenshot = await this.#getScreenshot(
|
||||
msg.target.browsingContext,
|
||||
browsingContext,
|
||||
format,
|
||||
quality
|
||||
).catch(e => {
|
||||
@@ -357,9 +358,14 @@ export class ReportBrokenSiteParent extends JSWindowActorParent {
|
||||
return Promise.resolve(undefined);
|
||||
});
|
||||
|
||||
const zoom = browsingContext.fullZoom;
|
||||
const scale = browsingContext.topChromeWindow?.devicePixelRatio || 1;
|
||||
const devicePixelRatio = scale * zoom;
|
||||
|
||||
return {
|
||||
antitracking: this.#getAntitrackingInfo(msg.target.browsingContext),
|
||||
browser: await this.#getBrowserInfo(),
|
||||
devicePixelRatio,
|
||||
screenshot,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user