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

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

Issue 1058403002: Revert of Refactor frame navigation/detach state cleanup to be more sane. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 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/web/tests/PinchViewportTest.cpp ('k') | Source/web/tests/WebViewTest.cpp » ('j') | 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 6562 matching lines...) Expand 10 before | Expand all | Expand 10 after
6573 6573
6574 // Make sure that an embedder-triggered detach with a remote frame parent 6574 // Make sure that an embedder-triggered detach with a remote frame parent
6575 // doesn't leave behind dangling pointers. 6575 // doesn't leave behind dangling pointers.
6576 TEST_F(WebFrameTest, EmbedderTriggeredDetachWithRemoteMainFrame) 6576 TEST_F(WebFrameTest, EmbedderTriggeredDetachWithRemoteMainFrame)
6577 { 6577 {
6578 // FIXME: Refactor some of this logic into WebViewHelper to make it easier t o 6578 // FIXME: Refactor some of this logic into WebViewHelper to make it easier t o
6579 // write tests with a top-level remote frame. 6579 // write tests with a top-level remote frame.
6580 FrameTestHelpers::TestWebViewClient viewClient; 6580 FrameTestHelpers::TestWebViewClient viewClient;
6581 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 6581 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
6582 WebView* view = WebView::create(&viewClient); 6582 WebView* view = WebView::create(&viewClient);
6583 view->setMainFrame(remoteClient.frame()); 6583 view->setMainFrame(WebRemoteFrame::create(&remoteClient));
6584 FrameTestHelpers::TestWebFrameClient childFrameClient; 6584 FrameTestHelpers::TestWebFrameClient childFrameClient;
6585 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild("", WebSandboxFlags::None, &childFrameClient); 6585 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc alChild("", WebSandboxFlags::None, &childFrameClient);
6586 6586
6587 // Purposely keep the LocalFrame alive so it's the last thing to be destroye d. 6587 // Purposely keep the LocalFrame alive so it's the last thing to be destroye d.
6588 RefPtrWillBePersistent<Frame> childCoreFrame = toCoreFrame(childFrame); 6588 RefPtrWillBePersistent<Frame> childCoreFrame = toCoreFrame(childFrame);
6589 view->close(); 6589 view->close();
6590 childCoreFrame.clear(); 6590 childCoreFrame.clear();
6591 } 6591 }
6592 6592
6593 class WebFrameSwapTest : public WebFrameTest { 6593 class WebFrameSwapTest : public WebFrameTest {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
6787 TEST_F(WebFrameSwapTest, SwapPreservesGlobalContext) 6787 TEST_F(WebFrameSwapTest, SwapPreservesGlobalContext)
6788 { 6788 {
6789 v8::HandleScope scope(v8::Isolate::GetCurrent()); 6789 v8::HandleScope scope(v8::Isolate::GetCurrent());
6790 v8::Local<v8::Value> windowTop = mainFrame()->executeScriptAndReturnValue(We bScriptSource("window")); 6790 v8::Local<v8::Value> windowTop = mainFrame()->executeScriptAndReturnValue(We bScriptSource("window"));
6791 ASSERT_TRUE(windowTop->IsObject()); 6791 ASSERT_TRUE(windowTop->IsObject());
6792 v8::Local<v8::Value> originalWindow = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource( 6792 v8::Local<v8::Value> originalWindow = mainFrame()->executeScriptAndReturnVal ue(WebScriptSource(
6793 "document.querySelector('#frame2').contentWindow;")); 6793 "document.querySelector('#frame2').contentWindow;"));
6794 ASSERT_TRUE(originalWindow->IsObject()); 6794 ASSERT_TRUE(originalWindow->IsObject());
6795 6795
6796 // Make sure window reference stays the same when swapping to a remote frame . 6796 // Make sure window reference stays the same when swapping to a remote frame .
6797 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 6797 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(nullptr);
6798 WebRemoteFrame* remoteFrame = remoteClient.frame();
6799 WebFrame* targetFrame = mainFrame()->firstChild()->nextSibling(); 6798 WebFrame* targetFrame = mainFrame()->firstChild()->nextSibling();
6800 targetFrame->swap(remoteFrame); 6799 targetFrame->swap(remoteFrame);
6801 // FIXME: This cleanup should be unnecessary, but the interaction between fr ame detach 6800 // FIXME: This cleanup should be unnecessary, but the interaction between fr ame detach
6802 // and swap is completely broken atm. swap() calls detachChildren() on the f rame being 6801 // and swap is completely broken atm. swap() calls detachChildren() on the f rame being
6803 // swapped out, and frame B has a child. When the child of B is detached, it schedules a 6802 // swapped out, and frame B has a child. When the child of B is detached, it schedules a
6804 // FrameLoader timer to check for load completion in its parent. 6803 // FrameLoader timer to check for load completion in its parent.
6805 // Other tests end up spinning the message loop (e.g. to wait for load compl etion of 6804 // Other tests end up spinning the message loop (e.g. to wait for load compl etion of
6806 // another test page, so this timer callback is processed before FrameHost a nd Page are 6805 // another test page, so this timer callback is processed before FrameHost a nd Page are
6807 // destroyed by the reset() at the end of the test case. However, this test does not spin 6806 // destroyed by the reset() at the end of the test case. However, this test does not spin
6808 // the event loop in its body, so the timer task remains in the queue and en ds up running 6807 // the event loop in its body, so the timer task remains in the queue and en ds up running
(...skipping 26 matching lines...) Expand all
6835 // Manually reset to break WebViewHelper's dependency on the stack allocated 6834 // Manually reset to break WebViewHelper's dependency on the stack allocated
6836 // TestWebFrameClient. 6835 // TestWebFrameClient.
6837 reset(); 6836 reset();
6838 remoteFrame->close(); 6837 remoteFrame->close();
6839 } 6838 }
6840 6839
6841 TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable) 6840 TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable)
6842 { 6841 {
6843 v8::HandleScope scope(v8::Isolate::GetCurrent()); 6842 v8::HandleScope scope(v8::Isolate::GetCurrent());
6844 6843
6845 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 6844 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(nullptr);
6846 WebRemoteFrame* remoteFrame = remoteClient.frame();
6847 mainFrame()->lastChild()->swap(remoteFrame); 6845 mainFrame()->lastChild()->swap(remoteFrame);
6848 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); 6846 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
6849 v8::Local<v8::Value> remoteWindow = mainFrame()->executeScriptAndReturnValue (WebScriptSource("window[2]")); 6847 v8::Local<v8::Value> remoteWindow = mainFrame()->executeScriptAndReturnValue (WebScriptSource("window[2]"));
6850 EXPECT_TRUE(remoteWindow->IsObject()); 6848 EXPECT_TRUE(remoteWindow->IsObject());
6851 v8::Local<v8::Value> windowLength = mainFrame()->executeScriptAndReturnValue (WebScriptSource("window.length")); 6849 v8::Local<v8::Value> windowLength = mainFrame()->executeScriptAndReturnValue (WebScriptSource("window.length"));
6852 ASSERT_TRUE(windowLength->IsNumber()); 6850 ASSERT_TRUE(windowLength->IsNumber());
6853 v8::Local<v8::Integer> windowLengthInteger = windowLength->ToInteger(); 6851 v8::Local<v8::Integer> windowLengthInteger = windowLength->ToInteger();
6854 EXPECT_EQ(3, windowLengthInteger->Value()); 6852 EXPECT_EQ(3, windowLengthInteger->Value());
6855
6856 reset();
6857 } 6853 }
6858 6854
6859 TEST_F(WebFrameSwapTest, RemoteFrameLengthAccess) 6855 TEST_F(WebFrameSwapTest, RemoteFrameLengthAccess)
6860 { 6856 {
6861 v8::HandleScope scope(v8::Isolate::GetCurrent()); 6857 v8::HandleScope scope(v8::Isolate::GetCurrent());
6862 6858
6863 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 6859 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(nullptr);
6864 WebRemoteFrame* remoteFrame = remoteClient.frame();
6865 mainFrame()->lastChild()->swap(remoteFrame); 6860 mainFrame()->lastChild()->swap(remoteFrame);
6866 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); 6861 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
6867 v8::Local<v8::Value> remoteWindowLength = mainFrame()->executeScriptAndRetur nValue(WebScriptSource("window[2].length")); 6862 v8::Local<v8::Value> remoteWindowLength = mainFrame()->executeScriptAndRetur nValue(WebScriptSource("window[2].length"));
6868 ASSERT_TRUE(remoteWindowLength->IsNumber()); 6863 ASSERT_TRUE(remoteWindowLength->IsNumber());
6869 v8::Local<v8::Integer> remoteWindowLengthInteger = remoteWindowLength->ToInt eger(); 6864 v8::Local<v8::Integer> remoteWindowLengthInteger = remoteWindowLength->ToInt eger();
6870 EXPECT_EQ(0, remoteWindowLengthInteger->Value()); 6865 EXPECT_EQ(0, remoteWindowLengthInteger->Value());
6871
6872 reset();
6873 } 6866 }
6874 6867
6875 TEST_F(WebFrameSwapTest, RemoteWindowNamedAccess) 6868 TEST_F(WebFrameSwapTest, RemoteWindowNamedAccess)
6876 { 6869 {
6877 v8::HandleScope scope(v8::Isolate::GetCurrent()); 6870 v8::HandleScope scope(v8::Isolate::GetCurrent());
6878 6871
6879 // FIXME: Once OOPIF unit test infrastructure is in place, test that named 6872 // FIXME: Once OOPIF unit test infrastructure is in place, test that named
6880 // window access on a remote window works. For now, just test that accessing 6873 // window access on a remote window works. For now, just test that accessing
6881 // a named property doesn't crash. 6874 // a named property doesn't crash.
6882 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 6875 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(nullptr);
6883 WebRemoteFrame* remoteFrame = remoteClient.frame();
6884 mainFrame()->lastChild()->swap(remoteFrame); 6876 mainFrame()->lastChild()->swap(remoteFrame);
6885 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique()); 6877 remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
6886 v8::Local<v8::Value> remoteWindowProperty = mainFrame()->executeScriptAndRet urnValue(WebScriptSource("window[2].foo")); 6878 v8::Local<v8::Value> remoteWindowProperty = mainFrame()->executeScriptAndRet urnValue(WebScriptSource("window[2].foo"));
6887 EXPECT_TRUE(remoteWindowProperty.IsEmpty()); 6879 EXPECT_TRUE(remoteWindowProperty.IsEmpty());
6888
6889 reset();
6890 } 6880 }
6891 6881
6892 class RemoteToLocalSwapWebFrameClient : public FrameTestHelpers::TestWebFrameCli ent { 6882 class RemoteToLocalSwapWebFrameClient : public FrameTestHelpers::TestWebFrameCli ent {
6893 public: 6883 public:
6894 explicit RemoteToLocalSwapWebFrameClient(WebRemoteFrame* remoteFrame) 6884 explicit RemoteToLocalSwapWebFrameClient(WebRemoteFrame* remoteFrame)
6895 : m_historyCommitType(WebHistoryInertCommit) 6885 : m_historyCommitType(WebHistoryInertCommit)
6896 , m_remoteFrame(remoteFrame) 6886 , m_remoteFrame(remoteFrame)
6897 { 6887 {
6898 } 6888 }
6899 6889
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
6939 6929
6940 const WebURLRequest& lastRequest() const { return m_lastRequest; } 6930 const WebURLRequest& lastRequest() const { return m_lastRequest; }
6941 6931
6942 private: 6932 private:
6943 WebURLRequest m_lastRequest; 6933 WebURLRequest m_lastRequest;
6944 }; 6934 };
6945 6935
6946 TEST_F(WebFrameSwapTest, NavigateRemoteFrameViaLocation) 6936 TEST_F(WebFrameSwapTest, NavigateRemoteFrameViaLocation)
6947 { 6937 {
6948 RemoteNavigationClient client; 6938 RemoteNavigationClient client;
6949 WebRemoteFrame* remoteFrame = client.frame(); 6939 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(&client);
6950 WebFrame* targetFrame = mainFrame()->firstChild(); 6940 WebFrame* targetFrame = mainFrame()->firstChild();
6951 ASSERT_TRUE(targetFrame); 6941 ASSERT_TRUE(targetFrame);
6952 targetFrame->swap(remoteFrame); 6942 targetFrame->swap(remoteFrame);
6953 ASSERT_TRUE(mainFrame()->firstChild()); 6943 ASSERT_TRUE(mainFrame()->firstChild());
6954 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); 6944 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame);
6955 6945
6956 remoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("http:/ /127.0.0.1")); 6946 remoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("http:/ /127.0.0.1"));
6957 mainFrame()->executeScript(WebScriptSource( 6947 mainFrame()->executeScript(WebScriptSource(
6958 "document.getElementsByTagName('iframe')[0].contentWindow.location = 'da ta:text/html,hi'")); 6948 "document.getElementsByTagName('iframe')[0].contentWindow.location = 'da ta:text/html,hi'"));
6959 ASSERT_FALSE(client.lastRequest().isNull()); 6949 ASSERT_FALSE(client.lastRequest().isNull());
6960 EXPECT_EQ(WebURL(toKURL("data:text/html,hi")), client.lastRequest().url()); 6950 EXPECT_EQ(WebURL(toKURL("data:text/html,hi")), client.lastRequest().url());
6961 6951
6962 // Manually reset to break WebViewHelper's dependency on the stack allocated 6952 // Manually reset to break WebViewHelper's dependency on the stack allocated
6963 // TestWebFrameClient. 6953 // TestWebFrameClient.
6964 reset(); 6954 reset();
6955 remoteFrame->close();
6965 } 6956 }
6966 6957
6967 class MockDocumentThreadableLoaderClient : public DocumentThreadableLoaderClient { 6958 class MockDocumentThreadableLoaderClient : public DocumentThreadableLoaderClient {
6968 public: 6959 public:
6969 MockDocumentThreadableLoaderClient() : m_failed(false) { } 6960 MockDocumentThreadableLoaderClient() : m_failed(false) { }
6970 virtual void didFail(const ResourceError&) override { m_failed = true;} 6961 virtual void didFail(const ResourceError&) override { m_failed = true;}
6971 6962
6972 void reset() { m_failed = false; } 6963 void reset() { m_failed = false; }
6973 bool failed() { return m_failed; } 6964 bool failed() { return m_failed; }
6974 6965
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
7072 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); 7063 EXPECT_EQ(4u, frameClient.provisionalLoadCount());
7073 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); 7064 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition());
7074 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); 7065 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount());
7075 } 7066 }
7076 7067
7077 TEST_F(WebFrameTest, DetachRemoteFrame) 7068 TEST_F(WebFrameTest, DetachRemoteFrame)
7078 { 7069 {
7079 FrameTestHelpers::TestWebViewClient viewClient; 7070 FrameTestHelpers::TestWebViewClient viewClient;
7080 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7071 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7081 WebView* view = WebView::create(&viewClient); 7072 WebView* view = WebView::create(&viewClient);
7082 view->setMainFrame(remoteClient.frame()); 7073 view->setMainFrame(WebRemoteFrame::create(&remoteClient));
7083 FrameTestHelpers::TestWebRemoteFrameClient childFrameClient; 7074 FrameTestHelpers::TestWebRemoteFrameClient childFrameClient;
7084 WebRemoteFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createRe moteChild("", WebSandboxFlags::None, &childFrameClient); 7075 WebRemoteFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createRe moteChild("", WebSandboxFlags::None, &childFrameClient);
7085 childFrame->detach(); 7076 childFrame->detach();
7086 view->close(); 7077 view->close();
7087 } 7078 }
7088 7079
7089 } // namespace blink 7080 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/tests/PinchViewportTest.cpp ('k') | Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698