| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 5066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5077 router->RouteMouseEvent(root_view, &click_event); | 5077 router->RouteMouseEvent(root_view, &click_event); |
| 5078 | 5078 |
| 5079 context_menu_delegate.Wait(); | 5079 context_menu_delegate.Wait(); |
| 5080 | 5080 |
| 5081 ContextMenuParams params = context_menu_delegate.getParams(); | 5081 ContextMenuParams params = context_menu_delegate.getParams(); |
| 5082 | 5082 |
| 5083 EXPECT_EQ(point.x(), params.x); | 5083 EXPECT_EQ(point.x(), params.x); |
| 5084 EXPECT_EQ(point.y(), params.y); | 5084 EXPECT_EQ(point.y(), params.y); |
| 5085 } | 5085 } |
| 5086 | 5086 |
| 5087 class ShowWidgetMessageFilter : public content::BrowserMessageFilter { |
| 5088 public: |
| 5089 ShowWidgetMessageFilter() |
| 5090 : content::BrowserMessageFilter(ViewMsgStart), |
| 5091 message_loop_runner_(new content::MessageLoopRunner), |
| 5092 message_received_(false) {} |
| 5093 |
| 5094 bool OnMessageReceived(const IPC::Message& message) override { |
| 5095 IPC_BEGIN_MESSAGE_MAP(ShowWidgetMessageFilter, message) |
| 5096 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget) |
| 5097 IPC_END_MESSAGE_MAP() |
| 5098 return false; |
| 5099 } |
| 5100 |
| 5101 gfx::Rect last_initial_rect() const { return initial_rect_; } |
| 5102 |
| 5103 void Wait() { |
| 5104 if (!message_received_) { |
| 5105 initial_rect_ = gfx::Rect(); |
| 5106 message_loop_runner_->Run(); |
| 5107 } |
| 5108 } |
| 5109 |
| 5110 void Reset() { |
| 5111 message_received_ = false; |
| 5112 initial_rect_ = gfx::Rect(); |
| 5113 } |
| 5114 |
| 5115 private: |
| 5116 ~ShowWidgetMessageFilter() override {} |
| 5117 |
| 5118 void OnShowWidget(int route_id, const gfx::Rect& initial_rect) { |
| 5119 content::BrowserThread::PostTask( |
| 5120 content::BrowserThread::UI, FROM_HERE, |
| 5121 base::Bind(&ShowWidgetMessageFilter::OnShowWidgetOnUI, this, route_id, |
| 5122 initial_rect)); |
| 5123 } |
| 5124 |
| 5125 void OnShowWidgetOnUI(int route_id, const gfx::Rect& initial_rect) { |
| 5126 initial_rect_ = initial_rect; |
| 5127 message_received_ = true; |
| 5128 message_loop_runner_->Quit(); |
| 5129 } |
| 5130 |
| 5131 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
| 5132 gfx::Rect initial_rect_; |
| 5133 bool message_received_; |
| 5134 |
| 5135 DISALLOW_COPY_AND_ASSIGN(ShowWidgetMessageFilter); |
| 5136 }; |
| 5137 |
| 5138 // Test that clicking a select element in an out-of-process iframe creates |
| 5139 // a popup menu in the correct position. |
| 5140 #if defined(OS_ANDROID) || defined(OS_MACOSX) |
| 5141 // Page Popups work differently on Aura than on Android and Mac. This tests |
| 5142 // only the Aura mechanism. |
| 5143 #define MAYBE_PagePopupMenuTest DISABLED_PagePopupMenuTest |
| 5144 #else |
| 5145 #define MAYBE_PagePopupMenuTest PagePopupMenuTest |
| 5146 #endif |
| 5147 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_PagePopupMenuTest) { |
| 5148 GURL main_url( |
| 5149 embedded_test_server()->GetURL("/cross_site_iframe_factory.html?a(a)")); |
| 5150 NavigateToURL(shell(), main_url); |
| 5151 |
| 5152 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 5153 ->GetFrameTree() |
| 5154 ->root(); |
| 5155 |
| 5156 // Position main window to ensure consistent screen coordinates. |
| 5157 RenderWidgetHostViewBase* rwhv_root = static_cast<RenderWidgetHostViewBase*>( |
| 5158 root->current_frame_host()->GetRenderWidgetHost()->GetView()); |
| 5159 rwhv_root->SetBounds(gfx::Rect(100, 100, 500, 500)); |
| 5160 static_cast<WebContentsImpl*>(shell()->web_contents())->SendScreenRects(); |
| 5161 |
| 5162 content::TestNavigationObserver navigation_observer(shell()->web_contents()); |
| 5163 FrameTreeNode* child_node = root->child_at(0); |
| 5164 GURL site_url(embedded_test_server()->GetURL( |
| 5165 "baz.com", "/site_isolation/page-with-select.html")); |
| 5166 NavigateFrameToURL(child_node, site_url); |
| 5167 navigation_observer.Wait(); |
| 5168 |
| 5169 RenderWidgetHostViewBase* rwhv_child = static_cast<RenderWidgetHostViewBase*>( |
| 5170 child_node->current_frame_host()->GetRenderWidgetHost()->GetView()); |
| 5171 |
| 5172 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
| 5173 child_node->current_frame_host()->GetSiteInstance()); |
| 5174 |
| 5175 scoped_refptr<ShowWidgetMessageFilter> filter = new ShowWidgetMessageFilter(); |
| 5176 child_node->current_frame_host()->GetProcess()->AddFilter(filter.get()); |
| 5177 |
| 5178 // Target left-click event to child frame. |
| 5179 blink::WebMouseEvent click_event; |
| 5180 click_event.type = blink::WebInputEvent::MouseDown; |
| 5181 click_event.button = blink::WebPointerProperties::ButtonLeft; |
| 5182 click_event.x = 15; |
| 5183 click_event.y = 15; |
| 5184 click_event.clickCount = 1; |
| 5185 rwhv_child->ProcessMouseEvent(click_event); |
| 5186 |
| 5187 filter->Wait(); |
| 5188 |
| 5189 gfx::Rect popup_rect = filter->last_initial_rect(); |
| 5190 |
| 5191 EXPECT_EQ(popup_rect.x() - rwhv_root->GetViewBounds().x(), 354); |
| 5192 EXPECT_EQ(popup_rect.y() - rwhv_root->GetViewBounds().y(), 94); |
| 5193 } |
| 5194 |
| 5087 // Test for https://crbug.com/526304, where a parent frame executes a | 5195 // Test for https://crbug.com/526304, where a parent frame executes a |
| 5088 // remote-to-local navigation on a child frame and immediately removes the same | 5196 // remote-to-local navigation on a child frame and immediately removes the same |
| 5089 // child frame. This test exercises the path where the detach happens before | 5197 // child frame. This test exercises the path where the detach happens before |
| 5090 // the provisional local frame is created. | 5198 // the provisional local frame is created. |
| 5091 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 5199 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| 5092 NavigateProxyAndDetachBeforeProvisionalFrameCreation) { | 5200 NavigateProxyAndDetachBeforeProvisionalFrameCreation) { |
| 5093 GURL main_url(embedded_test_server()->GetURL( | 5201 GURL main_url(embedded_test_server()->GetURL( |
| 5094 "a.com", "/cross_site_iframe_factory.html?a(b,b)")); | 5202 "a.com", "/cross_site_iframe_factory.html?a(b,b)")); |
| 5095 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 5203 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| 5096 | 5204 |
| (...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5992 EXPECT_EQ(b_url, root->current_url()); | 6100 EXPECT_EQ(b_url, root->current_url()); |
| 5993 | 6101 |
| 5994 // Verify that the same RenderViewHost is preserved and that it is no longer | 6102 // Verify that the same RenderViewHost is preserved and that it is no longer |
| 5995 // in swapped out state. | 6103 // in swapped out state. |
| 5996 EXPECT_EQ(rvh, contents->GetFrameTree()->GetRenderViewHost( | 6104 EXPECT_EQ(rvh, contents->GetFrameTree()->GetRenderViewHost( |
| 5997 root->current_frame_host()->GetSiteInstance())); | 6105 root->current_frame_host()->GetSiteInstance())); |
| 5998 EXPECT_FALSE(rvh->is_swapped_out_); | 6106 EXPECT_FALSE(rvh->is_swapped_out_); |
| 5999 } | 6107 } |
| 6000 | 6108 |
| 6001 } // namespace content | 6109 } // namespace content |
| OLD | NEW |