OLD | NEW |
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 4703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4714 , m_willSendRequestCallCount(0) | 4714 , m_willSendRequestCallCount(0) |
4715 , m_childFrameCreationCount(0) | 4715 , m_childFrameCreationCount(0) |
4716 { | 4716 { |
4717 } | 4717 } |
4718 | 4718 |
4719 void setChildWebFrameClient(WebFrameClient* client) { m_client = client; } | 4719 void setChildWebFrameClient(WebFrameClient* client) { m_client = client; } |
4720 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; } | 4720 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; } |
4721 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } | 4721 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } |
4722 int childFrameCreationCount() const { return m_childFrameCreationCount; } | 4722 int childFrameCreationCount() const { return m_childFrameCreationCount; } |
4723 | 4723 |
4724 virtual WebFrame* createChildFrame(WebFrame*, const WebString&) | 4724 virtual WebFrame* createChildFrame(WebFrame* parent, const WebString&) |
4725 { | 4725 { |
4726 m_childFrameCreationCount++; | 4726 m_childFrameCreationCount++; |
4727 return WebFrame::create(m_client); | 4727 WebFrame* frame = WebFrame::create(m_client); |
| 4728 parent->appendChild(frame); |
| 4729 return frame; |
4728 } | 4730 } |
4729 | 4731 |
4730 virtual void willSendRequest(WebFrame* frame, unsigned, WebURLRequest& reque
st, const WebURLResponse&) | 4732 virtual void frameDetached(WebFrame* frame) OVERRIDE |
| 4733 { |
| 4734 if (frame->parent()) |
| 4735 frame->parent()->removeChild(frame); |
| 4736 frame->close(); |
| 4737 } |
| 4738 |
| 4739 virtual void willSendRequest(WebFrame* frame, unsigned, WebURLRequest& reque
st, const WebURLResponse&) OVERRIDE |
4731 { | 4740 { |
4732 m_policy = request.cachePolicy(); | 4741 m_policy = request.cachePolicy(); |
4733 m_willSendRequestCallCount++; | 4742 m_willSendRequestCallCount++; |
4734 } | 4743 } |
4735 | 4744 |
4736 private: | 4745 private: |
4737 WebURLRequest::CachePolicy m_policy; | 4746 WebURLRequest::CachePolicy m_policy; |
4738 WebFrameClient* m_client; | 4747 WebFrameClient* m_client; |
4739 int m_willSendRequestCallCount; | 4748 int m_willSendRequestCallCount; |
4740 int m_childFrameCreationCount; | 4749 int m_childFrameCreationCount; |
4741 }; | 4750 }; |
4742 | 4751 |
4743 TEST_F(WebFrameTest, ReloadIframe) | 4752 TEST_F(WebFrameTest, ReloadIframe) |
4744 { | 4753 { |
4745 registerMockedHttpURLLoad("iframe_reload.html"); | 4754 registerMockedHttpURLLoad("iframe_reload.html"); |
4746 registerMockedHttpURLLoad("visible_iframe.html"); | 4755 registerMockedHttpURLLoad("visible_iframe.html"); |
4747 TestCachePolicyWebFrameClient mainClient; | 4756 TestCachePolicyWebFrameClient mainClient; |
4748 TestCachePolicyWebFrameClient childClient; | 4757 TestCachePolicyWebFrameClient childClient; |
4749 mainClient.setChildWebFrameClient(&childClient); | 4758 mainClient.setChildWebFrameClient(&childClient); |
4750 | 4759 |
4751 FrameTestHelpers::WebViewHelper webViewHelper; | 4760 FrameTestHelpers::WebViewHelper webViewHelper; |
4752 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, &mai
nClient); | 4761 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, &mai
nClient); |
4753 | 4762 |
4754 WebFrameImpl* mainFrame = webViewHelper.webViewImpl()->mainFrameImpl(); | 4763 WebFrameImpl* mainFrame = webViewHelper.webViewImpl()->mainFrameImpl(); |
4755 WebFrameImpl* childFrame = toWebFrameImpl(mainFrame->firstChild()); | 4764 RefPtr<WebFrameImpl> childFrame = toWebFrameImpl(mainFrame->firstChild()); |
4756 ASSERT_EQ(childFrame->client(), &childClient); | 4765 ASSERT_EQ(childFrame->client(), &childClient); |
4757 EXPECT_EQ(mainClient.childFrameCreationCount(), 1); | 4766 EXPECT_EQ(mainClient.childFrameCreationCount(), 1); |
4758 EXPECT_EQ(childClient.willSendRequestCallCount(), 1); | 4767 EXPECT_EQ(childClient.willSendRequestCallCount(), 1); |
4759 EXPECT_EQ(childClient.cachePolicy(), WebURLRequest::UseProtocolCachePolicy); | 4768 EXPECT_EQ(childClient.cachePolicy(), WebURLRequest::UseProtocolCachePolicy); |
4760 | 4769 |
4761 mainFrame->reload(false); | 4770 mainFrame->reload(false); |
4762 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); | 4771 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); |
4763 | 4772 |
4764 // A new WebFrame should have been created, but the child WebFrameClient sho
uld be reused. | 4773 // A new WebFrame should have been created, but the child WebFrameClient sho
uld be reused. |
4765 ASSERT_FALSE(childFrame == toWebFrameImpl(mainFrame->firstChild())); | 4774 ASSERT_NE(childFrame, toWebFrameImpl(mainFrame->firstChild())); |
4766 ASSERT_EQ(toWebFrameImpl(mainFrame->firstChild())->client(), &childClient); | 4775 ASSERT_EQ(toWebFrameImpl(mainFrame->firstChild())->client(), &childClient); |
4767 | 4776 |
4768 EXPECT_EQ(mainClient.childFrameCreationCount(), 2); | 4777 EXPECT_EQ(mainClient.childFrameCreationCount(), 2); |
4769 EXPECT_EQ(childClient.willSendRequestCallCount(), 2); | 4778 EXPECT_EQ(childClient.willSendRequestCallCount(), 2); |
4770 EXPECT_EQ(childClient.cachePolicy(), WebURLRequest::ReloadIgnoringCacheData)
; | 4779 EXPECT_EQ(childClient.cachePolicy(), WebURLRequest::ReloadIgnoringCacheData)
; |
4771 } | 4780 } |
4772 | 4781 |
4773 TEST_F(WebFrameTest, ExportHistoryItemFromChildFrame) | 4782 TEST_F(WebFrameTest, ExportHistoryItemFromChildFrame) |
4774 { | 4783 { |
4775 registerMockedHttpURLLoad("iframe_reload.html"); | 4784 registerMockedHttpURLLoad("iframe_reload.html"); |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5130 // Change width, ensure optimized logic for height change doesn't break
repaint on width change. | 5139 // Change width, ensure optimized logic for height change doesn't break
repaint on width change. |
5131 frameView->setTracksRepaints(true); | 5140 frameView->setTracksRepaints(true); |
5132 webView->resize(WebSize(300, 300)); | 5141 webView->resize(WebSize(300, 300)); |
5133 webView->layout(); | 5142 webView->layout(); |
5134 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 300, 300), WebCore::unionRect(fram
eView->trackedRepaintRects())); | 5143 EXPECT_EQ_RECT(WebCore::IntRect(0, 0, 300, 300), WebCore::unionRect(fram
eView->trackedRepaintRects())); |
5135 frameView->setTracksRepaints(false); | 5144 frameView->setTracksRepaints(false); |
5136 } | 5145 } |
5137 } | 5146 } |
5138 | 5147 |
5139 } // namespace | 5148 } // namespace |
OLD | NEW |