OLD | NEW |
---|---|
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 Loading... | |
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 // TODO(https://crbug.com/702330): Enable this test. | 305 #if (defined(OS_LINUX) && !defined(USE_OZONE)) || defined(OS_WIN) |
alexmos
2017/03/30 17:16:11
What's wrong with the test on the excluded platfor
avallee
2017/04/02 02:27:30
For Mac, I wrote a sample that just prints mousemo
| |
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. |
alexmos
2017/03/30 17:16:11
nit: I'd keep the reference to the bug here.
avallee
2017/04/02 02:27:30
Done.
| |
308 IN_PROC_BROWSER_TEST_F(SitePerProcessInteractiveBrowserTest, | 308 IN_PROC_BROWSER_TEST_F(SitePerProcessInteractiveBrowserTest, |
309 DISABLED_TabAndMouseFocusNavigation) { | 309 TabAndMouseFocusNavigation) { |
310 GURL main_url(embedded_test_server()->GetURL( | 310 GURL main_url(embedded_test_server()->GetURL( |
311 "a.com", "/cross_site_iframe_factory.html?a(b,c)")); | 311 "a.com", "/cross_site_iframe_factory.html?a(b,c)")); |
312 ui_test_utils::NavigateToURL(browser(), main_url); | 312 ui_test_utils::NavigateToURL(browser(), main_url); |
313 | 313 |
314 content::WebContents* web_contents = | 314 content::WebContents* web_contents = |
315 browser()->tab_strip_model()->GetActiveWebContents(); | 315 browser()->tab_strip_model()->GetActiveWebContents(); |
316 | 316 |
317 content::RenderFrameHost* main_frame = web_contents->GetMainFrame(); | 317 content::RenderFrameHost* main_frame = web_contents->GetMainFrame(); |
318 content::RenderFrameHost* child1 = ChildFrameAt(main_frame, 0); | 318 content::RenderFrameHost* child1 = ChildFrameAt(main_frame, 0); |
319 ASSERT_NE(nullptr, child1); | 319 ASSERT_NE(nullptr, child1); |
320 content::RenderFrameHost* child2 = ChildFrameAt(main_frame, 1); | 320 content::RenderFrameHost* child2 = ChildFrameAt(main_frame, 1); |
321 ASSERT_NE(nullptr, child2); | 321 ASSERT_NE(nullptr, child2); |
322 | 322 |
323 // 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 |
324 // from focus events. | 324 // from focus events. |
325 EXPECT_TRUE(ExecuteScript(main_frame, "window.name = 'root';")); | 325 EXPECT_TRUE(ExecuteScript(main_frame, "window.name = 'root';")); |
326 EXPECT_TRUE(ExecuteScript(child1, "window.name = 'child1';")); | 326 EXPECT_TRUE(ExecuteScript(child1, "window.name = 'child1';")); |
327 EXPECT_TRUE(ExecuteScript(child2, "window.name = 'child2';")); | 327 EXPECT_TRUE(ExecuteScript(child2, "window.name = 'child2';")); |
328 | 328 |
329 // 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 |
330 // 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 |
331 // have an <input>, then two <iframe> elements, then another <input>. | 331 // have an <input>, then two <iframe> elements, then another <input>. |
332 // 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 |
333 // 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 |
334 // 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> |
335 // 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 |
336 // iframe: 55,18;55,67 | 336 // iframe: 55,18;55,67 |
337 std::string script = | 337 std::string script = |
338 "function onFocus(e) {" | 338 "function onFocus(e) {" |
339 " console.log(window.name+'-focused-'+ e.target.id);" | |
340 " domAutomationController.setAutomationId(0);" | 339 " domAutomationController.setAutomationId(0);" |
341 " domAutomationController.send(window.name + '-focused-' + e.target.id);" | 340 " domAutomationController.send(window.name + '-focused-' + e.target.id);" |
342 "}" | 341 "}" |
343 "" | 342 "" |
344 "function getElementCoords(element) {" | 343 "function getElementCoords(element) {" |
345 " var rect = element.getBoundingClientRect();" | 344 " var rect = element.getBoundingClientRect();" |
346 " return Math.floor(rect.left + 0.5 * rect.width) +','+" | 345 " return Math.floor(rect.left + 0.5 * rect.width) +','+" |
347 " Math.floor(rect.top + 0.5 * rect.height);" | 346 " Math.floor(rect.top + 0.5 * rect.height);" |
348 "}" | 347 "}" |
349 "function getIframeCoords(element) {" | 348 "function getIframeCoords(element) {" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
467 click_element_and_wait_for_message(child2_input_coords[0])); | 466 click_element_and_wait_for_message(child2_input_coords[0])); |
468 EXPECT_EQ(child2, web_contents->GetFocusedFrame()); | 467 EXPECT_EQ(child2, web_contents->GetFocusedFrame()); |
469 EXPECT_EQ("\"child1-focused-input2\"", press_tab_and_wait_for_message(true)); | 468 EXPECT_EQ("\"child1-focused-input2\"", press_tab_and_wait_for_message(true)); |
470 EXPECT_EQ(child1, web_contents->GetFocusedFrame()); | 469 EXPECT_EQ(child1, web_contents->GetFocusedFrame()); |
471 | 470 |
472 // Ensure there are no pending focus events after tabbing. | 471 // Ensure there are no pending focus events after tabbing. |
473 EXPECT_EQ("\"root-focused-input1\"", | 472 EXPECT_EQ("\"root-focused-input1\"", |
474 click_element_and_wait_for_message(main_frame_input_coords[0])) | 473 click_element_and_wait_for_message(main_frame_input_coords[0])) |
475 << "Unexpected extra focus events."; | 474 << "Unexpected extra focus events."; |
476 } | 475 } |
476 #endif | |
477 | 477 |
478 namespace { | 478 namespace { |
479 | 479 |
480 // Helper to retrieve the frame's (window.innerWidth, window.innerHeight). | 480 // Helper to retrieve the frame's (window.innerWidth, window.innerHeight). |
481 gfx::Size GetFrameSize(content::RenderFrameHost* frame) { | 481 gfx::Size GetFrameSize(content::RenderFrameHost* frame) { |
482 int width = 0; | 482 int width = 0; |
483 EXPECT_TRUE(ExecuteScriptAndExtractInt( | 483 EXPECT_TRUE(ExecuteScriptAndExtractInt( |
484 frame, "domAutomationController.send(window.innerWidth);", &width)); | 484 frame, "domAutomationController.send(window.innerWidth);", &width)); |
485 | 485 |
486 int height = 0; | 486 int height = 0; |
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1333 | 1333 |
1334 // 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 |
1335 // potential rounding errors, we assume a larger limit (which is slightly | 1335 // potential rounding errors, we assume a larger limit (which is slightly |
1336 // larger than square root of 2). | 1336 // larger than square root of 2). |
1337 EXPECT_LT(error.Length(), 1.4143f) | 1337 EXPECT_LT(error.Length(), 1.4143f) |
1338 << "Origin of bounds from focused node changed event is '" | 1338 << "Origin of bounds from focused node changed event is '" |
1339 << focus_observer.focused_node_bounds_in_screen().ToString() | 1339 << focus_observer.focused_node_bounds_in_screen().ToString() |
1340 << "' but AutofillClient is reporting '" << bounds_origin.ToString() | 1340 << "' but AutofillClient is reporting '" << bounds_origin.ToString() |
1341 << "'"; | 1341 << "'"; |
1342 } | 1342 } |
OLD | NEW |