are websockets not supported in Firefox 19? - javascript

i am trying to write a websocket page, and it works in Chrome and some other browsers on my Ubuntu machine.
however, firefox would not run the websocket part, and both window[WebSocket] and window[MozWebSocket] return "undefined". does firefox not support websockets?

Use (from MDN docs):
var mySocket = new WebSocket("ws://www.example.com/socketserver", "protocol");
It is supported from Firefox 6.0 (known as MozWebSocket prior to Fx 11 - see #Dracs' comment).

Extensions like TorButton can set network.websocket.enabled to false in about:config. Make sure it's true.

Related

How to detect that browser is running in Safari on iOS 11 via JavaScript?

I want to detect that my JS code in a webpage is running in Safari on iOS 11, which supports some new features.
I can do something like
if (window.navigator.userAgent.includes('OS 11_0')) {
// iOS 11
}
but I believe this is considered unreliable.
Is there some feature or a hack that works only on iOS 11 and not on other OS and can be used to detect that version without inspecting the userAgent?
Update: I am talking about getUserMedia so I am not sure if ther is a way to test it presence without triggering the microphone permission request.
Check out this solution, and then you could do something like this:
ver = iOSversion();
if (ver[0]==11) {
// do something
}
The shared snippet can also be used to detect any specific iOS version, >iOS 2.

How to set Protractor configuration to run on FireFox and enable CORS

I'm running my protractor tests with Chrome and i'd like to run them with Firefox too. Problem is I can't find how to enable CORS in firefox like I do in Chrome.
This is my configuration for Chrome:
capabilities:{
'browserName': 'chrome',
'chromeOptions': {
'args': ['--disable-web-security']
}
},
Hate to say it but FireFox doesn't have similar functionality.
In fact, out of the main four browsers (Chrome, Safari, FF and IE), only Chrome and IE will allow you to run with web security disabled and only Chrome from the command line.
Source: I spent a lot of time looking for a way to run each of these browsers with CORS security disabled and failed on all accounts except for Chrome and IE.
with selenium webdriverjs we can use this
npm : https://github.com/saadtazi/firefox-profile-js
var FirefoxProfile = require('firefox-profile'),
webdriverjs = require('webdriverjs');
var fp = new FirefoxProfile();
fp.setPreference("security.fileuri.strict_origin_policy", false);
And this is the link to set specific firefox profile for Protractor
https://github.com/juliemr/protractor-demo/tree/master/howtos/setFirefoxProfile

Firefox video tag getVideoPlaybackQuality() is not a function

According to MDN documentation, getVideoPlaybackQuality() on HTMLVideoElement is available after version 25.0.
However, I tried to call it on video element in Firefox 38.1.0 and got an getVideoPlaybackQuality is not a function error.
Is this api actually available for Firefox?
According to Firefox MSE bug report,
Firefox has a whitelist limiting MSE (to YouTube, Netflix, and Dailymotion) while we fix some compatibility bugs. The whitelist will likely be removed in Firefox 42, making MSE available to all websites.
Did you catch the footnote in Mozilla's documentation ... that the function is only available if you switch on a config flag?
Load about:config in Firefox and search for the media.mediasource.enabled flag, then set it to true and try your function call again.
EDIT: If I'm reading correctly, the release notes for Firefox 37 and Firefox 38 seem to indicate that the MediaSource API is currently implemented for YouTube only. However, it's enabled for Firefox Nightlies right now.

How to get the HTTP protocol version via JavaScript

Is it possible to determine the HTTP protocol version using JavaScript? I need to detect if the user is using HTTP/2 protocol (and congratulate him if this was the case).
console.log(performance.getEntries()[0].nextHopProtocol)
See also: https://caniuse.com/mdn-api_performanceresourcetiming_nexthopprotocol
Works in
Edge since 17
Firefox (Desktop and Mobile) since 45
Chrome (Desktop and Mobile) since 61
Safari Mac 14.1 (tested here, but not yet updated on MDN/caniuse)
if (location.protocol == "http/2"){
alert('congratulations!');
}

WebSocket versions and backwards compatibility

I've been experimenting with WebSockets for the past couple of days and I'm having some mixed experiences with the new, very cool, technology. I've written a simple chat client that uses the latest release from HTML5 Labs, which I believe is the hybi-09 draft spec release. The client works great in Chrome (dev channel v14.0). Everything functions as it should. However, in every other major browser that natively supports WebSockets (FireFox (v6.0b) (Yes, I did turn on WebSockets functionality), Safari (v5.1)), it can't connect for some reason. Here's some of my client code:
$(document).ready(connect);
function connect() {
if ('WebSocket' in window) {
websocket = new WebSocket('ws://' + window.location.hostname + ':4502/chat');
}
else if ('MozWebSocket' in window) {
websocket = new MozWebSocket('ws://' + window.location.hostname + ':4502/chat');
}
else {
//not supported
return;
}
websocket.onopen = function () {
//do some setup stuff
};
websocket.onclose = function () {
//DOH
};
websocket.onmessage = function (e) {
//Do some stuff with e.data
};
}
and some (C#) server code:
static void Main(string[] args)
{
var host = new WebSocketsHost<ReverseService>();
host.AddWebSocketsEndpoint("ws://" + Environment.MachineName + ":4502/chat");
host.Open();
Console.ReadLine();
}
Like I said, it connects fine in Chrome and hits the .onopen function as it should. In FF and Safari, it goes straight to the onclose function and never connects. In FF, I get the following errors:
"NetworkError: 501 Not Implemented - http://localhost:4502/chat"
Firefox can't establish a connection to the server at ws://localhost:4502/chat
And in Safari:
WebSocket frame (at 4294967295 bytes) is too long.
The only thing I can think of is some kind of backwards compatibility issue. I believe Chrome 14.x implements the draft 10 spec of hybi WebSockets and I think FF 6 implements draft 07 or 08 and I'm not sure about Safari 5.1. If anyone has any insight as to what the problem is and/or how/if I can fix it, I'd appreciate the help. Thanks!
Chrome 14 and Firefox 7 (Aurora build, prefixed with "Moz" but enabled by default) support the HyBi-10 version of the protocol. Everything else that has native WebSockets support is still using the Hixie-76 version of the protocol.
There are server implementations that already support the HyBi protocol and many more will soon now that Chrome 14 has it natively. There are some that have support for both Hixie-76 and the newer HyBi versions of the protocol (libwebsockets, websockify). I'm not particularly surprised that Microsoft's prototype server implementation only supports one version of the protocol (since they were not in the game during the Hixie period).
Update:
Some server options:
libwebsockets - C implementation
websockify - My python implementation. websockify is a websockets to TCP socket proxy/bridge, but websocket.py is a generic websocket module.
Here is a .NET based (free) WebSocketServer that supports Hybi10 and the older protocols. Can be found at http://xsockets.net
or run the add to your project (MVC3) by using Install-Package XSockets in the Package Manager Console in Visual Studio 2010 ( Also think the 2008 will do Nuget now)
I uses one of the videos as help http://xsockets.net/Video/Index
Here is a WebSockets protocol test report listing conformance of Chrome 14 and Firefox 7/8 to specific features of the latest protocol spec.
The test suite is part of Autobahn WebSockets, a little project of mine that includes Python/Twisted-based WebSockets implementation, which can be used to write clients and servers.
Code is Apache 2.0 licensed and all on GitHub.

Categories