bring back frontend sanity check w/ App.checkBrowserFeatures()

This commit is contained in:
Andrew Dolgov 2018-12-11 12:30:48 +03:00
parent f3c04fc5d8
commit 2cbc2f5261
2 changed files with 27 additions and 5 deletions

View File

@ -266,15 +266,18 @@ function fatalError(code, msg, ext_info) {
msg = ERRORS[code]; msg = ERRORS[code];
} }
let content = "<div><b>Error code:</b> " + code + "</div>" + let content = `<div><b>Error code:</b> ${code} </div>
"<p>" + msg + "</p>"; <p>${msg}</p>`;
if (ext_info) { if (ext_info) {
content = content + "<div><b>Additional information:</b></div>" + content = content + `<div><b>Additional information:</b></div>
"<textarea style='width: 100%' readonly=\"1\">" + <textarea style='width: 100%' readonly="1">${ext_info}</textarea>`;
ext_info + "</textarea>";
} }
content += `<div style='text-align : center'>
<button dojoType="dijit.form.Button" onclick="window.location.reload()">
${__('Try again')}</button></div>`;
const dialog = new dijit.Dialog({ const dialog = new dijit.Dialog({
title: "Fatal error", title: "Fatal error",
style: "width: 600px", style: "width: 600px",

View File

@ -65,6 +65,9 @@ require(["dojo/_base/kernel",
constructor: function () { constructor: function () {
parser.parse(); parser.parse();
if (!this.checkBrowserFeatures())
return;
this.setLoadingProgress(30); this.setLoadingProgress(30);
this.initHotkeyActions(); this.initHotkeyActions();
@ -89,6 +92,22 @@ require(["dojo/_base/kernel",
} }
}); });
}, },
checkBrowserFeatures: function() {
let errorMsg = "";
['requestIdleCallback', 'MutationObserver'].each(function(wf) {
if (! (wf in window)) {
errorMsg = `Browser feature check failed: <code>window.${wf}</code> not found.`;
throw $break;
}
});
if (errorMsg) {
fatalError(4, errorMsg, navigator.userAgent);
}
return errorMsg == "";
},
initSecondStage: function () { initSecondStage: function () {
this.enableCsrfSupport(); this.enableCsrfSupport();