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

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

Issue 1380163006: setLoadFinishTime on ImageResource for ImageDocument. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unit test Created 5 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 7997 matching lines...) Expand 10 before | Expand all | Expand 10 after
8217 } 8223 }
8218 8224
8219 TEST_F(WebFrameTest, MaxFramesDetach) 8225 TEST_F(WebFrameTest, MaxFramesDetach)
8220 { 8226 {
8221 registerMockedHttpURLLoad("max-frames-detach.html"); 8227 registerMockedHttpURLLoad("max-frames-detach.html");
8222 FrameTestHelpers::WebViewHelper webViewHelper; 8228 FrameTestHelpers::WebViewHelper webViewHelper;
8223 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max- frames-detach.html", true); 8229 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max- frames-detach.html", true);
8224 webViewImpl->mainFrameImpl()->collectGarbage(); 8230 webViewImpl->mainFrameImpl()->collectGarbage();
8225 } 8231 }
8226 8232
8233 TEST_F(WebFrameTest, ImageDocumentLoadFinishTime)
8234 {
8235 // Loading an image resource directly generates an ImageDocument with
8236 // the document loader feeding image data into the resource of a generated
8237 // img tag. We expect the load finish time to be the same for the document
8238 // and the image resource.
8239
8240 registerMockedHttpURLLoadWithMimeType("white-1x1.png", "image/png");
8241 FrameTestHelpers::WebViewHelper webViewHelper;
8242 webViewHelper.initializeAndLoad(m_baseURL + "white-1x1.png");
8243 WebView* webView = webViewHelper.webView();
8244 Document* document = toWebLocalFrameImpl(webView->mainFrame())->frame()->doc ument();
8245
8246 EXPECT_TRUE(document);
8247 EXPECT_TRUE(document->isImageDocument());
8248
8249 ImageDocument* imgDocument = toImageDocument(document);
8250 ImageResource* resource = imgDocument->cachedImage();
8251
8252 EXPECT_TRUE(resource);
8253 EXPECT_NE(0, resource->loadFinishTime());
8254
8255 DocumentLoader* loader = document->loader();
8256
8257 EXPECT_TRUE(loader);
8258 EXPECT_EQ(loader->timing().responseEnd(), resource->loadFinishTime());
8259 }
8260
8227 } // namespace blink 8261 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698