OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "content/browser/frame_host/frame_navigation_entry.h" | 8 #include "content/browser/frame_host/frame_navigation_entry.h" |
9 #include "content/browser/frame_host/frame_tree.h" | 9 #include "content/browser/frame_host/frame_tree.h" |
10 #include "content/browser/frame_host/navigation_controller_impl.h" | 10 #include "content/browser/frame_host/navigation_controller_impl.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 "foo.com", "/navigation_controller/simple_page_1.html")); | 59 "foo.com", "/navigation_controller/simple_page_1.html")); |
60 NavigateFrameToURL(root->child_at(0), foo_url); | 60 NavigateFrameToURL(root->child_at(0), foo_url); |
61 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 61 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
62 | 62 |
63 // We should only have swapped processes in --site-per-process. | 63 // We should only have swapped processes in --site-per-process. |
64 bool cross_process = root->current_frame_host()->GetProcess() != | 64 bool cross_process = root->current_frame_host()->GetProcess() != |
65 root->child_at(0)->current_frame_host()->GetProcess(); | 65 root->child_at(0)->current_frame_host()->GetProcess(); |
66 EXPECT_EQ(AreAllSitesIsolatedForTesting(), cross_process); | 66 EXPECT_EQ(AreAllSitesIsolatedForTesting(), cross_process); |
67 } | 67 } |
68 | 68 |
| 69 // Verifies that the base, history, and data URLs for LoadDataWithBaseURL end up |
| 70 // in the expected parts of the NavigationEntry in each stage of navigation, and |
| 71 // that we don't kill the renderer on reload. See https://crbug.com/522567. |
69 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, LoadDataWithBaseURL) { | 72 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, LoadDataWithBaseURL) { |
70 const GURL base_url("http://baseurl"); | 73 const GURL base_url("http://baseurl"); |
71 const GURL history_url("http://historyurl"); | 74 const GURL history_url("http://historyurl"); |
72 const std::string data = "<html><body>foo</body></html>"; | 75 const std::string data = "<html><body>foo</body></html>"; |
| 76 const GURL data_url = GURL("data:text/html;charset=utf-8," + data); |
73 | 77 |
74 const NavigationController& controller = | 78 const NavigationControllerImpl& controller = |
75 shell()->web_contents()->GetController(); | 79 static_cast<const NavigationControllerImpl&>( |
76 // Load data. Blocks until it is done. | 80 shell()->web_contents()->GetController()); |
77 content::LoadDataWithBaseURL(shell(), history_url, data, base_url); | |
78 | 81 |
79 // We should use history_url instead of the base_url as the original url of | 82 // Load data, but don't commit yet. |
| 83 TestNavigationObserver same_tab_observer(shell()->web_contents(), 1); |
| 84 shell()->LoadDataWithBaseURL(history_url, data, base_url); |
| 85 |
| 86 // Verify the pending NavigationEntry. |
| 87 NavigationEntryImpl* pending_entry = controller.GetPendingEntry(); |
| 88 EXPECT_EQ(base_url, pending_entry->GetBaseURLForDataURL()); |
| 89 EXPECT_EQ(history_url, pending_entry->GetVirtualURL()); |
| 90 EXPECT_EQ(history_url, pending_entry->GetHistoryURLForDataURL()); |
| 91 EXPECT_EQ(data_url, pending_entry->GetURL()); |
| 92 |
| 93 // Let the navigation commit. |
| 94 same_tab_observer.Wait(); |
| 95 |
| 96 // Verify the last committed NavigationEntry. |
| 97 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); |
| 98 EXPECT_EQ(base_url, entry->GetBaseURLForDataURL()); |
| 99 EXPECT_EQ(history_url, entry->GetVirtualURL()); |
| 100 EXPECT_EQ(history_url, entry->GetHistoryURLForDataURL()); |
| 101 EXPECT_EQ(data_url, entry->GetURL()); |
| 102 |
| 103 // We should use data_url instead of the base_url as the original url of |
80 // this navigation entry, because base_url is only used for resolving relative | 104 // this navigation entry, because base_url is only used for resolving relative |
81 // paths in the data, or enforcing same origin policy. | 105 // paths in the data, or enforcing same origin policy. |
82 EXPECT_EQ(controller.GetVisibleEntry()->GetOriginalRequestURL(), history_url); | 106 EXPECT_EQ(data_url, entry->GetOriginalRequestURL()); |
| 107 |
| 108 // Now reload and make sure the renderer isn't killed. |
| 109 ReloadBlockUntilNavigationsComplete(shell(), 1); |
| 110 EXPECT_TRUE(shell()->web_contents()->GetMainFrame()->IsRenderFrameLive()); |
| 111 |
| 112 // Verify the last committed NavigationEntry hasn't changed. |
| 113 NavigationEntryImpl* reload_entry = controller.GetLastCommittedEntry(); |
| 114 EXPECT_EQ(entry, reload_entry); |
| 115 EXPECT_EQ(base_url, reload_entry->GetBaseURLForDataURL()); |
| 116 EXPECT_EQ(history_url, reload_entry->GetVirtualURL()); |
| 117 EXPECT_EQ(history_url, reload_entry->GetHistoryURLForDataURL()); |
| 118 EXPECT_EQ(data_url, reload_entry->GetOriginalRequestURL()); |
| 119 EXPECT_EQ(data_url, reload_entry->GetURL()); |
83 } | 120 } |
84 | 121 |
85 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, UniqueIDs) { | 122 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, UniqueIDs) { |
86 const NavigationControllerImpl& controller = | 123 const NavigationControllerImpl& controller = |
87 static_cast<const NavigationControllerImpl&>( | 124 static_cast<const NavigationControllerImpl&>( |
88 shell()->web_contents()->GetController()); | 125 shell()->web_contents()->GetController()); |
89 | 126 |
90 GURL main_url(embedded_test_server()->GetURL( | 127 GURL main_url(embedded_test_server()->GetURL( |
91 "/navigation_controller/page_with_link_to_load_iframe.html")); | 128 "/navigation_controller/page_with_link_to_load_iframe.html")); |
92 NavigateToURL(shell(), main_url); | 129 NavigateToURL(shell(), main_url); |
(...skipping 2425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2518 EXPECT_EQ(original_url, capturer.all_params()[1].url); | 2555 EXPECT_EQ(original_url, capturer.all_params()[1].url); |
2519 EXPECT_EQ(original_url, shell()->web_contents()->GetLastCommittedURL()); | 2556 EXPECT_EQ(original_url, shell()->web_contents()->GetLastCommittedURL()); |
2520 } | 2557 } |
2521 | 2558 |
2522 // Make sure the renderer is still alive. | 2559 // Make sure the renderer is still alive. |
2523 EXPECT_TRUE( | 2560 EXPECT_TRUE( |
2524 ExecuteScript(shell()->web_contents(), "console.log('Success');")); | 2561 ExecuteScript(shell()->web_contents(), "console.log('Success');")); |
2525 } | 2562 } |
2526 | 2563 |
2527 } // namespace content | 2564 } // namespace content |
OLD | NEW |