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

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

Issue 948143002: Remove unused WebFrame::swap() path for local frames. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: nullptr 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
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 6845 matching lines...) Expand 10 before | Expand all | Expand 10 after
6856 6856
6857 void reset() { m_webViewHelper.reset(); } 6857 void reset() { m_webViewHelper.reset(); }
6858 WebFrame* mainFrame() const { return m_webViewHelper.webView()->mainFrame(); } 6858 WebFrame* mainFrame() const { return m_webViewHelper.webView()->mainFrame(); }
6859 6859
6860 private: 6860 private:
6861 FrameTestHelpers::WebViewHelper m_webViewHelper; 6861 FrameTestHelpers::WebViewHelper m_webViewHelper;
6862 }; 6862 };
6863 6863
6864 TEST_F(WebFrameSwapTest, SwapMainFrame) 6864 TEST_F(WebFrameSwapTest, SwapMainFrame)
6865 { 6865 {
6866 WebFrame* remoteFrame = WebRemoteFrame::create(0); 6866 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(nullptr);
6867 mainFrame()->swap(remoteFrame); 6867 mainFrame()->swap(remoteFrame);
6868 6868
6869 FrameTestHelpers::TestWebFrameClient client; 6869 FrameTestHelpers::TestWebFrameClient client;
6870 WebFrame* localFrame = WebLocalFrame::create(&client); 6870 WebLocalFrame* localFrame = WebLocalFrame::create(&client);
6871 localFrame->initializeToReplaceRemoteFrame(remoteFrame);
6871 remoteFrame->swap(localFrame); 6872 remoteFrame->swap(localFrame);
6872 6873
6873 // Finally, make sure an embedder triggered load in the local frame swapped 6874 // Finally, make sure an embedder triggered load in the local frame swapped
6874 // back in works. 6875 // back in works.
6875 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 6876 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
6876 std::string content = localFrame->contentAsText(1024).utf8(); 6877 std::string content = localFrame->contentAsText(1024).utf8();
6877 EXPECT_EQ("hello", content); 6878 EXPECT_EQ("hello", content);
6878 6879
6879 // Manually reset to break WebViewHelper's dependency on the stack allocated 6880 // Manually reset to break WebViewHelper's dependency on the stack allocated
6880 // TestWebFrameClient. 6881 // TestWebFrameClient.
6881 reset(); 6882 reset();
6882 remoteFrame->close(); 6883 remoteFrame->close();
6883 } 6884 }
6884 6885
6885 void swapAndVerifyFirstChildConsistency(const char* const message, WebFrame* par ent, WebFrame* newChild) 6886 void swapAndVerifyFirstChildConsistency(const char* const message, WebFrame* par ent, WebFrame* newChild)
6886 { 6887 {
6887 SCOPED_TRACE(message); 6888 SCOPED_TRACE(message);
6888 parent->firstChild()->swap(newChild); 6889 parent->firstChild()->swap(newChild);
6889 6890
6890 EXPECT_EQ(newChild, parent->firstChild()); 6891 EXPECT_EQ(newChild, parent->firstChild());
6891 EXPECT_EQ(newChild->parent(), parent); 6892 EXPECT_EQ(newChild->parent(), parent);
6892 EXPECT_EQ(newChild, parent->lastChild()->previousSibling()->previousSibling( )); 6893 EXPECT_EQ(newChild, parent->lastChild()->previousSibling()->previousSibling( ));
6893 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()->previousSibling()); 6894 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()->previousSibling());
6894 } 6895 }
6895 6896
6896 TEST_F(WebFrameSwapTest, SwapFirstChild) 6897 TEST_F(WebFrameSwapTest, SwapFirstChild)
6897 { 6898 {
6898 WebFrame* remoteFrame = WebRemoteFrame::create(0); 6899 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(nullptr);
6899 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame ); 6900 swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame );
6900 6901
6901 FrameTestHelpers::TestWebFrameClient client; 6902 FrameTestHelpers::TestWebFrameClient client;
6902 WebFrame* localFrame = WebLocalFrame::create(&client); 6903 WebLocalFrame* localFrame = WebLocalFrame::create(&client);
6904 localFrame->initializeToReplaceRemoteFrame(remoteFrame);
6903 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame) ; 6905 swapAndVerifyFirstChildConsistency("remote->local", mainFrame(), localFrame) ;
6904 6906
6905 // FIXME: This almost certainly fires more load events on the iframe element 6907 // FIXME: This almost certainly fires more load events on the iframe element
6906 // than it should. 6908 // than it should.
6907 // Finally, make sure an embedder triggered load in the local frame swapped 6909 // Finally, make sure an embedder triggered load in the local frame swapped
6908 // back in works. 6910 // back in works.
6909 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 6911 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
6910 std::string content = localFrame->contentAsText(1024).utf8(); 6912 std::string content = localFrame->contentAsText(1024).utf8();
6911 EXPECT_EQ("hello", content); 6913 EXPECT_EQ("hello", content);
6912 6914
(...skipping 12 matching lines...) Expand all
6925 EXPECT_EQ(newChild, parent->lastChild()->previousSibling()); 6927 EXPECT_EQ(newChild, parent->lastChild()->previousSibling());
6926 EXPECT_EQ(newChild->parent(), parent); 6928 EXPECT_EQ(newChild->parent(), parent);
6927 EXPECT_EQ(newChild, parent->firstChild()->nextSibling()); 6929 EXPECT_EQ(newChild, parent->firstChild()->nextSibling());
6928 EXPECT_EQ(newChild->previousSibling(), parent->firstChild()); 6930 EXPECT_EQ(newChild->previousSibling(), parent->firstChild());
6929 EXPECT_EQ(newChild, parent->lastChild()->previousSibling()); 6931 EXPECT_EQ(newChild, parent->lastChild()->previousSibling());
6930 EXPECT_EQ(newChild->nextSibling(), parent->lastChild()); 6932 EXPECT_EQ(newChild->nextSibling(), parent->lastChild());
6931 } 6933 }
6932 6934
6933 TEST_F(WebFrameSwapTest, SwapMiddleChild) 6935 TEST_F(WebFrameSwapTest, SwapMiddleChild)
6934 { 6936 {
6935 WebFrame* remoteFrame = WebRemoteFrame::create(0); 6937 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(nullptr);
6936 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), remoteFram e); 6938 swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), remoteFram e);
6937 6939
6938 FrameTestHelpers::TestWebFrameClient client; 6940 FrameTestHelpers::TestWebFrameClient client;
6939 WebFrame* localFrame = WebLocalFrame::create(&client); 6941 WebLocalFrame* localFrame = WebLocalFrame::create(&client);
6942 localFrame->initializeToReplaceRemoteFrame(remoteFrame);
6940 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame ); 6943 swapAndVerifyMiddleChildConsistency("remote->local", mainFrame(), localFrame );
6941 6944
6942 // FIXME: This almost certainly fires more load events on the iframe element 6945 // FIXME: This almost certainly fires more load events on the iframe element
6943 // than it should. 6946 // than it should.
6944 // Finally, make sure an embedder triggered load in the local frame swapped 6947 // Finally, make sure an embedder triggered load in the local frame swapped
6945 // back in works. 6948 // back in works.
6946 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 6949 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
6947 std::string content = localFrame->contentAsText(1024).utf8(); 6950 std::string content = localFrame->contentAsText(1024).utf8();
6948 EXPECT_EQ("hello", content); 6951 EXPECT_EQ("hello", content);
6949 6952
6950 // Manually reset to break WebViewHelper's dependency on the stack allocated 6953 // Manually reset to break WebViewHelper's dependency on the stack allocated
6951 // TestWebFrameClient. 6954 // TestWebFrameClient.
6952 reset(); 6955 reset();
6953 remoteFrame->close(); 6956 remoteFrame->close();
6954 } 6957 }
6955 6958
6956 void swapAndVerifyLastChildConsistency(const char* const message, WebFrame* pare nt, WebFrame* newChild) 6959 void swapAndVerifyLastChildConsistency(const char* const message, WebFrame* pare nt, WebFrame* newChild)
6957 { 6960 {
6958 SCOPED_TRACE(message); 6961 SCOPED_TRACE(message);
6959 parent->lastChild()->swap(newChild); 6962 parent->lastChild()->swap(newChild);
6960 6963
6961 EXPECT_EQ(newChild, parent->lastChild()); 6964 EXPECT_EQ(newChild, parent->lastChild());
6962 EXPECT_EQ(newChild->parent(), parent); 6965 EXPECT_EQ(newChild->parent(), parent);
6963 EXPECT_EQ(newChild, parent->firstChild()->nextSibling()->nextSibling()); 6966 EXPECT_EQ(newChild, parent->firstChild()->nextSibling()->nextSibling());
6964 EXPECT_EQ(newChild->previousSibling(), parent->firstChild()->nextSibling()); 6967 EXPECT_EQ(newChild->previousSibling(), parent->firstChild()->nextSibling());
6965 } 6968 }
6966 6969
6967 TEST_F(WebFrameSwapTest, SwapLastChild) 6970 TEST_F(WebFrameSwapTest, SwapLastChild)
6968 { 6971 {
6969 WebFrame* remoteFrame = WebRemoteFrame::create(0); 6972 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(nullptr);
6970 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame) ; 6973 swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame) ;
6971 6974
6972 FrameTestHelpers::TestWebFrameClient client; 6975 FrameTestHelpers::TestWebFrameClient client;
6973 WebFrame* localFrame = WebLocalFrame::create(&client); 6976 WebLocalFrame* localFrame = WebLocalFrame::create(&client);
6977 localFrame->initializeToReplaceRemoteFrame(remoteFrame);
6974 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame); 6978 swapAndVerifyLastChildConsistency("remote->local", mainFrame(), localFrame);
6975 6979
6976 // FIXME: This almost certainly fires more load events on the iframe element 6980 // FIXME: This almost certainly fires more load events on the iframe element
6977 // than it should. 6981 // than it should.
6978 // Finally, make sure an embedder triggered load in the local frame swapped 6982 // Finally, make sure an embedder triggered load in the local frame swapped
6979 // back in works. 6983 // back in works.
6980 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 6984 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
6981 std::string content = localFrame->contentAsText(1024).utf8(); 6985 std::string content = localFrame->contentAsText(1024).utf8();
6982 EXPECT_EQ("hello", content); 6986 EXPECT_EQ("hello", content);
6983 6987
(...skipping 22 matching lines...) Expand all
7006 swapAndVerifySubframeConsistency("local->remote", targetFrame, remoteFrame); 7010 swapAndVerifySubframeConsistency("local->remote", targetFrame, remoteFrame);
7007 7011
7008 targetFrame = mainFrame()->firstChild()->nextSibling(); 7012 targetFrame = mainFrame()->firstChild()->nextSibling();
7009 EXPECT_TRUE(targetFrame); 7013 EXPECT_TRUE(targetFrame);
7010 7014
7011 // Create child frames in the target frame before testing the swap. 7015 // Create child frames in the target frame before testing the swap.
7012 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; 7016 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient;
7013 remoteFrame->createRemoteChild("", WebSandboxFlags::None, &remoteFrameClient ); 7017 remoteFrame->createRemoteChild("", WebSandboxFlags::None, &remoteFrameClient );
7014 7018
7015 FrameTestHelpers::TestWebFrameClient client; 7019 FrameTestHelpers::TestWebFrameClient client;
7016 WebFrame* localFrame = WebLocalFrame::create(&client); 7020 WebLocalFrame* localFrame = WebLocalFrame::create(&client);
7021 localFrame->initializeToReplaceRemoteFrame(remoteFrame);
7017 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame); 7022 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame);
7018 7023
7019 // FIXME: This almost certainly fires more load events on the iframe element 7024 // FIXME: This almost certainly fires more load events on the iframe element
7020 // than it should. 7025 // than it should.
7021 // Finally, make sure an embedder triggered load in the local frame swapped 7026 // Finally, make sure an embedder triggered load in the local frame swapped
7022 // back in works. 7027 // back in works.
7023 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7028 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
7024 std::string content = localFrame->contentAsText(1024).utf8(); 7029 std::string content = localFrame->contentAsText(1024).utf8();
7025 EXPECT_EQ("hello", content); 7030 EXPECT_EQ("hello", content);
7026 7031
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
7210 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); 7215 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount());
7211 7216
7212 // Neither should a page reload. 7217 // Neither should a page reload.
7213 localFrame->reload(); 7218 localFrame->reload();
7214 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); 7219 EXPECT_EQ(4u, frameClient.provisionalLoadCount());
7215 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); 7220 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition());
7216 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); 7221 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount());
7217 } 7222 }
7218 7223
7219 } // namespace 7224 } // namespace
OLDNEW
« Source/web/WebLocalFrameImpl.cpp ('K') | « Source/web/WebLocalFrameImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698