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

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

Issue 2837213002: OOPIF: Instrument TabAndMouseNavigation for WIN Flakiness. (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 | 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 "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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 EXPECT_EQ("\"child2-focused-input2\"", press_tab_and_wait_for_message(true)); 320 EXPECT_EQ("\"child2-focused-input2\"", press_tab_and_wait_for_message(true));
321 EXPECT_EQ(child2, web_contents->GetFocusedFrame()); 321 EXPECT_EQ(child2, web_contents->GetFocusedFrame());
322 EXPECT_EQ("\"child2-focused-input1\"", press_tab_and_wait_for_message(true)); 322 EXPECT_EQ("\"child2-focused-input1\"", press_tab_and_wait_for_message(true));
323 EXPECT_EQ("\"child1-focused-input2\"", press_tab_and_wait_for_message(true)); 323 EXPECT_EQ("\"child1-focused-input2\"", press_tab_and_wait_for_message(true));
324 EXPECT_EQ(child1, web_contents->GetFocusedFrame()); 324 EXPECT_EQ(child1, web_contents->GetFocusedFrame());
325 EXPECT_EQ("\"child1-focused-input1\"", press_tab_and_wait_for_message(true)); 325 EXPECT_EQ("\"child1-focused-input1\"", press_tab_and_wait_for_message(true));
326 EXPECT_EQ("\"root-focused-input1\"", press_tab_and_wait_for_message(true)); 326 EXPECT_EQ("\"root-focused-input1\"", press_tab_and_wait_for_message(true));
327 EXPECT_EQ(main_frame, web_contents->GetFocusedFrame()); 327 EXPECT_EQ(main_frame, web_contents->GetFocusedFrame());
328 } 328 }
329 329
330 #if (defined(OS_LINUX) && !defined(USE_OZONE)) 330 #if (defined(OS_LINUX) && !defined(USE_OZONE)) || defined(OS_WIN)
331 // Ensures that renderers know to advance focus to sibling frames and parent 331 // Ensures that renderers know to advance focus to sibling frames and parent
332 // frames in the presence of mouse click initiated focus changes. 332 // frames in the presence of mouse click initiated focus changes.
333 // Verifies against regression of https://crbug.com/702330 333 // Verifies against regression of https://crbug.com/702330
334 IN_PROC_BROWSER_TEST_F(SitePerProcessInteractiveBrowserTest, 334 IN_PROC_BROWSER_TEST_F(SitePerProcessInteractiveBrowserTest,
335 TabAndMouseFocusNavigation) { 335 TabAndMouseFocusNavigation) {
336 GURL main_url(embedded_test_server()->GetURL( 336 GURL main_url(embedded_test_server()->GetURL(
337 "a.com", "/cross_site_iframe_factory.html?a(b,c)")); 337 "a.com", "/cross_site_iframe_factory.html?a(b,c)"));
338 ui_test_utils::NavigateToURL(browser(), main_url); 338 ui_test_utils::NavigateToURL(browser(), main_url);
339 339
340 content::WebContents* web_contents = 340 content::WebContents* web_contents =
(...skipping 19 matching lines...) Expand all
360 // beginning and one at the end. For root frame, this means that we will 360 // beginning and one at the end. For root frame, this means that we will
361 // have an <input>, then two <iframe> elements, then another <input>. 361 // have an <input>, then two <iframe> elements, then another <input>.
362 // The script will send back the coordinates to click for each <input>, in the 362 // The script will send back the coordinates to click for each <input>, in the
363 // document's space. Additionally, the outer frame will return the top left 363 // document's space. Additionally, the outer frame will return the top left
364 // point of each <iframe> to transform the coordinates of the inner <input> 364 // point of each <iframe> to transform the coordinates of the inner <input>
365 // elements. For example, main frame: 497,18;497,185:381,59;499,59 and each 365 // elements. For example, main frame: 497,18;497,185:381,59;499,59 and each
366 // iframe: 55,18;55,67 366 // iframe: 55,18;55,67
367 std::string script = 367 std::string script =
368 "function onFocus(e) {" 368 "function onFocus(e) {"
369 " domAutomationController.setAutomationId(0);" 369 " domAutomationController.setAutomationId(0);"
370 " console.log(window.name + '-focused-' + e.target.id);"
370 " domAutomationController.send(window.name + '-focused-' + e.target.id);" 371 " domAutomationController.send(window.name + '-focused-' + e.target.id);"
371 "}" 372 "}"
372 "" 373 ""
373 "function getElementCoords(element) {" 374 "function getElementCoords(element) {"
374 " var rect = element.getBoundingClientRect();" 375 " var rect = element.getBoundingClientRect();"
375 " return Math.floor(rect.left + 0.5 * rect.width) +','+" 376 " return Math.floor(rect.left + 0.5 * rect.width) +','+"
376 " Math.floor(rect.top + 0.5 * rect.height);" 377 " Math.floor(rect.top + 0.5 * rect.height);"
377 "}" 378 "}"
378 "function getIframeCoords(element) {" 379 "function getIframeCoords(element) {"
379 " var rect = element.getBoundingClientRect();" 380 " var rect = element.getBoundingClientRect();"
380 " return Math.floor(rect.left) +','+" 381 " return Math.floor(rect.left) +','+"
381 " Math.floor(rect.top);" 382 " Math.floor(rect.top);"
382 "}" 383 "}"
384 "function onClick(e) {"
385 " console.log('Click event ' + window.name + ' at: ' + e.x + ', ' + e.y "
386 " + ' screen: ' + e.screenX + ', ' + e.screenY);"
387 "}"
383 "" 388 ""
389 "window.addEventListener('click', onClick);"
390 "console.log(document.location.origin);"
384 "document.styleSheets[0].insertRule('input {width:100%;margin:0;}', 1);" 391 "document.styleSheets[0].insertRule('input {width:100%;margin:0;}', 1);"
385 "document.styleSheets[0].insertRule('h2 {margin:0;}', 1);" 392 "document.styleSheets[0].insertRule('h2 {margin:0;}', 1);"
386 "var input1 = document.createElement('input');" 393 "var input1 = document.createElement('input');"
387 "input1.id = 'input1';" 394 "input1.id = 'input1';"
388 "input1.addEventListener('focus', onFocus, false);" 395 "input1.addEventListener('focus', onFocus, false);"
389 "var input2 = document.createElement('input');" 396 "var input2 = document.createElement('input');"
390 "input2.id = 'input2';" 397 "input2.id = 'input2';"
391 "input2.addEventListener('focus', onFocus, false);" 398 "input2.addEventListener('focus', onFocus, false);"
392 "document.body.insertBefore(input1, document.body.firstChild);" 399 "document.body.insertBefore(input1, document.body.firstChild);"
393 "document.body.appendChild(input2);" 400 "document.body.appendChild(input2);"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 auto child1_input_coords = parse_points(result, iframe1_offset); 440 auto child1_input_coords = parse_points(result, iframe1_offset);
434 EXPECT_TRUE(ExecuteScriptAndExtractString(child2, script, &result)); 441 EXPECT_TRUE(ExecuteScriptAndExtractString(child2, script, &result));
435 auto child2_input_coords = parse_points(result, iframe2_offset); 442 auto child2_input_coords = parse_points(result, iframe2_offset);
436 443
437 // Helper to simulate a tab press and wait for a focus message. 444 // Helper to simulate a tab press and wait for a focus message.
438 auto press_tab_and_wait_for_message = [web_contents](bool reverse) { 445 auto press_tab_and_wait_for_message = [web_contents](bool reverse) {
439 content::DOMMessageQueue msg_queue; 446 content::DOMMessageQueue msg_queue;
440 std::string reply; 447 std::string reply;
441 SimulateKeyPress(web_contents, ui::DomKey::TAB, ui::DomCode::TAB, 448 SimulateKeyPress(web_contents, ui::DomKey::TAB, ui::DomCode::TAB,
442 ui::VKEY_TAB, false, reverse /* shift */, false, false); 449 ui::VKEY_TAB, false, reverse /* shift */, false, false);
450 LOG(INFO) << "Press tab";
443 EXPECT_TRUE(msg_queue.WaitForMessage(&reply)); 451 EXPECT_TRUE(msg_queue.WaitForMessage(&reply));
444 return reply; 452 return reply;
445 }; 453 };
446 454
447 auto click_element_and_wait_for_message = 455 auto click_element_and_wait_for_message =
448 [web_contents](const gfx::Point& point) { 456 [web_contents](const gfx::Point& point) {
449 content::DOMMessageQueue msg_queue; 457 content::DOMMessageQueue msg_queue;
450 458
451 auto content_bounds = web_contents->GetContainerBounds(); 459 auto content_bounds = web_contents->GetContainerBounds();
452 ui_controls::SendMouseMove(point.x() + content_bounds.x(), 460 ui_controls::SendMouseMove(point.x() + content_bounds.x(),
453 point.y() + content_bounds.y()); 461 point.y() + content_bounds.y());
454 ui_controls::SendMouseClick(ui_controls::LEFT); 462 ui_controls::SendMouseClick(ui_controls::LEFT);
455 463
456 std::string reply; 464 std::string reply;
465 LOG(INFO) << "Click element";
457 EXPECT_TRUE(msg_queue.WaitForMessage(&reply)); 466 EXPECT_TRUE(msg_queue.WaitForMessage(&reply));
458 return reply; 467 return reply;
459 }; 468 };
460 469
461 // Tab from child1 back to root. 470 // Tab from child1 back to root.
462 EXPECT_EQ("\"root-focused-input1\"", 471 EXPECT_EQ("\"root-focused-input1\"",
463 click_element_and_wait_for_message(main_frame_input_coords[0])); 472 click_element_and_wait_for_message(main_frame_input_coords[0]));
464 EXPECT_EQ(main_frame, web_contents->GetFocusedFrame()); 473 EXPECT_EQ(main_frame, web_contents->GetFocusedFrame());
465 auto frame_focused = base::MakeUnique<content::FrameFocusedObserver>(child1); 474 auto frame_focused = base::MakeUnique<content::FrameFocusedObserver>(child1);
466 EXPECT_EQ("\"child1-focused-input1\"", 475 EXPECT_EQ("\"child1-focused-input1\"",
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 } 1467 }
1459 1468
1460 // To make sure we never clicked into the date picker, get current date value 1469 // To make sure we never clicked into the date picker, get current date value
1461 // and make sure it matches the cached value. 1470 // and make sure it matches the cached value.
1462 std::string date; 1471 std::string date;
1463 ASSERT_TRUE(ExecuteScriptAndExtractString( 1472 ASSERT_TRUE(ExecuteScriptAndExtractString(
1464 child_frame, "window.domAutomationController.send(input.value);", &date)); 1473 child_frame, "window.domAutomationController.send(input.value);", &date));
1465 EXPECT_EQ(cached_date, date) << "Cached date was '" << cached_date 1474 EXPECT_EQ(cached_date, date) << "Cached date was '" << cached_date
1466 << "' but current date is '" << date << "'."; 1475 << "' but current date is '" << date << "'.";
1467 } 1476 }
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