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/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 shell()->web_contents()->GetController(); | 50 shell()->web_contents()->GetController(); |
51 // Load data. Blocks until it is done. | 51 // Load data. Blocks until it is done. |
52 content::LoadDataWithBaseURL(shell(), history_url, data, base_url); | 52 content::LoadDataWithBaseURL(shell(), history_url, data, base_url); |
53 | 53 |
54 // We should use history_url instead of the base_url as the original url of | 54 // We should use history_url instead of the base_url as the original url of |
55 // this navigation entry, because base_url is only used for resolving relative | 55 // this navigation entry, because base_url is only used for resolving relative |
56 // paths in the data, or enforcing same origin policy. | 56 // paths in the data, or enforcing same origin policy. |
57 EXPECT_EQ(controller.GetVisibleEntry()->GetOriginalRequestURL(), history_url); | 57 EXPECT_EQ(controller.GetVisibleEntry()->GetOriginalRequestURL(), history_url); |
58 } | 58 } |
59 | 59 |
| 60 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, UniqueIDs) { |
| 61 const NavigationControllerImpl& controller = |
| 62 static_cast<const NavigationControllerImpl&>( |
| 63 shell()->web_contents()->GetController()); |
| 64 |
| 65 GURL main_url(embedded_test_server()->GetURL( |
| 66 "/navigation_controller/page_with_link_to_load_iframe.html")); |
| 67 NavigateToURL(shell(), main_url); |
| 68 ASSERT_EQ(1, controller.GetEntryCount()); |
| 69 |
| 70 // Use JavaScript to click the link and load the iframe. |
| 71 std::string script = "document.getElementById('link').click()"; |
| 72 EXPECT_TRUE(content::ExecuteScript(shell()->web_contents(), script)); |
| 73 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 74 ASSERT_EQ(2, controller.GetEntryCount()); |
| 75 |
| 76 // Unique IDs should... um... be unique. |
| 77 ASSERT_NE(controller.GetEntryAtIndex(0)->GetUniqueID(), |
| 78 controller.GetEntryAtIndex(1)->GetUniqueID()); |
| 79 } |
| 80 |
60 // The renderer uses the position in the history list as a clue to whether a | 81 // The renderer uses the position in the history list as a clue to whether a |
61 // navigation is stale. In the case where the entry limit is reached and the | 82 // navigation is stale. In the case where the entry limit is reached and the |
62 // history list is pruned, make sure that there is no mismatch that would cause | 83 // history list is pruned, make sure that there is no mismatch that would cause |
63 // it to start incorrectly rejecting navigations as stale. See | 84 // it to start incorrectly rejecting navigations as stale. See |
64 // http://crbug.com/89798. | 85 // http://crbug.com/89798. |
65 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 86 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
66 DontIgnoreBackAfterNavEntryLimit) { | 87 DontIgnoreBackAfterNavEntryLimit) { |
67 NavigationController& controller = | 88 NavigationController& controller = |
68 shell()->web_contents()->GetController(); | 89 shell()->web_contents()->GetController(); |
69 | 90 |
(...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1409 // tricky. | 1430 // tricky. |
1410 EXPECT_EQ(nullptr, controller.GetPendingEntry()); | 1431 EXPECT_EQ(nullptr, controller.GetPendingEntry()); |
1411 shell()->web_contents()->Stop(); | 1432 shell()->web_contents()->Stop(); |
1412 watcher.Wait(); | 1433 watcher.Wait(); |
1413 } | 1434 } |
1414 | 1435 |
1415 ResourceDispatcherHost::Get()->SetDelegate(nullptr); | 1436 ResourceDispatcherHost::Get()->SetDelegate(nullptr); |
1416 } | 1437 } |
1417 | 1438 |
1418 } // namespace content | 1439 } // namespace content |
OLD | NEW |