2019-09-15 14:16:32 +02:00
|
|
|
import { Features } from 'util/features';
|
2018-08-30 22:16:31 +02:00
|
|
|
|
|
|
|
const FeatureTester = {
|
|
|
|
test() {
|
|
|
|
return Promise.resolve()
|
|
|
|
.then(() => this.checkWebAssembly())
|
|
|
|
.then(() => this.checkLocalStorage());
|
|
|
|
},
|
|
|
|
|
|
|
|
checkWebAssembly() {
|
|
|
|
try {
|
2019-08-18 08:05:38 +02:00
|
|
|
const module = new global.WebAssembly.Module(
|
|
|
|
Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00)
|
|
|
|
);
|
2018-08-30 22:16:31 +02:00
|
|
|
return new global.WebAssembly.Instance(module) instanceof global.WebAssembly.Instance;
|
|
|
|
} catch (e) {
|
|
|
|
throw 'WebAssembly is not supported';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
checkLocalStorage() {
|
2019-09-15 08:11:11 +02:00
|
|
|
if (Features.isDesktop) {
|
2018-08-30 22:21:57 +02:00
|
|
|
return;
|
|
|
|
}
|
2018-08-30 22:16:31 +02:00
|
|
|
try {
|
|
|
|
localStorage.setItem('_test', '1');
|
|
|
|
localStorage.removeItem('_test');
|
|
|
|
} catch (e) {
|
2019-09-15 12:37:11 +02:00
|
|
|
throw 'LocalStorage is not supported';
|
2018-08-30 22:16:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-09-15 14:16:32 +02:00
|
|
|
export { FeatureTester };
|