Pass EmbeddedTestServer to CrossSiteRedirector handler.
When setting up a CrossSiteRedirector request handler for an EmbeddedTestServer,
the current code gets the server's base_ur() and binds it so that it can be used
in the request handler.
This means that the server needs to be initialized (so that there is a socket
and we can build the base_url) but not yet accepting connections because that
would mean adding the request handler isn't thread safe.
In order to fix issue 546060 I've been updating tests[1] that do the following
(not thread safe):
embedded_test_server()->Start();
SetupCrossSiteRedirector(embedded_test_server());
to do this in a thread safe manner instead:
// Initialize so that there is a listen socket to build the base_url from.
embedded_test_server()->InitializeAndListen();
SetupCrossSiteRedirector(embedded_test_server());
// Start accepting connections once the request handler is added.
embedded_test_server()->StartAcceptingConnections();
This CL updates the SetupCrossSiteRedirector() code to bind the test server
rather then the server's base_url() so that these tests can simply do:
SetupCrossSiteRedirector(embedded_test_server());
embedded_test_server()->Start();
[1] https://codereview.chromium.org/2479033002, https://codereview.chromium.org/2491073002
BUG=546060
Review-Url: https://codereview.chromium.org/2483213006
Cr-Commit-Position: refs/heads/master@{#431334}
3 files changed