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 1794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1805 cross_site_rfh_type.c_str()); | 1805 cross_site_rfh_type.c_str()); |
1806 EXPECT_EQ(tree, DepictFrameTree(root)); | 1806 EXPECT_EQ(tree, DepictFrameTree(root)); |
1807 | 1807 |
1808 navigation_observer.Wait(); | 1808 navigation_observer.Wait(); |
1809 EXPECT_TRUE(observer.last_navigation_succeeded()); | 1809 EXPECT_TRUE(observer.last_navigation_succeeded()); |
1810 EXPECT_EQ(cross_site_url, observer.last_navigation_url()); | 1810 EXPECT_EQ(cross_site_url, observer.last_navigation_url()); |
1811 EXPECT_EQ(0U, child->child_count()); | 1811 EXPECT_EQ(0U, child->child_count()); |
1812 } | 1812 } |
1813 } | 1813 } |
1814 | 1814 |
1815 // Verify that scrolling property propagates to child frames correctly. | |
1816 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | |
1817 FrameOwnerPropertiesPropagationScrolling) { | |
1818 GURL main_url(embedded_test_server()->GetURL( | |
1819 "a.com", "/frame_owner_properties_scrolling.html")); | |
1820 NavigateToURL(shell(), main_url); | |
1821 | |
1822 // It is safe to obtain the root frame tree node here, as it doesn't change. | |
1823 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | |
1824 ->GetFrameTree() | |
1825 ->root(); | |
1826 ASSERT_EQ(1u, root->child_count()); | |
1827 | |
1828 EXPECT_EQ( | |
1829 " Site A ------------ proxies for B\n" | |
1830 " +--Site B ------- proxies for A\n" | |
1831 "Where A = http://a.com/\n" | |
1832 " B = http://b.com/", | |
1833 DepictFrameTree(root)); | |
1834 | |
1835 FrameTreeNode* child = root->child_at(0); | |
1836 | |
1837 auto has_scrollbar = [](RenderFrameHostImpl* rfh) { | |
1838 int client_width; | |
1839 EXPECT_TRUE(ExecuteScriptAndExtractInt(rfh, | |
1840 "window.domAutomationController.send(document.body.clientWidth);", | |
1841 &client_width)); | |
1842 const int THRESHOLD = 4; | |
1843 const int FRAME_ELEMENT_WIDTH = 200; | |
alexmos
2015/09/23 22:38:27
I wonder if there's an easier way to check if the
lazyboy
2015/09/30 23:37:54
That gives us whether there's any content to scrol
alexmos
2015/10/02 21:24:19
Acknowledged. Perhaps explain the need for thresh
lazyboy
2015/10/05 22:16:08
Done.
| |
1844 return client_width + THRESHOLD < FRAME_ELEMENT_WIDTH; | |
1845 }; | |
1846 | |
1847 auto set_scrolling_property = [](RenderFrameHostImpl* parent_rfh, | |
1848 const std::string& value) { | |
1849 EXPECT_TRUE(ExecuteScript( | |
1850 parent_rfh, | |
1851 base::StringPrintf( | |
1852 "window.domAutomationController.send(" | |
alexmos
2015/09/23 22:38:27
I don't think ExecuteScript needs the domAutomatio
lazyboy
2015/09/30 23:37:54
Done.
| |
1853 "document.getElementById('child-1').setAttribute(" | |
1854 " 'scrolling', '%s'));", value.c_str()))); | |
1855 }; | |
1856 | |
1857 GURL urls[4] = { | |
alexmos
2015/09/23 22:38:27
nit: can omit array size, here and below.
lazyboy
2015/09/30 23:37:54
Done.
| |
1858 // Remote to remote. | |
1859 embedded_test_server()->GetURL("b.com", "/tall_page1.html"), | |
1860 // Remote to local. | |
1861 embedded_test_server()->GetURL("a.com", "/tall_page1.html"), | |
1862 // Local to local. | |
1863 embedded_test_server()->GetURL("a.com", "/tall_page2.html"), | |
alexmos
2015/09/23 22:38:27
Do we really need to test the local-to-local case?
lazyboy
2015/09/30 23:37:54
Removed local to local case.
| |
1864 // Local to remote. | |
1865 embedded_test_server()->GetURL("b.com", "/tall_page2.html") | |
alexmos
2015/09/23 22:38:27
Can we get away with using just one tall page? Do
lazyboy
2015/09/30 23:37:54
Using one tall_page.html
| |
1866 }; | |
1867 const std::string scrolling_values[3] = { | |
1868 "yes", "auto", "no" | |
1869 }; | |
1870 | |
1871 for (size_t i = 0; i < arraysize(scrolling_values); ++i) { | |
1872 bool expect_scrollbar = scrolling_values[i] != "no"; | |
1873 set_scrolling_property(root->current_frame_host(), scrolling_values[i]); | |
1874 for (size_t j = 0; j < arraysize(urls); ++j) { | |
1875 NavigateFrameToURL(child, urls[j]); | |
1876 | |
1877 // TODO(alexmos): This can be removed once TestFrameNavigationObserver is | |
1878 // fixed to use DidFinishLoad. | |
1879 EXPECT_TRUE( | |
alexmos
2015/09/23 22:38:27
nit: line break doesn't look necessary.
lazyboy
2015/09/30 23:37:54
Done.
| |
1880 WaitForRenderFrameReady(child->current_frame_host())); | |
1881 | |
1882 EXPECT_EQ(expect_scrollbar, has_scrollbar(child->current_frame_host())); | |
1883 } | |
1884 } | |
1885 } | |
1886 | |
1887 // Verify that marginwidth and marginheight properties propagate to child | |
1888 // frames correctly. | |
1889 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | |
1890 FrameOwnerPropertiesPropagationMargin) { | |
1891 GURL main_url(embedded_test_server()->GetURL( | |
1892 "a.com", "/frame_owner_properties_margin.html")); | |
1893 NavigateToURL(shell(), main_url); | |
1894 | |
1895 // It is safe to obtain the root frame tree node here, as it doesn't change. | |
1896 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | |
1897 ->GetFrameTree() | |
1898 ->root(); | |
1899 ASSERT_EQ(1u, root->child_count()); | |
1900 | |
1901 EXPECT_EQ( | |
1902 " Site A ------------ proxies for B\n" | |
1903 " +--Site B ------- proxies for A\n" | |
1904 "Where A = http://a.com/\n" | |
1905 " B = http://b.com/", | |
1906 DepictFrameTree(root)); | |
1907 | |
1908 FrameTreeNode* child = root->child_at(0); | |
1909 | |
1910 std::string margin_width; | |
1911 EXPECT_TRUE(ExecuteScriptAndExtractString( | |
1912 child->current_frame_host(), | |
1913 "window.domAutomationController.send(" | |
1914 "document.body.getAttribute('marginwidth'));", | |
1915 &margin_width)); | |
1916 EXPECT_EQ("10", margin_width); | |
1917 | |
1918 std::string margin_height; | |
1919 EXPECT_TRUE(ExecuteScriptAndExtractString( | |
1920 child->current_frame_host(), | |
1921 "window.domAutomationController.send(" | |
1922 "document.body.getAttribute('marginheight'));", | |
1923 &margin_height)); | |
1924 EXPECT_EQ("50", margin_height); | |
1925 | |
1926 GURL urls[4] = { | |
1927 // Remote to remote. | |
1928 embedded_test_server()->GetURL("b.com", "/title1.html"), | |
1929 // Remote to local. | |
1930 embedded_test_server()->GetURL("a.com", "/title1.html"), | |
1931 // Local to local. | |
1932 embedded_test_server()->GetURL("a.com", "/title2.html"), | |
1933 // Local to remote. | |
1934 embedded_test_server()->GetURL("b.com", "/title2.html") | |
1935 }; | |
1936 | |
1937 int current_margin_width = 15; | |
1938 int current_margin_height = 25; | |
1939 for (size_t i = 0; i < arraysize(urls); ++i) { | |
1940 // Change marginwidth and marginheight before navigating. | |
1941 EXPECT_TRUE(ExecuteScript( | |
1942 root->current_frame_host(), | |
1943 base::StringPrintf( | |
1944 "window.domAutomationController.send(" | |
alexmos
2015/09/23 22:38:27
See earlier comment about domAutomationController.
lazyboy
2015/09/30 23:37:54
Done.
| |
1945 "document.getElementById('child-1').setAttribute(" | |
1946 " 'marginwidth', '%d'));", current_margin_width))); | |
1947 EXPECT_TRUE(ExecuteScript( | |
1948 root->current_frame_host(), | |
1949 base::StringPrintf( | |
1950 "window.domAutomationController.send(" | |
1951 "document.getElementById('child-1').setAttribute(" | |
1952 " 'marginheight', '%d'));", current_margin_height))); | |
1953 | |
1954 // Navigate. | |
alexmos
2015/09/23 22:38:27
nit: no need for this comment. Instead, maybe exp
lazyboy
2015/09/30 23:37:54
Done.
| |
1955 NavigateFrameToURL(child, urls[i]); | |
1956 // TODO(alexmos): This can be removed once TestFrameNavigationObserver is | |
1957 // fixed to use DidFinishLoad. | |
1958 EXPECT_TRUE( | |
alexmos
2015/09/23 22:38:27
nit: no line break
lazyboy
2015/09/30 23:37:54
Done.
| |
1959 WaitForRenderFrameReady(child->current_frame_host())); | |
1960 | |
1961 std::string actual_margin_width; | |
1962 EXPECT_TRUE(ExecuteScriptAndExtractString( | |
1963 child->current_frame_host(), | |
1964 "window.domAutomationController.send(" | |
1965 "document.body.getAttribute('marginwidth'));", | |
1966 &actual_margin_width)); | |
1967 EXPECT_EQ(base::IntToString(current_margin_width), actual_margin_width); | |
1968 | |
1969 std::string actual_margin_height; | |
1970 EXPECT_TRUE(ExecuteScriptAndExtractString( | |
alexmos
2015/09/23 22:38:27
Does ExecuteScriptAndExtractInt not work for these
lazyboy
2015/09/30 23:37:54
No. getAttribute returns string.
alexmos
2015/10/02 21:24:19
Acknowledged.
| |
1971 child->current_frame_host(), | |
1972 "window.domAutomationController.send(" | |
1973 "document.body.getAttribute('marginheight'));", | |
1974 &actual_margin_height)); | |
1975 EXPECT_EQ(base::IntToString(current_margin_height), actual_margin_height); | |
1976 | |
1977 current_margin_width += 5; | |
1978 current_margin_height += 10; | |
1979 } | |
1980 } | |
1981 | |
1815 // Verify origin replication with an A-embed-B-embed-C-embed-A hierarchy. | 1982 // Verify origin replication with an A-embed-B-embed-C-embed-A hierarchy. |
1816 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginReplication) { | 1983 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginReplication) { |
1817 GURL main_url(embedded_test_server()->GetURL( | 1984 GURL main_url(embedded_test_server()->GetURL( |
1818 "a.com", "/cross_site_iframe_factory.html?a(b(c(a),b), a)")); | 1985 "a.com", "/cross_site_iframe_factory.html?a(b(c(a),b), a)")); |
1819 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 1986 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
1820 | 1987 |
1821 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1988 // It is safe to obtain the root frame tree node here, as it doesn't change. |
1822 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 1989 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
1823 ->GetFrameTree() | 1990 ->GetFrameTree() |
1824 ->root(); | 1991 ->root(); |
(...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3365 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 3532 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
3366 popup_root->child_at(0)->current_frame_host(), | 3533 popup_root->child_at(0)->current_frame_host(), |
3367 "window.domAutomationController.send(" | 3534 "window.domAutomationController.send(" |
3368 " postToOpenerOfSibling('subframe2', 'msg', '*'));", | 3535 " postToOpenerOfSibling('subframe2', 'msg', '*'));", |
3369 &success)); | 3536 &success)); |
3370 EXPECT_TRUE(success); | 3537 EXPECT_TRUE(success); |
3371 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | 3538 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
3372 } | 3539 } |
3373 | 3540 |
3374 } // namespace content | 3541 } // namespace content |
OLD | NEW |