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

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

Issue 2804303004: Revert of OOPIF: Enable TabAndMouseFocusNavigation. (Closed)
Patch Set: 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 | third_party/WebKit/Source/core/page/FocusController.cpp » ('j') | 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 "base/test/test_timeouts.h"
9 #include "chrome/browser/password_manager/chrome_password_manager_client.h" 9 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
10 #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"
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 EXPECT_EQ("\"child2-focused-input2\"", press_tab_and_wait_for_message(true)); 295 EXPECT_EQ("\"child2-focused-input2\"", press_tab_and_wait_for_message(true));
296 EXPECT_EQ(child2, web_contents->GetFocusedFrame()); 296 EXPECT_EQ(child2, web_contents->GetFocusedFrame());
297 EXPECT_EQ("\"child2-focused-input1\"", press_tab_and_wait_for_message(true)); 297 EXPECT_EQ("\"child2-focused-input1\"", press_tab_and_wait_for_message(true));
298 EXPECT_EQ("\"child1-focused-input2\"", press_tab_and_wait_for_message(true)); 298 EXPECT_EQ("\"child1-focused-input2\"", press_tab_and_wait_for_message(true));
299 EXPECT_EQ(child1, web_contents->GetFocusedFrame()); 299 EXPECT_EQ(child1, web_contents->GetFocusedFrame());
300 EXPECT_EQ("\"child1-focused-input1\"", press_tab_and_wait_for_message(true)); 300 EXPECT_EQ("\"child1-focused-input1\"", press_tab_and_wait_for_message(true));
301 EXPECT_EQ("\"root-focused-input1\"", press_tab_and_wait_for_message(true)); 301 EXPECT_EQ("\"root-focused-input1\"", press_tab_and_wait_for_message(true));
302 EXPECT_EQ(main_frame, web_contents->GetFocusedFrame()); 302 EXPECT_EQ(main_frame, web_contents->GetFocusedFrame());
303 } 303 }
304 304
305 #if (defined(OS_LINUX) && !defined(USE_OZONE)) || defined(OS_WIN) 305 // TODO(https://crbug.com/702330): Enable this test.
306 // Ensures that renderers know to advance focus to sibling frames and parent 306 // Ensures that renderers know to advance focus to sibling frames and parent
307 // frames in the presence of mouse click initiated focus changes. 307 // frames in the presence of mouse click initiated focus changes.
308 // Verifies against regression of https://crbug.com/702330
309 IN_PROC_BROWSER_TEST_F(SitePerProcessInteractiveBrowserTest, 308 IN_PROC_BROWSER_TEST_F(SitePerProcessInteractiveBrowserTest,
310 TabAndMouseFocusNavigation) { 309 DISABLED_TabAndMouseFocusNavigation) {
311 GURL main_url(embedded_test_server()->GetURL( 310 GURL main_url(embedded_test_server()->GetURL(
312 "a.com", "/cross_site_iframe_factory.html?a(b,c)")); 311 "a.com", "/cross_site_iframe_factory.html?a(b,c)"));
313 ui_test_utils::NavigateToURL(browser(), main_url); 312 ui_test_utils::NavigateToURL(browser(), main_url);
314 313
315 content::WebContents* web_contents = 314 content::WebContents* web_contents =
316 browser()->tab_strip_model()->GetActiveWebContents(); 315 browser()->tab_strip_model()->GetActiveWebContents();
317 316
318 content::RenderFrameHost* main_frame = web_contents->GetMainFrame(); 317 content::RenderFrameHost* main_frame = web_contents->GetMainFrame();
319 content::RenderFrameHost* child1 = ChildFrameAt(main_frame, 0); 318 content::RenderFrameHost* child1 = ChildFrameAt(main_frame, 0);
320 ASSERT_NE(nullptr, child1); 319 ASSERT_NE(nullptr, child1);
321 content::RenderFrameHost* child2 = ChildFrameAt(main_frame, 1); 320 content::RenderFrameHost* child2 = ChildFrameAt(main_frame, 1);
322 ASSERT_NE(nullptr, child2); 321 ASSERT_NE(nullptr, child2);
323 322
324 // Assign a name to each frame. This will be sent along in test messages 323 // Assign a name to each frame. This will be sent along in test messages
325 // from focus events. 324 // from focus events.
326 EXPECT_TRUE(ExecuteScript(main_frame, "window.name = 'root';")); 325 EXPECT_TRUE(ExecuteScript(main_frame, "window.name = 'root';"));
327 EXPECT_TRUE(ExecuteScript(child1, "window.name = 'child1';")); 326 EXPECT_TRUE(ExecuteScript(child1, "window.name = 'child1';"));
328 EXPECT_TRUE(ExecuteScript(child2, "window.name = 'child2';")); 327 EXPECT_TRUE(ExecuteScript(child2, "window.name = 'child2';"));
329 328
330 // This script will insert two <input> fields in the document, one at the 329 // This script will insert two <input> fields in the document, one at the
331 // beginning and one at the end. For root frame, this means that we will 330 // beginning and one at the end. For root frame, this means that we will
332 // have an <input>, then two <iframe> elements, then another <input>. 331 // have an <input>, then two <iframe> elements, then another <input>.
333 // The script will send back the coordinates to click for each <input>, in the 332 // The script will send back the coordinates to click for each <input>, in the
334 // document's space. Additionally, the outer frame will return the top left 333 // document's space. Additionally, the outer frame will return the top left
335 // point of each <iframe> to transform the coordinates of the inner <input> 334 // point of each <iframe> to transform the coordinates of the inner <input>
336 // elements. For example, main frame: 497,18;497,185:381,59;499,59 and each 335 // elements. For example, main frame: 497,18;497,185:381,59;499,59 and each
337 // iframe: 55,18;55,67 336 // iframe: 55,18;55,67
338 std::string script = 337 std::string script =
339 "function onFocus(e) {" 338 "function onFocus(e) {"
339 " console.log(window.name+'-focused-'+ e.target.id);"
340 " domAutomationController.setAutomationId(0);" 340 " domAutomationController.setAutomationId(0);"
341 " domAutomationController.send(window.name + '-focused-' + e.target.id);" 341 " domAutomationController.send(window.name + '-focused-' + e.target.id);"
342 "}" 342 "}"
343 "" 343 ""
344 "function getElementCoords(element) {" 344 "function getElementCoords(element) {"
345 " var rect = element.getBoundingClientRect();" 345 " var rect = element.getBoundingClientRect();"
346 " return Math.floor(rect.left + 0.5 * rect.width) +','+" 346 " return Math.floor(rect.left + 0.5 * rect.width) +','+"
347 " Math.floor(rect.top + 0.5 * rect.height);" 347 " Math.floor(rect.top + 0.5 * rect.height);"
348 "}" 348 "}"
349 "function getIframeCoords(element) {" 349 "function getIframeCoords(element) {"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 426
427 std::string reply; 427 std::string reply;
428 EXPECT_TRUE(msg_queue.WaitForMessage(&reply)); 428 EXPECT_TRUE(msg_queue.WaitForMessage(&reply));
429 return reply; 429 return reply;
430 }; 430 };
431 431
432 // Tab from child1 back to root. 432 // Tab from child1 back to root.
433 EXPECT_EQ("\"root-focused-input1\"", 433 EXPECT_EQ("\"root-focused-input1\"",
434 click_element_and_wait_for_message(main_frame_input_coords[0])); 434 click_element_and_wait_for_message(main_frame_input_coords[0]));
435 EXPECT_EQ(main_frame, web_contents->GetFocusedFrame()); 435 EXPECT_EQ(main_frame, web_contents->GetFocusedFrame());
436 auto frame_focused = base::MakeUnique<content::FrameFocusedObserver>(child1);
437 EXPECT_EQ("\"child1-focused-input1\"", 436 EXPECT_EQ("\"child1-focused-input1\"",
438 click_element_and_wait_for_message(child1_input_coords[0])); 437 click_element_and_wait_for_message(child1_input_coords[0]));
439 frame_focused->Wait(); 438 EXPECT_EQ(child1, web_contents->GetFocusedFrame());
440 frame_focused = base::MakeUnique<content::FrameFocusedObserver>(main_frame);
441 EXPECT_EQ("\"root-focused-input1\"", press_tab_and_wait_for_message(true)); 439 EXPECT_EQ("\"root-focused-input1\"", press_tab_and_wait_for_message(true));
442 frame_focused->Wait(); 440 EXPECT_EQ(main_frame, web_contents->GetFocusedFrame());
443 441
444 // Tab from child2 forward to root. 442 // Tab from child2 forward to root.
445 EXPECT_EQ("\"root-focused-input2\"", 443 EXPECT_EQ("\"root-focused-input2\"",
446 click_element_and_wait_for_message(main_frame_input_coords[1])); 444 click_element_and_wait_for_message(main_frame_input_coords[1]));
447 EXPECT_EQ(main_frame, web_contents->GetFocusedFrame()); 445 EXPECT_EQ(main_frame, web_contents->GetFocusedFrame());
448 frame_focused = base::MakeUnique<content::FrameFocusedObserver>(child2);
449 EXPECT_EQ("\"child2-focused-input2\"", 446 EXPECT_EQ("\"child2-focused-input2\"",
450 click_element_and_wait_for_message(child2_input_coords[1])); 447 click_element_and_wait_for_message(child2_input_coords[1]));
451 frame_focused->Wait(); 448 EXPECT_EQ(child2, web_contents->GetFocusedFrame());
452 frame_focused = base::MakeUnique<content::FrameFocusedObserver>(main_frame);
453 EXPECT_EQ("\"root-focused-input2\"", press_tab_and_wait_for_message(false)); 449 EXPECT_EQ("\"root-focused-input2\"", press_tab_and_wait_for_message(false));
454 frame_focused->Wait(); 450 EXPECT_EQ(main_frame, web_contents->GetFocusedFrame());
455 451
456 // Tab forward from child1 to child2. 452 // Tab forward from child1 to child2.
457 frame_focused = base::MakeUnique<content::FrameFocusedObserver>(child2);
458 EXPECT_EQ("\"child2-focused-input1\"", 453 EXPECT_EQ("\"child2-focused-input1\"",
459 click_element_and_wait_for_message(child2_input_coords[0])); 454 click_element_and_wait_for_message(child2_input_coords[0]));
460 frame_focused->Wait(); 455 EXPECT_EQ(child2, web_contents->GetFocusedFrame());
461 frame_focused = base::MakeUnique<content::FrameFocusedObserver>(child1);
462 EXPECT_EQ("\"child1-focused-input2\"", 456 EXPECT_EQ("\"child1-focused-input2\"",
463 click_element_and_wait_for_message(child1_input_coords[1])); 457 click_element_and_wait_for_message(child1_input_coords[1]));
464 frame_focused->Wait(); 458 EXPECT_EQ(child1, web_contents->GetFocusedFrame());
465 frame_focused = base::MakeUnique<content::FrameFocusedObserver>(child2);
466 EXPECT_EQ("\"child2-focused-input1\"", press_tab_and_wait_for_message(false)); 459 EXPECT_EQ("\"child2-focused-input1\"", press_tab_and_wait_for_message(false));
467 frame_focused->Wait(); 460 EXPECT_EQ(child2, web_contents->GetFocusedFrame());
468 461
469 // Tab backward from child2 to child1. 462 // Tab backward from child2 to child1.
470 frame_focused = base::MakeUnique<content::FrameFocusedObserver>(child1);
471 EXPECT_EQ("\"child1-focused-input2\"", 463 EXPECT_EQ("\"child1-focused-input2\"",
472 click_element_and_wait_for_message(child1_input_coords[1])); 464 click_element_and_wait_for_message(child1_input_coords[1]));
473 frame_focused->Wait(); 465 EXPECT_EQ(child1, web_contents->GetFocusedFrame());
474 frame_focused = base::MakeUnique<content::FrameFocusedObserver>(child2);
475 EXPECT_EQ("\"child2-focused-input1\"", 466 EXPECT_EQ("\"child2-focused-input1\"",
476 click_element_and_wait_for_message(child2_input_coords[0])); 467 click_element_and_wait_for_message(child2_input_coords[0]));
477 frame_focused->Wait(); 468 EXPECT_EQ(child2, web_contents->GetFocusedFrame());
478 frame_focused = base::MakeUnique<content::FrameFocusedObserver>(child1);
479 EXPECT_EQ("\"child1-focused-input2\"", press_tab_and_wait_for_message(true)); 469 EXPECT_EQ("\"child1-focused-input2\"", press_tab_and_wait_for_message(true));
480 // EXPECT_EQ(child1, web_contents->GetFocusedFrame()); 470 EXPECT_EQ(child1, web_contents->GetFocusedFrame());
481 frame_focused->Wait();
482 471
483 // Ensure there are no pending focus events after tabbing. 472 // Ensure there are no pending focus events after tabbing.
484 EXPECT_EQ("\"root-focused-input1\"", 473 EXPECT_EQ("\"root-focused-input1\"",
485 click_element_and_wait_for_message(main_frame_input_coords[0])) 474 click_element_and_wait_for_message(main_frame_input_coords[0]))
486 << "Unexpected extra focus events."; 475 << "Unexpected extra focus events.";
487 } 476 }
488 #endif
489 477
490 namespace { 478 namespace {
491 479
492 // Helper to retrieve the frame's (window.innerWidth, window.innerHeight). 480 // Helper to retrieve the frame's (window.innerWidth, window.innerHeight).
493 gfx::Size GetFrameSize(content::RenderFrameHost* frame) { 481 gfx::Size GetFrameSize(content::RenderFrameHost* frame) {
494 int width = 0; 482 int width = 0;
495 EXPECT_TRUE(ExecuteScriptAndExtractInt( 483 EXPECT_TRUE(ExecuteScriptAndExtractInt(
496 frame, "domAutomationController.send(window.innerWidth);", &width)); 484 frame, "domAutomationController.send(window.innerWidth);", &width));
497 485
498 int height = 0; 486 int height = 0;
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 1332
1345 // Ideally, the length of the error vector should be 0.0f. But due to 1333 // Ideally, the length of the error vector should be 0.0f. But due to
1346 // potential rounding errors, we assume a larger limit (which is slightly 1334 // potential rounding errors, we assume a larger limit (which is slightly
1347 // larger than square root of 2). 1335 // larger than square root of 2).
1348 EXPECT_LT(error.Length(), 1.4143f) 1336 EXPECT_LT(error.Length(), 1.4143f)
1349 << "Origin of bounds from focused node changed event is '" 1337 << "Origin of bounds from focused node changed event is '"
1350 << focus_observer.focused_node_bounds_in_screen().ToString() 1338 << focus_observer.focused_node_bounds_in_screen().ToString()
1351 << "' but AutofillClient is reporting '" << bounds_origin.ToString() 1339 << "' but AutofillClient is reporting '" << bounds_origin.ToString()
1352 << "'"; 1340 << "'";
1353 } 1341 }
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/page/FocusController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698