gecko-dev/dom/reporting/tests/head.js
Arnaud Renevier 4ba9c81516 Bug 1607364 - CrashReporting API r=baku
Implement Crash Report for Reporting API.

The browser test will force a crash of the renderer and check that a report is
sent to the server. Because of this (intentional) crash, the verification test
fail. So we disable verification test for that test.

Differential Revision: https://phabricator.services.mozilla.com/D58053

--HG--
extra : moz-landing-system : lando
2020-01-28 18:06:47 +00:00

38 lines
887 B
JavaScript

"use strict";
/* exported storeReportingHeader */
async function storeReportingHeader(browser, reportingURL, extraParams = "") {
await SpecialPowers.spawn(
browser,
[{ url: reportingURL, extraParams }],
async obj => {
await content
.fetch(
obj.url +
"?task=header" +
(obj.extraParams.length ? "&" + obj.extraParams : "")
)
.then(r => r.text())
.then(text => {
is(text, "OK", "Report-to header sent");
});
}
);
}
/* exported checkReport */
function checkReport(reportingURL) {
return new Promise(resolve => {
let id = setInterval(_ => {
fetch(reportingURL + "?task=check")
.then(r => r.text())
.then(text => {
if (text) {
resolve(JSON.parse(text));
clearInterval(id);
}
});
}, 1000);
});
}