websockets-binary.js 538 B

1234567891011121314151617181920
  1. // binaryType is truthy if there is support.. returns "blob" in new-ish chrome.
  2. // plus.google.com/115535723976198353696/posts/ERN6zYozENV
  3. // github.com/Modernizr/Modernizr/issues/370
  4. Modernizr.addTest('websocketsbinary', function() {
  5. var protocol = 'https:'==location.protocol?'wss':'ws',
  6. protoBin;
  7. if('WebSocket' in window) {
  8. if( protoBin = 'binaryType' in WebSocket.prototype ) {
  9. return protoBin;
  10. }
  11. try {
  12. return !!(new WebSocket(protocol+'://.').binaryType);
  13. } catch (e){}
  14. }
  15. return false;
  16. });