Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/site_per_process_browsertest.h" | 5 #include "content/browser/site_per_process_browsertest.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 #include "content/public/test/test_navigation_observer.h" | 34 #include "content/public/test/test_navigation_observer.h" |
| 35 #include "content/public/test/test_utils.h" | 35 #include "content/public/test/test_utils.h" |
| 36 #include "content/shell/browser/shell.h" | 36 #include "content/shell/browser/shell.h" |
| 37 #include "content/test/content_browser_test_utils_internal.h" | 37 #include "content/test/content_browser_test_utils_internal.h" |
| 38 #include "content/test/test_frame_navigation_observer.h" | 38 #include "content/test/test_frame_navigation_observer.h" |
| 39 #include "ipc/ipc_security_test_util.h" | 39 #include "ipc/ipc_security_test_util.h" |
| 40 #include "net/dns/mock_host_resolver.h" | 40 #include "net/dns/mock_host_resolver.h" |
| 41 #include "net/test/embedded_test_server/embedded_test_server.h" | 41 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 42 #include "third_party/WebKit/public/web/WebInputEvent.h" | 42 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 43 #include "third_party/WebKit/public/web/WebSandboxFlags.h" | 43 #include "third_party/WebKit/public/web/WebSandboxFlags.h" |
| 44 #include "ui/gfx/switches.h" | |
| 44 | 45 |
| 45 namespace content { | 46 namespace content { |
| 46 | 47 |
| 47 namespace { | 48 namespace { |
| 48 | 49 |
| 49 // Helper function to send a postMessage and wait for a reply message. The | 50 // Helper function to send a postMessage and wait for a reply message. The |
| 50 // |post_message_script| is executed on the |sender_ftn| frame, and the sender | 51 // |post_message_script| is executed on the |sender_ftn| frame, and the sender |
| 51 // frame is expected to post |reply_status| from the DOMAutomationController | 52 // frame is expected to post |reply_status| from the DOMAutomationController |
| 52 // when it receives a reply. | 53 // when it receives a reply. |
| 53 void PostMessageAndWaitForReply(FrameTreeNode* sender_ftn, | 54 void PostMessageAndWaitForReply(FrameTreeNode* sender_ftn, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 const std::string& name) { | 91 const std::string& name) { |
| 91 bool success = false; | 92 bool success = false; |
| 92 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 93 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 93 caller_frame, | 94 caller_frame, |
| 94 "window.domAutomationController.send(" | 95 "window.domAutomationController.send(" |
| 95 " !!window.open('" + url.spec() + "', '" + name + "'));", | 96 " !!window.open('" + url.spec() + "', '" + name + "'));", |
| 96 &success)); | 97 &success)); |
| 97 EXPECT_TRUE(success); | 98 EXPECT_TRUE(success); |
| 98 } | 99 } |
| 99 | 100 |
| 101 class RenderWidgetHostMouseEventMonitor { | |
| 102 public: | |
| 103 RenderWidgetHostMouseEventMonitor(RenderWidgetHost* host) | |
|
sadrul
2015/11/03 18:00:00
explicit
lfg
2015/11/03 20:49:16
Done.
| |
| 104 : host_(host), event_received(false) { | |
| 105 host_->AddMouseEventCallback( | |
| 106 base::Bind(&RenderWidgetHostMouseEventMonitor::MouseEventCallback, | |
| 107 base::Unretained(this))); | |
| 108 } | |
| 109 ~RenderWidgetHostMouseEventMonitor() { | |
| 110 host_->RemoveMouseEventCallback( | |
| 111 base::Bind(&RenderWidgetHostMouseEventMonitor::MouseEventCallback, | |
| 112 base::Unretained(this))); | |
| 113 } | |
| 114 bool EventWasReceived() { return event_received; } | |
|
sadrul
2015/11/03 18:00:00
const
lfg
2015/11/03 20:49:16
Done.
| |
| 115 void ResetEventReceived() { event_received = false; } | |
| 116 const blink::WebMouseEvent& event() const { return event_; } | |
| 117 | |
| 118 private: | |
| 119 bool MouseEventCallback(const blink::WebMouseEvent& event) { | |
| 120 event_received = true; | |
| 121 event_ = event; | |
| 122 return false; | |
| 123 } | |
| 124 RenderWidgetHost* host_; | |
| 125 bool event_received; | |
|
sadrul
2015/11/03 18:00:00
event_received_
lfg
2015/11/03 20:49:16
Done.
| |
| 126 blink::WebMouseEvent event_; | |
| 127 }; | |
|
sadrul
2015/11/03 18:00:00
DISALLOW_COPY_...
(I realize that you are just mo
lfg
2015/11/03 20:49:16
Done.
| |
| 128 | |
| 129 // Helper function that performs a surface hittest. | |
| 130 void SurfaceHitTestTestHelper( | |
| 131 Shell* shell, | |
| 132 net::test_server::EmbeddedTestServer* embedded_test_server) { | |
| 133 if (!UseSurfacesEnabled()) | |
| 134 return; | |
| 135 | |
| 136 GURL main_url(embedded_test_server->GetURL( | |
| 137 "/frame_tree/page_with_positioned_frame.html")); | |
| 138 NavigateToURL(shell, main_url); | |
| 139 | |
| 140 // It is safe to obtain the root frame tree node here, as it doesn't change. | |
| 141 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell->web_contents()) | |
| 142 ->GetFrameTree() | |
| 143 ->root(); | |
| 144 ASSERT_EQ(1U, root->child_count()); | |
| 145 | |
| 146 FrameTreeNode* child_node = root->child_at(0); | |
| 147 GURL site_url(embedded_test_server->GetURL("baz.com", "/title1.html")); | |
| 148 EXPECT_EQ(site_url, child_node->current_url()); | |
| 149 EXPECT_NE(shell->web_contents()->GetSiteInstance(), | |
| 150 child_node->current_frame_host()->GetSiteInstance()); | |
| 151 | |
| 152 // Create listeners for mouse events. | |
| 153 RenderWidgetHostMouseEventMonitor main_frame_monitor( | |
| 154 root->current_frame_host()->GetRenderWidgetHost()); | |
| 155 RenderWidgetHostMouseEventMonitor child_frame_monitor( | |
| 156 child_node->current_frame_host()->GetRenderWidgetHost()); | |
| 157 | |
| 158 RenderWidgetHostInputEventRouter* router = | |
| 159 static_cast<WebContentsImpl*>(shell->web_contents()) | |
| 160 ->GetInputEventRouter(); | |
| 161 | |
| 162 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( | |
| 163 root->current_frame_host()->GetRenderWidgetHost()->GetView()); | |
| 164 RenderWidgetHostViewBase* rwhv_child = static_cast<RenderWidgetHostViewBase*>( | |
| 165 child_node->current_frame_host()->GetRenderWidgetHost()->GetView()); | |
| 166 | |
| 167 // We need to wait for a compositor frame from the child frame, at which | |
| 168 // point its surface will be created. | |
| 169 while (rwhv_child->RendererFrameNumber() <= 0) { | |
| 170 // TODO(lazyboy): Find a better way to avoid sleeping like this. See | |
| 171 // http://crbug.com/405282 for details. | |
| 172 base::RunLoop run_loop; | |
| 173 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | |
| 174 FROM_HERE, run_loop.QuitClosure(), | |
| 175 base::TimeDelta::FromMilliseconds(10)); | |
| 176 run_loop.Run(); | |
| 177 } | |
|
sadrul
2015/11/03 18:00:00
This is still unfortunate. I have left a comment i
| |
| 178 | |
| 179 uint32_t cur_render_frame_number = root_view->RendererFrameNumber(); | |
| 180 | |
| 181 // Target input event to child frame. | |
| 182 blink::WebMouseEvent child_event; | |
| 183 child_event.type = blink::WebInputEvent::MouseDown; | |
| 184 child_event.button = blink::WebPointerProperties::ButtonLeft; | |
| 185 child_event.x = 75; | |
| 186 child_event.y = 75; | |
| 187 child_event.clickCount = 1; | |
| 188 main_frame_monitor.ResetEventReceived(); | |
| 189 child_frame_monitor.ResetEventReceived(); | |
| 190 router->RouteMouseEvent(root_view, &child_event); | |
| 191 | |
| 192 while (!child_frame_monitor.EventWasReceived()) { | |
| 193 // This is working around a big synchronization problem. It is very | |
| 194 // difficult to know if we have received a compositor frame from the | |
| 195 // main frame renderer *after* it received the child frame's surface | |
| 196 // ID. Hit testing won't work until this happens. So if the hit test | |
| 197 // fails then we wait for another frame to arrive and try again. | |
| 198 // TODO(kenrb): We need a better way to do all of this, possibly coming | |
| 199 // from http://crbug.com/405282. | |
| 200 while (root_view->RendererFrameNumber() <= cur_render_frame_number) { | |
| 201 base::RunLoop run_loop; | |
| 202 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | |
| 203 FROM_HERE, run_loop.QuitClosure(), | |
| 204 base::TimeDelta::FromMilliseconds(10)); | |
| 205 run_loop.Run(); | |
| 206 } | |
| 207 cur_render_frame_number = root_view->RendererFrameNumber(); | |
| 208 child_event.type = blink::WebInputEvent::MouseDown; | |
| 209 child_event.button = blink::WebPointerProperties::ButtonLeft; | |
| 210 child_event.x = 75; | |
| 211 child_event.y = 75; | |
| 212 child_event.clickCount = 1; | |
| 213 main_frame_monitor.ResetEventReceived(); | |
| 214 child_frame_monitor.ResetEventReceived(); | |
| 215 router->RouteMouseEvent(root_view, &child_event); | |
| 216 } | |
|
sadrul
2015/11/03 18:00:00
eugh ... this too! We really need to find a better
lfg
2015/11/03 20:49:16
I discussed an alternative to this with kenrb@, wh
| |
| 217 | |
| 218 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); | |
| 219 EXPECT_EQ(23, child_frame_monitor.event().x); | |
| 220 EXPECT_EQ(23, child_frame_monitor.event().y); | |
| 221 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); | |
| 222 | |
| 223 child_frame_monitor.ResetEventReceived(); | |
| 224 main_frame_monitor.ResetEventReceived(); | |
| 225 | |
| 226 // Target input event to main frame. | |
| 227 blink::WebMouseEvent main_event; | |
| 228 main_event.type = blink::WebInputEvent::MouseDown; | |
| 229 main_event.button = blink::WebPointerProperties::ButtonLeft; | |
| 230 main_event.x = 1; | |
| 231 main_event.y = 1; | |
| 232 main_event.clickCount = 1; | |
| 233 // Ladies and gentlemen, THIS is the main_event! | |
| 234 router->RouteMouseEvent(root_view, &main_event); | |
| 235 | |
| 236 EXPECT_FALSE(child_frame_monitor.EventWasReceived()); | |
| 237 EXPECT_TRUE(main_frame_monitor.EventWasReceived()); | |
| 238 EXPECT_EQ(1, main_frame_monitor.event().x); | |
| 239 EXPECT_EQ(1, main_frame_monitor.event().y); | |
| 240 } | |
| 241 | |
| 100 class RedirectNotificationObserver : public NotificationObserver { | 242 class RedirectNotificationObserver : public NotificationObserver { |
| 101 public: | 243 public: |
| 102 // Register to listen for notifications of the given type from either a | 244 // Register to listen for notifications of the given type from either a |
| 103 // specific source, or from all sources if |source| is | 245 // specific source, or from all sources if |source| is |
| 104 // NotificationService::AllSources(). | 246 // NotificationService::AllSources(). |
| 105 RedirectNotificationObserver(int notification_type, | 247 RedirectNotificationObserver(int notification_type, |
| 106 const NotificationSource& source); | 248 const NotificationSource& source); |
| 107 ~RedirectNotificationObserver() override; | 249 ~RedirectNotificationObserver() override; |
| 108 | 250 |
| 109 // Wait until the specified notification occurs. If the notification was | 251 // Wait until the specified notification occurs. If the notification was |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 base::CommandLine* command_line) { | 452 base::CommandLine* command_line) { |
| 311 IsolateAllSitesForTesting(command_line); | 453 IsolateAllSitesForTesting(command_line); |
| 312 }; | 454 }; |
| 313 | 455 |
| 314 void SitePerProcessBrowserTest::SetUpOnMainThread() { | 456 void SitePerProcessBrowserTest::SetUpOnMainThread() { |
| 315 host_resolver()->AddRule("*", "127.0.0.1"); | 457 host_resolver()->AddRule("*", "127.0.0.1"); |
| 316 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 458 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 317 SetupCrossSiteRedirector(embedded_test_server()); | 459 SetupCrossSiteRedirector(embedded_test_server()); |
| 318 } | 460 } |
| 319 | 461 |
| 462 // | |
| 463 // SitePerProcessHighDPIBrowserTest | |
| 464 // | |
| 465 | |
| 466 SitePerProcessHighDPIBrowserTest::SitePerProcessHighDPIBrowserTest() {} | |
| 467 | |
| 468 void SitePerProcessHighDPIBrowserTest::SetUpCommandLine( | |
| 469 base::CommandLine* command_line) { | |
| 470 SitePerProcessBrowserTest::SetUpCommandLine(command_line); | |
| 471 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, | |
| 472 base::StringPrintf("2")); | |
| 473 }; | |
| 474 | |
| 320 // Ensure that navigating subframes in --site-per-process mode works and the | 475 // Ensure that navigating subframes in --site-per-process mode works and the |
| 321 // correct documents are committed. | 476 // correct documents are committed. |
| 322 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { | 477 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { |
| 323 GURL main_url(embedded_test_server()->GetURL( | 478 GURL main_url(embedded_test_server()->GetURL( |
| 324 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); | 479 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); |
| 325 NavigateToURL(shell(), main_url); | 480 NavigateToURL(shell(), main_url); |
| 326 | 481 |
| 327 // It is safe to obtain the root frame tree node here, as it doesn't change. | 482 // It is safe to obtain the root frame tree node here, as it doesn't change. |
| 328 FrameTreeNode* root = | 483 FrameTreeNode* root = |
| 329 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 484 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 439 " |--Site C ------- proxies for A\n" | 594 " |--Site C ------- proxies for A\n" |
| 440 " +--Site A ------- proxies for C\n" | 595 " +--Site A ------- proxies for C\n" |
| 441 " |--Site A -- proxies for C\n" | 596 " |--Site A -- proxies for C\n" |
| 442 " +--Site A -- proxies for C\n" | 597 " +--Site A -- proxies for C\n" |
| 443 " +--Site A -- proxies for C\n" | 598 " +--Site A -- proxies for C\n" |
| 444 "Where A = http://a.com/\n" | 599 "Where A = http://a.com/\n" |
| 445 " C = http://bar.com/", | 600 " C = http://bar.com/", |
| 446 DepictFrameTree(root)); | 601 DepictFrameTree(root)); |
| 447 } | 602 } |
| 448 | 603 |
| 449 class RenderWidgetHostMouseEventMonitor { | |
| 450 public: | |
| 451 RenderWidgetHostMouseEventMonitor(RenderWidgetHost* host) | |
| 452 : host_(host), event_received(false) { | |
| 453 host_->AddMouseEventCallback( | |
| 454 base::Bind(&RenderWidgetHostMouseEventMonitor::MouseEventCallback, | |
| 455 base::Unretained(this))); | |
| 456 } | |
| 457 ~RenderWidgetHostMouseEventMonitor() { | |
| 458 host_->RemoveMouseEventCallback( | |
| 459 base::Bind(&RenderWidgetHostMouseEventMonitor::MouseEventCallback, | |
| 460 base::Unretained(this))); | |
| 461 } | |
| 462 bool EventWasReceived() { return event_received; } | |
| 463 void ResetEventReceived() { event_received = false; } | |
| 464 const blink::WebMouseEvent& event() const { return event_; } | |
| 465 | |
| 466 private: | |
| 467 bool MouseEventCallback(const blink::WebMouseEvent& event) { | |
| 468 event_received = true; | |
| 469 event_ = event; | |
| 470 return false; | |
| 471 } | |
| 472 RenderWidgetHost* host_; | |
| 473 bool event_received; | |
| 474 blink::WebMouseEvent event_; | |
| 475 }; | |
| 476 | |
| 477 // Test that mouse events are being routed to the correct RenderWidgetHostView | 604 // Test that mouse events are being routed to the correct RenderWidgetHostView |
| 478 // based on coordinates. | 605 // based on coordinates. |
| 479 #if defined(OS_ANDROID) | 606 #if defined(OS_ANDROID) |
| 480 // Browser process hit testing is not implemented on Android. | 607 // Browser process hit testing is not implemented on Android. |
| 481 // https://crbug.com/491334 | 608 // https://crbug.com/491334 |
| 482 #define MAYBE_SurfaceHitTestTest DISABLED_SurfaceHitTestTest | 609 #define MAYBE_SurfaceHitTestTest DISABLED_SurfaceHitTestTest |
| 483 #else | 610 #else |
| 484 #define MAYBE_SurfaceHitTestTest SurfaceHitTestTest | 611 #define MAYBE_SurfaceHitTestTest SurfaceHitTestTest |
| 485 #endif | 612 #endif |
| 486 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_SurfaceHitTestTest) { | 613 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_SurfaceHitTestTest) { |
| 487 if (!UseSurfacesEnabled()) | 614 SurfaceHitTestTestHelper(shell(), embedded_test_server()); |
| 488 return; | 615 } |
| 489 | 616 |
| 490 GURL main_url(embedded_test_server()->GetURL( | 617 // Same test as above, but runs in high-dpi mode. |
| 491 "/frame_tree/page_with_positioned_frame.html")); | 618 #if defined(OS_ANDROID) || defined(OS_WIN) |
| 492 NavigateToURL(shell(), main_url); | 619 // Browser process hit testing is not implemented on Android. |
| 493 | 620 // https://crbug.com/491334 |
| 494 // It is safe to obtain the root frame tree node here, as it doesn't change. | 621 // Windows is disabled because of https://crbug.com/545547. |
| 495 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 622 #define MAYBE_HighDPISurfaceHitTestTest DISABLED_SurfaceHitTestTest |
| 496 ->GetFrameTree() | 623 #else |
| 497 ->root(); | 624 #define MAYBE_HighDPISurfaceHitTestTest SurfaceHitTestTest |
| 498 ASSERT_EQ(1U, root->child_count()); | 625 #endif |
| 499 | 626 IN_PROC_BROWSER_TEST_F(SitePerProcessHighDPIBrowserTest, |
| 500 FrameTreeNode* child_node = root->child_at(0); | 627 MAYBE_HighDPISurfaceHitTestTest) { |
| 501 GURL site_url(embedded_test_server()->GetURL("baz.com", "/title1.html")); | 628 SurfaceHitTestTestHelper(shell(), embedded_test_server()); |
| 502 EXPECT_EQ(site_url, child_node->current_url()); | |
| 503 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | |
| 504 child_node->current_frame_host()->GetSiteInstance()); | |
| 505 | |
| 506 // Create listeners for mouse events. | |
| 507 RenderWidgetHostMouseEventMonitor main_frame_monitor( | |
| 508 root->current_frame_host()->GetRenderWidgetHost()); | |
| 509 RenderWidgetHostMouseEventMonitor child_frame_monitor( | |
| 510 child_node->current_frame_host()->GetRenderWidgetHost()); | |
| 511 | |
| 512 RenderWidgetHostInputEventRouter* router = | |
| 513 static_cast<WebContentsImpl*>(shell()->web_contents()) | |
| 514 ->GetInputEventRouter(); | |
| 515 | |
| 516 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( | |
| 517 root->current_frame_host()->GetRenderWidgetHost()->GetView()); | |
| 518 RenderWidgetHostViewBase* rwhv_child = static_cast<RenderWidgetHostViewBase*>( | |
| 519 child_node->current_frame_host()->GetRenderWidgetHost()->GetView()); | |
| 520 | |
| 521 // We need to wait for a compositor frame from the child frame, at which | |
| 522 // point its surface will be created. | |
| 523 while (rwhv_child->RendererFrameNumber() <= 0) { | |
| 524 // TODO(lazyboy): Find a better way to avoid sleeping like this. See | |
| 525 // http://crbug.com/405282 for details. | |
| 526 base::RunLoop run_loop; | |
| 527 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | |
| 528 FROM_HERE, run_loop.QuitClosure(), | |
| 529 base::TimeDelta::FromMilliseconds(10)); | |
| 530 run_loop.Run(); | |
| 531 } | |
| 532 | |
| 533 uint32_t cur_render_frame_number = root_view->RendererFrameNumber(); | |
| 534 | |
| 535 // Target input event to child frame. | |
| 536 blink::WebMouseEvent child_event; | |
| 537 child_event.type = blink::WebInputEvent::MouseDown; | |
| 538 child_event.button = blink::WebPointerProperties::ButtonLeft; | |
| 539 child_event.x = 75; | |
| 540 child_event.y = 75; | |
| 541 child_event.clickCount = 1; | |
| 542 main_frame_monitor.ResetEventReceived(); | |
| 543 child_frame_monitor.ResetEventReceived(); | |
| 544 router->RouteMouseEvent(root_view, &child_event); | |
| 545 | |
| 546 while (!child_frame_monitor.EventWasReceived()) { | |
| 547 // This is working around a big synchronization problem. It is very | |
| 548 // difficult to know if we have received a compositor frame from the | |
| 549 // main frame renderer *after* it received the child frame's surface | |
| 550 // ID. Hit testing won't work until this happens. So if the hit test | |
| 551 // fails then we wait for another frame to arrive and try again. | |
| 552 // TODO(kenrb): We need a better way to do all of this, possibly coming | |
| 553 // from http://crbug.com/405282. | |
| 554 while (root_view->RendererFrameNumber() <= cur_render_frame_number) { | |
| 555 base::RunLoop run_loop; | |
| 556 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | |
| 557 FROM_HERE, run_loop.QuitClosure(), | |
| 558 base::TimeDelta::FromMilliseconds(10)); | |
| 559 run_loop.Run(); | |
| 560 } | |
| 561 cur_render_frame_number = root_view->RendererFrameNumber(); | |
| 562 child_event.type = blink::WebInputEvent::MouseDown; | |
| 563 child_event.button = blink::WebPointerProperties::ButtonLeft; | |
| 564 child_event.x = 75; | |
| 565 child_event.y = 75; | |
| 566 child_event.clickCount = 1; | |
| 567 main_frame_monitor.ResetEventReceived(); | |
| 568 child_frame_monitor.ResetEventReceived(); | |
| 569 router->RouteMouseEvent(root_view, &child_event); | |
| 570 } | |
| 571 | |
| 572 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); | |
| 573 EXPECT_EQ(23, child_frame_monitor.event().x); | |
| 574 EXPECT_EQ(23, child_frame_monitor.event().y); | |
| 575 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); | |
| 576 | |
| 577 child_frame_monitor.ResetEventReceived(); | |
| 578 main_frame_monitor.ResetEventReceived(); | |
| 579 | |
| 580 // Target input event to main frame. | |
| 581 blink::WebMouseEvent main_event; | |
| 582 main_event.type = blink::WebInputEvent::MouseDown; | |
| 583 main_event.button = blink::WebPointerProperties::ButtonLeft; | |
| 584 main_event.x = 1; | |
| 585 main_event.y = 1; | |
| 586 main_event.clickCount = 1; | |
| 587 // Ladies and gentlemen, THIS is the main_event! | |
| 588 router->RouteMouseEvent(root_view, &main_event); | |
| 589 | |
| 590 EXPECT_FALSE(child_frame_monitor.EventWasReceived()); | |
| 591 EXPECT_TRUE(main_frame_monitor.EventWasReceived()); | |
| 592 EXPECT_EQ(1, main_frame_monitor.event().x); | |
| 593 EXPECT_EQ(1, main_frame_monitor.event().y); | |
| 594 } | 629 } |
| 595 | 630 |
| 596 // Tests OOPIF rendering by checking that the RWH of the iframe generates | 631 // Tests OOPIF rendering by checking that the RWH of the iframe generates |
| 597 // OnSwapCompositorFrame message. | 632 // OnSwapCompositorFrame message. |
| 598 #if defined(OS_ANDROID) | 633 #if defined(OS_ANDROID) |
| 599 // http://crbug.com/471850 | 634 // http://crbug.com/471850 |
| 600 #define MAYBE_CompositorFrameSwapped DISABLED_CompositorFrameSwapped | 635 #define MAYBE_CompositorFrameSwapped DISABLED_CompositorFrameSwapped |
| 601 #else | 636 #else |
| 602 #define MAYBE_CompositorFrameSwapped CompositorFrameSwapped | 637 #define MAYBE_CompositorFrameSwapped CompositorFrameSwapped |
| 603 #endif | 638 #endif |
| (...skipping 3016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3620 | 3655 |
| 3621 // Use new window to navigate main window. | 3656 // Use new window to navigate main window. |
| 3622 std::string script = | 3657 std::string script = |
| 3623 "window.opener.location.href = '" + cross_url.spec() + "'"; | 3658 "window.opener.location.href = '" + cross_url.spec() + "'"; |
| 3624 EXPECT_TRUE(ExecuteScript(popup->web_contents(), script)); | 3659 EXPECT_TRUE(ExecuteScript(popup->web_contents(), script)); |
| 3625 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 3660 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 3626 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), cross_url); | 3661 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), cross_url); |
| 3627 } | 3662 } |
| 3628 | 3663 |
| 3629 } // namespace content | 3664 } // namespace content |
| OLD | NEW |