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

Side by Side Diff: Source/web/tests/WebFrameTest.cpp

Issue 879423003: Move Location to DOMWindow (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase, #include cleanup Created 5 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/frame/RemoteDOMWindow.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 6722 matching lines...) Expand 10 before | Expand all | Expand 10 after
6733 class WebFrameSwapTest : public WebFrameTest { 6733 class WebFrameSwapTest : public WebFrameTest {
6734 protected: 6734 protected:
6735 WebFrameSwapTest() 6735 WebFrameSwapTest()
6736 { 6736 {
6737 registerMockedHttpURLLoad("frame-a-b-c.html"); 6737 registerMockedHttpURLLoad("frame-a-b-c.html");
6738 registerMockedHttpURLLoad("subframe-a.html"); 6738 registerMockedHttpURLLoad("subframe-a.html");
6739 registerMockedHttpURLLoad("subframe-b.html"); 6739 registerMockedHttpURLLoad("subframe-b.html");
6740 registerMockedHttpURLLoad("subframe-c.html"); 6740 registerMockedHttpURLLoad("subframe-c.html");
6741 registerMockedHttpURLLoad("subframe-hello.html"); 6741 registerMockedHttpURLLoad("subframe-hello.html");
6742 6742
6743 m_webViewHelper.initializeAndLoad(m_baseURL + "frame-a-b-c.html"); 6743 m_webViewHelper.initializeAndLoad(m_baseURL + "frame-a-b-c.html", true);
6744 } 6744 }
6745 6745
6746 void reset() { m_webViewHelper.reset(); } 6746 void reset() { m_webViewHelper.reset(); }
6747 WebFrame* mainFrame() const { return m_webViewHelper.webView()->mainFrame(); } 6747 WebFrame* mainFrame() const { return m_webViewHelper.webView()->mainFrame(); }
6748 6748
6749 private: 6749 private:
6750 FrameTestHelpers::WebViewHelper m_webViewHelper; 6750 FrameTestHelpers::WebViewHelper m_webViewHelper;
6751 }; 6751 };
6752 6752
6753 TEST_F(WebFrameSwapTest, SwapMainFrame) 6753 TEST_F(WebFrameSwapTest, SwapMainFrame)
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
6953 localFrame->initializeToReplaceRemoteFrame(remoteFrame); 6953 localFrame->initializeToReplaceRemoteFrame(remoteFrame);
6954 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 6954 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
6955 EXPECT_EQ(WebStandardCommit, client.historyCommitType()); 6955 EXPECT_EQ(WebStandardCommit, client.historyCommitType());
6956 6956
6957 // Manually reset to break WebViewHelper's dependency on the stack allocated 6957 // Manually reset to break WebViewHelper's dependency on the stack allocated
6958 // TestWebFrameClient. 6958 // TestWebFrameClient.
6959 reset(); 6959 reset();
6960 remoteFrame->close(); 6960 remoteFrame->close();
6961 } 6961 }
6962 6962
6963 class RemoteNavigationClient : public FrameTestHelpers::TestWebRemoteFrameClient {
6964 public:
6965 void navigate(const WebURLRequest& request, bool shouldReplaceCurrentEntry) override
6966 {
6967 m_lastRequest = request;
6968 }
6969
6970 const WebURLRequest& lastRequest() const { return m_lastRequest; }
6971
6972 private:
6973 WebURLRequest m_lastRequest;
6974 };
6975
6976 TEST_F(WebFrameSwapTest, NavigateRemoteFrameViaLocation)
6977 {
6978 RemoteNavigationClient client;
6979 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(&client);
6980 WebFrame* targetFrame = mainFrame()->firstChild();
6981 ASSERT_TRUE(targetFrame);
6982 targetFrame->swap(remoteFrame);
6983 ASSERT_TRUE(mainFrame()->firstChild());
6984 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame);
6985
6986 remoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("http:/ /127.0.0.1"));
6987 mainFrame()->executeScript(WebScriptSource(
6988 "document.getElementsByTagName('iframe')[0].contentWindow.location = 'da ta:text/html,hi'"));
6989 ASSERT_FALSE(client.lastRequest().isNull());
6990 EXPECT_EQ(WebURL(toKURL("data:text/html,hi")), client.lastRequest().url());
6991
6992 // Manually reset to break WebViewHelper's dependency on the stack allocated
6993 // TestWebFrameClient.
6994 reset();
6995 remoteFrame->close();
6996 }
6997
6963 class MockDocumentThreadableLoaderClient : public DocumentThreadableLoaderClient { 6998 class MockDocumentThreadableLoaderClient : public DocumentThreadableLoaderClient {
6964 public: 6999 public:
6965 MockDocumentThreadableLoaderClient() : m_failed(false) { } 7000 MockDocumentThreadableLoaderClient() : m_failed(false) { }
6966 virtual void didFail(const ResourceError&) override { m_failed = true;} 7001 virtual void didFail(const ResourceError&) override { m_failed = true;}
6967 7002
6968 void reset() { m_failed = false; } 7003 void reset() { m_failed = false; }
6969 bool failed() { return m_failed; } 7004 bool failed() { return m_failed; }
6970 7005
6971 bool m_failed; 7006 bool m_failed;
6972 }; 7007 };
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
7064 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); 7099 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount());
7065 7100
7066 // Neither should a page reload. 7101 // Neither should a page reload.
7067 localFrame->reload(); 7102 localFrame->reload();
7068 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); 7103 EXPECT_EQ(4u, frameClient.provisionalLoadCount());
7069 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); 7104 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition());
7070 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); 7105 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount());
7071 } 7106 }
7072 7107
7073 } // namespace 7108 } // namespace
OLDNEW
« no previous file with comments | « Source/core/frame/RemoteDOMWindow.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698