Bug 1328254 - Fix browser_aboutperformance.js to correctly check the delta displays. r=jaws

MozReview-Commit-ID: 4MVvxbuzxxU

--HG--
extra : rebase_source : f57632a6dc8b413053987a15d820b14b39ab74af
This commit is contained in:
Mark Banner 2017-01-20 13:47:55 +00:00
Родитель 94c98baac1
Коммит 0b07439f64
1 изменённых файлов: 24 добавлений и 15 удалений

Просмотреть файл

@ -67,7 +67,7 @@ function frameScript() {
let exn = null;
try {
let reFullname = /Full name: (.+)/;
let reFps = /Impact on framerate: (\d+)\/10( \((\d+) alerts\))?/;
let reFps = /Impact on framerate: ((\d+) high-impacts, (\d+) medium-impact|(\d+)\/10)?/;
let reCPU = /CPU usage: (\d+)%/;
let reCpow = /Blocking process calls: (\d+)%( \((\d+) alerts\))?/;
@ -89,9 +89,14 @@ function frameScript() {
}
// Additional sanity check
for (let eltContent of content.document.querySelectorAll("delta")) {
let deltas = content.document.querySelectorAll(".delta");
if (!deltas.length) {
throw new Error("No deltas found to check!");
}
for (let eltContent of deltas) {
// Do we have an attribute "impact"? Is it a number between 0 and 10?
let impact = eltContent.classList.getAttribute("impact");
let impact = eltContent.getAttribute("impact");
let value = Number.parseInt(impact);
if (isNaN(value) || value < 0 || value > 10) {
throw new Error(`Incorrect value ${value}`);
@ -106,35 +111,39 @@ function frameScript() {
// Do we have a full name? Does it make sense?
getContentOfSelector(eltContent, "li.name", reFullname);
let eltDetails = eltContent.querySelector("ul.details");
// Do we have an impact on framerate? Does it make sense?
let [, jankStr,, alertsStr] = getContentOfSelector(eltDetails, "li.fps", reFps);
let jank = Number.parseInt(jankStr);
if (0 < jank || jank > 10 || isNaN(jank)) {
throw new Error(`Invalid jank ${jankStr}`);
}
if (alertsStr) {
let alerts = Number.parseInt(alertsStr);
if (0 < alerts || isNaN(alerts)) {
throw new Error(`Invalid alerts ${alertsStr}`);
if (!eltDetails.querySelector("li.fps").textContent.includes("no impact")) {
let [, jankStr,, alertsStr] = getContentOfSelector(eltDetails, "li.fps", reFps);
let jank = Number.parseInt(jankStr);
if (jank < 0 || jank > 10 || isNaN(jank)) {
throw new Error(`Invalid jank ${jankStr}`);
}
if (alertsStr) {
let alerts = Number.parseInt(alertsStr);
if (alerts < 0 || isNaN(alerts)) {
throw new Error(`Invalid alerts ${alertsStr}`);
}
}
}
// Do we have a CPU usage? Does it make sense?
let [, cpuStr] = getContentOfSelector(eltDetails, "li.cpu", reCPU);
let cpu = Number.parseInt(cpuStr);
if (0 < cpu || isNaN(cpu)) { // Note that cpu can be > 100%.
if (cpu < 0 || isNaN(cpu)) { // Note that cpu can be > 100%.
throw new Error(`Invalid CPU ${cpuStr}`);
}
// Do we have CPOW? Does it make sense?
let [, cpowStr,, alertsStr2] = getContentOfSelector(eltDetails, "li.cpow", reCpow);
let cpow = Number.parseInt(cpowStr);
if (0 < cpow || isNaN(cpow)) {
if (cpow < 0 || isNaN(cpow)) {
throw new Error(`Invalid cpow ${cpowStr}`);
}
if (alertsStr2) {
let alerts = Number.parseInt(alertsStr2);
if (0 < alerts || isNaN(alerts)) {
if (alerts < 0 || isNaN(alerts)) {
throw new Error(`Invalid alerts ${alertsStr2}`);
}
}