Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2129)

Unified Diff: content/browser/site_per_process_browsertest.cc

Issue 1307013004: Propagate scrolling/marginwidth/marginheight property values to child frame. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from dcheng@ Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/site_per_process_browsertest.cc
diff --git a/content/browser/site_per_process_browsertest.cc b/content/browser/site_per_process_browsertest.cc
index 8a907d52d7d44a38dfba270d7488ff27cf59572c..0a0e654cf2fe1e0a5ad3cb0f5cd23f0f191bc387 100644
--- a/content/browser/site_per_process_browsertest.cc
+++ b/content/browser/site_per_process_browsertest.cc
@@ -1836,6 +1836,169 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
}
}
+// Verify that "scrolling" property on frame elements propagates to child frames
+// correctly.
+IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
+ FrameOwnerPropertiesPropagationScrolling) {
+ GURL main_url(embedded_test_server()->GetURL(
+ "a.com", "/frame_owner_properties_scrolling.html"));
+ NavigateToURL(shell(), main_url);
+
+ // It is safe to obtain the root frame tree node here, as it doesn't change.
+ FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
+ ->GetFrameTree()
+ ->root();
+ ASSERT_EQ(1u, root->child_count());
+
+ EXPECT_EQ(
+ " Site A ------------ proxies for B\n"
+ " +--Site B ------- proxies for A\n"
+ "Where A = http://a.com/\n"
+ " B = http://b.com/",
+ DepictFrameTree(root));
+
+ FrameTreeNode* child = root->child_at(0);
+
+ auto has_scrollbar = [](RenderFrameHostImpl* rfh) {
+ int client_width;
+ EXPECT_TRUE(ExecuteScriptAndExtractInt(rfh,
+ "window.domAutomationController.send(document.body.clientWidth);",
+ &client_width));
+ // Add a threshold to avoid any off-by-some pixels issue.
+ const int THRESHOLD = 4;
dcheng 2015/10/12 04:50:01 kThreshhold, kFrameElementWidth, etc.
lazyboy 2015/10/13 21:59:08 Done.
+ const int FRAME_ELEMENT_WIDTH = 200;
+ return client_width + THRESHOLD < FRAME_ELEMENT_WIDTH;
+ };
+
+ auto set_scrolling_property = [](RenderFrameHostImpl* parent_rfh,
+ const std::string& value) {
+ EXPECT_TRUE(ExecuteScript(
+ parent_rfh,
+ base::StringPrintf(
+ "document.getElementById('child-1').setAttribute("
+ " 'scrolling', '%s');", value.c_str())));
+ };
+
+ GURL urls[] = {
+ // Remote to remote.
+ embedded_test_server()->GetURL("b.com", "/tall_page.html"),
+ // Remote to local.
+ embedded_test_server()->GetURL("a.com", "/tall_page.html"),
+ // Local to remote.
+ embedded_test_server()->GetURL("b.com", "/tall_page.html")
+ };
+ const std::string scrolling_values[] = {
+ "yes", "auto", "no"
+ };
+
+ for (size_t i = 0; i < arraysize(scrolling_values); ++i) {
+ bool expect_scrollbar = scrolling_values[i] != "no";
+ set_scrolling_property(root->current_frame_host(), scrolling_values[i]);
+ for (size_t j = 0; j < arraysize(urls); ++j) {
+ NavigateFrameToURL(child, urls[j]);
+
+ // TODO(alexmos): This can be removed once TestFrameNavigationObserver is
+ // fixed to use DidFinishLoad.
+ EXPECT_TRUE(WaitForRenderFrameReady(child->current_frame_host()));
+
+ EXPECT_EQ(expect_scrollbar, has_scrollbar(child->current_frame_host()));
+ }
+ }
+}
+
+// Verify that "marginwidth" and "marginheight" properties on frame elements
+// propagate to child frames correctly.
+IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
+ FrameOwnerPropertiesPropagationMargin) {
+ GURL main_url(embedded_test_server()->GetURL(
+ "a.com", "/frame_owner_properties_margin.html"));
+ NavigateToURL(shell(), main_url);
+
+ // It is safe to obtain the root frame tree node here, as it doesn't change.
+ FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
+ ->GetFrameTree()
+ ->root();
+ ASSERT_EQ(1u, root->child_count());
+
+ EXPECT_EQ(
+ " Site A ------------ proxies for B\n"
+ " +--Site B ------- proxies for A\n"
+ "Where A = http://a.com/\n"
+ " B = http://b.com/",
+ DepictFrameTree(root));
+
+ FrameTreeNode* child = root->child_at(0);
+
+ std::string margin_width;
+ EXPECT_TRUE(ExecuteScriptAndExtractString(
+ child->current_frame_host(),
+ "window.domAutomationController.send("
+ "document.body.getAttribute('marginwidth'));",
+ &margin_width));
+ EXPECT_EQ("10", margin_width);
+
+ std::string margin_height;
+ EXPECT_TRUE(ExecuteScriptAndExtractString(
+ child->current_frame_host(),
+ "window.domAutomationController.send("
+ "document.body.getAttribute('marginheight'));",
+ &margin_height));
+ EXPECT_EQ("50", margin_height);
+
+ GURL urls[] = {
+ // Remote to remote.
+ embedded_test_server()->GetURL("b.com", "/title2.html"),
+ // Remote to local.
+ embedded_test_server()->GetURL("a.com", "/title1.html"),
+ // Local to remote.
+ embedded_test_server()->GetURL("b.com", "/title2.html")
+ };
+
+ int current_margin_width = 15;
+ int current_margin_height = 25;
+
+ // Before each navigation, we change the marginwidth and marginheight
+ // properties of the frame. We then check whether those properties are applied
+ // correctly after the navigation has completed.
+ for (size_t i = 0; i < arraysize(urls); ++i) {
+ // Change marginwidth and marginheight before navigating.
+ EXPECT_TRUE(ExecuteScript(
+ root->current_frame_host(),
+ base::StringPrintf(
+ "document.getElementById('child-1').setAttribute("
+ " 'marginwidth', '%d');", current_margin_width)));
+ EXPECT_TRUE(ExecuteScript(
+ root->current_frame_host(),
+ base::StringPrintf(
+ "document.getElementById('child-1').setAttribute("
+ " 'marginheight', '%d');", current_margin_height)));
+
+ NavigateFrameToURL(child, urls[i]);
+ // TODO(alexmos): This can be removed once TestFrameNavigationObserver is
+ // fixed to use DidFinishLoad.
+ EXPECT_TRUE(WaitForRenderFrameReady(child->current_frame_host()));
+
+ std::string actual_margin_width;
+ EXPECT_TRUE(ExecuteScriptAndExtractString(
+ child->current_frame_host(),
+ "window.domAutomationController.send("
+ "document.body.getAttribute('marginwidth'));",
+ &actual_margin_width));
+ EXPECT_EQ(base::IntToString(current_margin_width), actual_margin_width);
+
+ std::string actual_margin_height;
+ EXPECT_TRUE(ExecuteScriptAndExtractString(
+ child->current_frame_host(),
+ "window.domAutomationController.send("
+ "document.body.getAttribute('marginheight'));",
+ &actual_margin_height));
+ EXPECT_EQ(base::IntToString(current_margin_height), actual_margin_height);
+
+ current_margin_width += 5;
+ current_margin_height += 10;
+ }
+}
+
// Verify origin replication with an A-embed-B-embed-C-embed-A hierarchy.
IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginReplication) {
GURL main_url(embedded_test_server()->GetURL(

Powered by Google App Engine
This is Rietveld 408576698