-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
binary websocket support #370
Comments
In Modernizr 2.6.2, IE 10.0.9200.16438 on Win7
throws
so the test evals to false. But if you supply a valid host instead of "."
you get a truthy
which causes the test eval to true. Of course you might later get some unsightly error on the console if the WebSocket doesn't get a response it expects. So I'm not really sure what should be used to test this if IE doesn't like ".". |
Ok so here's a potential solution that returns expected results. It looks like everyone but Chrome exposes Modernizr.addTest('websocketsbinary', function() {
var protocol = 'https:'==location.protocol?'wss':'ws',
protoBin = "binaryType" in WebSocket.prototype;
if("WebSocket" in window) {
if( protoBin ) return protoBin;
try {
return !!(new WebSocket(protocol+'://.').binaryType);
} catch (e){}
}
return false;
}); @sirbarrence can you try this test case and see if that returns expected results for you? http://codepen.io/ryanseddon/pen/Ggydu |
Actually i'll need to put that protoBin variable inside the if as non WebSocket browsers will throw. Updated test case. |
Yeah, seems ok. IE 8 & 9 are false and IE 10 is true as expected. Chrome 24 (Mac) and Firefox 18 (Mac) are true as expected. |
* 'master' of github.com:Modernizr/Modernizr: (70 commits) Fixed a typo in `testMediaQuery()` Added wrapflow test, in AMD format - fixes Modernizr#786 Fixes missing brackets and removes unneeded "Pre 1.2" from the user agent regex ("webOS" already covers that). Corrected name for `touch` (to `touchevents`) in Modernizr-caniuse mapping Robustisize the binary WebSocket detect. Fixes Modernizr#370 Update detect for fullscreen api. Fixes Modernizr#739 Added DOM PointerEvents test as Modernizr.pointerevents Moved Modernizr.pointerevents -> Modernizr.csspointer events (API break...) Moved Modernizr.touch -> Modernizr.touchevents (kept an alias though) Matches Modernizr#777 in v3 land. Matches Modernizr#774 in v3 land. Matches Modernizr#773 in v3 land. whitespace Adds 'peerconnection' feature detection, namespaces WebRTC features together Tweaked csstransforms3d style test numbers to work around rounding bug in Chrome 23.0 when zoomed (Modernizr#760) Added fileinput test mobile UA blacklist for issue Modernizr#772 Added fileinput test mobile UA blacklist for issue Modernizr#772 adding docs from alex's email. whitespace SUPERSECRET MICROSOFT REQUESTED SENSORSHIP ...
* 3pre: (58 commits) fill up metadata a bit more, a few new conventions Saving full dependecies into package.json Removing node_modules, adding in metadata reader, ignoring generated metadata remove the node modules via an ignore Corrected name for `touch` (to `touchevents`) in Modernizr-caniuse mapping Robustisize the binary WebSocket detect. Fixes Modernizr#370 Update detect for fullscreen api. Fixes Modernizr#739 Added DOM PointerEvents test as Modernizr.pointerevents Moved Modernizr.pointerevents -> Modernizr.csspointer events (API break...) Moved Modernizr.touch -> Modernizr.touchevents (kept an alias though) Matches Modernizr#777 in v3 land. Matches Modernizr#774 in v3 land. Matches Modernizr#773 in v3 land. whitespace Adds 'peerconnection' feature detection, namespaces WebRTC features together Tweaked csstransforms3d style test numbers to work around rounding bug in Chrome 23.0 when zoomed (Modernizr#760) Added fileinput test mobile UA blacklist for issue Modernizr#772 Added fileinput test mobile UA blacklist for issue Modernizr#772 adding docs from alex's email. whitespace ... Conflicts: config-all.json feature-detects/css/animations.js feature-detects/forms/fileinput.js modular.html package.json
Thanks for the fix - however, obviously this did not find its way into a stable release. This is still broken in 2.7.1. Could someone tell me please why this is not fixed in public release? If I generate code using |
This was released in v2.8.0 |
* 'master' of github.com:Modernizr/Modernizr: (70 commits) Fixed a typo in `testMediaQuery()` Added wrapflow test, in AMD format - fixes Modernizr#786 Fixes missing brackets and removes unneeded "Pre 1.2" from the user agent regex ("webOS" already covers that). Corrected name for `touch` (to `touchevents`) in Modernizr-caniuse mapping Robustisize the binary WebSocket detect. Fixes Modernizr#370 Update detect for fullscreen api. Fixes Modernizr#739 Added DOM PointerEvents test as Modernizr.pointerevents Moved Modernizr.pointerevents -> Modernizr.csspointer events (API break...) Moved Modernizr.touch -> Modernizr.touchevents (kept an alias though) Matches Modernizr#777 in v3 land. Matches Modernizr#774 in v3 land. Matches Modernizr#773 in v3 land. whitespace Adds 'peerconnection' feature detection, namespaces WebRTC features together Tweaked csstransforms3d style test numbers to work around rounding bug in Chrome 23.0 when zoomed (Modernizr#760) Added fileinput test mobile UA blacklist for issue Modernizr#772 Added fileinput test mobile UA blacklist for issue Modernizr#772 adding docs from alex's email. whitespace SUPERSECRET MICROSOFT REQUESTED SENSORSHIP ...
* 3pre: (58 commits) fill up metadata a bit more, a few new conventions Saving full dependecies into package.json Removing node_modules, adding in metadata reader, ignoring generated metadata remove the node modules via an ignore Corrected name for `touch` (to `touchevents`) in Modernizr-caniuse mapping Robustisize the binary WebSocket detect. Fixes Modernizr#370 Update detect for fullscreen api. Fixes Modernizr#739 Added DOM PointerEvents test as Modernizr.pointerevents Moved Modernizr.pointerevents -> Modernizr.csspointer events (API break...) Moved Modernizr.touch -> Modernizr.touchevents (kept an alias though) Matches Modernizr#777 in v3 land. Matches Modernizr#774 in v3 land. Matches Modernizr#773 in v3 land. whitespace Adds 'peerconnection' feature detection, namespaces WebRTC features together Tweaked csstransforms3d style test numbers to work around rounding bug in Chrome 23.0 when zoomed (Modernizr#760) Added fileinput test mobile UA blacklist for issue Modernizr#772 Added fileinput test mobile UA blacklist for issue Modernizr#772 adding docs from alex's email. whitespace ... Conflicts: config-all.json feature-detects/css/animations.js feature-detects/forms/fileinput.js modular.html package.json
A facke connection to 'wss://localhost:17523' (randomly chosen) to detect the WebSocket binary support is not the best solution. First of all, check of prototype has the property 'binaryType'. If not, perform a dummy connection to 'wss://.' instead of 'wss://localhost:17523'. This patch was inspired by the discussion and implementation of Modernizr: Modernizr/Modernizr#370 https://github.com/Modernizr/Modernizr/blob/master/feature-detects/websockets/binary.js
A facke connection to 'wss://localhost:17523' (randomly chosen) to detect the WebSocket binary support is not the best solution. First of all, check of prototype has the property 'binaryType'. If not, perform a dummy connection to 'wss://.' instead of 'wss://localhost:17523'. This patch was inspired by the discussion and implementation of Modernizr: Modernizr/Modernizr#370 https://github.com/Modernizr/Modernizr/blob/master/feature-detects/websockets/binary.js
is the basic test.. truthy (returns
"blob"
) if there is support.. as there is in new chrome canary.https://plus.google.com/115535723976198353696/posts/ERN6zYozENV
The text was updated successfully, but these errors were encountered: