| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "base/values.h" | 6 #include "base/values.h" |
| 7 #include "content/browser/frame_host/navigation_entry_impl.h" | 7 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 8 #include "content/browser/web_contents/web_contents_impl.h" | 8 #include "content/browser/web_contents/web_contents_impl.h" |
| 9 #include "content/public/browser/load_notification_details.h" | 9 #include "content/public/browser/load_notification_details.h" |
| 10 #include "content/public/browser/navigation_controller.h" | 10 #include "content/public/browser/navigation_controller.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 namespace content { | 27 namespace content { |
| 28 | 28 |
| 29 void ResizeWebContentsView(Shell* shell, const gfx::Size& size, | 29 void ResizeWebContentsView(Shell* shell, const gfx::Size& size, |
| 30 bool set_start_page) { | 30 bool set_start_page) { |
| 31 // Shell::SizeTo is not implemented on Aura; WebContentsView::SizeContents | 31 // Shell::SizeTo is not implemented on Aura; WebContentsView::SizeContents |
| 32 // works on Win and ChromeOS but not Linux - we need to resize the shell | 32 // works on Win and ChromeOS but not Linux - we need to resize the shell |
| 33 // window on Linux because if we don't, the next layout of the unchanged shell | 33 // window on Linux because if we don't, the next layout of the unchanged shell |
| 34 // window will resize WebContentsView back to the previous size. | 34 // window will resize WebContentsView back to the previous size. |
| 35 // SizeContents is a hack and should not be relied on. | 35 // SizeContents is a hack and should not be relied on. |
| 36 #if defined(TOOLKIT_GTK) || defined(OS_MACOSX) | 36 #if defined(OS_MACOSX) |
| 37 shell->SizeTo(size); | 37 shell->SizeTo(size); |
| 38 // If |set_start_page| is true, start with blank page to make sure resize | 38 // If |set_start_page| is true, start with blank page to make sure resize |
| 39 // takes effect. | 39 // takes effect. |
| 40 if (set_start_page) | 40 if (set_start_page) |
| 41 NavigateToURL(shell, GURL("about://blank")); | 41 NavigateToURL(shell, GURL("about://blank")); |
| 42 #else | 42 #else |
| 43 shell->web_contents()->GetView()->SizeContents(size); | 43 shell->web_contents()->GetView()->SizeContents(size); |
| 44 #endif // defined(TOOLKIT_GTK) || defined(OS_MACOSX) | 44 #endif // defined(OS_MACOSX) |
| 45 } | 45 } |
| 46 | 46 |
| 47 class WebContentsImplBrowserTest : public ContentBrowserTest { | 47 class WebContentsImplBrowserTest : public ContentBrowserTest { |
| 48 public: | 48 public: |
| 49 WebContentsImplBrowserTest() {} | 49 WebContentsImplBrowserTest() {} |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 DISALLOW_COPY_AND_ASSIGN(WebContentsImplBrowserTest); | 52 DISALLOW_COPY_AND_ASSIGN(WebContentsImplBrowserTest); |
| 53 }; | 53 }; |
| 54 | 54 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 &shell()->web_contents()->GetController()); | 251 &shell()->web_contents()->GetController()); |
| 252 ASSERT_TRUE(ExecuteScript(shell()->web_contents(), | 252 ASSERT_TRUE(ExecuteScript(shell()->web_contents(), |
| 253 "window.location.href=\"#foo\";")); | 253 "window.location.href=\"#foo\";")); |
| 254 load_observer2.Wait(); | 254 load_observer2.Wait(); |
| 255 EXPECT_EQ(embedded_test_server()->GetURL("/title1.html#foo"), | 255 EXPECT_EQ(embedded_test_server()->GetURL("/title1.html#foo"), |
| 256 shell()->web_contents()->GetVisibleURL()); | 256 shell()->web_contents()->GetVisibleURL()); |
| 257 } | 257 } |
| 258 | 258 |
| 259 // TODO(shrikant): enable this for Windows when issue with | 259 // TODO(shrikant): enable this for Windows when issue with |
| 260 // force-compositing-mode is resolved (http://crbug.com/281726). | 260 // force-compositing-mode is resolved (http://crbug.com/281726). |
| 261 // For TOOLKIT_GTK failure, see http://crbug.com/351234. | |
| 262 // Also crashes under ThreadSanitizer, http://crbug.com/356758. | 261 // Also crashes under ThreadSanitizer, http://crbug.com/356758. |
| 263 #if defined(OS_WIN) || defined(OS_ANDROID) || defined(TOOLKIT_GTK) \ | 262 #if defined(OS_WIN) || defined(OS_ANDROID) \ |
| 264 || defined(THREAD_SANITIZER) | 263 || defined(THREAD_SANITIZER) |
| 265 #define MAYBE_GetSizeForNewRenderView DISABLED_GetSizeForNewRenderView | 264 #define MAYBE_GetSizeForNewRenderView DISABLED_GetSizeForNewRenderView |
| 266 #else | 265 #else |
| 267 #define MAYBE_GetSizeForNewRenderView GetSizeForNewRenderView | 266 #define MAYBE_GetSizeForNewRenderView GetSizeForNewRenderView |
| 268 #endif | 267 #endif |
| 269 // Test that RenderViewHost is created and updated at the size specified by | 268 // Test that RenderViewHost is created and updated at the size specified by |
| 270 // WebContentsDelegate::GetSizeForNewRenderView(). | 269 // WebContentsDelegate::GetSizeForNewRenderView(). |
| 271 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, | 270 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, |
| 272 MAYBE_GetSizeForNewRenderView) { | 271 MAYBE_GetSizeForNewRenderView) { |
| 273 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 272 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 // LoadingStateChanged should be called 4 times: start and stop for the | 431 // LoadingStateChanged should be called 4 times: start and stop for the |
| 433 // initial load of push_state.html, and start and stop for the "navigation" | 432 // initial load of push_state.html, and start and stop for the "navigation" |
| 434 // triggered by history.pushState(). However, the start notification for the | 433 // triggered by history.pushState(). However, the start notification for the |
| 435 // history.pushState() navigation should set to_different_document to false. | 434 // history.pushState() navigation should set to_different_document to false. |
| 436 EXPECT_EQ("pushState", shell()->web_contents()->GetURL().ref()); | 435 EXPECT_EQ("pushState", shell()->web_contents()->GetURL().ref()); |
| 437 EXPECT_EQ(4, delegate->loadingStateChangedCount()); | 436 EXPECT_EQ(4, delegate->loadingStateChangedCount()); |
| 438 EXPECT_EQ(3, delegate->loadingStateToDifferentDocumentCount()); | 437 EXPECT_EQ(3, delegate->loadingStateToDifferentDocumentCount()); |
| 439 } | 438 } |
| 440 | 439 |
| 441 } // namespace content | 440 } // namespace content |
| OLD | NEW |