| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "content/browser/frame_host/frame_tree_node.h" | 7 #include "content/browser/frame_host/frame_tree_node.h" |
| 8 #include "content/browser/frame_host/render_frame_host_impl.h" | 8 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 9 #include "content/browser/web_contents/web_contents_impl.h" | 9 #include "content/browser/web_contents/web_contents_impl.h" |
| 10 #include "content/public/browser/host_zoom_map.h" | 10 #include "content/public/browser/host_zoom_map.h" |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 scale_one_grandchild_width, kTolerance); | 309 scale_one_grandchild_width, kTolerance); |
| 310 | 310 |
| 311 const double new_default_zoom_level = | 311 const double new_default_zoom_level = |
| 312 default_zoom_level + ZoomFactorToZoomLevel(new_default_zoom_factor); | 312 default_zoom_level + ZoomFactorToZoomLevel(new_default_zoom_factor); |
| 313 | 313 |
| 314 host_zoom_map->SetZoomLevelForHost("b.com", new_default_zoom_level + 1.0); | 314 host_zoom_map->SetZoomLevelForHost("b.com", new_default_zoom_level + 1.0); |
| 315 host_zoom_map->SetDefaultZoomLevel(new_default_zoom_level); | 315 host_zoom_map->SetDefaultZoomLevel(new_default_zoom_level); |
| 316 | 316 |
| 317 WaitAndCheckFrameZoom(msg_queue, frame_observers); | 317 WaitAndCheckFrameZoom(msg_queue, frame_observers); |
| 318 } | 318 } |
| 319 EXPECT_DOUBLE_EQ( | 319 // Make this comparison approximate for Nexus5X test; |
| 320 // https://crbug.com/622858. |
| 321 EXPECT_NEAR( |
| 320 new_default_zoom_factor, | 322 new_default_zoom_factor, |
| 321 GetMainFrameZoomFactor(web_contents(), main_frame_window_border)); | 323 GetMainFrameZoomFactor(web_contents(), main_frame_window_border), |
| 324 0.01 |
| 325 ); |
| 322 } | 326 } |
| 323 | 327 |
| 324 IN_PROC_BROWSER_TEST_F(IFrameZoomBrowserTest, SiblingFramesZoom) { | 328 IN_PROC_BROWSER_TEST_F(IFrameZoomBrowserTest, SiblingFramesZoom) { |
| 325 std::string top_level_host("a.com"); | 329 std::string top_level_host("a.com"); |
| 326 GURL main_url(embedded_test_server()->GetURL( | 330 GURL main_url(embedded_test_server()->GetURL( |
| 327 top_level_host, "/cross_site_iframe_factory.html?a(b,b)")); | 331 top_level_host, "/cross_site_iframe_factory.html?a(b,b)")); |
| 328 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 332 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| 329 NavigationEntry* entry = | 333 NavigationEntry* entry = |
| 330 web_contents()->GetController().GetLastCommittedEntry(); | 334 web_contents()->GetController().GetLastCommittedEntry(); |
| 331 ASSERT_TRUE(entry); | 335 ASSERT_TRUE(entry); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 frame_observers.emplace_back(child, "child", | 412 frame_observers.emplace_back(child, "child", |
| 409 scale_one_child_width, kTolerance); | 413 scale_one_child_width, kTolerance); |
| 410 | 414 |
| 411 const double new_zoom_level = | 415 const double new_zoom_level = |
| 412 default_zoom_level + ZoomFactorToZoomLevel(new_zoom_factor); | 416 default_zoom_level + ZoomFactorToZoomLevel(new_zoom_factor); |
| 413 host_zoom_map->SetZoomLevelForHost(top_level_host, new_zoom_level); | 417 host_zoom_map->SetZoomLevelForHost(top_level_host, new_zoom_level); |
| 414 | 418 |
| 415 WaitAndCheckFrameZoom(msg_queue, frame_observers); | 419 WaitAndCheckFrameZoom(msg_queue, frame_observers); |
| 416 } | 420 } |
| 417 | 421 |
| 418 EXPECT_DOUBLE_EQ( | 422 // Make this comparison approximate for Nexus5X test; |
| 423 // https://crbug.com/622858. |
| 424 EXPECT_NEAR( |
| 419 new_zoom_factor, | 425 new_zoom_factor, |
| 420 GetMainFrameZoomFactor(web_contents(), main_frame_window_border)); | 426 GetMainFrameZoomFactor(web_contents(), main_frame_window_border), |
| 427 0.01 |
| 428 ); |
| 421 | 429 |
| 422 // Navigate child frame cross site, and make sure zoom is the same. | 430 // Navigate child frame cross site, and make sure zoom is the same. |
| 423 TestNavigationObserver observer(web_contents()); | 431 TestNavigationObserver observer(web_contents()); |
| 424 GURL url = embedded_test_server()->GetURL("c.com", "/title1.html"); | 432 GURL url = embedded_test_server()->GetURL("c.com", "/title1.html"); |
| 425 NavigateFrameToURL(root->child_at(0), url); | 433 NavigateFrameToURL(root->child_at(0), url); |
| 426 EXPECT_TRUE(observer.last_navigation_succeeded()); | 434 EXPECT_TRUE(observer.last_navigation_succeeded()); |
| 427 EXPECT_EQ(url, observer.last_navigation_url()); | 435 EXPECT_EQ(url, observer.last_navigation_url()); |
| 428 | 436 |
| 429 // Check that the child frame maintained the same scale after navigating | 437 // Check that the child frame maintained the same scale after navigating |
| 430 // cross-site. | 438 // cross-site. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 EXPECT_EQ(redirect_url, web_contents()->GetLastCommittedURL()); | 471 EXPECT_EQ(redirect_url, web_contents()->GetLastCommittedURL()); |
| 464 | 472 |
| 465 EXPECT_NEAR( | 473 EXPECT_NEAR( |
| 466 kZoomFactorForRedirectedHost, | 474 kZoomFactorForRedirectedHost, |
| 467 GetMainFrameZoomFactor(web_contents(), main_frame_window_border), | 475 GetMainFrameZoomFactor(web_contents(), main_frame_window_border), |
| 468 0.001); | 476 0.001); |
| 469 } | 477 } |
| 470 #endif | 478 #endif |
| 471 | 479 |
| 472 } // namespace content | 480 } // namespace content |
| OLD | NEW |