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

Side by Side Diff: chrome/browser/site_per_process_interactive_browsertest.cc

Issue 2781903002: Modify a test to wait for compositor frame of OOPIF synced with CSS modifications in parent process (Closed)
Patch Set: Addressing comments Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/strings/string_number_conversions.h" 6 #include "base/strings/string_number_conversions.h"
7 #include "base/test/scoped_feature_list.h" 7 #include "base/test/scoped_feature_list.h"
8 #include "base/test/test_timeouts.h"
8 #include "chrome/browser/password_manager/chrome_password_manager_client.h" 9 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
9 #include "chrome/browser/renderer_context_menu/render_view_context_menu_browsert est_util.h" 10 #include "chrome/browser/renderer_context_menu/render_view_context_menu_browsert est_util.h"
10 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_window.h" 12 #include "chrome/browser/ui/browser_window.h"
12 #include "chrome/browser/ui/exclusive_access/fullscreen_controller_test.h" 13 #include "chrome/browser/ui/exclusive_access/fullscreen_controller_test.h"
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" 14 #include "chrome/browser/ui/tabs/tab_strip_model.h"
14 #include "chrome/test/base/in_process_browser_test.h" 15 #include "chrome/test/base/in_process_browser_test.h"
15 #include "chrome/test/base/interactive_test_utils.h" 16 #include "chrome/test/base/interactive_test_utils.h"
16 #include "chrome/test/base/ui_test_utils.h" 17 #include "chrome/test/base/ui_test_utils.h"
17 #include "components/autofill/core/browser/autofill_client.h" 18 #include "components/autofill/core/browser/autofill_client.h"
18 #include "components/autofill/core/browser/test_autofill_client.h" 19 #include "components/autofill/core/browser/test_autofill_client.h"
19 #include "components/guest_view/browser/guest_view_manager_delegate.h" 20 #include "components/guest_view/browser/guest_view_manager_delegate.h"
20 #include "components/guest_view/browser/test_guest_view_manager.h" 21 #include "components/guest_view/browser/test_guest_view_manager.h"
21 #include "components/security_state/core/security_state.h" 22 #include "components/security_state/core/security_state.h"
23 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/focused_node_details.h" 24 #include "content/public/browser/focused_node_details.h"
23 #include "content/public/browser/navigation_handle.h" 25 #include "content/public/browser/navigation_handle.h"
24 #include "content/public/browser/notification_details.h" 26 #include "content/public/browser/notification_details.h"
25 #include "content/public/browser/notification_observer.h" 27 #include "content/public/browser/notification_observer.h"
26 #include "content/public/browser/notification_registrar.h" 28 #include "content/public/browser/notification_registrar.h"
27 #include "content/public/browser/notification_service.h" 29 #include "content/public/browser/notification_service.h"
28 #include "content/public/browser/notification_source.h" 30 #include "content/public/browser/notification_source.h"
29 #include "content/public/browser/render_frame_host.h" 31 #include "content/public/browser/render_frame_host.h"
30 #include "content/public/browser/render_widget_host.h" 32 #include "content/public/browser/render_widget_host.h"
31 #include "content/public/browser/render_widget_host_view.h" 33 #include "content/public/browser/render_widget_host_view.h"
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 1063
1062 private: 1064 private:
1063 content::NotificationRegistrar registrar_; 1065 content::NotificationRegistrar registrar_;
1064 bool observed_; 1066 bool observed_;
1065 gfx::Point focused_node_bounds_in_screen_; 1067 gfx::Point focused_node_bounds_in_screen_;
1066 scoped_refptr<content::MessageLoopRunner> loop_runner_; 1068 scoped_refptr<content::MessageLoopRunner> loop_runner_;
1067 1069
1068 DISALLOW_COPY_AND_ASSIGN(FocusedEditableNodeChangedObserver); 1070 DISALLOW_COPY_AND_ASSIGN(FocusedEditableNodeChangedObserver);
1069 }; 1071 };
1070 1072
1073 // Waits until transforming |sample_point| from |render_frame_host| coordinates
1074 // to its root frame's view's coordinates matches |transformed_point| within a
1075 // reasonable error margin less than or equal to |bound|. This method is used to
1076 // verify CSS changes on OOPIFs have been applied properly and the corresponding
1077 // compositor frame is updated as well. This way we can rest assured that the
1078 // future transformed and reported bounds for the elements inside
1079 // |render_frame_host| are correct.
1080 void WaitForFramePositionUpdated(content::RenderFrameHost* render_frame_host,
1081 const gfx::Point& sample_point,
1082 const gfx::Point& transformed_point,
1083 float bound) {
1084 while ((transformed_point -
1085 render_frame_host->GetView()->TransformPointToRootCoordSpace(
1086 sample_point))
1087 .Length() > bound) {
1088 base::RunLoop run_loop;
1089 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
1090 FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout());
1091 run_loop.Run();
1092 }
1093 }
1071 // This test verifies that displacements (margin, etc) in the position of an 1094 // This test verifies that displacements (margin, etc) in the position of an
1072 // OOPIF is considered when showing an AutofillClient warning pop-up for 1095 // OOPIF is considered when showing an AutofillClient warning pop-up for
1073 // unsecure web sites. 1096 // unsecure web sites.
1074 IN_PROC_BROWSER_TEST_F(SitePerProcessAutofillTest, 1097 IN_PROC_BROWSER_TEST_F(SitePerProcessAutofillTest,
1075 PasswordAutofillPopupPositionInsideOOPIF) { 1098 PasswordAutofillPopupPositionInsideOOPIF) {
alexmos 2017/03/28 19:48:13 Looks like the test was disabled in https://bugs.c
EhsanK 2017/03/28 20:11:09 Thanks for reminding me. Done!
1076 SetupMainTab(); 1099 SetupMainTab();
1077 ASSERT_TRUE( 1100 ASSERT_TRUE(
1078 base::FeatureList::IsEnabled(security_state::kHttpFormWarningFeature)); 1101 base::FeatureList::IsEnabled(security_state::kHttpFormWarningFeature));
1079 1102
1080 GURL main_url(embedded_test_server()->GetURL("a.com", "/iframe.html")); 1103 GURL main_url(embedded_test_server()->GetURL("a.com", "/iframe.html"));
1081 ui_test_utils::NavigateToURL(browser(), main_url); 1104 ui_test_utils::NavigateToURL(browser(), main_url);
1082 content::WebContents* active_web_contents = 1105 content::WebContents* active_web_contents =
1083 browser()->tab_strip_model()->GetActiveWebContents(); 1106 browser()->tab_strip_model()->GetActiveWebContents();
1084 1107
1085 // Add some displacement for <iframe>. 1108 // Add some displacement for <iframe>.
1086 ASSERT_TRUE(content::ExecuteScript( 1109 ASSERT_TRUE(content::ExecuteScript(
1087 active_web_contents, 1110 active_web_contents,
1088 base::StringPrintf("var iframe = document.querySelector('iframe');" 1111 base::StringPrintf("var iframe = document.querySelector('iframe');"
1089 "iframe.style.marginTop = '%dpx';" 1112 "iframe.style.position = 'fixed';"
1090 "iframe.style.marginLeft = '%dpx';", 1113 "iframe.style.border = 'none';"
1114 "iframe.style.top = '%dpx';"
1115 "iframe.style.left = '%dpx';",
1091 kIframeTopDisplacement, kIframeLeftDisplacement))); 1116 kIframeTopDisplacement, kIframeLeftDisplacement)));
1092 1117
1093 // Navigate the <iframe> to a simple page. 1118 // Navigate the <iframe> to a simple page.
1094 GURL frame_url = embedded_test_server()->GetURL("b.com", "/title1.html"); 1119 GURL frame_url = embedded_test_server()->GetURL("b.com", "/title1.html");
1095 EXPECT_TRUE(NavigateIframeToURL(active_web_contents, "test", frame_url)); 1120 EXPECT_TRUE(NavigateIframeToURL(active_web_contents, "test", frame_url));
1096 content::RenderFrameHost* child_frame = content::FrameMatchingPredicate( 1121 content::RenderFrameHost* child_frame = content::FrameMatchingPredicate(
1097 active_web_contents, base::Bind(&content::FrameIsChildOfMainFrame)); 1122 active_web_contents, base::Bind(&content::FrameIsChildOfMainFrame));
1098 1123
1124 WaitForFramePositionUpdated(
1125 child_frame, gfx::Point(),
1126 gfx::Point(kIframeLeftDisplacement, kIframeTopDisplacement), 1.4143f);
1127
1099 // We will need to listen to focus changes to find out about the container 1128 // We will need to listen to focus changes to find out about the container
1100 // bounds of any focused <input> elements on the page. 1129 // bounds of any focused <input> elements on the page.
1101 FocusedEditableNodeChangedObserver focus_observer; 1130 FocusedEditableNodeChangedObserver focus_observer;
1102 1131
1103 // Focus the child frame, add an <input> with type "password", and focus it. 1132 // Focus the child frame, add an <input> with type "password", and focus it.
1104 ASSERT_TRUE(ExecuteScript(child_frame, 1133 ASSERT_TRUE(ExecuteScript(child_frame,
1105 "window.focus();" 1134 "window.focus();"
1106 "var input = document.createElement('input');" 1135 "var input = document.createElement('input');"
1107 "input.type = 'password';" 1136 "input.type = 'password';"
1108 "document.body.appendChild(input);" 1137 "document.body.appendChild(input);"
(...skipping 21 matching lines...) Expand all
1130 1159
1131 // Ideally, the length of the error vector should be 0.0f. But due to 1160 // Ideally, the length of the error vector should be 0.0f. But due to
1132 // potential rounding errors, we assume a larger limit (which is slightly 1161 // potential rounding errors, we assume a larger limit (which is slightly
1133 // larger than square root of 2). 1162 // larger than square root of 2).
1134 EXPECT_LT(error.Length(), 1.4143f) 1163 EXPECT_LT(error.Length(), 1.4143f)
1135 << "Origin of bounds from focused node changed event is '" 1164 << "Origin of bounds from focused node changed event is '"
1136 << focus_observer.focused_node_bounds_in_screen().ToString() 1165 << focus_observer.focused_node_bounds_in_screen().ToString()
1137 << "' but AutofillClient is reporting '" << bounds_origin.ToString() 1166 << "' but AutofillClient is reporting '" << bounds_origin.ToString()
1138 << "'"; 1167 << "'";
1139 } 1168 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698