-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#660] Implement WebAssembly warning
Signed-off-by: Marius David Wieschollek <passwords.public@mdns.eu>
- Loading branch information
1 parent
79a28c7
commit 419d1cc
Showing
6 changed files
with
55 additions
and
30 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,65 @@ | ||
function isCompatibleBrowser() { | ||
function checkBrowserSupport() { | ||
try { | ||
if(!window.hasOwnProperty('crypto') || typeof window.crypto.subtle !== "object") { | ||
console.error('Web Crypto API not supported'); | ||
return false; | ||
return 'crypto'; | ||
} | ||
|
||
if(!window.hasOwnProperty('TextEncoder')) { | ||
console.error('TextEncoder not supported'); | ||
return false; | ||
return 'TextEncoder'; | ||
} | ||
|
||
if(!window.hasOwnProperty('WebAssembly') || typeof window.WebAssembly.instantiate !== "function") { | ||
console.error('WebAssembly not supported'); | ||
return false; | ||
return 'WebAssembly'; | ||
} | ||
} catch(e) { | ||
console.error(e); | ||
|
||
return false; | ||
return 'ECMAScript 2017 / ES2017'; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
function showBrowserCompatibilityWarning() { | ||
function showBrowserCompatibilityWarning(reason) { | ||
var imgpath = OC.filePath('passwords', 'img', 'browser/'), | ||
container = document.getElementById('main'); | ||
container = document.getElementById('main'), | ||
title = 'Your browser is outdated', | ||
message = 'Your browser is outdated and does not have the necessary functionality to run this app.' + | ||
'<br>Please check if an update is available for your browser or choose a modern and compatible browser from the list below.'; | ||
|
||
if(reason === 'WebAssembly') { | ||
var handbookLink = null, | ||
settings = OCP.InitialState.loadState('passwords', 'settings'); | ||
|
||
if(settings && settings['server.handbook.url']) { | ||
handbookLink = settings['server.handbook.url.web'] + 'Enable-WebAssembly'; | ||
} | ||
|
||
title = 'Your browser does not support WebAssembly'; | ||
message = 'Your browser does not support WebAssembly (WASM), which is required to run this app. ' + | ||
'<br>In some browsers, WebAssembly must be enabled in the browser configuration.<br>' + | ||
(handbookLink ? '<a target="_blank" rel="noreferrer noopener" href="' + handbookLink + '">':'') + | ||
'A guide to enable WebAssembly can be found in the Passwords App handbook.' + | ||
(handbookLink ? '</a>':'') + | ||
'<br><br>If your browser does not have WebAssembly support, check if an update is available for your browser or choose a modern and compatible browser from the list below.'; | ||
} | ||
|
||
container.innerHTML = | ||
'<div class="passwords-browser-compatibility">' + | ||
'<h1 class="title">Your Browser is outdated</h1>' + | ||
'<div class="message">Your browser is outdated and does not provide the necessary functionality to display this page.' + | ||
'<br>Please check if an update is available for your browser or choose a modern and compatible browser from the list below.' + | ||
'</div><div class="browser">' + | ||
'<div class="passwords-browser-compatibility"><h1 class="title">' + title + '</h1><div class="message">' + message + '</div><div class="browser">' + | ||
'<a target="_blank" rel="noreferrer noopener" href="https://www.mozilla.org/firefox/new/" style="background-image: url(' + imgpath + 'firefox.png)">Firefox</a>' + | ||
'<a target="_blank" rel="noreferrer noopener" href="https://vivaldi.com/download/" style="background-image: url(' + imgpath + 'vivaldi.png)">Vivaldi</a>' + | ||
'<a target="_blank" rel="noreferrer noopener" href="https://brave.com/" style="background-image: url(' + imgpath + 'brave.png)">Brave</a>' + | ||
'<a target="_blank" rel="noreferrer noopener" href="https://www.torproject.org/download/" style="background-image: url(' + imgpath + 'tor.png)">Tor Browser</a>' + | ||
'</div></div>'; | ||
container.setAttribute('class', ''); | ||
|
||
throw new Error('Browser does not suport ECMAScript 2017 / ES2017'); | ||
console.error('Browser does not support ' + reason); | ||
throw new Error('Browser does not support ' + reason); | ||
} | ||
|
||
function checkSystem() { | ||
if(!isCompatibleBrowser()) showBrowserCompatibilityWarning(); | ||
var reason = checkBrowserSupport(); | ||
if(reason !== true) showBrowserCompatibilityWarning(reason); | ||
} | ||
|
||
window.addEventListener('DOMContentLoaded', checkSystem, false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters