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

Side by Side Diff: content/browser/site_per_process_browsertest.cc

Issue 1820043002: Update nested OOPIF's screen rects when parent is repositioned in page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nasko comments addressed Created 4 years, 9 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 | « content/browser/frame_host/frame_tree.cc ('k') | 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 (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
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 10 matching lines...) Expand all
5170 bool message_received_; 5171 bool message_received_;
5171 5172
5172 DISALLOW_COPY_AND_ASSIGN(ShowWidgetMessageFilter); 5173 DISALLOW_COPY_AND_ASSIGN(ShowWidgetMessageFilter);
5173 }; 5174 };
5174 5175
5175 // Test that clicking a select element in an out-of-process iframe creates 5176 // Test that clicking a select element in an out-of-process iframe creates
5176 // a popup menu in the correct position. 5177 // a popup menu in the correct position.
5177 #if defined(OS_ANDROID) || defined(OS_MACOSX) 5178 #if defined(OS_ANDROID) || defined(OS_MACOSX)
5178 // Page Popups work differently on Aura than on Android and Mac. This tests 5179 // Page Popups work differently on Aura than on Android and Mac. This tests
5179 // only the Aura mechanism. 5180 // only the Aura mechanism.
5180 #define MAYBE_PagePopupMenuTest DISABLED_PagePopupMenuTest 5181 #define MAYBE_PopupMenuTest DISABLED_PopupMenuTest
5181 #else 5182 #else
5182 #define MAYBE_PagePopupMenuTest PagePopupMenuTest 5183 #define MAYBE_PopupMenuTest PopupMenuTest
5183 #endif 5184 #endif
5184 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_PagePopupMenuTest) { 5185 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_PopupMenuTest) {
5185 GURL main_url( 5186 GURL main_url(
5186 embedded_test_server()->GetURL("/cross_site_iframe_factory.html?a(a)")); 5187 embedded_test_server()->GetURL("/cross_site_iframe_factory.html?a(a)"));
5187 NavigateToURL(shell(), main_url); 5188 NavigateToURL(shell(), main_url);
5188 5189
5189 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 5190 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
5190 ->GetFrameTree() 5191 ->GetFrameTree()
5191 ->root(); 5192 ->root();
5192 5193
5193 // Position main window to ensure consistent screen coordinates. 5194 // Position main window to ensure consistent screen coordinates.
5194 RenderWidgetHostViewBase* rwhv_root = static_cast<RenderWidgetHostViewBase*>( 5195 RenderWidgetHostViewBase* rwhv_root = static_cast<RenderWidgetHostViewBase*>(
(...skipping 27 matching lines...) Expand all
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_NestedPopupMenuTest DISABLED_NestedPopupMenuTest
5241 #else
5242 #define MAYBE_NestedPopupMenuTest NestedPopupMenuTest
5243 #endif
5244 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_NestedPopupMenuTest) {
5245 GURL main_url(embedded_test_server()->GetURL(
5246 "/cross_site_iframe_factory.html?a(b(c))"));
5247 NavigateToURL(shell(), main_url);
5248
5249 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
5250 ->GetFrameTree()
5251 ->root();
5252
5253 // Position main window to ensure consistent screen coordinates.
5254 RenderWidgetHostViewBase* rwhv_root = static_cast<RenderWidgetHostViewBase*>(
5255 root->current_frame_host()->GetRenderWidgetHost()->GetView());
5256 rwhv_root->SetBounds(gfx::Rect(100, 100, 500, 500));
5257 static_cast<WebContentsImpl*>(shell()->web_contents())->SendScreenRects();
5258
5259 // For clarity, we are labeling the frame tree nodes as:
5260 // - root_node
5261 // \-> b_node (out-of-process from root and c_node)
5262 // \-> c_node (out-of-process from root and b_node)
5263
5264 content::TestNavigationObserver navigation_observer(shell()->web_contents());
5265 FrameTreeNode* b_node = root->child_at(0);
5266 FrameTreeNode* c_node = b_node->child_at(0);
5267 GURL site_url(embedded_test_server()->GetURL(
5268 "baz.com", "/site_isolation/page-with-select.html"));
5269 NavigateFrameToURL(c_node, site_url);
5270
5271 RenderWidgetHostViewBase* rwhv_c_node =
5272 static_cast<RenderWidgetHostViewBase*>(
5273 c_node->current_frame_host()->GetRenderWidgetHost()->GetView());
5274
5275 EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
5276 c_node->current_frame_host()->GetSiteInstance());
5277
5278 scoped_refptr<ShowWidgetMessageFilter> filter = new ShowWidgetMessageFilter();
5279 c_node->current_frame_host()->GetProcess()->AddFilter(filter.get());
5280
5281 // Target left-click event to child frame.
5282 blink::WebMouseEvent click_event;
5283 click_event.type = blink::WebInputEvent::MouseDown;
5284 click_event.button = blink::WebPointerProperties::ButtonLeft;
5285 click_event.x = 15;
5286 click_event.y = 15;
5287 click_event.clickCount = 1;
5288 rwhv_c_node->ProcessMouseEvent(click_event);
5289
5290 filter->Wait();
5291
5292 gfx::Rect popup_rect = filter->last_initial_rect();
5293
5294 EXPECT_EQ(popup_rect.x() - rwhv_root->GetViewBounds().x(), 354);
5295 EXPECT_EQ(popup_rect.y() - rwhv_root->GetViewBounds().y(), 154);
5296
5297 // Prompt the WebContents to dismiss the popup by clicking elsewhere.
5298 click_event.button = blink::WebPointerProperties::ButtonLeft;
5299 click_event.x = 1;
5300 click_event.y = 1;
5301 click_event.clickCount = 1;
5302 rwhv_c_node->ProcessMouseEvent(click_event);
5303
5304 // Save the screen rect for b_node. Since it updates asynchronously from
5305 // the script command that changes it, we need to wait for it to change
5306 // before attempting to create the popup widget again.
5307 gfx::Rect last_b_node_bounds_rect =
5308 b_node->current_frame_host()->GetView()->GetViewBounds();
5309
5310 std::string script =
5311 "var iframe = document.querySelector('iframe');"
5312 "iframe.style.position = 'absolute';"
5313 "iframe.style.left = 150;"
5314 "iframe.style.top = 150;";
5315 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script));
5316
5317 filter->Reset();
5318
5319 // Busy loop to wait for b_node's screen rect to get updated. There
5320 // doesn't seem to be any better way to find out when this happens.
5321 while (last_b_node_bounds_rect.x() ==
5322 b_node->current_frame_host()->GetView()->GetViewBounds().x() &&
5323 last_b_node_bounds_rect.y() ==
5324 b_node->current_frame_host()->GetView()->GetViewBounds().y()) {
5325 base::RunLoop run_loop;
5326 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
5327 FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout());
5328 run_loop.Run();
5329 }
5330
5331 click_event.button = blink::WebPointerProperties::ButtonLeft;
5332 click_event.x = 15;
5333 click_event.y = 15;
5334 click_event.clickCount = 1;
5335 rwhv_c_node->ProcessMouseEvent(click_event);
5336
5337 filter->Wait();
5338
5339 popup_rect = filter->last_initial_rect();
5340
5341 EXPECT_EQ(popup_rect.x() - rwhv_root->GetViewBounds().x(), 203);
5342 EXPECT_EQ(popup_rect.y() - rwhv_root->GetViewBounds().y(), 248);
5343 }
5344
5232 // Test for https://crbug.com/526304, where a parent frame executes a 5345 // 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 5346 // 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 5347 // child frame. This test exercises the path where the detach happens before
5235 // the provisional local frame is created. 5348 // the provisional local frame is created.
5236 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 5349 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
5237 NavigateProxyAndDetachBeforeProvisionalFrameCreation) { 5350 NavigateProxyAndDetachBeforeProvisionalFrameCreation) {
5238 GURL main_url(embedded_test_server()->GetURL( 5351 GURL main_url(embedded_test_server()->GetURL(
5239 "a.com", "/cross_site_iframe_factory.html?a(b,b)")); 5352 "a.com", "/cross_site_iframe_factory.html?a(b,b)"));
5240 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 5353 EXPECT_TRUE(NavigateToURL(shell(), main_url));
5241 5354
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
6137 EXPECT_EQ(b_url, root->current_url()); 6250 EXPECT_EQ(b_url, root->current_url());
6138 6251
6139 // Verify that the same RenderViewHost is preserved and that it is no longer 6252 // Verify that the same RenderViewHost is preserved and that it is no longer
6140 // in swapped out state. 6253 // in swapped out state.
6141 EXPECT_EQ(rvh, contents->GetFrameTree()->GetRenderViewHost( 6254 EXPECT_EQ(rvh, contents->GetFrameTree()->GetRenderViewHost(
6142 root->current_frame_host()->GetSiteInstance())); 6255 root->current_frame_host()->GetSiteInstance()));
6143 EXPECT_FALSE(rvh->is_swapped_out_); 6256 EXPECT_FALSE(rvh->is_swapped_out_);
6144 } 6257 }
6145 6258
6146 } // namespace content 6259 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/frame_tree.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698