[fuchsia] Implement browser tests for WebRunner Context service.

Tests may interact with the WebRunner FIDL services and the underlying
browser objects for end to end testing of service and browser
functionality.

* Add a browser test launcher main() for WebRunner.
* Add some simple navigation tests.
* Wire up GoBack()/GoForward() FIDL calls.
* Add embedded test server resources and initialization logic.
* Add missing deletion & notification calls to BrowserContext dtor.
* Use FIDL events for navigation state changes.

* Bug fixes:
  ** Move BrowserContext and Screen deletion to PostMainMessageLoopRun(),
     so that they may use the MessageLoop during teardown.
  ** Fix Frame dtor to allow for null WindowTreeHosts (headless case)
  ** Fix std::move logic in Frame ctor which lead to no WebContents
     observer being registered.

Bug: 871594

Change-Id: I36bcbd2436d534d366c6be4eeb54b9f9feadd1ac
Reviewed-on: https://chromium-review.googlesource.com/1164539
Commit-Queue: Kevin Marshall <kmarshall@chromium.org>
Reviewed-by: Wez <wez@chromium.org>
Reviewed-by: Fabrice de Gans-Riberi <fdegans@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584155}
void WebRunnerBrowserMainParts::PreMainMessageLoopRun() {
  DCHECK(!screen_);

  auto platform_screen = ui::OzonePlatform::GetInstance()->CreateScreen();
  if (platform_screen) {
    screen_ = std::make_unique<aura::ScreenOzone>(std::move(platform_screen));
  } else {
    screen_ = std::make_unique<WebRunnerScreen>();
  }

  display::Screen::SetScreenInstance(screen_.get());

  DCHECK(!browser_context_);
   browser_context_ =
       std::make_unique<WebRunnerBrowserContext>(GetWebContextDataDir());
 
  context_service_ = std::make_unique<ContextImpl>(browser_context_.get());
 
   context_binding_ = std::make_unique<fidl::Binding<chromium::web::Context>>(
      context_service_.get(), fidl::InterfaceRequest<chromium::web::Context>(
                                  std::move(context_channel_)));
 
  // Quit the browser main loop when the Context connection is dropped.
  context_binding_->set_error_handler([this]() {
    DLOG(WARNING) << "Client connection to Context service dropped.";
    context_service_.reset();
    std::move(quit_closure_).Run();
  });
 }

void WebRunnerBrowserMainParts::PreMainMessageLoopRun() {
  DCHECK(!screen_);

  auto platform_screen = ui::OzonePlatform::GetInstance()->CreateScreen();
  if (platform_screen) {
    screen_ = std::make_unique<aura::ScreenOzone>(std::move(platform_screen));
  } else {
    screen_ = std::make_unique<WebRunnerScreen>();
  }

  display::Screen::SetScreenInstance(screen_.get());

  DCHECK(!browser_context_);
   browser_context_ =
       std::make_unique<WebRunnerBrowserContext>(GetWebContextDataDir());
 
  fidl::InterfaceRequest<chromium::web::Context> context_request(
      std::move(context_channel_));
 
  context_impl_ = std::make_unique<ContextImpl>(browser_context_.get());
   context_binding_ = std::make_unique<fidl::Binding<chromium::web::Context>>(
      context_impl_.get(), std::move(context_request));
 
  context_binding_->set_error_handler(
      [this]() { std::move(quit_closure_).Run(); });
 }
