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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 #include "core/fetch/ResourceFetcher.h" | 54 #include "core/fetch/ResourceFetcher.h" |
55 #include "core/frame/FrameHost.h" | 55 #include "core/frame/FrameHost.h" |
56 #include "core/frame/FrameView.h" | 56 #include "core/frame/FrameView.h" |
57 #include "core/frame/LocalFrame.h" | 57 #include "core/frame/LocalFrame.h" |
58 #include "core/frame/RemoteFrame.h" | 58 #include "core/frame/RemoteFrame.h" |
59 #include "core/frame/Settings.h" | 59 #include "core/frame/Settings.h" |
60 #include "core/frame/VisualViewport.h" | 60 #include "core/frame/VisualViewport.h" |
61 #include "core/html/HTMLDocument.h" | 61 #include "core/html/HTMLDocument.h" |
62 #include "core/html/HTMLFormElement.h" | 62 #include "core/html/HTMLFormElement.h" |
63 #include "core/html/HTMLMediaElement.h" | 63 #include "core/html/HTMLMediaElement.h" |
| 64 #include "core/html/ImageDocument.h" |
64 #include "core/input/EventHandler.h" | 65 #include "core/input/EventHandler.h" |
65 #include "core/layout/HitTestResult.h" | 66 #include "core/layout/HitTestResult.h" |
66 #include "core/layout/LayoutFullScreen.h" | 67 #include "core/layout/LayoutFullScreen.h" |
67 #include "core/layout/LayoutView.h" | 68 #include "core/layout/LayoutView.h" |
68 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" | 69 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" |
69 #include "core/loader/DocumentLoader.h" | 70 #include "core/loader/DocumentLoader.h" |
70 #include "core/loader/DocumentThreadableLoader.h" | 71 #include "core/loader/DocumentThreadableLoader.h" |
71 #include "core/loader/DocumentThreadableLoaderClient.h" | 72 #include "core/loader/DocumentThreadableLoaderClient.h" |
72 #include "core/loader/FrameLoadRequest.h" | 73 #include "core/loader/FrameLoadRequest.h" |
73 #include "core/loader/ThreadableLoader.h" | 74 #include "core/loader/ThreadableLoader.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 void registerMockedHttpURLLoadWithCSP(const std::string& fileName, const std
::string& csp, bool reportOnly = false) | 201 void registerMockedHttpURLLoadWithCSP(const std::string& fileName, const std
::string& csp, bool reportOnly = false) |
201 { | 202 { |
202 WebURLResponse response; | 203 WebURLResponse response; |
203 response.initialize(); | 204 response.initialize(); |
204 response.setMIMEType("text/html"); | 205 response.setMIMEType("text/html"); |
205 response.addHTTPHeaderField(reportOnly ? WebString("Content-Security-Pol
icy-Report-Only") : WebString("Content-Security-Policy"), WebString::fromUTF8(cs
p)); | 206 response.addHTTPHeaderField(reportOnly ? WebString("Content-Security-Pol
icy-Report-Only") : WebString("Content-Security-Policy"), WebString::fromUTF8(cs
p)); |
206 std::string fullString = m_baseURL + fileName; | 207 std::string fullString = m_baseURL + fileName; |
207 URLTestHelpers::registerMockedURLLoadWithCustomResponse(toKURL(fullStrin
g.c_str()), WebString::fromUTF8(fileName.c_str()), WebString::fromUTF8(""), resp
onse); | 208 URLTestHelpers::registerMockedURLLoadWithCustomResponse(toKURL(fullStrin
g.c_str()), WebString::fromUTF8(fileName.c_str()), WebString::fromUTF8(""), resp
onse); |
208 } | 209 } |
209 | 210 |
| 211 void registerMockedHttpURLLoadWithMimeType(const std::string& fileName, cons
t std::string& mimeType) |
| 212 { |
| 213 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU
RL.c_str()), WebString::fromUTF8(fileName.c_str()), WebString::fromUTF8(mimeType
)); |
| 214 } |
| 215 |
210 void applyViewportStyleOverride(FrameTestHelpers::WebViewHelper* webViewHelp
er) | 216 void applyViewportStyleOverride(FrameTestHelpers::WebViewHelper* webViewHelp
er) |
211 { | 217 { |
212 RefPtrWillBeRawPtr<StyleSheetContents> styleSheet = StyleSheetContents::
create(CSSParserContext(UASheetMode, 0)); | 218 RefPtrWillBeRawPtr<StyleSheetContents> styleSheet = StyleSheetContents::
create(CSSParserContext(UASheetMode, 0)); |
213 styleSheet->parseString(loadResourceAsASCIIString("viewportAndroid.css")
); | 219 styleSheet->parseString(loadResourceAsASCIIString("viewportAndroid.css")
); |
214 OwnPtrWillBeRawPtr<RuleSet> ruleSet = RuleSet::create(); | 220 OwnPtrWillBeRawPtr<RuleSet> ruleSet = RuleSet::create(); |
215 ruleSet->addRulesFromSheet(styleSheet.get(), MediaQueryEvaluator("screen
")); | 221 ruleSet->addRulesFromSheet(styleSheet.get(), MediaQueryEvaluator("screen
")); |
216 | 222 |
217 Document* document = toLocalFrame(webViewHelper->webViewImpl()->page()->
mainFrame())->document(); | 223 Document* document = toLocalFrame(webViewHelper->webViewImpl()->page()->
mainFrame())->document(); |
218 document->ensureStyleResolver().viewportStyleResolver()->collectViewport
Rules(ruleSet.get(), ViewportStyleResolver::UserAgentOrigin); | 224 document->ensureStyleResolver().viewportStyleResolver()->collectViewport
Rules(ruleSet.get(), ViewportStyleResolver::UserAgentOrigin); |
219 document->ensureStyleResolver().viewportStyleResolver()->resolve(); | 225 document->ensureStyleResolver().viewportStyleResolver()->resolve(); |
(...skipping 7995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8215 } | 8221 } |
8216 | 8222 |
8217 TEST_F(WebFrameTest, MaxFramesDetach) | 8223 TEST_F(WebFrameTest, MaxFramesDetach) |
8218 { | 8224 { |
8219 registerMockedHttpURLLoad("max-frames-detach.html"); | 8225 registerMockedHttpURLLoad("max-frames-detach.html"); |
8220 FrameTestHelpers::WebViewHelper webViewHelper; | 8226 FrameTestHelpers::WebViewHelper webViewHelper; |
8221 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max-
frames-detach.html", true); | 8227 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max-
frames-detach.html", true); |
8222 webViewImpl->mainFrameImpl()->collectGarbage(); | 8228 webViewImpl->mainFrameImpl()->collectGarbage(); |
8223 } | 8229 } |
8224 | 8230 |
| 8231 TEST_F(WebFrameTest, ImageDocumentLoadFinishTime) |
| 8232 { |
| 8233 // Loading an image resource directly generates an ImageDocument with |
| 8234 // the document loader feeding image data into the resource of a generated |
| 8235 // img tag. We expect the load finish time to be the same for the document |
| 8236 // and the image resource. |
| 8237 |
| 8238 registerMockedHttpURLLoadWithMimeType("white-1x1.png", "image/png"); |
| 8239 FrameTestHelpers::WebViewHelper webViewHelper; |
| 8240 webViewHelper.initializeAndLoad(m_baseURL + "white-1x1.png"); |
| 8241 WebView* webView = webViewHelper.webView(); |
| 8242 Document* document = toWebLocalFrameImpl(webView->mainFrame())->frame()->doc
ument(); |
| 8243 |
| 8244 EXPECT_TRUE(document); |
| 8245 EXPECT_TRUE(document->isImageDocument()); |
| 8246 |
| 8247 ImageDocument* imgDocument = toImageDocument(document); |
| 8248 ImageResource* resource = imgDocument->cachedImage(); |
| 8249 |
| 8250 EXPECT_TRUE(resource); |
| 8251 EXPECT_NE(0, resource->loadFinishTime()); |
| 8252 |
| 8253 DocumentLoader* loader = document->loader(); |
| 8254 |
| 8255 EXPECT_TRUE(loader); |
| 8256 EXPECT_EQ(loader->timing().responseEnd(), resource->loadFinishTime()); |
| 8257 } |
| 8258 |
8225 } // namespace blink | 8259 } // namespace blink |
OLD | NEW |