Change them to Modernizr tests and add more rules

This commit is contained in:
Michael Telatynski 2020-02-05 14:05:46 +00:00
parent 032efafe2e
commit 7d49078f22
3 changed files with 26 additions and 21 deletions

View File

@ -11,6 +11,16 @@
"test/css/objectfit", "test/css/objectfit",
"test/storage/localstorage", "test/storage/localstorage",
"test/workers/webworkers", "test/workers/webworkers",
"test/indexeddb" "test/indexeddb",
"test/es6/array",
"test/es6/collections",
"test/es6/promises",
"test/serviceworker",
"test/svg",
"test/svg/asimg",
"test/svg/filters",
"test/css/animations",
"test/css/filters",
"test/network/fetch"
] ]
} }

View File

@ -53,12 +53,23 @@ import CallHandler from 'matrix-react-sdk/src/CallHandler';
let lastLocationHashSet = null; let lastLocationHashSet = null;
function checkBrowserFeatures(featureList) { function checkBrowserFeatures() {
if (!window.Modernizr) { if (!window.Modernizr) {
console.error("Cannot check features - Modernizr global is missing."); console.error("Cannot check features - Modernizr global is missing.");
return false; return false;
} }
// custom checks atop Modernizr because it doesn't have ES2018/ES2019 checks in it for some features we depend on,
// Modernizr requires rules to be lowercase with no punctuation:
// ES2018: http://www.ecma-international.org/ecma-262/9.0/#sec-promise.prototype.finally
window.Modernizr.addTest("promiseprototypefinally", () =>
window.Promise && window.Promise.prototype && typeof window.Promise.prototype.finally === "function");
// ES2019: http://www.ecma-international.org/ecma-262/10.0/#sec-object.fromentries
window.Modernizr.addTest("objectfromentries", () =>
window.Object && typeof window.Object.fromEntries === "function");
const featureList = Object.keys(window.Modernizr);
let featureComplete = true; let featureComplete = true;
for (let i = 0; i < featureList.length; i++) { for (let i = 0; i < featureList.length; i++) {
if (window.Modernizr[featureList[i]] === undefined) { if (window.Modernizr[featureList[i]] === undefined) {
@ -74,19 +85,6 @@ function checkBrowserFeatures(featureList) {
featureComplete = false; featureComplete = false;
} }
} }
// custom checks atop Modernizr because it doesn't have ES2018/ES2019 checks in it for some features we depend on:
// ES2018: http://www.ecma-international.org/ecma-262/9.0/#sec-promise.prototype.finally
if (!Promise || !Promise.prototype || typeof Promise.prototype.finally !== "function") {
console.error("Browser missing feature: Promise.prototype.finally");
featureComplete = false;
}
// ES2019: http://www.ecma-international.org/ecma-262/10.0/#sec-object.fromentries
if (!Object || typeof Object.fromEntries !== "function") {
console.error("Browser missing feature: Object.fromEntries");
featureComplete = false;
}
return featureComplete; return featureComplete;
} }
@ -273,10 +271,7 @@ export async function loadApp() {
return; return;
} }
const validBrowser = checkBrowserFeatures([ const validBrowser = checkBrowserFeatures();
"displaytable", "flexbox", "es5object", "es5function", "localstorage",
"objectfit", "indexeddb", "webworkers",
]);
const acceptInvalidBrowser = window.localStorage && window.localStorage.getItem('mx_accepts_unsupported_browser'); const acceptInvalidBrowser = window.localStorage && window.localStorage.getItem('mx_accepts_unsupported_browser');

File diff suppressed because one or more lines are too long