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

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: Remove a stale comment 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 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 1237
1236 private: 1238 private:
1237 content::NotificationRegistrar registrar_; 1239 content::NotificationRegistrar registrar_;
1238 bool observed_; 1240 bool observed_;
1239 gfx::Point focused_node_bounds_in_screen_; 1241 gfx::Point focused_node_bounds_in_screen_;
1240 scoped_refptr<content::MessageLoopRunner> loop_runner_; 1242 scoped_refptr<content::MessageLoopRunner> loop_runner_;
1241 1243
1242 DISALLOW_COPY_AND_ASSIGN(FocusedEditableNodeChangedObserver); 1244 DISALLOW_COPY_AND_ASSIGN(FocusedEditableNodeChangedObserver);
1243 }; 1245 };
1244 1246
1247 // Waits until transforming |sample_point| from |render_frame_host| coordinates
1248 // to its root frame's view's coordinates matches |transformed_point| within a
1249 // reasonable error margin less than or equal to |bound|. This method is used to
1250 // verify CSS changes on OOPIFs have been applied properly and the corresponding
1251 // compositor frame is updated as well. This way we can rest assured that the
1252 // future transformed and reported bounds for the elements inside
1253 // |render_frame_host| are correct.
1254 void WaitForFramePositionUpdated(content::RenderFrameHost* render_frame_host,
1255 const gfx::Point& sample_point,
1256 const gfx::Point& transformed_point,
1257 float bound) {
1258 while ((transformed_point -
1259 render_frame_host->GetView()->TransformPointToRootCoordSpace(
1260 sample_point))
1261 .Length() > bound) {
1262 base::RunLoop run_loop;
1263 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
1264 FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout());
1265 run_loop.Run();
1266 }
1267 }
1245 // This test verifies that displacements (margin, etc) in the position of an 1268 // This test verifies that displacements (margin, etc) in the position of an
1246 // OOPIF is considered when showing an AutofillClient warning pop-up for 1269 // OOPIF is considered when showing an AutofillClient warning pop-up for
1247 // unsecure web sites. 1270 // unsecure web sites.
1248 // Test is flaky. crbug.com/705914
1249 IN_PROC_BROWSER_TEST_F(SitePerProcessAutofillTest, 1271 IN_PROC_BROWSER_TEST_F(SitePerProcessAutofillTest,
1250 DISABLED_PasswordAutofillPopupPositionInsideOOPIF) { 1272 PasswordAutofillPopupPositionInsideOOPIF) {
1251 SetupMainTab(); 1273 SetupMainTab();
1252 ASSERT_TRUE( 1274 ASSERT_TRUE(
1253 base::FeatureList::IsEnabled(security_state::kHttpFormWarningFeature)); 1275 base::FeatureList::IsEnabled(security_state::kHttpFormWarningFeature));
1254 1276
1255 GURL main_url(embedded_test_server()->GetURL("a.com", "/iframe.html")); 1277 GURL main_url(embedded_test_server()->GetURL("a.com", "/iframe.html"));
1256 ui_test_utils::NavigateToURL(browser(), main_url); 1278 ui_test_utils::NavigateToURL(browser(), main_url);
1257 content::WebContents* active_web_contents = 1279 content::WebContents* active_web_contents =
1258 browser()->tab_strip_model()->GetActiveWebContents(); 1280 browser()->tab_strip_model()->GetActiveWebContents();
1259 1281
1260 // Add some displacement for <iframe>. 1282 // Add some displacement for <iframe>.
1261 ASSERT_TRUE(content::ExecuteScript( 1283 ASSERT_TRUE(content::ExecuteScript(
1262 active_web_contents, 1284 active_web_contents,
1263 base::StringPrintf("var iframe = document.querySelector('iframe');" 1285 base::StringPrintf("var iframe = document.querySelector('iframe');"
1264 "iframe.style.marginTop = '%dpx';" 1286 "iframe.style.position = 'fixed';"
1265 "iframe.style.marginLeft = '%dpx';", 1287 "iframe.style.border = 'none';"
1288 "iframe.style.top = '%dpx';"
1289 "iframe.style.left = '%dpx';",
1266 kIframeTopDisplacement, kIframeLeftDisplacement))); 1290 kIframeTopDisplacement, kIframeLeftDisplacement)));
1267 1291
1268 // Navigate the <iframe> to a simple page. 1292 // Navigate the <iframe> to a simple page.
1269 GURL frame_url = embedded_test_server()->GetURL("b.com", "/title1.html"); 1293 GURL frame_url = embedded_test_server()->GetURL("b.com", "/title1.html");
1270 EXPECT_TRUE(NavigateIframeToURL(active_web_contents, "test", frame_url)); 1294 EXPECT_TRUE(NavigateIframeToURL(active_web_contents, "test", frame_url));
1271 content::RenderFrameHost* child_frame = content::FrameMatchingPredicate( 1295 content::RenderFrameHost* child_frame = content::FrameMatchingPredicate(
1272 active_web_contents, base::Bind(&content::FrameIsChildOfMainFrame)); 1296 active_web_contents, base::Bind(&content::FrameIsChildOfMainFrame));
1273 1297
1298 WaitForFramePositionUpdated(
1299 child_frame, gfx::Point(),
1300 gfx::Point(kIframeLeftDisplacement, kIframeTopDisplacement), 1.4143f);
1301
1274 // We will need to listen to focus changes to find out about the container 1302 // We will need to listen to focus changes to find out about the container
1275 // bounds of any focused <input> elements on the page. 1303 // bounds of any focused <input> elements on the page.
1276 FocusedEditableNodeChangedObserver focus_observer; 1304 FocusedEditableNodeChangedObserver focus_observer;
1277 1305
1278 // Focus the child frame, add an <input> with type "password", and focus it. 1306 // Focus the child frame, add an <input> with type "password", and focus it.
1279 ASSERT_TRUE(ExecuteScript(child_frame, 1307 ASSERT_TRUE(ExecuteScript(child_frame,
1280 "window.focus();" 1308 "window.focus();"
1281 "var input = document.createElement('input');" 1309 "var input = document.createElement('input');"
1282 "input.type = 'password';" 1310 "input.type = 'password';"
1283 "document.body.appendChild(input);" 1311 "document.body.appendChild(input);"
(...skipping 21 matching lines...) Expand all
1305 1333
1306 // Ideally, the length of the error vector should be 0.0f. But due to 1334 // Ideally, the length of the error vector should be 0.0f. But due to
1307 // potential rounding errors, we assume a larger limit (which is slightly 1335 // potential rounding errors, we assume a larger limit (which is slightly
1308 // larger than square root of 2). 1336 // larger than square root of 2).
1309 EXPECT_LT(error.Length(), 1.4143f) 1337 EXPECT_LT(error.Length(), 1.4143f)
1310 << "Origin of bounds from focused node changed event is '" 1338 << "Origin of bounds from focused node changed event is '"
1311 << focus_observer.focused_node_bounds_in_screen().ToString() 1339 << focus_observer.focused_node_bounds_in_screen().ToString()
1312 << "' but AutofillClient is reporting '" << bounds_origin.ToString() 1340 << "' but AutofillClient is reporting '" << bounds_origin.ToString()
1313 << "'"; 1341 << "'";
1314 } 1342 }
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