OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/site_per_process_browsertest.h" | 5 #include "content/browser/site_per_process_browsertest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 1819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1830 cross_site_rfh_type.c_str()); | 1830 cross_site_rfh_type.c_str()); |
1831 EXPECT_EQ(tree, DepictFrameTree(root)); | 1831 EXPECT_EQ(tree, DepictFrameTree(root)); |
1832 | 1832 |
1833 navigation_observer.Wait(); | 1833 navigation_observer.Wait(); |
1834 EXPECT_TRUE(observer.last_navigation_succeeded()); | 1834 EXPECT_TRUE(observer.last_navigation_succeeded()); |
1835 EXPECT_EQ(cross_site_url, observer.last_navigation_url()); | 1835 EXPECT_EQ(cross_site_url, observer.last_navigation_url()); |
1836 EXPECT_EQ(0U, child->child_count()); | 1836 EXPECT_EQ(0U, child->child_count()); |
1837 } | 1837 } |
1838 } | 1838 } |
1839 | 1839 |
| 1840 // Verify that "scrolling" property on frame elements propagates to child frames |
| 1841 // correctly. |
| 1842 // Does not work on android since android has scrollbars overlayed. |
| 1843 #if defined(OS_ANDROID) |
| 1844 #define MAYBE_FrameOwnerPropertiesPropagationScrolling \ |
| 1845 DISABLED_FrameOwnerPropertiesPropagationScrolling |
| 1846 #else |
| 1847 #define MAYBE_FrameOwnerPropertiesPropagationScrolling \ |
| 1848 FrameOwnerPropertiesPropagationScrolling |
| 1849 #endif |
| 1850 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| 1851 MAYBE_FrameOwnerPropertiesPropagationScrolling) { |
| 1852 GURL main_url(embedded_test_server()->GetURL( |
| 1853 "a.com", "/frame_owner_properties_scrolling.html")); |
| 1854 NavigateToURL(shell(), main_url); |
| 1855 |
| 1856 // It is safe to obtain the root frame tree node here, as it doesn't change. |
| 1857 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 1858 ->GetFrameTree() |
| 1859 ->root(); |
| 1860 ASSERT_EQ(1u, root->child_count()); |
| 1861 |
| 1862 EXPECT_EQ( |
| 1863 " Site A ------------ proxies for B\n" |
| 1864 " +--Site B ------- proxies for A\n" |
| 1865 "Where A = http://a.com/\n" |
| 1866 " B = http://b.com/", |
| 1867 DepictFrameTree(root)); |
| 1868 |
| 1869 FrameTreeNode* child = root->child_at(0); |
| 1870 |
| 1871 // If the available client width within the iframe is smaller than the |
| 1872 // frame element's width, we assume there's a scrollbar. |
| 1873 // Also note that just comparing clientHeight and scrollHeight of the frame's |
| 1874 // document will not work. |
| 1875 auto has_scrollbar = [](RenderFrameHostImpl* rfh) { |
| 1876 int client_width; |
| 1877 EXPECT_TRUE(ExecuteScriptAndExtractInt(rfh, |
| 1878 "window.domAutomationController.send(document.body.clientWidth);", |
| 1879 &client_width)); |
| 1880 const int kFrameElementWidth = 200; |
| 1881 return client_width < kFrameElementWidth; |
| 1882 }; |
| 1883 |
| 1884 auto set_scrolling_property = [](RenderFrameHostImpl* parent_rfh, |
| 1885 const std::string& value) { |
| 1886 EXPECT_TRUE(ExecuteScript( |
| 1887 parent_rfh, |
| 1888 base::StringPrintf( |
| 1889 "document.getElementById('child-1').setAttribute(" |
| 1890 " 'scrolling', '%s');", value.c_str()))); |
| 1891 }; |
| 1892 |
| 1893 // Run the test over variety of parent/child cases. |
| 1894 GURL urls[] = { |
| 1895 // Remote to remote. |
| 1896 embedded_test_server()->GetURL("c.com", "/tall_page.html"), |
| 1897 // Remote to local. |
| 1898 embedded_test_server()->GetURL("a.com", "/tall_page.html"), |
| 1899 // Local to remote. |
| 1900 embedded_test_server()->GetURL("b.com", "/tall_page.html") |
| 1901 }; |
| 1902 const std::string scrolling_values[] = { |
| 1903 "yes", "auto", "no" |
| 1904 }; |
| 1905 |
| 1906 for (size_t i = 0; i < arraysize(scrolling_values); ++i) { |
| 1907 bool expect_scrollbar = scrolling_values[i] != "no"; |
| 1908 set_scrolling_property(root->current_frame_host(), scrolling_values[i]); |
| 1909 for (size_t j = 0; j < arraysize(urls); ++j) { |
| 1910 NavigateFrameToURL(child, urls[j]); |
| 1911 |
| 1912 // TODO(alexmos): This can be removed once TestFrameNavigationObserver is |
| 1913 // fixed to use DidFinishLoad. |
| 1914 EXPECT_TRUE(WaitForRenderFrameReady(child->current_frame_host())); |
| 1915 |
| 1916 EXPECT_EQ(expect_scrollbar, has_scrollbar(child->current_frame_host())); |
| 1917 } |
| 1918 } |
| 1919 } |
| 1920 |
| 1921 // Verify that "marginwidth" and "marginheight" properties on frame elements |
| 1922 // propagate to child frames correctly. |
| 1923 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| 1924 FrameOwnerPropertiesPropagationMargin) { |
| 1925 GURL main_url(embedded_test_server()->GetURL( |
| 1926 "a.com", "/frame_owner_properties_margin.html")); |
| 1927 NavigateToURL(shell(), main_url); |
| 1928 |
| 1929 // It is safe to obtain the root frame tree node here, as it doesn't change. |
| 1930 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 1931 ->GetFrameTree() |
| 1932 ->root(); |
| 1933 ASSERT_EQ(1u, root->child_count()); |
| 1934 |
| 1935 EXPECT_EQ( |
| 1936 " Site A ------------ proxies for B\n" |
| 1937 " +--Site B ------- proxies for A\n" |
| 1938 "Where A = http://a.com/\n" |
| 1939 " B = http://b.com/", |
| 1940 DepictFrameTree(root)); |
| 1941 |
| 1942 FrameTreeNode* child = root->child_at(0); |
| 1943 |
| 1944 std::string margin_width; |
| 1945 EXPECT_TRUE(ExecuteScriptAndExtractString( |
| 1946 child->current_frame_host(), |
| 1947 "window.domAutomationController.send(" |
| 1948 "document.body.getAttribute('marginwidth'));", |
| 1949 &margin_width)); |
| 1950 EXPECT_EQ("10", margin_width); |
| 1951 |
| 1952 std::string margin_height; |
| 1953 EXPECT_TRUE(ExecuteScriptAndExtractString( |
| 1954 child->current_frame_host(), |
| 1955 "window.domAutomationController.send(" |
| 1956 "document.body.getAttribute('marginheight'));", |
| 1957 &margin_height)); |
| 1958 EXPECT_EQ("50", margin_height); |
| 1959 |
| 1960 // Run the test over variety of parent/child cases. |
| 1961 GURL urls[] = { |
| 1962 // Remote to remote. |
| 1963 embedded_test_server()->GetURL("c.com", "/title2.html"), |
| 1964 // Remote to local. |
| 1965 embedded_test_server()->GetURL("a.com", "/title1.html"), |
| 1966 // Local to remote. |
| 1967 embedded_test_server()->GetURL("b.com", "/title2.html") |
| 1968 }; |
| 1969 |
| 1970 int current_margin_width = 15; |
| 1971 int current_margin_height = 25; |
| 1972 |
| 1973 // Before each navigation, we change the marginwidth and marginheight |
| 1974 // properties of the frame. We then check whether those properties are applied |
| 1975 // correctly after the navigation has completed. |
| 1976 for (size_t i = 0; i < arraysize(urls); ++i) { |
| 1977 // Change marginwidth and marginheight before navigating. |
| 1978 EXPECT_TRUE(ExecuteScript( |
| 1979 root->current_frame_host(), |
| 1980 base::StringPrintf( |
| 1981 "document.getElementById('child-1').setAttribute(" |
| 1982 " 'marginwidth', '%d');", current_margin_width))); |
| 1983 EXPECT_TRUE(ExecuteScript( |
| 1984 root->current_frame_host(), |
| 1985 base::StringPrintf( |
| 1986 "document.getElementById('child-1').setAttribute(" |
| 1987 " 'marginheight', '%d');", current_margin_height))); |
| 1988 |
| 1989 NavigateFrameToURL(child, urls[i]); |
| 1990 // TODO(alexmos): This can be removed once TestFrameNavigationObserver is |
| 1991 // fixed to use DidFinishLoad. |
| 1992 EXPECT_TRUE(WaitForRenderFrameReady(child->current_frame_host())); |
| 1993 |
| 1994 std::string actual_margin_width; |
| 1995 EXPECT_TRUE(ExecuteScriptAndExtractString( |
| 1996 child->current_frame_host(), |
| 1997 "window.domAutomationController.send(" |
| 1998 "document.body.getAttribute('marginwidth'));", |
| 1999 &actual_margin_width)); |
| 2000 EXPECT_EQ(base::IntToString(current_margin_width), actual_margin_width); |
| 2001 |
| 2002 std::string actual_margin_height; |
| 2003 EXPECT_TRUE(ExecuteScriptAndExtractString( |
| 2004 child->current_frame_host(), |
| 2005 "window.domAutomationController.send(" |
| 2006 "document.body.getAttribute('marginheight'));", |
| 2007 &actual_margin_height)); |
| 2008 EXPECT_EQ(base::IntToString(current_margin_height), actual_margin_height); |
| 2009 |
| 2010 current_margin_width += 5; |
| 2011 current_margin_height += 10; |
| 2012 } |
| 2013 } |
| 2014 |
1840 // Verify origin replication with an A-embed-B-embed-C-embed-A hierarchy. | 2015 // Verify origin replication with an A-embed-B-embed-C-embed-A hierarchy. |
1841 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginReplication) { | 2016 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginReplication) { |
1842 GURL main_url(embedded_test_server()->GetURL( | 2017 GURL main_url(embedded_test_server()->GetURL( |
1843 "a.com", "/cross_site_iframe_factory.html?a(b(c(a),b), a)")); | 2018 "a.com", "/cross_site_iframe_factory.html?a(b(c(a),b), a)")); |
1844 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 2019 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
1845 | 2020 |
1846 // It is safe to obtain the root frame tree node here, as it doesn't change. | 2021 // It is safe to obtain the root frame tree node here, as it doesn't change. |
1847 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 2022 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
1848 ->GetFrameTree() | 2023 ->GetFrameTree() |
1849 ->root(); | 2024 ->root(); |
(...skipping 1742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3592 | 3767 |
3593 // CursorMessageFilter::Wait() implicitly tests whether we receive a | 3768 // CursorMessageFilter::Wait() implicitly tests whether we receive a |
3594 // ViewHostMsg_SetCursor message from the renderer process, because it does | 3769 // ViewHostMsg_SetCursor message from the renderer process, because it does |
3595 // does not return otherwise. | 3770 // does not return otherwise. |
3596 filter->Wait(); | 3771 filter->Wait(); |
3597 EXPECT_EQ(filter->last_set_cursor_routing_id(), rwh_child->GetRoutingID()); | 3772 EXPECT_EQ(filter->last_set_cursor_routing_id(), rwh_child->GetRoutingID()); |
3598 } | 3773 } |
3599 #endif | 3774 #endif |
3600 | 3775 |
3601 } // namespace content | 3776 } // namespace content |
OLD | NEW |