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 5870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5881 EXPECT_TRUE(firstItem); | 5881 EXPECT_TRUE(firstItem); |
5882 | 5882 |
5883 registerMockedHttpURLLoad("white-1x1.png"); | 5883 registerMockedHttpURLLoad("white-1x1.png"); |
5884 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); | 5884 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); |
5885 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); | 5885 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); |
5886 | 5886 |
5887 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem.get()), We
bHistoryDifferentDocumentLoad, WebURLRequest::UseProtocolCachePolicy); | 5887 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem.get()), We
bHistoryDifferentDocumentLoad, WebURLRequest::UseProtocolCachePolicy); |
5888 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); | 5888 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); |
5889 | 5889 |
5890 FrameTestHelpers::reloadFrame(frame); | 5890 FrameTestHelpers::reloadFrame(frame); |
5891 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); | 5891 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().getCachePolicy()); |
5892 } | 5892 } |
5893 | 5893 |
5894 TEST_P(ParameterizedWebFrameTest, BackDuringChildFrameReload) | 5894 TEST_P(ParameterizedWebFrameTest, BackDuringChildFrameReload) |
5895 { | 5895 { |
5896 registerMockedHttpURLLoad("page_with_blank_iframe.html"); | 5896 registerMockedHttpURLLoad("page_with_blank_iframe.html"); |
5897 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5897 FrameTestHelpers::WebViewHelper webViewHelper(this); |
5898 webViewHelper.initializeAndLoad(m_baseURL + "page_with_blank_iframe.html", t
rue); | 5898 webViewHelper.initializeAndLoad(m_baseURL + "page_with_blank_iframe.html", t
rue); |
5899 WebFrame* mainFrame = webViewHelper.webView()->mainFrame(); | 5899 WebFrame* mainFrame = webViewHelper.webView()->mainFrame(); |
5900 const FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mainFrameI
mpl()->frame()->loader(); | 5900 const FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mainFrameI
mpl()->frame()->loader(); |
5901 WebFrame* childFrame = mainFrame->firstChild(); | 5901 WebFrame* childFrame = mainFrame->firstChild(); |
(...skipping 22 matching lines...) Expand all Loading... |
5924 webViewHelper.initializeAndLoad(m_baseURL + "reload_post.html", true); | 5924 webViewHelper.initializeAndLoad(m_baseURL + "reload_post.html", true); |
5925 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5925 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
5926 | 5926 |
5927 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.forms[0].submit()"); | 5927 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.forms[0].submit()"); |
5928 // Pump requests one more time after the javascript URL has executed to | 5928 // Pump requests one more time after the javascript URL has executed to |
5929 // trigger the actual POST load request. | 5929 // trigger the actual POST load request. |
5930 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainF
rame()); | 5930 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webView()->mainF
rame()); |
5931 EXPECT_EQ(WebString::fromUTF8("POST"), frame->dataSource()->request().httpMe
thod()); | 5931 EXPECT_EQ(WebString::fromUTF8("POST"), frame->dataSource()->request().httpMe
thod()); |
5932 | 5932 |
5933 FrameTestHelpers::reloadFrame(frame); | 5933 FrameTestHelpers::reloadFrame(frame); |
5934 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); | 5934 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().getCachePolicy()); |
5935 EXPECT_EQ(WebNavigationTypeFormResubmitted, frame->dataSource()->navigationT
ype()); | 5935 EXPECT_EQ(WebNavigationTypeFormResubmitted, frame->dataSource()->navigationT
ype()); |
5936 } | 5936 } |
5937 | 5937 |
5938 TEST_P(ParameterizedWebFrameTest, LoadHistoryItemReload) | 5938 TEST_P(ParameterizedWebFrameTest, LoadHistoryItemReload) |
5939 { | 5939 { |
5940 registerMockedHttpURLLoad("fragment_middle_click.html"); | 5940 registerMockedHttpURLLoad("fragment_middle_click.html"); |
5941 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5941 FrameTestHelpers::WebViewHelper webViewHelper(this); |
5942 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue); | 5942 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue); |
5943 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5943 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
5944 const FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mainFrameI
mpl()->frame()->loader(); | 5944 const FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mainFrameI
mpl()->frame()->loader(); |
5945 RefPtrWillBePersistent<HistoryItem> firstItem = mainFrameLoader.currentItem(
); | 5945 RefPtrWillBePersistent<HistoryItem> firstItem = mainFrameLoader.currentItem(
); |
5946 EXPECT_TRUE(firstItem); | 5946 EXPECT_TRUE(firstItem); |
5947 | 5947 |
5948 registerMockedHttpURLLoad("white-1x1.png"); | 5948 registerMockedHttpURLLoad("white-1x1.png"); |
5949 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); | 5949 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); |
5950 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); | 5950 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); |
5951 | 5951 |
5952 // Cache policy overrides should take. | 5952 // Cache policy overrides should take. |
5953 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem), WebHisto
ryDifferentDocumentLoad, WebURLRequest::ReloadIgnoringCacheData); | 5953 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem), WebHisto
ryDifferentDocumentLoad, WebURLRequest::ReloadIgnoringCacheData); |
5954 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); | 5954 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); |
5955 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().cachePolicy()); | 5955 EXPECT_EQ(WebURLRequest::ReloadIgnoringCacheData, frame->dataSource()->reque
st().getCachePolicy()); |
5956 } | 5956 } |
5957 | 5957 |
5958 | 5958 |
5959 class TestCachePolicyWebFrameClient : public FrameTestHelpers::TestWebFrameClien
t { | 5959 class TestCachePolicyWebFrameClient : public FrameTestHelpers::TestWebFrameClien
t { |
5960 public: | 5960 public: |
5961 explicit TestCachePolicyWebFrameClient(TestCachePolicyWebFrameClient* parent
Client) | 5961 explicit TestCachePolicyWebFrameClient(TestCachePolicyWebFrameClient* parent
Client) |
5962 : m_parentClient(parentClient) | 5962 : m_parentClient(parentClient) |
5963 , m_policy(WebURLRequest::UseProtocolCachePolicy) | 5963 , m_policy(WebURLRequest::UseProtocolCachePolicy) |
5964 , m_childClient(0) | 5964 , m_childClient(0) |
5965 , m_willSendRequestCallCount(0) | 5965 , m_willSendRequestCallCount(0) |
5966 , m_childFrameCreationCount(0) | 5966 , m_childFrameCreationCount(0) |
5967 { | 5967 { |
5968 } | 5968 } |
5969 | 5969 |
5970 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child
Client = client; } | 5970 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child
Client = client; } |
5971 WebURLRequest::CachePolicy cachePolicy() const { return m_policy; } | 5971 WebURLRequest::CachePolicy getCachePolicy() const { return m_policy; } |
5972 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } | 5972 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } |
5973 int childFrameCreationCount() const { return m_childFrameCreationCount; } | 5973 int childFrameCreationCount() const { return m_childFrameCreationCount; } |
5974 | 5974 |
5975 virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType s
cope, const WebString&, const WebString&, WebSandboxFlags, const WebFrameOwnerPr
operties& frameOwnerProperties) | 5975 virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType s
cope, const WebString&, const WebString&, WebSandboxFlags, const WebFrameOwnerPr
operties& frameOwnerProperties) |
5976 { | 5976 { |
5977 ASSERT(m_childClient); | 5977 ASSERT(m_childClient); |
5978 m_childFrameCreationCount++; | 5978 m_childFrameCreationCount++; |
5979 WebFrame* frame = WebLocalFrame::create(scope, m_childClient); | 5979 WebFrame* frame = WebLocalFrame::create(scope, m_childClient); |
5980 parent->appendChild(frame); | 5980 parent->appendChild(frame); |
5981 return frame; | 5981 return frame; |
(...skipping 12 matching lines...) Expand all Loading... |
5994 { | 5994 { |
5995 if (m_parentClient) { | 5995 if (m_parentClient) { |
5996 m_parentClient->didStopLoading(); | 5996 m_parentClient->didStopLoading(); |
5997 return; | 5997 return; |
5998 } | 5998 } |
5999 TestWebFrameClient::didStopLoading(); | 5999 TestWebFrameClient::didStopLoading(); |
6000 } | 6000 } |
6001 | 6001 |
6002 void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest& request,
const WebURLResponse&) override | 6002 void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest& request,
const WebURLResponse&) override |
6003 { | 6003 { |
6004 m_policy = request.cachePolicy(); | 6004 m_policy = request.getCachePolicy(); |
6005 m_willSendRequestCallCount++; | 6005 m_willSendRequestCallCount++; |
6006 } | 6006 } |
6007 | 6007 |
6008 private: | 6008 private: |
6009 TestCachePolicyWebFrameClient* m_parentClient; | 6009 TestCachePolicyWebFrameClient* m_parentClient; |
6010 | 6010 |
6011 WebURLRequest::CachePolicy m_policy; | 6011 WebURLRequest::CachePolicy m_policy; |
6012 TestCachePolicyWebFrameClient* m_childClient; | 6012 TestCachePolicyWebFrameClient* m_childClient; |
6013 int m_willSendRequestCallCount; | 6013 int m_willSendRequestCallCount; |
6014 int m_childFrameCreationCount; | 6014 int m_childFrameCreationCount; |
6015 }; | 6015 }; |
6016 | 6016 |
6017 TEST_P(ParameterizedWebFrameTest, ReloadIframe) | 6017 TEST_P(ParameterizedWebFrameTest, ReloadIframe) |
6018 { | 6018 { |
6019 registerMockedHttpURLLoad("iframe_reload.html"); | 6019 registerMockedHttpURLLoad("iframe_reload.html"); |
6020 registerMockedHttpURLLoad("visible_iframe.html"); | 6020 registerMockedHttpURLLoad("visible_iframe.html"); |
6021 TestCachePolicyWebFrameClient mainClient(0); | 6021 TestCachePolicyWebFrameClient mainClient(0); |
6022 TestCachePolicyWebFrameClient childClient(&mainClient); | 6022 TestCachePolicyWebFrameClient childClient(&mainClient); |
6023 mainClient.setChildWebFrameClient(&childClient); | 6023 mainClient.setChildWebFrameClient(&childClient); |
6024 | 6024 |
6025 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6025 FrameTestHelpers::WebViewHelper webViewHelper(this); |
6026 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, &mai
nClient); | 6026 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, &mai
nClient); |
6027 | 6027 |
6028 WebLocalFrameImpl* mainFrame = webViewHelper.webViewImpl()->mainFrameImpl(); | 6028 WebLocalFrameImpl* mainFrame = webViewHelper.webViewImpl()->mainFrameImpl(); |
6029 RefPtrWillBeRawPtr<WebLocalFrameImpl> childFrame = toWebLocalFrameImpl(mainF
rame->firstChild()); | 6029 RefPtrWillBeRawPtr<WebLocalFrameImpl> childFrame = toWebLocalFrameImpl(mainF
rame->firstChild()); |
6030 ASSERT_EQ(childFrame->client(), &childClient); | 6030 ASSERT_EQ(childFrame->client(), &childClient); |
6031 EXPECT_EQ(mainClient.childFrameCreationCount(), 1); | 6031 EXPECT_EQ(mainClient.childFrameCreationCount(), 1); |
6032 EXPECT_EQ(childClient.willSendRequestCallCount(), 1); | 6032 EXPECT_EQ(childClient.willSendRequestCallCount(), 1); |
6033 EXPECT_EQ(childClient.cachePolicy(), WebURLRequest::UseProtocolCachePolicy); | 6033 EXPECT_EQ(childClient.getCachePolicy(), WebURLRequest::UseProtocolCachePolic
y); |
6034 | 6034 |
6035 FrameTestHelpers::reloadFrame(mainFrame); | 6035 FrameTestHelpers::reloadFrame(mainFrame); |
6036 | 6036 |
6037 // A new WebFrame should have been created, but the child WebFrameClient sho
uld be reused. | 6037 // A new WebFrame should have been created, but the child WebFrameClient sho
uld be reused. |
6038 ASSERT_NE(childFrame, toWebLocalFrameImpl(mainFrame->firstChild())); | 6038 ASSERT_NE(childFrame, toWebLocalFrameImpl(mainFrame->firstChild())); |
6039 ASSERT_EQ(toWebLocalFrameImpl(mainFrame->firstChild())->client(), &childClie
nt); | 6039 ASSERT_EQ(toWebLocalFrameImpl(mainFrame->firstChild())->client(), &childClie
nt); |
6040 | 6040 |
6041 EXPECT_EQ(mainClient.childFrameCreationCount(), 2); | 6041 EXPECT_EQ(mainClient.childFrameCreationCount(), 2); |
6042 EXPECT_EQ(childClient.willSendRequestCallCount(), 2); | 6042 EXPECT_EQ(childClient.willSendRequestCallCount(), 2); |
6043 EXPECT_EQ(childClient.cachePolicy(), WebURLRequest::ReloadIgnoringCacheData)
; | 6043 EXPECT_EQ(childClient.getCachePolicy(), WebURLRequest::ReloadIgnoringCacheDa
ta); |
6044 } | 6044 } |
6045 | 6045 |
6046 class TestSameDocumentWebFrameClient : public FrameTestHelpers::TestWebFrameClie
nt { | 6046 class TestSameDocumentWebFrameClient : public FrameTestHelpers::TestWebFrameClie
nt { |
6047 public: | 6047 public: |
6048 TestSameDocumentWebFrameClient() | 6048 TestSameDocumentWebFrameClient() |
6049 : m_frameLoadTypeSameSeen(false) | 6049 : m_frameLoadTypeSameSeen(false) |
6050 { | 6050 { |
6051 } | 6051 } |
6052 | 6052 |
6053 virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest&,
const WebURLResponse&) | 6053 virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest&,
const WebURLResponse&) |
(...skipping 27 matching lines...) Expand all Loading... |
6081 public: | 6081 public: |
6082 TestSameDocumentWithImageWebFrameClient() | 6082 TestSameDocumentWithImageWebFrameClient() |
6083 : m_numOfImageRequests(0) | 6083 : m_numOfImageRequests(0) |
6084 { | 6084 { |
6085 } | 6085 } |
6086 | 6086 |
6087 virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest&
request, const WebURLResponse&) | 6087 virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest&
request, const WebURLResponse&) |
6088 { | 6088 { |
6089 if (request.requestContext() == WebURLRequest::RequestContextImage) { | 6089 if (request.requestContext() == WebURLRequest::RequestContextImage) { |
6090 m_numOfImageRequests++; | 6090 m_numOfImageRequests++; |
6091 EXPECT_EQ(WebURLRequest::UseProtocolCachePolicy, request.cachePolicy
()); | 6091 EXPECT_EQ(WebURLRequest::UseProtocolCachePolicy, request.getCachePol
icy()); |
6092 } | 6092 } |
6093 } | 6093 } |
6094 | 6094 |
6095 int numOfImageRequests() const { return m_numOfImageRequests; } | 6095 int numOfImageRequests() const { return m_numOfImageRequests; } |
6096 | 6096 |
6097 private: | 6097 private: |
6098 int m_numOfImageRequests; | 6098 int m_numOfImageRequests; |
6099 }; | 6099 }; |
6100 | 6100 |
6101 TEST_P(ParameterizedWebFrameTest, NavigateToSameNoConditionalRequestForSubresour
ce) | 6101 TEST_P(ParameterizedWebFrameTest, NavigateToSameNoConditionalRequestForSubresour
ce) |
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6874 | 6874 |
6875 TEST_P(ParameterizedWebFrameTest, ReloadBypassingCache) | 6875 TEST_P(ParameterizedWebFrameTest, ReloadBypassingCache) |
6876 { | 6876 { |
6877 // Check that a reload ignoring cache on a frame will result in the cache | 6877 // Check that a reload ignoring cache on a frame will result in the cache |
6878 // policy of the request being set to ReloadBypassingCache. | 6878 // policy of the request being set to ReloadBypassingCache. |
6879 registerMockedHttpURLLoad("foo.html"); | 6879 registerMockedHttpURLLoad("foo.html"); |
6880 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6880 FrameTestHelpers::WebViewHelper webViewHelper(this); |
6881 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true); | 6881 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true); |
6882 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 6882 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
6883 FrameTestHelpers::reloadFrameIgnoringCache(frame); | 6883 FrameTestHelpers::reloadFrameIgnoringCache(frame); |
6884 EXPECT_EQ(WebURLRequest::ReloadBypassingCache, frame->dataSource()->request(
).cachePolicy()); | 6884 EXPECT_EQ(WebURLRequest::ReloadBypassingCache, frame->dataSource()->request(
).getCachePolicy()); |
6885 } | 6885 } |
6886 | 6886 |
6887 static void nodeImageTestValidation(const IntSize& referenceBitmapSize, DragImag
e* dragImage) | 6887 static void nodeImageTestValidation(const IntSize& referenceBitmapSize, DragImag
e* dragImage) |
6888 { | 6888 { |
6889 // Prepare the reference bitmap. | 6889 // Prepare the reference bitmap. |
6890 SkBitmap bitmap; | 6890 SkBitmap bitmap; |
6891 bitmap.allocN32Pixels(referenceBitmapSize.width(), referenceBitmapSize.heigh
t()); | 6891 bitmap.allocN32Pixels(referenceBitmapSize.width(), referenceBitmapSize.heigh
t()); |
6892 SkCanvas canvas(bitmap); | 6892 SkCanvas canvas(bitmap); |
6893 canvas.drawColor(SK_ColorGREEN); | 6893 canvas.drawColor(SK_ColorGREEN); |
6894 | 6894 |
(...skipping 1624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8519 } | 8519 } |
8520 | 8520 |
8521 TEST_F(WebFrameVisibilityChangeTest, RemoteFrameParentVisibilityChange) | 8521 TEST_F(WebFrameVisibilityChangeTest, RemoteFrameParentVisibilityChange) |
8522 { | 8522 { |
8523 swapLocalFrameToRemoteFrame(); | 8523 swapLocalFrameToRemoteFrame(); |
8524 executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').p
arentElement.style.display = 'none';")); | 8524 executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').p
arentElement.style.display = 'none';")); |
8525 EXPECT_FALSE(remoteFrameClient()->isVisible()); | 8525 EXPECT_FALSE(remoteFrameClient()->isVisible()); |
8526 } | 8526 } |
8527 | 8527 |
8528 } // namespace blink | 8528 } // namespace blink |
OLD | NEW |