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

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

Issue 879423003: Move Location to DOMWindow (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 11 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
Index: Source/web/tests/WebFrameTest.cpp
diff --git a/Source/web/tests/WebFrameTest.cpp b/Source/web/tests/WebFrameTest.cpp
index d9166f990e44cd01d3fbc3d18187fa59b6a4ea96..c1615be22461c7a3a9da2332289e793fdb1eab3f 100644
--- a/Source/web/tests/WebFrameTest.cpp
+++ b/Source/web/tests/WebFrameTest.cpp
@@ -6693,7 +6693,7 @@ protected:
registerMockedHttpURLLoad("subframe-c.html");
registerMockedHttpURLLoad("subframe-hello.html");
- m_webViewHelper.initializeAndLoad(m_baseURL + "frame-a-b-c.html");
+ m_webViewHelper.initializeAndLoad(m_baseURL + "frame-a-b-c.html", true);
}
void reset() { m_webViewHelper.reset(); }
@@ -6913,6 +6913,42 @@ TEST_F(WebFrameSwapTest, HistoryCommitTypeAfterRemoteToLocalSwap)
remoteFrame->close();
}
+class RemoteNavigationClient : public FrameTestHelpers::TestWebRemoteFrameClient {
+public:
+ RemoteNavigationClient() { }
dcheng 2015/02/02 19:27:52 Nit: I think it's fine to omit the constructor in
Nate Chapin 2015/02/02 21:02:00 Done.
+
+ void navigate(const WebURLRequest& request, bool shouldReplaceCurrentEntry) override
+ {
+ m_lastRequest = request;
+ }
+
+ const WebURLRequest& lastRequest() { return m_lastRequest; }
dcheng 2015/02/02 19:27:52 Nit: const.
Nate Chapin 2015/02/02 21:01:59 Done.
+
+ WebURLRequest m_lastRequest;
dcheng 2015/02/02 19:27:52 Nit: make this private, since we have an accessor.
Nate Chapin 2015/02/02 21:02:00 Done.
+};
+
+TEST_F(WebFrameSwapTest, NavigateRemoteFrameViaLocation)
+{
+ RemoteNavigationClient client;
+ WebRemoteFrame* remoteFrame = WebRemoteFrame::create(&client);
+ WebFrame* targetFrame = mainFrame()->firstChild();
+ ASSERT_TRUE(targetFrame);
+ targetFrame->swap(remoteFrame);
+ ASSERT_TRUE(mainFrame()->firstChild());
+ ASSERT_EQ(mainFrame()->firstChild(), remoteFrame);
+
+ remoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("http://127.0.0.1"));
+ mainFrame()->executeScript(WebScriptSource(
+ "document.getElementsByTagName('iframe')[0].contentWindow.location = 'data:text/html,hi'"));
+ ASSERT_FALSE(client.lastRequest().isNull());
+ EXPECT_EQ(WebURL(toKURL("data:text/html,hi")), client.lastRequest().url());
+
+ // Manually reset to break WebViewHelper's dependency on the stack allocated
+ // TestWebFrameClient.
+ reset();
+ remoteFrame->close();
+}
+
class MockDocumentThreadableLoaderClient : public DocumentThreadableLoaderClient {
public:
MockDocumentThreadableLoaderClient() : m_failed(false) { }
« Source/core/frame/DOMWindowProperty.cpp ('K') | « Source/modules/webmidi/NavigatorWebMIDI.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698