Change them to Modernizr tests and add more rules

pull/12232/head
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/storage/localstorage",
"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;
function checkBrowserFeatures(featureList) {
function checkBrowserFeatures() {
if (!window.Modernizr) {
console.error("Cannot check features - Modernizr global is missing.");
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;
for (let i = 0; i < featureList.length; i++) {
if (window.Modernizr[featureList[i]] === undefined) {
@ -74,19 +85,6 @@ function checkBrowserFeatures(featureList) {
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;
}
@ -273,10 +271,7 @@ export async function loadApp() {
return;
}
const validBrowser = checkBrowserFeatures([
"displaytable", "flexbox", "es5object", "es5function", "localstorage",
"objectfit", "indexeddb", "webworkers",
]);
const validBrowser = checkBrowserFeatures();
const acceptInvalidBrowser = window.localStorage && window.localStorage.getItem('mx_accepts_unsupported_browser');

File diff suppressed because one or more lines are too long