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

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

Issue 1052993006: Refactor frame navigation/detach state cleanup to be more sane. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: shuffle Created 5 years, 9 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 d303c2aa1226396621fb7f3999da81aea0c35aeb..e27f7916465b44dc9693d0a9d835397a43593146 100644
--- a/Source/web/tests/WebFrameTest.cpp
+++ b/Source/web/tests/WebFrameTest.cpp
@@ -6580,7 +6580,7 @@ TEST_F(WebFrameTest, EmbedderTriggeredDetachWithRemoteMainFrame)
FrameTestHelpers::TestWebViewClient viewClient;
FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
WebView* view = WebView::create(&viewClient);
- view->setMainFrame(WebRemoteFrame::create(&remoteClient));
+ view->setMainFrame(remoteClient.frame());
FrameTestHelpers::TestWebFrameClient childFrameClient;
WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLocalChild("", WebSandboxFlags::None, &childFrameClient);
@@ -6794,7 +6794,8 @@ TEST_F(WebFrameSwapTest, SwapPreservesGlobalContext)
ASSERT_TRUE(originalWindow->IsObject());
// Make sure window reference stays the same when swapping to a remote frame.
- WebRemoteFrame* remoteFrame = WebRemoteFrame::create(nullptr);
+ FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
+ WebRemoteFrame* remoteFrame = remoteClient.frame();
WebFrame* targetFrame = mainFrame()->firstChild()->nextSibling();
targetFrame->swap(remoteFrame);
// FIXME: This cleanup should be unnecessary, but the interaction between frame detach
@@ -6841,7 +6842,8 @@ TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable)
{
v8::HandleScope scope(v8::Isolate::GetCurrent());
- WebRemoteFrame* remoteFrame = WebRemoteFrame::create(nullptr);
+ FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
+ WebRemoteFrame* remoteFrame = remoteClient.frame();
mainFrame()->lastChild()->swap(remoteFrame);
remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
v8::Local<v8::Value> remoteWindow = mainFrame()->executeScriptAndReturnValue(WebScriptSource("window[2]"));
@@ -6850,19 +6852,24 @@ TEST_F(WebFrameSwapTest, RemoteFramesAreIndexable)
ASSERT_TRUE(windowLength->IsNumber());
v8::Local<v8::Integer> windowLengthInteger = windowLength->ToInteger();
EXPECT_EQ(3, windowLengthInteger->Value());
+
+ reset();
}
TEST_F(WebFrameSwapTest, RemoteFrameLengthAccess)
{
v8::HandleScope scope(v8::Isolate::GetCurrent());
- WebRemoteFrame* remoteFrame = WebRemoteFrame::create(nullptr);
+ FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
+ WebRemoteFrame* remoteFrame = remoteClient.frame();
mainFrame()->lastChild()->swap(remoteFrame);
remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
v8::Local<v8::Value> remoteWindowLength = mainFrame()->executeScriptAndReturnValue(WebScriptSource("window[2].length"));
ASSERT_TRUE(remoteWindowLength->IsNumber());
v8::Local<v8::Integer> remoteWindowLengthInteger = remoteWindowLength->ToInteger();
EXPECT_EQ(0, remoteWindowLengthInteger->Value());
+
+ reset();
}
TEST_F(WebFrameSwapTest, RemoteWindowNamedAccess)
@@ -6872,11 +6879,14 @@ TEST_F(WebFrameSwapTest, RemoteWindowNamedAccess)
// FIXME: Once OOPIF unit test infrastructure is in place, test that named
// window access on a remote window works. For now, just test that accessing
// a named property doesn't crash.
- WebRemoteFrame* remoteFrame = WebRemoteFrame::create(nullptr);
+ FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
+ WebRemoteFrame* remoteFrame = remoteClient.frame();
mainFrame()->lastChild()->swap(remoteFrame);
remoteFrame->setReplicatedOrigin(SecurityOrigin::createUnique());
v8::Local<v8::Value> remoteWindowProperty = mainFrame()->executeScriptAndReturnValue(WebScriptSource("window[2].foo"));
EXPECT_TRUE(remoteWindowProperty.IsEmpty());
+
+ reset();
}
class RemoteToLocalSwapWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
@@ -6936,7 +6946,7 @@ private:
TEST_F(WebFrameSwapTest, NavigateRemoteFrameViaLocation)
{
RemoteNavigationClient client;
- WebRemoteFrame* remoteFrame = WebRemoteFrame::create(&client);
+ WebRemoteFrame* remoteFrame = client.frame();
WebFrame* targetFrame = mainFrame()->firstChild();
ASSERT_TRUE(targetFrame);
targetFrame->swap(remoteFrame);
@@ -6952,7 +6962,6 @@ TEST_F(WebFrameSwapTest, NavigateRemoteFrameViaLocation)
// Manually reset to break WebViewHelper's dependency on the stack allocated
// TestWebFrameClient.
reset();
- remoteFrame->close();
}
class MockDocumentThreadableLoaderClient : public DocumentThreadableLoaderClient {
@@ -7070,7 +7079,7 @@ TEST_F(WebFrameTest, DetachRemoteFrame)
FrameTestHelpers::TestWebViewClient viewClient;
FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
WebView* view = WebView::create(&viewClient);
- view->setMainFrame(WebRemoteFrame::create(&remoteClient));
+ view->setMainFrame(remoteClient.frame());
FrameTestHelpers::TestWebRemoteFrameClient childFrameClient;
WebRemoteFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createRemoteChild("", WebSandboxFlags::None, &childFrameClient);
childFrame->detach();

Powered by Google App Engine
This is Rietveld 408576698