binary.js 790 B

123456789101112131415161718192021222324252627282930
  1. /*!
  2. {
  3. "name": "Binary WebSockets",
  4. "property": "websocketsbinary",
  5. "tags": ["websockets"],
  6. "builderAliases": ["websockets_binary"]
  7. }
  8. !*/
  9. define(['Modernizr'], function(Modernizr) {
  10. // binaryType is truthy if there is support.. returns "blob" in new-ish chrome.
  11. // plus.google.com/115535723976198353696/posts/ERN6zYozENV
  12. // github.com/Modernizr/Modernizr/issues/370
  13. Modernizr.addTest('websocketsbinary', function() {
  14. var protocol = 'https:' === location.protocol ? 'wss' : 'ws',
  15. protoBin;
  16. if ('WebSocket' in window) {
  17. protoBin = 'binaryType' in WebSocket.prototype;
  18. if (protoBin) {
  19. return protoBin;
  20. }
  21. try {
  22. return !!(new WebSocket(protocol + '://.').binaryType);
  23. } catch (e) {}
  24. }
  25. return false;
  26. });
  27. });