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
|
selectedBrowser
|
||||||
).catch(err => {
|
).catch(err => {
|
||||||
console.error("Report Broken Site: unexpected error", err);
|
console.error("Report Broken Site: unexpected error", err);
|
||||||
|
state.currentTabWebcompatDetailsPromise = undefined;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -836,6 +836,18 @@ async function tabTo(match, win = window) {
|
|||||||
return undefined;
|
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() {
|
async function setupStrictETP() {
|
||||||
await UrlClassifierTestUtils.addTestTrackers();
|
await UrlClassifierTestUtils.addTestTrackers();
|
||||||
registerCleanupFunction(() => {
|
registerCleanupFunction(() => {
|
||||||
|
|||||||
@@ -317,6 +317,8 @@ async function testSend(tab, menu, expectedOverrides = {}) {
|
|||||||
"Got a default UA string"
|
"Got a default UA string"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
filterFrameworkDetectorFails(ping.tabInfo, expected.tabInfo);
|
||||||
|
|
||||||
ok(areObjectsEqual(ping, expected), "ping matches expectations");
|
ok(areObjectsEqual(ping, expected), "ping matches expectations");
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -261,6 +261,8 @@ async function testSendMoreInfo(tab, menu, expectedOverrides = {}) {
|
|||||||
ok(isScreenshotValid, "Got a valid screenshot");
|
ok(isScreenshotValid, "Got a valid screenshot");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filterFrameworkDetectorFails(message.details, expected.details);
|
||||||
|
|
||||||
ok(areObjectsEqual(message, expected), "sent info matches expectations");
|
ok(areObjectsEqual(message, expected), "sent info matches expectations");
|
||||||
|
|
||||||
// re-opening the panel, the url and description should be reset
|
// re-opening the panel, the url and description should be reset
|
||||||
|
|||||||
@@ -187,20 +187,32 @@ const FrameworkDetector = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
checkWindow(window) {
|
checkWindow(window) {
|
||||||
const script = `
|
try {
|
||||||
(function() {
|
const script = `
|
||||||
function ${FrameworkDetector.hasFastClickPageScript};
|
(function() {
|
||||||
function ${FrameworkDetector.hasMobifyPageScript};
|
function ${FrameworkDetector.hasFastClickPageScript};
|
||||||
function ${FrameworkDetector.hasMarfeelPageScript};
|
function ${FrameworkDetector.hasMobifyPageScript};
|
||||||
const win = window.wrappedJSObject || window;
|
function ${FrameworkDetector.hasMarfeelPageScript};
|
||||||
return {
|
const win = window.wrappedJSObject || window;
|
||||||
fastclick: hasFastClickPageScript(win),
|
return {
|
||||||
mobify: hasMobifyPageScript(win),
|
fastclick: hasFastClickPageScript(win),
|
||||||
marfeel: hasMarfeelPageScript(win),
|
mobify: hasMobifyPageScript(win),
|
||||||
}
|
marfeel: hasMarfeelPageScript(win),
|
||||||
})();
|
}
|
||||||
`;
|
})();
|
||||||
return RunScriptInFrame(window, script);
|
`;
|
||||||
|
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([
|
return Promise.all([
|
||||||
this.#getConsoleLogs(docShell),
|
this.#getConsoleLogs(docShell),
|
||||||
this.sendQuery("GetWebcompatInfoFromParentProcess", SCREENSHOT_FORMAT),
|
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 frameworks = FrameworkDetector.checkWindow(win);
|
const { languages, userAgent } = win.navigator;
|
||||||
const { languages, userAgent } = win.navigator;
|
|
||||||
|
|
||||||
if (browser.platform.name !== "linux") {
|
if (browser.platform.name !== "linux") {
|
||||||
delete browser.prefs["layers.acceleration.force-enabled"];
|
delete browser.prefs["layers.acceleration.force-enabled"];
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
antitracking,
|
antitracking,
|
||||||
browser,
|
browser,
|
||||||
consoleLog,
|
consoleLog,
|
||||||
devicePixelRatio,
|
devicePixelRatio,
|
||||||
frameworks,
|
frameworks,
|
||||||
languages,
|
languages,
|
||||||
screenshot,
|
screenshot,
|
||||||
url: win.location.href,
|
url: win.location.href,
|
||||||
userAgent,
|
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() {
|
async #getConsoleLogs() {
|
||||||
|
|||||||
@@ -347,9 +347,10 @@ export class ReportBrokenSiteParent extends JSWindowActorParent {
|
|||||||
async receiveMessage(msg) {
|
async receiveMessage(msg) {
|
||||||
switch (msg.name) {
|
switch (msg.name) {
|
||||||
case "GetWebcompatInfoFromParentProcess": {
|
case "GetWebcompatInfoFromParentProcess": {
|
||||||
|
const { browsingContext } = msg.target;
|
||||||
const { format, quality } = msg.data;
|
const { format, quality } = msg.data;
|
||||||
const screenshot = await this.#getScreenshot(
|
const screenshot = await this.#getScreenshot(
|
||||||
msg.target.browsingContext,
|
browsingContext,
|
||||||
format,
|
format,
|
||||||
quality
|
quality
|
||||||
).catch(e => {
|
).catch(e => {
|
||||||
@@ -357,9 +358,14 @@ export class ReportBrokenSiteParent extends JSWindowActorParent {
|
|||||||
return Promise.resolve(undefined);
|
return Promise.resolve(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const zoom = browsingContext.fullZoom;
|
||||||
|
const scale = browsingContext.topChromeWindow?.devicePixelRatio || 1;
|
||||||
|
const devicePixelRatio = scale * zoom;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
antitracking: this.#getAntitrackingInfo(msg.target.browsingContext),
|
antitracking: this.#getAntitrackingInfo(msg.target.browsingContext),
|
||||||
browser: await this.#getBrowserInfo(),
|
browser: await this.#getBrowserInfo(),
|
||||||
|
devicePixelRatio,
|
||||||
screenshot,
|
screenshot,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user