Index: Source/web/tests/WebFrameTest.cpp |
diff --git a/Source/web/tests/WebFrameTest.cpp b/Source/web/tests/WebFrameTest.cpp |
index 629eec70fd68d5de57cecfe4a7073e72187ea154..06e07264a3761016b6026fbb0fb40431d164ebda 100644 |
--- a/Source/web/tests/WebFrameTest.cpp |
+++ b/Source/web/tests/WebFrameTest.cpp |
@@ -49,6 +49,7 @@ |
#include "core/editing/VisiblePosition.h" |
#include "core/events/MouseEvent.h" |
#include "core/fetch/MemoryCache.h" |
+#include "core/frame/FrameProtector.h" |
#include "core/frame/FrameView.h" |
#include "core/frame/LocalFrame.h" |
#include "core/frame/Settings.h" |
@@ -98,6 +99,7 @@ |
#include "public/web/WebTextCheckingResult.h" |
#include "public/web/WebViewClient.h" |
#include "web/WebLocalFrameImpl.h" |
+#include "web/WebRemoteFrameImpl.h" |
#include "web/WebViewImpl.h" |
#include "web/tests/FrameTestHelpers.h" |
#include "wtf/Forward.h" |
@@ -191,7 +193,9 @@ protected: |
webViewHelper->initializeAndLoad(m_baseURL + "nodeimage.html"); |
webViewHelper->webView()->resize(WebSize(640, 480)); |
webViewHelper->webView()->layout(); |
- RefPtr<blink::LocalFrame> frame = toLocalFrame(webViewHelper->webViewImpl()->page()->mainFrame()); |
+ LocalFrame* frame = toLocalFrame(webViewHelper->webViewImpl()->page()->mainFrame()); |
+ FrameProtector protect(frame); |
+ ASSERT(frame); |
blink::Element* element = frame->document()->getElementById(testcase.c_str()); |
return frame->nodeImage(*element); |
} |
@@ -647,8 +651,10 @@ TEST_F(WebFrameTest, PostMessageThenDetach) |
FrameTestHelpers::WebViewHelper webViewHelper; |
webViewHelper.initializeAndLoad("about:blank"); |
- RefPtr<blink::LocalFrame> frame = toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame()); |
- blink::NonThrowableExceptionState exceptionState; |
+ |
+ LocalFrame* frame = toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame()); |
+ FrameProtector protect(frame); |
+ NonThrowableExceptionState exceptionState; |
frame->domWindow()->postMessage(blink::SerializedScriptValue::create("message"), 0, "*", frame->domWindow(), exceptionState); |
webViewHelper.reset(); |
EXPECT_FALSE(exceptionState.hadException()); |
@@ -3434,8 +3440,8 @@ TEST_F(WebFrameTest, FindOnDetachedFrame) |
WebFindOptions options; |
WebString searchText = WebString::fromUTF8(kFindString); |
WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame()); |
- RefPtr<WebLocalFrameImpl> secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext(false)); |
- RefPtr<blink::LocalFrame> holdSecondFrame = secondFrame->frame(); |
+ RefPtrWillBeRawPtr<WebLocalFrameImpl> secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext(false)); |
+ FrameProtector holdSecondFrame(secondFrame->frame()); |
// Detach the frame before finding. |
EXPECT_TRUE(mainFrame->document().getElementById("frame").remove()); |
@@ -3453,8 +3459,6 @@ TEST_F(WebFrameTest, FindOnDetachedFrame) |
runPendingTasks(); |
EXPECT_TRUE(client.findResultsAreReady()); |
- |
- holdSecondFrame.release(); |
} |
TEST_F(WebFrameTest, FindDetachFrameBeforeScopeStrings) |
@@ -3476,7 +3480,7 @@ TEST_F(WebFrameTest, FindDetachFrameBeforeScopeStrings) |
WebString searchText = WebString::fromUTF8(kFindString); |
WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame()); |
WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext(false)); |
- RefPtr<blink::LocalFrame> holdSecondFrame = secondFrame->frame(); |
+ FrameProtector holdSecondFrame(secondFrame->frame()); |
for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0)); |
@@ -3494,8 +3498,6 @@ TEST_F(WebFrameTest, FindDetachFrameBeforeScopeStrings) |
runPendingTasks(); |
EXPECT_TRUE(client.findResultsAreReady()); |
- |
- holdSecondFrame.release(); |
} |
TEST_F(WebFrameTest, FindDetachFrameWhileScopingStrings) |
@@ -3517,7 +3519,7 @@ TEST_F(WebFrameTest, FindDetachFrameWhileScopingStrings) |
WebString searchText = WebString::fromUTF8(kFindString); |
WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame()); |
WebLocalFrameImpl* secondFrame = toWebLocalFrameImpl(mainFrame->traverseNext(false)); |
- RefPtr<blink::LocalFrame> holdSecondFrame = secondFrame->frame(); |
+ FrameProtector holdSecondFrame(secondFrame->frame()); |
for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false)) |
EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0)); |
@@ -3535,8 +3537,6 @@ TEST_F(WebFrameTest, FindDetachFrameWhileScopingStrings) |
runPendingTasks(); |
EXPECT_TRUE(client.findResultsAreReady()); |
- |
- holdSecondFrame.release(); |
} |
TEST_F(WebFrameTest, ResetMatchCount) |
@@ -5122,7 +5122,7 @@ TEST_F(WebFrameTest, ModifiedClickNewWindow) |
blink::KURL destination = toKURL(m_baseURL + "hello_world.html"); |
// ctrl+click event |
- RefPtrWillBeRawPtr<blink::Event> event = blink::MouseEvent::create(blink::EventTypeNames::click, false, false, |
+ RefPtrWillBeRawPtr<Event> event = blink::MouseEvent::create(blink::EventTypeNames::click, false, false, |
document->domWindow(), 0, 0, 0, 0, 0, 0, 0, true, false, false, false, 0, nullptr, nullptr); |
blink::FrameLoadRequest frameRequest(document, blink::ResourceRequest(destination)); |
frameRequest.setTriggeringEvent(event); |
@@ -5290,7 +5290,7 @@ TEST_F(WebFrameTest, ReloadIframe) |
webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, &mainClient); |
WebLocalFrameImpl* mainFrame = webViewHelper.webViewImpl()->mainFrameImpl(); |
- RefPtr<WebLocalFrameImpl> childFrame = toWebLocalFrameImpl(mainFrame->firstChild()); |
+ RefPtrWillBeRawPtr<WebLocalFrameImpl> childFrame = toWebLocalFrameImpl(mainFrame->firstChild()); |
ASSERT_EQ(childFrame->client(), &childClient); |
EXPECT_EQ(mainClient.childFrameCreationCount(), 1); |
EXPECT_EQ(childClient.willSendRequestCallCount(), 1); |
@@ -5984,6 +5984,8 @@ void swapAndVerifyFirstChildConsistency(const char* const message, WebFrame* par |
TEST_F(WebFrameSwapTest, SwapFirstChild) |
{ |
WebFrame* remoteFrame = WebRemoteFrame::create(0); |
+ // FIXME: Oilpan: add a guard/protector-like helper type that tidies this up. |
+ RefPtrWillBePersistent<WebRemoteFrameImpl> protect(toWebRemoteFrameImpl(remoteFrame)); |
swapAndVerifyFirstChildConsistency("local->remote", mainFrame(), remoteFrame); |
FrameTestHelpers::TestWebFrameClient client; |
@@ -6021,6 +6023,7 @@ void swapAndVerifyMiddleChildConsistency(const char* const message, WebFrame* pa |
TEST_F(WebFrameSwapTest, SwapMiddleChild) |
{ |
WebFrame* remoteFrame = WebRemoteFrame::create(0); |
+ RefPtrWillBePersistent<WebRemoteFrameImpl> protect(toWebRemoteFrameImpl(remoteFrame)); |
swapAndVerifyMiddleChildConsistency("local->remote", mainFrame(), remoteFrame); |
FrameTestHelpers::TestWebFrameClient client; |
@@ -6055,6 +6058,7 @@ void swapAndVerifyLastChildConsistency(const char* const message, WebFrame* pare |
TEST_F(WebFrameSwapTest, SwapLastChild) |
{ |
WebFrame* remoteFrame = WebRemoteFrame::create(0); |
+ RefPtrWillBePersistent<WebRemoteFrameImpl> protect(toWebRemoteFrameImpl(remoteFrame)); |
swapAndVerifyLastChildConsistency("local->remote", mainFrame(), remoteFrame); |
FrameTestHelpers::TestWebFrameClient client; |
@@ -6100,7 +6104,8 @@ TEST_F(WebFrameTest, LoaderOriginAccess) |
blink::KURL resourceUrl(blink::ParsedURLString, "chrome://test.pdf"); |
registerMockedChromeURLLoad("test.pdf"); |
- RefPtr<blink::LocalFrame> frame = toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame()); |
+ LocalFrame* frame = toLocalFrame(webViewHelper.webViewImpl()->page()->mainFrame()); |
+ FrameProtector protect(frame); |
MockDocumentThreadableLoaderClient client; |
blink::ThreadableLoaderOptions options; |