Port the user agent test.

https://github.com/ariya/phantomjs/issues/12439