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

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

Issue 1802383004: Fix in-page navigation after LoadDataWithBaseURL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test for LoadDataAsStringWithBaseURL on android 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 | « no previous file | content/renderer/render_frame_impl.h » ('j') | 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 same_tab_observer.Wait(); 196 same_tab_observer.Wait();
197 EXPECT_EQ(2, controller.GetEntryCount()); 197 EXPECT_EQ(2, controller.GetEntryCount());
198 NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); 198 NavigationEntryImpl* entry = controller.GetLastCommittedEntry();
199 EXPECT_TRUE(entry->GetBaseURLForDataURL().is_empty()); 199 EXPECT_TRUE(entry->GetBaseURLForDataURL().is_empty());
200 EXPECT_TRUE(entry->GetHistoryURLForDataURL().is_empty()); 200 EXPECT_TRUE(entry->GetHistoryURLForDataURL().is_empty());
201 EXPECT_EQ(navigate_url, entry->GetVirtualURL()); 201 EXPECT_EQ(navigate_url, entry->GetVirtualURL());
202 EXPECT_EQ(navigate_url, entry->GetURL()); 202 EXPECT_EQ(navigate_url, entry->GetURL());
203 } 203 }
204 } 204 }
205 205
206 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
207 FragmentNavigateFromLoadDataWithBaseURL) {
208 const GURL base_url("http://baseurl");
209 const GURL history_url("http://historyurl");
210 const std::string data =
211 "<html><body>"
212 " <p id=\"frag\"><a id=\"fraglink\" href=\"#frag\">in-page nav</a></p>"
213 "</body></html>";
214
215 const NavigationControllerImpl& controller =
216 static_cast<const NavigationControllerImpl&>(
217 shell()->web_contents()->GetController());
218
219 // Load data and commit.
220 TestNavigationObserver same_tab_observer(shell()->web_contents(), 1);
221 #if defined(OS_ANDROID)
222 shell()->LoadDataAsStringWithBaseURL(history_url, data, base_url);
223 #else
224 shell()->LoadDataWithBaseURL(history_url, data, base_url);
225 #endif
226 same_tab_observer.Wait();
227 EXPECT_EQ(1, controller.GetEntryCount());
228 const GURL data_url = controller.GetLastCommittedEntry()->GetURL();
229
230 // Perform a fragment navigation using a javascript: URL.
231 GURL js_url("javascript:document.location = '#frag';");
232 NavigateToURL(shell(), js_url);
233 EXPECT_EQ(2, controller.GetEntryCount());
234 NavigationEntryImpl* entry = controller.GetLastCommittedEntry();
235 // TODO(boliu): These expectations maybe incorrect due to crbug.com/561034.
236 EXPECT_TRUE(entry->GetBaseURLForDataURL().is_empty());
237 EXPECT_TRUE(entry->GetHistoryURLForDataURL().is_empty());
238 EXPECT_EQ(data_url, entry->GetVirtualURL());
239 EXPECT_EQ(data_url, entry->GetURL());
240
241 // Passes if renderer is still alive.
242 EXPECT_TRUE(
243 ExecuteScript(shell()->web_contents(), "console.log('Success');"));
244 }
245
206 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, UniqueIDs) { 246 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, UniqueIDs) {
207 const NavigationControllerImpl& controller = 247 const NavigationControllerImpl& controller =
208 static_cast<const NavigationControllerImpl&>( 248 static_cast<const NavigationControllerImpl&>(
209 shell()->web_contents()->GetController()); 249 shell()->web_contents()->GetController());
210 250
211 GURL main_url(embedded_test_server()->GetURL( 251 GURL main_url(embedded_test_server()->GetURL(
212 "/navigation_controller/page_with_link_to_load_iframe.html")); 252 "/navigation_controller/page_with_link_to_load_iframe.html"));
213 NavigateToURL(shell(), main_url); 253 NavigateToURL(shell(), main_url);
214 ASSERT_EQ(1, controller.GetEntryCount()); 254 ASSERT_EQ(1, controller.GetEntryCount());
215 255
(...skipping 3258 matching lines...) Expand 10 before | Expand all | Expand 10 after
3474 observer.Wait(); 3514 observer.Wait();
3475 3515
3476 EXPECT_EQ(3, controller.GetEntryCount()); 3516 EXPECT_EQ(3, controller.GetEntryCount());
3477 EXPECT_EQ(3, RendererHistoryLength(shell())); 3517 EXPECT_EQ(3, RendererHistoryLength(shell()));
3478 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); 3518 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
3479 3519
3480 EXPECT_EQ(frame_url_1, frame->current_url()); 3520 EXPECT_EQ(frame_url_1, frame->current_url());
3481 } 3521 }
3482 3522
3483 } // namespace content 3523 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/render_frame_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698