Commit 954dff9e authored by avi's avatar avi Committed by Commit bot

Ensure that unique ids are unique.

BUG=369661
TEST=NavigationControllerBrowserTest.UniqueIDs

Review URL: https://codereview.chromium.org/1139823006

Cr-Commit-Position: refs/heads/master@{#330893}
parent 803ff930
...@@ -57,6 +57,27 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, LoadDataWithBaseURL) { ...@@ -57,6 +57,27 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, LoadDataWithBaseURL) {
EXPECT_EQ(controller.GetVisibleEntry()->GetOriginalRequestURL(), history_url); EXPECT_EQ(controller.GetVisibleEntry()->GetOriginalRequestURL(), history_url);
} }
IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, UniqueIDs) {
const NavigationControllerImpl& controller =
static_cast<const NavigationControllerImpl&>(
shell()->web_contents()->GetController());
GURL main_url(embedded_test_server()->GetURL(
"/navigation_controller/page_with_link_to_load_iframe.html"));
NavigateToURL(shell(), main_url);
ASSERT_EQ(1, controller.GetEntryCount());
// Use JavaScript to click the link and load the iframe.
std::string script = "document.getElementById('link').click()";
EXPECT_TRUE(content::ExecuteScript(shell()->web_contents(), script));
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
ASSERT_EQ(2, controller.GetEntryCount());
// Unique IDs should... um... be unique.
ASSERT_NE(controller.GetEntryAtIndex(0)->GetUniqueID(),
controller.GetEntryAtIndex(1)->GetUniqueID());
}
// The renderer uses the position in the history list as a clue to whether a // The renderer uses the position in the history list as a clue to whether a
// navigation is stale. In the case where the entry limit is reached and the // navigation is stale. In the case where the entry limit is reached and the
// history list is pruned, make sure that there is no mismatch that would cause // history list is pruned, make sure that there is no mismatch that would cause
......
...@@ -346,8 +346,8 @@ NavigationEntryImpl* NavigationEntryImpl::Clone() const { ...@@ -346,8 +346,8 @@ NavigationEntryImpl* NavigationEntryImpl::Clone() const {
// the same tab. // the same tab.
copy->frame_tree_.reset(frame_tree_->Clone()); copy->frame_tree_.reset(frame_tree_->Clone());
// Copy all state over, unless cleared in ResetForCommit. // Copy most state over, unless cleared in ResetForCommit.
copy->unique_id_ = unique_id_; // Don't copy unique_id_, otherwise it won't be unique.
copy->bindings_ = bindings_; copy->bindings_ = bindings_;
copy->page_type_ = page_type_; copy->page_type_ = page_type_;
copy->virtual_url_ = virtual_url_; copy->virtual_url_ = virtual_url_;
......
<html>
<head></head>
<body>
<p><a href="simple_page_1.html" id="link" target="frame">go</a>
<p><iframe src="about:blank" name="frame"></iframe>
</body>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment