Warn when WebRTC isn't detected in the webext

Trac 31067
This commit is contained in:
Arlo Breault 2019-07-03 15:35:01 +02:00
parent 4494dbd3ca
commit 095f4a0510
5 changed files with 23 additions and 7 deletions

View file

@ -2,6 +2,10 @@
Entry point.
###
if (not TESTING? or not TESTING) and not Util.featureDetect()
console.log 'webrtc feature not detected. shutting down'
return
snowflake = null
query = Query.parse(location)

View file

@ -17,6 +17,12 @@ log = (msg) ->
dbg = (msg) -> log msg if debug
if not Util.featureDetect()
chrome.runtime.onConnect.addListener (port) ->
port.postMessage
missingFeature: true
return
init = () ->
config = new Config
ui = new WebExtUI()

View file

@ -31,9 +31,5 @@ else
SessionDescription = window.RTCSessionDescription ||
window.mozRTCSessionDescription
if typeof PeerConnection isnt 'function'
console.log 'webrtc feature not detected. shutting down'
return
WebSocket = window.WebSocket
XMLHttpRequest = window.XMLHttpRequest

View file

@ -34,6 +34,8 @@ class Util
return true
return false
@featureDetect = () ->
return typeof PeerConnection is 'function'
class Query
###

View file

@ -3,11 +3,19 @@ const port = chrome.runtime.connect({
});
port.onMessage.addListener((m) => {
const active = m.active;
const div = document.getElementById('active');
const img = div.querySelector('img');
const enabled = m.enabled
const ps = div.querySelectorAll('p');
if (m.missingFeature) {
div.querySelector('img').src = "icons/status-off.png";
ps[0].innerText = "Snowflake is off";
ps[1].innerText = "WebRTC feature is not detected.";
ps[1].style.color = 'firebrick';
document.querySelector('.toggle').style.display = 'none';
return;
}
const active = m.active;
const img = div.querySelector('img');
const enabled = m.enabled;
const clients = active ? 1 : 0;
const enabledText = document.getElementById('toggle');
if (enabled) {