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

Side by Side Diff: content/browser/frame_host/navigation_controller_impl_browsertest.cc

Issue 2099623002: Add a content_browsertest for LoadDataWithBaseURL + Back. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Windows compile Created 4 years, 5 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 | « no previous file | 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 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 "content/browser/frame_host/navigation_controller_impl.h" 5 #include "content/browser/frame_host/navigation_controller_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // Verify the last committed NavigationEntry hasn't changed. 125 // Verify the last committed NavigationEntry hasn't changed.
126 NavigationEntryImpl* reload_entry = controller.GetLastCommittedEntry(); 126 NavigationEntryImpl* reload_entry = controller.GetLastCommittedEntry();
127 EXPECT_EQ(entry, reload_entry); 127 EXPECT_EQ(entry, reload_entry);
128 EXPECT_EQ(base_url, reload_entry->GetBaseURLForDataURL()); 128 EXPECT_EQ(base_url, reload_entry->GetBaseURLForDataURL());
129 EXPECT_EQ(history_url, reload_entry->GetVirtualURL()); 129 EXPECT_EQ(history_url, reload_entry->GetVirtualURL());
130 EXPECT_EQ(history_url, reload_entry->GetHistoryURLForDataURL()); 130 EXPECT_EQ(history_url, reload_entry->GetHistoryURLForDataURL());
131 EXPECT_EQ(data_url, reload_entry->GetOriginalRequestURL()); 131 EXPECT_EQ(data_url, reload_entry->GetOriginalRequestURL());
132 EXPECT_EQ(data_url, reload_entry->GetURL()); 132 EXPECT_EQ(data_url, reload_entry->GetURL());
133 } 133 }
134 134
135 // Verify which page loads when going back to a LoadDataWithBaseURL entry.
136 // See https://crbug.com/612196.
137 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
138 LoadDataWithBaseURLTitleAfterBack) {
139 const GURL base_url("http://baseurl");
140 const GURL history_url(
141 embedded_test_server()->GetURL("/navigation_controller/form.html"));
142 const std::string data1 = "<html><title>One</title><body>foo</body></html>";
143 const GURL data_url1 = GURL("data:text/html;charset=utf-8," + data1);
144
145 NavigationControllerImpl& controller = static_cast<NavigationControllerImpl&>(
146 shell()->web_contents()->GetController());
147
148 {
149 TestNavigationObserver same_tab_observer(shell()->web_contents(), 1);
150 shell()->LoadDataWithBaseURL(history_url, data1, base_url);
151 same_tab_observer.Wait();
152 }
153
154 // Verify the last committed NavigationEntry.
155 NavigationEntryImpl* entry = controller.GetLastCommittedEntry();
156 EXPECT_EQ(base_url, entry->GetBaseURLForDataURL());
157 EXPECT_EQ(history_url, entry->GetVirtualURL());
158 EXPECT_EQ(history_url, entry->GetHistoryURLForDataURL());
159 EXPECT_EQ(data_url1, entry->GetURL());
160
161 // Navigate again to a different data URL.
162 const std::string data2 = "<html><title>Two</title><body>bar</body></html>";
163 const GURL data_url2 = GURL("data:text/html;charset=utf-8," + data2);
164 {
165 TestNavigationObserver same_tab_observer(shell()->web_contents(), 1);
166 // Load data, not loaddatawithbaseurl.
167 EXPECT_TRUE(NavigateToURL(shell(), data_url2));
168 same_tab_observer.Wait();
169 }
170
171 // Go back.
172 TestNavigationObserver back_load_observer(shell()->web_contents());
173 controller.GoBack();
174 back_load_observer.Wait();
175
176 // Check title.
177 // TODO(creis): The default navigation path incorrectly loads the history_url
178 // and claims it loaded the data_url (due to a bug where GoToEntry does not
179 // handle this case). This is confusing. When using subframe
180 // FrameNavigationEntries, we load the data URL when going back, as expected.
181 if (SiteIsolationPolicy::UseSubframeNavigationEntries())
Charlie Reis 2016/06/24 17:02:12 Here's the bit where I switch the test's expectati
182 EXPECT_EQ("One", base::UTF16ToUTF8(shell()->web_contents()->GetTitle()));
183 else
184 EXPECT_EQ("form", base::UTF16ToUTF8(shell()->web_contents()->GetTitle()));
185
186 // Verify the last committed NavigationEntry.
187 NavigationEntryImpl* back_entry = controller.GetLastCommittedEntry();
188 EXPECT_EQ(base_url, back_entry->GetBaseURLForDataURL());
189 EXPECT_EQ(history_url, back_entry->GetVirtualURL());
190 EXPECT_EQ(history_url, back_entry->GetHistoryURLForDataURL());
191 EXPECT_EQ(data_url1, back_entry->GetOriginalRequestURL());
192 EXPECT_EQ(data_url1, back_entry->GetURL());
193
194 EXPECT_EQ(data_url1,
195 shell()->web_contents()->GetMainFrame()->GetLastCommittedURL());
196 }
197
135 #if defined(OS_ANDROID) 198 #if defined(OS_ANDROID)
136 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, 199 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
137 LoadDataWithInvalidBaseURL) { 200 LoadDataWithInvalidBaseURL) {
138 const GURL base_url("http://"); // Invalid. 201 const GURL base_url("http://"); // Invalid.
139 const GURL history_url("http://historyurl"); 202 const GURL history_url("http://historyurl");
140 const std::string title = "invalid_base_url"; 203 const std::string title = "invalid_base_url";
141 const std::string data = base::StringPrintf( 204 const std::string data = base::StringPrintf(
142 "<html><head><title>%s</title></head><body>foo</body></html>", 205 "<html><head><title>%s</title></head><body>foo</body></html>",
143 title.c_str()); 206 title.c_str());
144 const GURL data_url = GURL("data:text/html;charset=utf-8," + data); 207 const GURL data_url = GURL("data:text/html;charset=utf-8," + data);
(...skipping 4537 matching lines...) Expand 10 before | Expand all | Expand 10 after
4682 std::string body; 4745 std::string body;
4683 EXPECT_TRUE(ExecuteScriptAndExtractString( 4746 EXPECT_TRUE(ExecuteScriptAndExtractString(
4684 shell()->web_contents(), 4747 shell()->web_contents(),
4685 "window.domAutomationController.send(" 4748 "window.domAutomationController.send("
4686 "document.getElementsByTagName('pre')[0].innerText);", 4749 "document.getElementsByTagName('pre')[0].innerText);",
4687 &body)); 4750 &body));
4688 EXPECT_EQ("text=value\n", body); 4751 EXPECT_EQ("text=value\n", body);
4689 } 4752 }
4690 4753
4691 } // namespace content 4754 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698