#include <optional>
#include "base/json/json_reader.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/gmock_expected_support.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "cc/base/math_util.h"
#include "content/browser/renderer_host/cross_process_frame_connector.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_view_child_frame.h"
#include "content/browser/site_per_process_browsertest.h"
#include "content/common/input/actions_parser.h"
#include "content/common/input/synthetic_pointer_action.h"
#include "content/common/input/synthetic_touchscreen_pinch_gesture.h"
#include "content/public/browser/render_process_host_priority_client.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/public/test/hit_test_region_observer.h"
#include "content/public/test/synchronize_visual_properties_interceptor.h"
#include "content/public/test/test_frame_navigation_observer.h"
#include "content/test/render_document_feature.h"
#include "content/test/render_widget_host_visibility_observer.h"
#include "mojo/public/cpp/test_support/test_utils.h"
#include "third_party/blink/public/mojom/frame/frame.mojom-test-utils.h"
#if defined(USE_AURA)
#include "ui/aura/window_tree_host.h"
#endif
#if BUILDFLAG(IS_MAC)
#include "content/common/input/synthetic_touchpad_pinch_gesture.h"
#include "ui/base/test/scoped_preferred_scroller_style_mac.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ui/aura/test/test_screen.h"
#endif
namespace content {
namespace {
double GetFrameDeviceScaleFactor(const ToRenderFrameHost& adapter) { … }
void LayoutNonRecursiveForTestingViewportIntersection(
const ToRenderFrameHost& execution_target) { … }
bool CheckIntersectsViewport(bool expected, FrameTreeNode* node) { … }
void SimulateMouseClick(RenderWidgetHost* rwh, int x, int y) { … }
}
class UpdateViewportIntersectionMessageFilter
: public blink::mojom::RemoteFrameHostInterceptorForTesting { … };
class FakeRemoteMainFrame : public blink::mojom::RemoteMainFrame { … };
class UpdateTextAutosizerInfoProxyObserver
: public RenderFrameProxyHost::TestObserver { … };
class TextAutosizerPageInfoInterceptor
: public blink::mojom::LocalMainFrameHostInterceptorForTesting { … };
class SitePerProcessHighDPIBrowserTest : public SitePerProcessBrowserTest { … };
IN_PROC_BROWSER_TEST_P(SitePerProcessHighDPIBrowserTest,
SubframeLoadsWithCorrectDeviceScaleFactor) { … }
class SitePerProcessCompositorViewportBrowserTest
: public SitePerProcessBrowserTestBase,
public testing::WithParamInterface<double> { … };
IN_PROC_BROWSER_TEST_P(SitePerProcessCompositorViewportBrowserTest,
DISABLED_OopifCompositorViewportSizeRelativeToParent) { … }
#if BUILDFLAG(IS_ANDROID)
INSTANTIATE_TEST_SUITE_P(SitePerProcess,
SitePerProcessCompositorViewportBrowserTest,
testing::Values(1.0));
#else
INSTANTIATE_TEST_SUITE_P(…);
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest,
SubframeUpdateToCorrectDeviceScaleFactor) {
GURL main_url(embedded_test_server()->GetURL(
"a.com", "/cross_site_iframe_factory.html?a(b)"));
EXPECT_TRUE(NavigateToURL(shell(), main_url));
EXPECT_EQ(1.0, GetFrameDeviceScaleFactor(web_contents()));
FrameTreeNode* root = web_contents()->GetPrimaryFrameTree().root();
ASSERT_EQ(1U, root->child_count());
FrameTreeNode* child = root->child_at(0);
EXPECT_EQ(1.0, GetFrameDeviceScaleFactor(child));
double expected_dip_scale = 2.0;
aura::TestScreen* test_screen =
static_cast<aura::TestScreen*>(display::Screen::GetScreen());
test_screen->CreateHostForPrimaryDisplay();
test_screen->SetDeviceScaleFactor(expected_dip_scale);
aura::WindowTreeHost* window_tree_host = shell()->window()->GetHost();
window_tree_host->SetBoundsInPixels(window_tree_host->GetBoundsInPixels());
const char kScript[] = R"(
new Promise(resolve => {
if (window.devicePixelRatio == 2)
resolve(window.devicePixelRatio);
window.matchMedia('screen and (min-resolution: 2dppx)')
.addListener(function(e) {
if (e.matches) {
resolve(window.devicePixelRatio);
}
});
});
)";
EXPECT_EQ(expected_dip_scale, EvalJs(child, kScript).ExtractDouble());
EXPECT_EQ(expected_dip_scale,
EvalJs(web_contents(), kScript).ExtractDouble());
}
#endif
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_MAC)
#define MAYBE_ScaledIframeRasterSize …
#else
#define MAYBE_ScaledIframeRasterSize …
#endif
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest,
MAYBE_ScaledIframeRasterSize) { … }
#if BUILDFLAG(IS_ANDROID)
#define MAYBE_ScaledNestedIframeRasterSize …
#else
#define MAYBE_ScaledNestedIframeRasterSize …
#endif
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest,
MAYBE_ScaledNestedIframeRasterSize) { … }
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest,
IframeInMulticolCompositingRect) { … }
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest,
DISABLED_FrameViewportIntersectionTestSimple) { … }
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest,
FrameViewportOffsetTestSimple) { … }
IN_PROC_BROWSER_TEST_P(
SitePerProcessBrowserTest,
DISABLED_NestedIframeTransformedIntoViewViewportIntersection) { … }
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest,
DISABLED_PopupMenuInTallIframeTest) { … }
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest,
NestedFrameViewportIntersectionUpdated) { … }
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest,
NestedFrameMainFrameDocumentIntersectionUpdated) { … }
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest,
DISABLED_MainFrameScrollOffset) { … }
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest,
FrameViewportIntersectionTestAggregate) { … }
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest, ScrollByRAF) { … }
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest, TextAutosizerPageInfo) { … }
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest,
CompositorViewportPixelSizeTest) { … }
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest,
DISABLED_NoResizeAfterIframeLoad) { … }
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest, ViewBoundsInNestedFrameTest) { … }
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#define MAYBE_FrameOwnerPropertiesPropagationScrolling …
#else
#define MAYBE_FrameOwnerPropertiesPropagationScrolling …
#endif
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest,
MAYBE_FrameOwnerPropertiesPropagationScrolling) { … }
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest,
FrameOwnerPropertiesPropagationMargin) { … }
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest,
FrameOwnerPropertiesPropagationCSP) { … }
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_CHROMEOS_LACROS)
#define MAYBE_CSSVisibilityChanged …
#else
#define MAYBE_CSSVisibilityChanged …
#endif
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest, MAYBE_CSSVisibilityChanged) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_HiddenOOPIFWillNotGenerateCompositorFrames …
#else
#define MAYBE_HiddenOOPIFWillNotGenerateCompositorFrames …
#endif
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest,
MAYBE_HiddenOOPIFWillNotGenerateCompositorFrames) { … }
IN_PROC_BROWSER_TEST_P(
SitePerProcessBrowserTest,
HiddenOOPIFWillNotGenerateCompositorFramesAfterNavigation) { … }
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest, ScreenCoordinates) { … }
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest, VisibilityChange) { … }
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest,
DISABLED_PageScaleFactorPropagatesToOOPIFs) { … }
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest,
DISABLED_CompositingScaleFactorInNestedFrameTest) { … }
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest,
CompositingScaleFactorWithZeroScaleTransform) { … }
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest,
ResizeAndCrossProcessPostMessagePreserveOrder) { … }
#if BUILDFLAG(IS_ANDROID)
#define MAYBE_DisableScrollOopifInPinchZoomedPage …
#else
#define MAYBE_DisableScrollOopifInPinchZoomedPage …
#endif
IN_PROC_BROWSER_TEST_P(SitePerProcessBrowserTest,
MAYBE_DisableScrollOopifInPinchZoomedPage) { … }
INSTANTIATE_TEST_SUITE_P(…);
}