[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [snowflake/master] Remove Modernizr dependency



commit f3254e340273b110fb205e862050148b2b14838f
Author: Arlo Breault <arlolra@xxxxxxxxx>
Date:   Wed May 1 09:26:25 2019 -0400

    Remove Modernizr dependency
    
    And inline its only use site.
---
 proxy/modernizr-config.json | 11 -----------
 proxy/package.json          |  4 +---
 proxy/shims.coffee          | 14 ++++++--------
 proxy/static/embed.html     |  1 -
 proxy/static/modernizr.js   |  3 ---
 proxy/static/snowflake.html |  1 -
 6 files changed, 7 insertions(+), 27 deletions(-)

diff --git a/proxy/modernizr-config.json b/proxy/modernizr-config.json
deleted file mode 100644
index 1cad4d3..0000000
--- a/proxy/modernizr-config.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
-  "minify": true,
-  "options": [
-    "prefixed"
-  ],
-  "feature-detects": [
-    "test/websockets",
-    "test/webrtc/datachannel",
-    "test/webrtc/peerconnection"
-  ]
-}
\ No newline at end of file
diff --git a/proxy/package.json b/proxy/package.json
index 276adcf..cc4cc78 100644
--- a/proxy/package.json
+++ b/proxy/package.json
@@ -11,7 +11,6 @@
     "lint": "cake lint",
     "build": "cake build",
     "clean": "cake clean",
-    "modern": "modernizr -c modernizr-config.json -d static/",
     "prepublish": "npm run build",
     "start": "node build/snowflake.js"
   },
