Backport some TestWebServer commits from upstream.

The most important commit is 4adebb3 (the other one just adds the
infrastructure it requires), which I landed upstream to get
org.xwalk.runtime.client.test.CrossOriginXhrTest and
org.xwalk.runtime.client.embedded.test.CrossOriginXhrTest to work again
after we moved Crosswalk to M39.

Those tests need TestWebServer to be listening in a specific port
instead of using a random one available, which was the new behaviour.

Necessary for fixing XWALK-2755.