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

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

Issue 2369613003: Require WebLocalFrame to be created with a non-null client (Closed)
Patch Set: oops Created 4 years, 2 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
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 5871 matching lines...) Expand 10 before | Expand all | Expand 10 after
5882 , m_willSendRequestCallCount(0) 5882 , m_willSendRequestCallCount(0)
5883 , m_childFrameCreationCount(0) 5883 , m_childFrameCreationCount(0)
5884 { 5884 {
5885 } 5885 }
5886 5886
5887 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child Client = client; } 5887 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child Client = client; }
5888 WebCachePolicy getCachePolicy() const { return m_policy; } 5888 WebCachePolicy getCachePolicy() const { return m_policy; }
5889 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } 5889 int willSendRequestCallCount() const { return m_willSendRequestCallCount; }
5890 int childFrameCreationCount() const { return m_childFrameCreationCount; } 5890 int childFrameCreationCount() const { return m_childFrameCreationCount; }
5891 5891
5892 virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType s cope, const WebString&, const WebString&, WebSandboxFlags, const WebFrameOwnerPr operties& frameOwnerProperties) 5892 virtual WebLocalFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeT ype scope, const WebString&, const WebString&, WebSandboxFlags, const WebFrameOw nerProperties& frameOwnerProperties)
5893 { 5893 {
5894 DCHECK(m_childClient); 5894 DCHECK(m_childClient);
5895 m_childFrameCreationCount++; 5895 m_childFrameCreationCount++;
5896 WebFrame* frame = WebLocalFrame::create(scope, m_childClient); 5896 WebLocalFrame* frame = WebLocalFrame::create(scope, m_childClient);
5897 parent->appendChild(frame); 5897 parent->appendChild(frame);
5898 return frame; 5898 return frame;
5899 } 5899 }
5900 5900
5901 virtual void didStartLoading(bool toDifferentDocument) 5901 virtual void didStartLoading(bool toDifferentDocument)
5902 { 5902 {
5903 if (m_parentClient) { 5903 if (m_parentClient) {
5904 m_parentClient->didStartLoading(toDifferentDocument); 5904 m_parentClient->didStartLoading(toDifferentDocument);
5905 return; 5905 return;
5906 } 5906 }
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
6270 // After commit, there is. 6270 // After commit, there is.
6271 HistoryItem* item = mainFrameLoader.currentItem(); 6271 HistoryItem* item = mainFrameLoader.currentItem();
6272 ASSERT_TRUE(item); 6272 ASSERT_TRUE(item);
6273 EXPECT_EQ(WTF::String(url.data()), item->urlString()); 6273 EXPECT_EQ(WTF::String(url.data()), item->urlString());
6274 } 6274 }
6275 6275
6276 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient { 6276 class FailCreateChildFrame : public FrameTestHelpers::TestWebFrameClient {
6277 public: 6277 public:
6278 FailCreateChildFrame() : m_callCount(0) { } 6278 FailCreateChildFrame() : m_callCount(0) { }
6279 6279
6280 WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType scope, co nst WebString& frameName, const WebString& frameUniqueName, WebSandboxFlags sand boxFlags, const WebFrameOwnerProperties& frameOwnerProperties) override 6280 WebLocalFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType scop e, const WebString& frameName, const WebString& frameUniqueName, WebSandboxFlags sandboxFlags, const WebFrameOwnerProperties& frameOwnerProperties) override
6281 { 6281 {
6282 ++m_callCount; 6282 ++m_callCount;
6283 return 0; 6283 return nullptr;
6284 } 6284 }
6285 6285
6286 int callCount() const { return m_callCount; } 6286 int callCount() const { return m_callCount; }
6287 6287
6288 private: 6288 private:
6289 int m_callCount; 6289 int m_callCount;
6290 }; 6290 };
6291 6291
6292 // Test that we don't crash if WebFrameClient::createChildFrame() fails. 6292 // Test that we don't crash if WebFrameClient::createChildFrame() fails.
6293 TEST_P(ParameterizedWebFrameTest, CreateChildFrameFailure) 6293 TEST_P(ParameterizedWebFrameTest, CreateChildFrameFailure)
(...skipping 2691 matching lines...) Expand 10 before | Expand all | Expand 10 after
8985 FrameTestHelpers::WebViewHelper helper; 8985 FrameTestHelpers::WebViewHelper helper;
8986 helper.initializeAndLoad(url, true); 8986 helper.initializeAndLoad(url, true);
8987 Platform::current()->getURLLoaderMockFactory()->setLoaderDelegate(nullptr); 8987 Platform::current()->getURLLoaderMockFactory()->setLoaderDelegate(nullptr);
8988 8988
8989 Document* document = toLocalFrame(helper.webView()->page()->mainFrame())->do cument(); 8989 Document* document = toLocalFrame(helper.webView()->page()->mainFrame())->do cument();
8990 EXPECT_TRUE(document->isImageDocument()); 8990 EXPECT_TRUE(document->isImageDocument());
8991 EXPECT_EQ(Resource::DecodeError, toImageDocument(document)->cachedImage()->g etStatus()); 8991 EXPECT_EQ(Resource::DecodeError, toImageDocument(document)->cachedImage()->g etStatus());
8992 } 8992 }
8993 8993
8994 } // namespace blink 8994 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698