@@ -22,8 +21,7 @@
   "license": "BSD-3-Clause",
   "devDependencies": {
     "coffeelint": "^1.16.0",
-    "jasmine": "2.5.2",
-    "modernizr": "^3.3.1"
+    "jasmine": "2.5.2"
   },
   "dependencies": {
     "coffee-script": "^1.12.2",
diff --git a/proxy/shims.coffee b/proxy/shims.coffee
index 325184c..a0f53ea 100644
--- a/proxy/shims.coffee
+++ b/proxy/shims.coffee
@@ -22,17 +22,15 @@ else
   window = this
   location = window.location.search.substr(1)
 
-  prop = Modernizr.prefixed 'RTCPeerConnection', window, false
-  if not prop
-    console.log 'webrtc feature not detected. shutting down'
-    return
-
-  PeerConnection = window[prop]
-
-  ### FIXME: push these upstream ###
+  PeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection ||
+    window.webkitRTCPeerConnection
   IceCandidate = window.RTCIceCandidate || window.mozRTCIceCandidate
   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
diff --git a/proxy/static/embed.html b/proxy/static/embed.html
index 9efe369..32c26ca 100644
--- a/proxy/static/embed.html
+++ b/proxy/static/embed.html
@@ -3,7 +3,6 @@
 <head>
   <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
   <meta http-equiv="refresh" content="86400">
-  <script type="text/javascript" src="modernizr.js"></script>
   <script type="text/javascript" src="snowflake.js"></script>
   <style>
   * {
diff --git a/proxy/static/modernizr.js b/proxy/static/modernizr.js
deleted file mode 100644
index 8c77f81..0000000
--- a/proxy/static/modernizr.js
+++ /dev/null
@@ -1,3 +0,0 @@
-/*! modernizr 3.3.1 (Custom Build) | MIT *
- * http://modernizr.com/download/?-datachannel-peerconnection-websockets-prefixed !*/
-!function(e,n,t){function r(e,n){return typeof e===n}function o(){var e,n,t,o,i,s,a;for(var f in h)if(h.hasOwnProperty(f)){if(e=[],n=h[f],n.name&&(e.push(n.name.toLowerCase()),n.options&&n.options.aliases&&n.options.aliases.length))for(t=0;t<n.options.aliases.length;t++)e.push(n.options.aliases[t].toLowerCase());for(o=r(n.fn,"function")?n.fn():n.fn,i=0;i<e.length;i++)s=e[i],a=s.split("."),1===a.length?Modernizr[a[0]]=o:(!Modernizr[a[0]]||Modernizr[a[0]]instanceof Boolean||(Modernizr[a[0]]=new Boolean(Modernizr[a[0]])),Modernizr[a[0]][a[1]]=o),C.push((o?"":"no-")+a.join("-"))}}function i(e,n){return!!~(""+e).indexOf(n)}function s(){return"function"!=typeof n.createElement?n.createElement(arguments[0]):x?n.createElementNS.call(n,"http://www.w3.org/2000/svg",arguments[0]):n.createElement.apply(n,arguments)}function a(){var e=n.body;return e||(e=s(x?"svg":"body"),e.fake=!0),e}function f(e,t,r,o){var i,f,u,l,d="modernizr",p=s("div"),c=a();if(parseInt(r,10))for(;r--;)u=s("div"),u.id=o?o[r
 ]:d+(r+1),p.appendChild(u);return i=s("style"),i.type="text/css",i.id="s"+d,(c.fake?c:p).appendChild(i),c.appendChild(p),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(n.createTextNode(e)),p.id=d,c.fake&&(c.style.background="",c.style.overflow="hidden",l=S.style.overflow,S.style.overflow="hidden",S.appendChild(c)),f=t(p,e),c.fake?(c.parentNode.removeChild(c),S.style.overflow=l,S.offsetHeight):p.parentNode.removeChild(p),!!f}function u(e){return e.replace(/([A-Z])/g,function(e,n){return"-"+n.toLowerCase()}).replace(/^ms-/,"-ms-")}function l(n,r){var o=n.length;if("CSS"in e&&"supports"in e.CSS){for(;o--;)if(e.CSS.supports(u(n[o]),r))return!0;return!1}if("CSSSupportsRule"in e){for(var i=[];o--;)i.push("("+u(n[o])+":"+r+")");return i=i.join(" or "),f("@supports ("+i+") { #modernizr { position: absolute; } }",function(e){return"absolute"==getComputedStyle(e,null).position})}return t}function d(e){return e.replace(/([a-z])-([a-z])/g,function(e,n,t){return n+t.toUpperCase()}).replace(/^
 -/,"")}function p(e,n,o,a){function f(){p&&(delete T.style,delete T.modElem)}if(a=r(a,"undefined")?!1:a,!r(o,"undefined")){var u=l(e,o);if(!r(u,"undefined"))return u}for(var p,c,m,v,h,y=["modernizr","tspan"];!T.style;)p=!0,T.modElem=s(y.shift()),T.style=T.modElem.style;for(m=e.length,c=0;m>c;c++)if(v=e[c],h=T.style[v],i(v,"-")&&(v=d(v)),T.style[v]!==t){if(a||r(o,"undefined"))return f(),"pfx"==n?v:!0;try{T.style[v]=o}catch(C){}if(T.style[v]!=h)return f(),"pfx"==n?v:!0}return f(),!1}function c(e,n){return function(){return e.apply(n,arguments)}}function m(e,n,t){var o;for(var i in e)if(e[i]in n)return t===!1?e[i]:(o=n[e[i]],r(o,"function")?c(o,t||n):o);return!1}function v(e,n,t,o,i){var s=e.charAt(0).toUpperCase()+e.slice(1),a=(e+" "+w.join(s+" ")+s).split(" ");return r(n,"string")||r(n,"undefined")?p(a,n,o,i):(a=(e+" "+b.join(s+" ")+s).split(" "),m(a,n,t))}var h=[],y={_version:"3.3.1",_config:{classPrefix:"",enableClasses:!0,enableJSClass:!0,usePrefixes:!0},_q:[],on:function(e,n){var
  t=this;setTimeout(function(){n(t[e])},0)},addTest:function(e,n,t){h.push({name:e,fn:n,options:t})},addAsyncTest:function(e){h.push({name:null,fn:e})}},Modernizr=function(){};Modernizr.prototype=y,Modernizr=new Modernizr;var C=[],g="Moz O ms Webkit",w=y._config.usePrefixes?g.split(" "):[];y._cssomPrefixes=w;var S=n.documentElement,x="svg"===S.nodeName.toLowerCase(),_={elem:s("modernizr")};Modernizr._q.push(function(){delete _.elem});var T={style:_.elem.style};Modernizr._q.unshift(function(){delete T.style});var b=y._config.usePrefixes?g.toLowerCase().split(" "):[];y._domPrefixes=b,y.testAllProps=v;var E=function(n){var r,o=prefixes.length,i=e.CSSRule;if("undefined"==typeof i)return t;if(!n)return!1;if(n=n.replace(/^@/,""),r=n.replace(/-/g,"_").toUpperCase()+"_RULE",r in i)return"@"+n;for(var s=0;o>s;s++){var a=prefixes[s],f=a.toUpperCase()+"_"+r;if(f in i)return"@-"+a.toLowerCase()+"-"+n}return!1};y.atRule=E;var P=y.prefixed=function(e,n,t){return 0===e.indexOf("@")?E(e):(-1!=e.inde
 xOf("-")&&(e=d(e)),n?v(e,n,t):v(e,"pfx"))};Modernizr.addTest("websockets","WebSocket"in e&&2===e.WebSocket.CLOSING),Modernizr.addTest("peerconnection",!!P("RTCPeerConnection",e)),Modernizr.addTest("datachannel",function(){if(!Modernizr.peerconnection)return!1;for(var n=0,t=b.length;t>n;n++){var r=e[b[n]+"RTCPeerConnection"];if(r){var o=new r({iceServers:[{url:"stun:0"}]});return"createDataChannel"in o}}return!1}),o(),delete y.addTest,delete y.addAsyncTest;for(var k=0;k<Modernizr._q.length;k++)Modernizr._q[k]();e.Modernizr=Modernizr}(window,document);
\ No newline at end of file
diff --git a/proxy/static/snowflake.html b/proxy/static/snowflake.html
index fb2c0e5..84790ed 100644
--- a/proxy/static/snowflake.html
+++ b/proxy/static/snowflake.html
@@ -3,7 +3,6 @@
 <head>
   <title>Snowflake</title>
   <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
-  <script type="text/javascript" src="modernizr.js"></script>
   <script type="text/javascript" src="snowflake.js"></script>
   <style>
   * {



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits