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

Unified Diff: Source/web/tests/WebFrameTest.cpp

Issue 1173513002: Fix Blink commit type for subframes after initial about:blank load. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Try removing Nasko's original fix Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« Source/core/loader/FrameLoader.cpp ('K') | « Source/web/WebLocalFrameImpl.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
}
« Source/core/loader/FrameLoader.cpp ('K') | « Source/web/WebLocalFrameImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698