| 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 4141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4152 webViewHelper.webView()->mainFrame()->setScrollOffset( | 4152 webViewHelper.webView()->mainFrame()->setScrollOffset( |
| 4153 WebSize(pageWidth / 4, pageHeight / 4)); | 4153 WebSize(pageWidth / 4, pageHeight / 4)); |
| 4154 webViewHelper.webView()->setPageScaleFactor(pageScaleFactor); | 4154 webViewHelper.webView()->setPageScaleFactor(pageScaleFactor); |
| 4155 | 4155 |
| 4156 WebSize previousOffset = | 4156 WebSize previousOffset = |
| 4157 webViewHelper.webView()->mainFrame()->getScrollOffset(); | 4157 webViewHelper.webView()->mainFrame()->getScrollOffset(); |
| 4158 float previousScale = webViewHelper.webView()->pageScaleFactor(); | 4158 float previousScale = webViewHelper.webView()->pageScaleFactor(); |
| 4159 | 4159 |
| 4160 // Reload the page and end up at the same url. State should be propagated. | 4160 // Reload the page and end up at the same url. State should be propagated. |
| 4161 webViewHelper.webView()->mainFrame()->reloadWithOverrideURL( | 4161 webViewHelper.webView()->mainFrame()->reloadWithOverrideURL( |
| 4162 toKURL(m_baseURL + firstURL), WebFrameLoadType::ReloadMainResource); | 4162 toKURL(m_baseURL + firstURL), WebFrameLoadType::Reload); |
| 4163 FrameTestHelpers::pumpPendingRequestsForFrameToLoad( | 4163 FrameTestHelpers::pumpPendingRequestsForFrameToLoad( |
| 4164 webViewHelper.webView()->mainFrame()); | 4164 webViewHelper.webView()->mainFrame()); |
| 4165 EXPECT_EQ(previousOffset.width, | 4165 EXPECT_EQ(previousOffset.width, |
| 4166 webViewHelper.webView()->mainFrame()->getScrollOffset().width); | 4166 webViewHelper.webView()->mainFrame()->getScrollOffset().width); |
| 4167 EXPECT_EQ(previousOffset.height, | 4167 EXPECT_EQ(previousOffset.height, |
| 4168 webViewHelper.webView()->mainFrame()->getScrollOffset().height); | 4168 webViewHelper.webView()->mainFrame()->getScrollOffset().height); |
| 4169 EXPECT_EQ(previousScale, webViewHelper.webView()->pageScaleFactor()); | 4169 EXPECT_EQ(previousScale, webViewHelper.webView()->pageScaleFactor()); |
| 4170 | 4170 |
| 4171 // Reload the page using the cache. State should not be propagated. | 4171 // Reload the page using the cache. State should not be propagated. |
| 4172 webViewHelper.webView()->mainFrame()->reloadWithOverrideURL( | 4172 webViewHelper.webView()->mainFrame()->reloadWithOverrideURL( |
| 4173 toKURL(m_baseURL + secondURL), WebFrameLoadType::ReloadMainResource); | 4173 toKURL(m_baseURL + secondURL), WebFrameLoadType::Reload); |
| 4174 FrameTestHelpers::pumpPendingRequestsForFrameToLoad( | 4174 FrameTestHelpers::pumpPendingRequestsForFrameToLoad( |
| 4175 webViewHelper.webView()->mainFrame()); | 4175 webViewHelper.webView()->mainFrame()); |
| 4176 EXPECT_EQ(0, webViewHelper.webView()->mainFrame()->getScrollOffset().width); | 4176 EXPECT_EQ(0, webViewHelper.webView()->mainFrame()->getScrollOffset().width); |
| 4177 EXPECT_EQ(0, webViewHelper.webView()->mainFrame()->getScrollOffset().height); | 4177 EXPECT_EQ(0, webViewHelper.webView()->mainFrame()->getScrollOffset().height); |
| 4178 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); | 4178 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); |
| 4179 | 4179 |
| 4180 // Reload the page while bypassing the cache. State should not be propagated. | 4180 // Reload the page while bypassing the cache. State should not be propagated. |
| 4181 webViewHelper.webView()->mainFrame()->reloadWithOverrideURL( | 4181 webViewHelper.webView()->mainFrame()->reloadWithOverrideURL( |
| 4182 toKURL(m_baseURL + thirdURL), WebFrameLoadType::ReloadBypassingCache); | 4182 toKURL(m_baseURL + thirdURL), WebFrameLoadType::ReloadBypassingCache); |
| 4183 FrameTestHelpers::pumpPendingRequestsForFrameToLoad( | 4183 FrameTestHelpers::pumpPendingRequestsForFrameToLoad( |
| (...skipping 2981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7165 // Sub-frames should not be forcibly revalidated. | 7165 // Sub-frames should not be forcibly revalidated. |
| 7166 // TODO(toyoshim): Will consider to revalidate main resources in sub-frames | 7166 // TODO(toyoshim): Will consider to revalidate main resources in sub-frames |
| 7167 // on reloads. Or will do only for bypassingCache. | 7167 // on reloads. Or will do only for bypassingCache. |
| 7168 EXPECT_EQ(childClient.getCachePolicy(), | 7168 EXPECT_EQ(childClient.getCachePolicy(), |
| 7169 WebCachePolicy::UseProtocolCachePolicy); | 7169 WebCachePolicy::UseProtocolCachePolicy); |
| 7170 } | 7170 } |
| 7171 | 7171 |
| 7172 class TestSameDocumentWebFrameClient | 7172 class TestSameDocumentWebFrameClient |
| 7173 : public FrameTestHelpers::TestWebFrameClient { | 7173 : public FrameTestHelpers::TestWebFrameClient { |
| 7174 public: | 7174 public: |
| 7175 TestSameDocumentWebFrameClient() | 7175 TestSameDocumentWebFrameClient() : m_frameLoadTypeReloadSeen(false) {} |
| 7176 : m_frameLoadTypeReloadMainResourceSeen(false) {} | |
| 7177 | 7176 |
| 7178 virtual void willSendRequest(WebLocalFrame* frame, WebURLRequest&) { | 7177 virtual void willSendRequest(WebLocalFrame* frame, WebURLRequest&) { |
| 7179 FrameLoader& frameLoader = toWebLocalFrameImpl(frame)->frame()->loader(); | 7178 FrameLoader& frameLoader = toWebLocalFrameImpl(frame)->frame()->loader(); |
| 7180 if (frameLoader.provisionalDocumentLoader()->loadType() == | 7179 if (frameLoader.provisionalDocumentLoader()->loadType() == |
| 7181 FrameLoadTypeReloadMainResource) | 7180 FrameLoadTypeReload) |
| 7182 m_frameLoadTypeReloadMainResourceSeen = true; | 7181 m_frameLoadTypeReloadSeen = true; |
| 7183 } | 7182 } |
| 7184 | 7183 |
| 7185 bool frameLoadTypeReloadMainResourceSeen() const { | 7184 bool frameLoadTypeReloadSeen() const { return m_frameLoadTypeReloadSeen; } |
| 7186 return m_frameLoadTypeReloadMainResourceSeen; | |
| 7187 } | |
| 7188 | 7185 |
| 7189 private: | 7186 private: |
| 7190 bool m_frameLoadTypeReloadMainResourceSeen; | 7187 bool m_frameLoadTypeReloadSeen; |
| 7191 }; | 7188 }; |
| 7192 | 7189 |
| 7193 TEST_P(ParameterizedWebFrameTest, NavigateToSame) { | 7190 TEST_P(ParameterizedWebFrameTest, NavigateToSame) { |
| 7194 registerMockedHttpURLLoad("navigate_to_same.html"); | 7191 registerMockedHttpURLLoad("navigate_to_same.html"); |
| 7195 TestSameDocumentWebFrameClient client; | 7192 TestSameDocumentWebFrameClient client; |
| 7196 FrameTestHelpers::WebViewHelper webViewHelper; | 7193 FrameTestHelpers::WebViewHelper webViewHelper; |
| 7197 webViewHelper.initializeAndLoad(m_baseURL + "navigate_to_same.html", true, | 7194 webViewHelper.initializeAndLoad(m_baseURL + "navigate_to_same.html", true, |
| 7198 &client); | 7195 &client); |
| 7199 EXPECT_FALSE(client.frameLoadTypeReloadMainResourceSeen()); | 7196 EXPECT_FALSE(client.frameLoadTypeReloadSeen()); |
| 7200 | 7197 |
| 7201 FrameLoadRequest frameRequest( | 7198 FrameLoadRequest frameRequest( |
| 7202 0, | 7199 0, |
| 7203 ResourceRequest(toLocalFrame(webViewHelper.webView()->page()->mainFrame()) | 7200 ResourceRequest(toLocalFrame(webViewHelper.webView()->page()->mainFrame()) |
| 7204 ->document() | 7201 ->document() |
| 7205 ->url())); | 7202 ->url())); |
| 7206 toLocalFrame(webViewHelper.webView()->page()->mainFrame()) | 7203 toLocalFrame(webViewHelper.webView()->page()->mainFrame()) |
| 7207 ->loader() | 7204 ->loader() |
| 7208 .load(frameRequest); | 7205 .load(frameRequest); |
| 7209 FrameTestHelpers::pumpPendingRequestsForFrameToLoad( | 7206 FrameTestHelpers::pumpPendingRequestsForFrameToLoad( |
| 7210 webViewHelper.webView()->mainFrame()); | 7207 webViewHelper.webView()->mainFrame()); |
| 7211 | 7208 |
| 7212 EXPECT_TRUE(client.frameLoadTypeReloadMainResourceSeen()); | 7209 EXPECT_TRUE(client.frameLoadTypeReloadSeen()); |
| 7213 } | 7210 } |
| 7214 | 7211 |
| 7215 class TestSameDocumentWithImageWebFrameClient | 7212 class TestSameDocumentWithImageWebFrameClient |
| 7216 : public FrameTestHelpers::TestWebFrameClient { | 7213 : public FrameTestHelpers::TestWebFrameClient { |
| 7217 public: | 7214 public: |
| 7218 TestSameDocumentWithImageWebFrameClient() : m_numOfImageRequests(0) {} | 7215 TestSameDocumentWithImageWebFrameClient() : m_numOfImageRequests(0) {} |
| 7219 | 7216 |
| 7220 virtual void willSendRequest(WebLocalFrame*, WebURLRequest& request) { | 7217 virtual void willSendRequest(WebLocalFrame*, WebURLRequest& request) { |
| 7221 if (request.getRequestContext() == WebURLRequest::RequestContextImage) { | 7218 if (request.getRequestContext() == WebURLRequest::RequestContextImage) { |
| 7222 m_numOfImageRequests++; | 7219 m_numOfImageRequests++; |
| (...skipping 4222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11445 EXPECT_FALSE(testSelectAll("<textarea></textarea>")); | 11442 EXPECT_FALSE(testSelectAll("<textarea></textarea>")); |
| 11446 EXPECT_TRUE(testSelectAll("<textarea>nonempty</textarea>")); | 11443 EXPECT_TRUE(testSelectAll("<textarea>nonempty</textarea>")); |
| 11447 EXPECT_FALSE(testSelectAll("<input>")); | 11444 EXPECT_FALSE(testSelectAll("<input>")); |
| 11448 EXPECT_TRUE(testSelectAll("<input value='nonempty'>")); | 11445 EXPECT_TRUE(testSelectAll("<input value='nonempty'>")); |
| 11449 // TODO(amaralp): Empty contenteditable should not have select all enabled. | 11446 // TODO(amaralp): Empty contenteditable should not have select all enabled. |
| 11450 EXPECT_TRUE(testSelectAll("<div contenteditable></div>")); | 11447 EXPECT_TRUE(testSelectAll("<div contenteditable></div>")); |
| 11451 EXPECT_TRUE(testSelectAll("<div contenteditable>nonempty</div>")); | 11448 EXPECT_TRUE(testSelectAll("<div contenteditable>nonempty</div>")); |
| 11452 } | 11449 } |
| 11453 | 11450 |
| 11454 } // namespace blink | 11451 } // namespace blink |
| OLD | NEW |