Index: Source/web/tests/WebFrameTest.cpp |
diff --git a/Source/web/tests/WebFrameTest.cpp b/Source/web/tests/WebFrameTest.cpp |
index edf9a86ff32ccf5e848305e7d73f3b183716cf8a..24d3df9c04646861313a7d0af59cdc3c04723b24 100644 |
--- a/Source/web/tests/WebFrameTest.cpp |
+++ b/Source/web/tests/WebFrameTest.cpp |
@@ -6525,10 +6525,26 @@ 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); |
+ |
+ // 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) |
{ |