Chromium Code Reviews| Index: Source/web/tests/WebFrameTest.cpp |
| diff --git a/Source/web/tests/WebFrameTest.cpp b/Source/web/tests/WebFrameTest.cpp |
| index 9e48b3385b43c931398739f86008b1903ea39a11..8d2b9843267f3662d015d30e6716ad4eedc66509 100644 |
| --- a/Source/web/tests/WebFrameTest.cpp |
| +++ b/Source/web/tests/WebFrameTest.cpp |
| @@ -5992,9 +5992,9 @@ private: |
| WebFrame* m_frame; |
| }; |
| -// Test which ensures that the first navigation in a subframe will always |
| -// result in history entry being replaced and not a new one added. |
| -TEST_P(ParameterizedWebFrameTest, DISABLED_FirstFrameNavigationReplacesHistory) |
|
Charlie Reis
2015/06/11 16:43:48
This was Nasko's test from https://codereview.chro
|
| +// Tests that the first navigation in an initially blank subframe will result in |
| +// a history entry being replaced and not a new one being added. |
| +TEST_P(ParameterizedWebFrameTest, FirstBlankSubframeNavigation) |
| { |
| registerMockedHttpURLLoad("history.html"); |
| registerMockedHttpURLLoad("find.html"); |
| @@ -6002,40 +6002,56 @@ TEST_P(ParameterizedWebFrameTest, DISABLED_FirstFrameNavigationReplacesHistory) |
| FrameTestHelpers::WebViewHelper webViewHelper(this); |
| TestHistoryWebFrameClient client; |
| webViewHelper.initializeAndLoad("about:blank", true, &client); |
| - EXPECT_TRUE(client.replacesCurrentHistoryItem()); |
| WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| - FrameTestHelpers::loadFrame(frame, |
| - "javascript:document.body.appendChild(document.createElement('iframe'))"); |
| + frame->executeScript(WebScriptSource(WebString::fromUTF8( |
| + "document.body.appendChild(document.createElement('iframe'))"))); |
| + |
| WebFrame* iframe = frame->firstChild(); |
| - EXPECT_EQ(client.frame(), iframe); |
| - EXPECT_TRUE(client.replacesCurrentHistoryItem()); |
| + ASSERT_EQ(&client, toWebLocalFrameImpl(iframe)->client()); |
| + EXPECT_EQ(iframe, client.frame()); |
| - FrameTestHelpers::loadFrame(frame, |
| - "javascript:window.frames[0].location.assign('" + m_baseURL + "history.html')"); |
| - EXPECT_EQ(client.frame(), iframe); |
| + std::string url1 = m_baseURL + "history.html"; |
| + FrameTestHelpers::loadFrame(iframe, url1); |
| + EXPECT_EQ(iframe, client.frame()); |
| + EXPECT_EQ(url1, iframe->document().url().string().utf8()); |
| EXPECT_TRUE(client.replacesCurrentHistoryItem()); |
| - FrameTestHelpers::loadFrame(frame, |
| - "javascript:window.frames[0].location.assign('" + m_baseURL + "find.html')"); |
| - EXPECT_EQ(client.frame(), iframe); |
| + std::string url2 = m_baseURL + "find.html"; |
| + FrameTestHelpers::loadFrame(iframe, url2); |
| + EXPECT_EQ(iframe, client.frame()); |
| + EXPECT_EQ(url2, iframe->document().url().string().utf8()); |
| EXPECT_FALSE(client.replacesCurrentHistoryItem()); |
| +} |
| + |
| +// Tests that a navigation in a frame with a non-blank initial URL will create |
| +// a new history item, unlike the case above. |
| +TEST_P(ParameterizedWebFrameTest, FirstNonBlankSubframeNavigation) |
| +{ |
| + registerMockedHttpURLLoad("history.html"); |
| + registerMockedHttpURLLoad("find.html"); |
| + |
| + FrameTestHelpers::WebViewHelper webViewHelper(this); |
| + TestHistoryWebFrameClient client; |
| + webViewHelper.initializeAndLoad("about:blank", true, &client); |
| - // Repeat the test, but start out the iframe with initial URL, which is not |
| - // "about:blank". |
| + WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| + |
| + std::string url1 = m_baseURL + "history.html"; |
| FrameTestHelpers::loadFrame(frame, |
| "javascript:var f = document.createElement('iframe'); " |
| - "f.src = '" + m_baseURL + "history.html';" |
| + "f.src = '" + url1 + "';" |
| "document.body.appendChild(f)"); |
| - iframe = frame->firstChild()->nextSibling(); |
| - EXPECT_EQ(client.frame(), iframe); |
| - EXPECT_TRUE(client.replacesCurrentHistoryItem()); |
| + WebFrame* iframe = frame->firstChild(); |
| + EXPECT_EQ(iframe, client.frame()); |
| + EXPECT_EQ(url1, iframe->document().url().string().utf8()); |
| - FrameTestHelpers::loadFrame(frame, |
| - "javascript:window.frames[1].location.assign('" + m_baseURL + "find.html')"); |
| - EXPECT_EQ(client.frame(), iframe); |
| + std::string url2 = m_baseURL + "find.html"; |
| + FrameTestHelpers::loadFrame(iframe, url2); |
| + EXPECT_EQ(iframe, client.frame()); |
| + EXPECT_EQ(url2, iframe->document().url().string().utf8()); |
| EXPECT_FALSE(client.replacesCurrentHistoryItem()); |
| } |