frame_host_impl_browsertest.cc 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2021 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include <lib/sys/cpp/service_directory.h>
  5. #include "content/public/test/browser_test.h"
  6. #include "fuchsia_web/common/test/test_navigation_listener.h"
  7. #include "fuchsia_web/webengine/browser/context_impl.h"
  8. #include "fuchsia_web/webengine/test/web_engine_browser_test.h"
  9. #include "testing/gtest/include/gtest/gtest.h"
  10. namespace {
  11. using FrameHostImplBrowserTest = WebEngineBrowserTest;
  12. } // namespace
  13. // Verify that it is possible to connect to the fuchsia.web.FrameHost service,
  14. // and that a Frame created in it uses a different ContextImpl than one created
  15. // via the fuchsia.web.Context.
  16. IN_PROC_BROWSER_TEST_F(FrameHostImplBrowserTest, IsolatedFromWebContext) {
  17. ASSERT_TRUE(embedded_test_server()->Start());
  18. // Create a new Frame via the fuchsia.web.Context, and spin the loop to
  19. // allow the request to be processed.
  20. fuchsia::web::FramePtr context_frame;
  21. context()->CreateFrameWithParams({}, context_frame.NewRequest());
  22. base::RunLoop().RunUntilIdle();
  23. // Verify that the FrameImpl can be found via the |context_impl()| to which
  24. // the fuchsia.web.Context is connected.
  25. EXPECT_TRUE(context_impl()->GetFrameImplForTest(&context_frame) != nullptr);
  26. // Create a new Frame via a FrameHost instance.
  27. fuchsia::web::FrameHostPtr frame_host;
  28. published_services().Connect(frame_host.NewRequest());
  29. fuchsia::web::FramePtr frame_host_frame;
  30. frame_host->CreateFrameWithParams({}, frame_host_frame.NewRequest());
  31. base::RunLoop().RunUntilIdle();
  32. // Verify that the new Frame cannot be resolved to a FrameImpl under the
  33. // |context_impl()| to which the fuchsia.web.Context is connected.
  34. EXPECT_TRUE(context_impl()->GetFrameImplForTest(&frame_host_frame) ==
  35. nullptr);
  36. }