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

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

Issue 409823002: Add a basic test for main frame swap. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed test Created 6 years, 2 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
« no previous file with comments | « no previous file | 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 edf9a86ff32ccf5e848305e7d73f3b183716cf8a..8b22ea1c520fdb0823513a9c233e16e626c4744d 100644
--- a/Source/web/tests/WebFrameTest.cpp
+++ b/Source/web/tests/WebFrameTest.cpp
@@ -6525,10 +6525,28 @@ private:
FrameTestHelpers::WebViewHelper m_webViewHelper;
};
-// FIXME: We should have tests for main frame swaps, but it interacts poorly
-// with the geolocation inspector agent, since the lifetime of the inspector
-// agent is tied to the Page, but the inspector agent is created by the
-// instantiation of the main frame.
+TEST_F(WebFrameSwapTest, SwapMainFrame)
+{
+ WebFrame* remoteFrame = WebRemoteFrame::create(0);
+ mainFrame()->swap(remoteFrame);
+
+ FrameTestHelpers::TestWebFrameClient client;
+ WebFrame* localFrame = WebLocalFrame::create(&client);
+ remoteFrame->swap(localFrame);
+
+ // FIXME: This almost certainly fires more load events on the iframe element
+ // than it should.
Nate Chapin 2014/10/16 21:17:46 This comment seems out of place?
dcheng 2014/10/16 21:20:20 It's about the call to loadFrame() below... but I
Nate Chapin 2014/10/16 21:21:47 Well, maybe I'm missing something, but I don't see
dcheng 2014/10/16 21:23:22 Hm. Good point. I've removed this FIXME.
+ // Finally, make sure an embedder triggered load in the local frame swapped
+ // back in works.
+ FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
+ std::string content = localFrame->contentAsText(1024).utf8();
+ EXPECT_EQ("hello", content);
+
+ // Manually reset to break WebViewHelper's dependency on the stack allocated
+ // TestWebFrameClient.
+ reset();
+ remoteFrame->close();
+}
void swapAndVerifyFirstChildConsistency(const char* const message, WebFrame* parent, WebFrame* newChild)
{
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698