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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 5129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5140 void Wait() { | 5140 void Wait() { |
| 5141 if (!message_received_) { | 5141 if (!message_received_) { |
| 5142 initial_rect_ = gfx::Rect(); | 5142 initial_rect_ = gfx::Rect(); |
| 5143 message_loop_runner_->Run(); | 5143 message_loop_runner_->Run(); |
| 5144 } | 5144 } |
| 5145 } | 5145 } |
| 5146 | 5146 |
| 5147 void Reset() { | 5147 void Reset() { |
| 5148 message_received_ = false; | 5148 message_received_ = false; |
| 5149 initial_rect_ = gfx::Rect(); | 5149 initial_rect_ = gfx::Rect(); |
| 5150 message_loop_runner_ = new content::MessageLoopRunner; | |
| 5150 } | 5151 } |
| 5151 | 5152 |
| 5152 private: | 5153 private: |
| 5153 ~ShowWidgetMessageFilter() override {} | 5154 ~ShowWidgetMessageFilter() override {} |
| 5154 | 5155 |
| 5155 void OnShowWidget(int route_id, const gfx::Rect& initial_rect) { | 5156 void OnShowWidget(int route_id, const gfx::Rect& initial_rect) { |
| 5156 content::BrowserThread::PostTask( | 5157 content::BrowserThread::PostTask( |
| 5157 content::BrowserThread::UI, FROM_HERE, | 5158 content::BrowserThread::UI, FROM_HERE, |
| 5158 base::Bind(&ShowWidgetMessageFilter::OnShowWidgetOnUI, this, route_id, | 5159 base::Bind(&ShowWidgetMessageFilter::OnShowWidgetOnUI, this, route_id, |
| 5159 initial_rect)); | 5160 initial_rect)); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5222 rwhv_child->ProcessMouseEvent(click_event); | 5223 rwhv_child->ProcessMouseEvent(click_event); |
| 5223 | 5224 |
| 5224 filter->Wait(); | 5225 filter->Wait(); |
| 5225 | 5226 |
| 5226 gfx::Rect popup_rect = filter->last_initial_rect(); | 5227 gfx::Rect popup_rect = filter->last_initial_rect(); |
| 5227 | 5228 |
| 5228 EXPECT_EQ(popup_rect.x() - rwhv_root->GetViewBounds().x(), 354); | 5229 EXPECT_EQ(popup_rect.x() - rwhv_root->GetViewBounds().x(), 354); |
| 5229 EXPECT_EQ(popup_rect.y() - rwhv_root->GetViewBounds().y(), 94); | 5230 EXPECT_EQ(popup_rect.y() - rwhv_root->GetViewBounds().y(), 94); |
| 5230 } | 5231 } |
| 5231 | 5232 |
| 5233 // Test that clicking a select element in a nested out-of-process iframe creates | |
| 5234 // a popup menu in the correct position, even if the top-level page repositions | |
| 5235 // its out-of-process iframe. This verifies that screen positioning information | |
| 5236 // is propagating down the frame tree correctly. | |
| 5237 #if defined(OS_ANDROID) || defined(OS_MACOSX) | |
| 5238 // Page Popups work differently on Aura than on Android and Mac. This tests | |
| 5239 // only the Aura mechanism. | |
| 5240 #define MAYBE_NestedPagePopupMenuTest DISABLED_NestedPagePopupMenuTest | |
| 5241 #else | |
| 5242 #define MAYBE_NestedPagePopupMenuTest NestedPagePopupMenuTest | |
| 5243 #endif | |
| 5244 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | |
| 5245 MAYBE_NestedPagePopupMenuTest) { | |
|
nasko
2016/03/22 13:56:54
nit: NestedFrames? MultipleNestedFrames? We've bee
kenrb
2016/03/22 15:40:20
That's fine. PagePopup is used throughout Blink to
| |
| 5246 GURL main_url(embedded_test_server()->GetURL( | |
| 5247 "/cross_site_iframe_factory.html?a(b(c))")); | |
| 5248 NavigateToURL(shell(), main_url); | |
| 5249 | |
| 5250 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | |
| 5251 ->GetFrameTree() | |
| 5252 ->root(); | |
| 5253 | |
| 5254 // Position main window to ensure consistent screen coordinates. | |
| 5255 RenderWidgetHostViewBase* rwhv_root = static_cast<RenderWidgetHostViewBase*>( | |
| 5256 root->current_frame_host()->GetRenderWidgetHost()->GetView()); | |
| 5257 rwhv_root->SetBounds(gfx::Rect(100, 100, 500, 500)); | |
| 5258 static_cast<WebContentsImpl*>(shell()->web_contents())->SendScreenRects(); | |
| 5259 | |
| 5260 // For clarity, we are labeling the frame tree nodes as: | |
| 5261 // - root_node | |
| 5262 // \-> b_node (out-of-process) | |
|
nasko
2016/03/22 13:56:54
nit: "out-of-process from root and c_node"? It wil
kenrb
2016/03/22 15:40:20
Done.
| |
| 5263 // \-> c_node (out-of-process) | |
| 5264 | |
| 5265 content::TestNavigationObserver navigation_observer(shell()->web_contents()); | |
| 5266 FrameTreeNode* b_node = root->child_at(0); | |
| 5267 FrameTreeNode* c_node = b_node->child_at(0); | |
| 5268 GURL site_url(embedded_test_server()->GetURL( | |
| 5269 "baz.com", "/site_isolation/page-with-select.html")); | |
| 5270 NavigateFrameToURL(c_node, site_url); | |
| 5271 navigation_observer.Wait(); | |
|
nasko
2016/03/22 13:56:54
No need to wait any longer. I've landed the CL to
kenrb
2016/03/22 15:40:20
Done.
| |
| 5272 | |
| 5273 RenderWidgetHostViewBase* rwhv_c_node = | |
| 5274 static_cast<RenderWidgetHostViewBase*>( | |
| 5275 c_node->current_frame_host()->GetRenderWidgetHost()->GetView()); | |
| 5276 | |
| 5277 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | |
| 5278 c_node->current_frame_host()->GetSiteInstance()); | |
| 5279 | |
| 5280 scoped_refptr<ShowWidgetMessageFilter> filter = new ShowWidgetMessageFilter(); | |
| 5281 c_node->current_frame_host()->GetProcess()->AddFilter(filter.get()); | |
| 5282 | |
| 5283 // Target left-click event to child frame. | |
| 5284 blink::WebMouseEvent click_event; | |
| 5285 click_event.type = blink::WebInputEvent::MouseDown; | |
| 5286 click_event.button = blink::WebPointerProperties::ButtonLeft; | |
| 5287 click_event.x = 15; | |
| 5288 click_event.y = 15; | |
| 5289 click_event.clickCount = 1; | |
| 5290 rwhv_c_node->ProcessMouseEvent(click_event); | |
| 5291 | |
| 5292 filter->Wait(); | |
| 5293 | |
| 5294 gfx::Rect popup_rect = filter->last_initial_rect(); | |
| 5295 | |
| 5296 EXPECT_EQ(popup_rect.x() - rwhv_root->GetViewBounds().x(), 354); | |
| 5297 EXPECT_EQ(popup_rect.y() - rwhv_root->GetViewBounds().y(), 154); | |
| 5298 | |
| 5299 // Prompt the WebContents to dismiss the popup by clicking elsewhere. | |
| 5300 click_event.button = blink::WebPointerProperties::ButtonLeft; | |
| 5301 click_event.x = 1; | |
| 5302 click_event.y = 1; | |
| 5303 click_event.clickCount = 1; | |
| 5304 rwhv_c_node->ProcessMouseEvent(click_event); | |
| 5305 | |
| 5306 // Save the screen rect for b_node. Since it updates asynchronously from | |
| 5307 // the script command that changes it, we need to wait for it to change | |
| 5308 // before attempting to create the popup widget again. | |
| 5309 gfx::Rect last_b_node_bounds_rect = | |
| 5310 b_node->current_frame_host()->GetView()->GetViewBounds(); | |
| 5311 | |
| 5312 std::string script = | |
| 5313 "var iframe = document.querySelector('iframe');" | |
| 5314 "iframe.style.position = 'absolute';" | |
| 5315 "iframe.style.left = 150;" | |
| 5316 "iframe.style.top = 150;"; | |
| 5317 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | |
| 5318 | |
| 5319 filter->Reset(); | |
| 5320 | |
| 5321 // Busy loop to wait for b_node's screen rect to get updated. There | |
| 5322 // doesn't seem to be any better way to find out when this happens. | |
|
nasko
2016/03/22 13:56:54
Can't be done with another message filter?
kenrb
2016/03/22 15:40:20
Not easily. We need to wait until after the messag
nasko
2016/03/22 16:18:00
Acknowledged.
| |
| 5323 while (last_b_node_bounds_rect.x() == | |
| 5324 b_node->current_frame_host()->GetView()->GetViewBounds().x() && | |
| 5325 last_b_node_bounds_rect.y() == | |
| 5326 b_node->current_frame_host()->GetView()->GetViewBounds().y()) { | |
| 5327 base::RunLoop run_loop; | |
| 5328 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | |
| 5329 FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout()); | |
| 5330 run_loop.Run(); | |
| 5331 } | |
| 5332 | |
| 5333 click_event.button = blink::WebPointerProperties::ButtonLeft; | |
| 5334 click_event.x = 15; | |
| 5335 click_event.y = 15; | |
| 5336 click_event.clickCount = 1; | |
| 5337 rwhv_c_node->ProcessMouseEvent(click_event); | |
| 5338 | |
| 5339 filter->Wait(); | |
| 5340 | |
| 5341 popup_rect = filter->last_initial_rect(); | |
|
nasko
2016/03/22 13:56:54
minor nit: if the rect can be updated, why call it
kenrb
2016/03/22 15:40:20
It's the name of the IPC parameter whose value we
nasko
2016/03/22 16:18:00
Acknowledged.
| |
| 5342 | |
| 5343 EXPECT_EQ(popup_rect.x() - rwhv_root->GetViewBounds().x(), 203); | |
| 5344 EXPECT_EQ(popup_rect.y() - rwhv_root->GetViewBounds().y(), 248); | |
| 5345 } | |
| 5346 | |
| 5232 // Test for https://crbug.com/526304, where a parent frame executes a | 5347 // Test for https://crbug.com/526304, where a parent frame executes a |
| 5233 // remote-to-local navigation on a child frame and immediately removes the same | 5348 // remote-to-local navigation on a child frame and immediately removes the same |
| 5234 // child frame. This test exercises the path where the detach happens before | 5349 // child frame. This test exercises the path where the detach happens before |
| 5235 // the provisional local frame is created. | 5350 // the provisional local frame is created. |
| 5236 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 5351 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| 5237 NavigateProxyAndDetachBeforeProvisionalFrameCreation) { | 5352 NavigateProxyAndDetachBeforeProvisionalFrameCreation) { |
| 5238 GURL main_url(embedded_test_server()->GetURL( | 5353 GURL main_url(embedded_test_server()->GetURL( |
| 5239 "a.com", "/cross_site_iframe_factory.html?a(b,b)")); | 5354 "a.com", "/cross_site_iframe_factory.html?a(b,b)")); |
| 5240 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 5355 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| 5241 | 5356 |
| (...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6137 EXPECT_EQ(b_url, root->current_url()); | 6252 EXPECT_EQ(b_url, root->current_url()); |
| 6138 | 6253 |
| 6139 // Verify that the same RenderViewHost is preserved and that it is no longer | 6254 // Verify that the same RenderViewHost is preserved and that it is no longer |
| 6140 // in swapped out state. | 6255 // in swapped out state. |
| 6141 EXPECT_EQ(rvh, contents->GetFrameTree()->GetRenderViewHost( | 6256 EXPECT_EQ(rvh, contents->GetFrameTree()->GetRenderViewHost( |
| 6142 root->current_frame_host()->GetSiteInstance())); | 6257 root->current_frame_host()->GetSiteInstance())); |
| 6143 EXPECT_FALSE(rvh->is_swapped_out_); | 6258 EXPECT_FALSE(rvh->is_swapped_out_); |
| 6144 } | 6259 } |
| 6145 | 6260 |
| 6146 } // namespace content | 6261 } // namespace content |
| OLD | NEW |