They way I see it, you can use JS -> PHP -> JS call and time the response, but that is pretty inaccurate. Also, you'd need to use a fair amount of data (excess bandwidth usage concerns) and would never get an explicit answer due to server headers that exist/don't exist between browsers. There's also a concern with service providers (cough comcast cough) where they give you 12 mbit speeds for the first few seconds, but choke you down to 3mbits afterward, so now your "Test" would say they're on an OC line but the stream itself would now have a data deficit and be buffering constantly.
The best solution is to build the logic in to the streaming protocol that can adjust based on how much/little data is coming in. Maybe it starts out at a low bandwidth quality and raises the bar when it notices the buffer is growing faster than the data is playing (this is what Hulu, YouTube or Amazon video do).