Diff
Modified: trunk/Tools/ChangeLog (139233 => 139234)
--- trunk/Tools/ChangeLog 2013-01-09 21:44:08 UTC (rev 139233)
+++ trunk/Tools/ChangeLog 2013-01-09 21:44:18 UTC (rev 139234)
@@ -1,3 +1,59 @@
+2013-01-09 Jochen Eisinger <[email protected]>
+
+ [chromium] move resource load callback dumping to TestRunner library
+ https://bugs.webkit.org/show_bug.cgi?id=106449
+
+ Reviewed by Adam Barth.
+
+ * DumpRenderTree/chromium/DRTTestRunner.cpp:
+ (DRTTestRunner::DRTTestRunner):
+ (DRTTestRunner::reset):
+ * DumpRenderTree/chromium/DRTTestRunner.h:
+ (DRTTestRunner):
+ * DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h:
+ (WebKit):
+ (WebTestRunner::WebTestDelegate::makeURLErrorDescription):
+ * DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h:
+ (WebKit):
+ (WebTestProxyBase):
+ (WebTestRunner::WebTestProxy::assignIdentifierToRequest):
+ (WebTestRunner::WebTestProxy::willRequestResource):
+ (WebTestRunner::WebTestProxy::willSendRequest):
+ (WebTestRunner::WebTestProxy::didReceiveResponse):
+ (WebTestRunner::WebTestProxy::didFinishResourceLoad):
+ (WebTestRunner::WebTestProxy::didFailResourceLoad):
+ * DumpRenderTree/chromium/TestRunner/public/WebTestRunner.h:
+ (WebTestRunner::WebTestRunner::shouldDumpResourceLoadCallbacks):
+ (WebTestRunner::WebTestRunner::shouldDumpResourceRequestCallbacks):
+ (WebTestRunner::WebTestRunner::shouldDumpResourceResponseMIMETypes):
+ * DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp:
+ (WebTestRunner::TestRunner::TestRunner):
+ (WebTestRunner::TestRunner::reset):
+ (WebTestRunner::TestRunner::shouldDumpResourceLoadCallbacks):
+ (WebTestRunner::TestRunner::shouldDumpResourceRequestCallbacks):
+ (WebTestRunner::TestRunner::shouldDumpResourceResponseMIMETypes):
+ (WebTestRunner):
+ (WebTestRunner::TestRunner::dumpResourceLoadCallbacks):
+ (WebTestRunner::TestRunner::dumpResourceRequestCallbacks):
+ (WebTestRunner::TestRunner::dumpResourceResponseMIMETypes):
+ * DumpRenderTree/chromium/TestRunner/src/TestRunner.h:
+ (TestRunner):
+ * DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp:
+ (WebTestRunner::WebTestProxyBase::reset):
+ (WebTestRunner):
+ (WebTestRunner::WebTestProxyBase::assignIdentifierToRequest):
+ (WebTestRunner::WebTestProxyBase::willRequestResource):
+ (WebTestRunner::WebTestProxyBase::willSendRequest):
+ (WebTestRunner::WebTestProxyBase::didReceiveResponse):
+ (WebTestRunner::WebTestProxyBase::didFinishResourceLoad):
+ (WebTestRunner::WebTestProxyBase::didFailResourceLoad):
+ * DumpRenderTree/chromium/WebViewHost.cpp:
+ (WebViewHost::willSendRequest):
+ (WebViewHost::makeURLErrorDescription):
+ (WebViewHost::reset):
+ * DumpRenderTree/chromium/WebViewHost.h:
+ (WebViewHost):
+
2013-01-09 Dan Carney <[email protected]>
[chromium] move dumpcreateview methods to testrunner library
Modified: trunk/Tools/DumpRenderTree/chromium/DRTTestRunner.cpp (139233 => 139234)
--- trunk/Tools/DumpRenderTree/chromium/DRTTestRunner.cpp 2013-01-09 21:44:08 UTC (rev 139233)
+++ trunk/Tools/DumpRenderTree/chromium/DRTTestRunner.cpp 2013-01-09 21:44:18 UTC (rev 139234)
@@ -119,9 +119,6 @@
bindMethod("displayInvalidatedRegion", &DRTTestRunner::displayInvalidatedRegion);
bindMethod("dumpBackForwardList", &DRTTestRunner::dumpBackForwardList);
bindMethod("dumpProgressFinishedCallback", &DRTTestRunner::dumpProgressFinishedCallback);
- bindMethod("dumpResourceLoadCallbacks", &DRTTestRunner::dumpResourceLoadCallbacks);
- bindMethod("dumpResourceRequestCallbacks", &DRTTestRunner::dumpResourceRequestCallbacks);
- bindMethod("dumpResourceResponseMIMETypes", &DRTTestRunner::dumpResourceResponseMIMETypes);
bindMethod("dumpSelectionRect", &DRTTestRunner::dumpSelectionRect);
bindMethod("dumpStatusCallbacks", &DRTTestRunner::dumpWindowStatusChanges);
bindMethod("dumpPermissionClientCallbacks", &DRTTestRunner::dumpPermissionClientCallbacks);
@@ -251,24 +248,6 @@
result->setNull();
}
-void DRTTestRunner::dumpResourceLoadCallbacks(const CppArgumentList&, CppVariant* result)
-{
- m_dumpResourceLoadCallbacks = true;
- result->setNull();
-}
-
-void DRTTestRunner::dumpResourceRequestCallbacks(const CppArgumentList&, CppVariant* result)
-{
- m_dumpResourceRequestCallbacks = true;
- result->setNull();
-}
-
-void DRTTestRunner::dumpResourceResponseMIMETypes(const CppArgumentList&, CppVariant* result)
-{
- m_dumpResourceResponseMIMETypes = true;
- result->setNull();
-}
-
void DRTTestRunner::dumpWindowStatusChanges(const CppArgumentList&, CppVariant* result)
{
m_dumpWindowStatusChanges = true;
@@ -466,9 +445,6 @@
if (m_shell)
m_shell->webViewHost()->setDeviceScaleFactor(1);
m_dumpProgressFinishedCallback = false;
- m_dumpResourceLoadCallbacks = false;
- m_dumpResourceRequestCallbacks = false;
- m_dumpResourceResponseMIMETypes = false;
m_dumpBackForwardList = false;
m_dumpWindowStatusChanges = false;
m_dumpSelectionRect = false;
Modified: trunk/Tools/DumpRenderTree/chromium/DRTTestRunner.h (139233 => 139234)
--- trunk/Tools/DumpRenderTree/chromium/DRTTestRunner.h 2013-01-09 21:44:08 UTC (rev 139233)
+++ trunk/Tools/DumpRenderTree/chromium/DRTTestRunner.h 2013-01-09 21:44:18 UTC (rev 139234)
@@ -84,21 +84,6 @@
// representation of the back/forward list. It ignores all arguments.
void dumpBackForwardList(const CppArgumentList&, CppVariant*);
- // This function sets a flag that tells the test_shell to dump a descriptive
- // line for each resource load callback. It takes no arguments, and ignores
- // any that may be present.
- void dumpResourceLoadCallbacks(const CppArgumentList&, CppVariant*);
-
- // This function sets a flag that tells the test_shell to print a line of
- // descriptive text for each element that requested a resource. It takes no
- // arguments, and ignores any that may be present.
- void dumpResourceRequestCallbacks(const CppArgumentList&, CppVariant*);
-
- // This function sets a flag that tells the test_shell to dump the MIME type
- // for each resource that was loaded. It takes no arguments, and ignores any
- // that may be present.
- void dumpResourceResponseMIMETypes(const CppArgumentList&, CppVariant*);
-
// This function sets a flag that tells the test_shell to dump all calls
// to window.status().
// It takes no arguments, and ignores any that may be present.
@@ -243,11 +228,6 @@
bool shouldDumpProgressFinishedCallback() { return m_dumpProgressFinishedCallback; }
void setShouldDumpProgressFinishedCallback(bool value) { m_dumpProgressFinishedCallback = value; }
- bool shouldDumpResourceLoadCallbacks() {return m_dumpResourceLoadCallbacks; }
- void setShouldDumpResourceRequestCallbacks(bool value) { m_dumpResourceRequestCallbacks = value; }
- bool shouldDumpResourceRequestCallbacks() { return m_dumpResourceRequestCallbacks; }
- void setShouldDumpResourceResponseMIMETypes(bool value) { m_dumpResourceResponseMIMETypes = value; }
- bool shouldDumpResourceResponseMIMETypes() {return m_dumpResourceResponseMIMETypes; }
bool shouldDumpStatusCallbacks() { return m_dumpWindowStatusChanges; }
bool shouldDumpSelectionRect() { return m_dumpSelectionRect; }
bool shouldDumpBackForwardList() { return m_dumpBackForwardList; }
@@ -349,18 +329,6 @@
// finished callback.
bool m_dumpProgressFinishedCallback;
- // If true, the test_shell will output a descriptive line for each resource
- // load callback.
- bool m_dumpResourceLoadCallbacks;
-
- // If true, the test_shell will output a descriptive line for each resource
- // request callback.
- bool m_dumpResourceRequestCallbacks;
-
- // If true, the test_shell will output the MIME type for each resource that
- // was loaded.
- bool m_dumpResourceResponseMIMETypes;
-
// If true, the test_shell will produce a dump of the back forward list as
// well.
bool m_dumpBackForwardList;
Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h (139233 => 139234)
--- trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h 2013-01-09 21:44:08 UTC (rev 139233)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h 2013-01-09 21:44:18 UTC (rev 139234)
@@ -34,11 +34,13 @@
#include "Platform/chromium/public/WebString.h"
#include "Platform/chromium/public/WebURL.h"
#include "Platform/chromium/public/WebVector.h"
+#include <string>
namespace WebKit {
-struct WebContextMenuData;
class WebGamepads;
class WebIntentRequest;
+struct WebContextMenuData;
+struct WebURLError;
}
namespace WebTestRunner {
@@ -74,6 +76,7 @@
virtual void applyPreferences() { };
virtual void setCurrentWebIntentRequest(const WebKit::WebIntentRequest&) { };
virtual WebKit::WebIntentRequest* currentWebIntentRequest() { return 0; }
+ virtual std::string makeURLErrorDescription(const WebKit::WebURLError&) { return std::string(); }
};
}
Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h (139233 => 139234)
--- trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h 2013-01-09 21:44:08 UTC (rev 139233)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h 2013-01-09 21:44:18 UTC (rev 139234)
@@ -38,9 +38,12 @@
#include "WebKit/chromium/public/WebNavigationPolicy.h"
#include "WebKit/chromium/public/WebTextAffinity.h"
#include "WebKit/chromium/public/WebTextDirection.h"
+#include <map>
+#include <string>
namespace WebKit {
class WebAccessibilityObject;
+class WebCachedURLRequest;
class WebDragData;
class WebFrame;
class WebImage;
@@ -53,6 +56,7 @@
class WebString;
class WebURL;
class WebURLRequest;
+class WebURLResponse;
class WebView;
struct WebPoint;
struct WebSize;
@@ -71,6 +75,8 @@
void setInterfaces(WebTestInterfaces*);
void setDelegate(WebTestDelegate*);
+ void reset();
+
void setPaintRect(const WebKit::WebRect&);
WebKit::WebRect paintRect() const;
@@ -116,12 +122,19 @@
void didDisplayInsecureContent(WebKit::WebFrame*);
void didRunInsecureContent(WebKit::WebFrame*, const WebKit::WebSecurityOrigin&, const WebKit::WebURL& insecureURL);
void didDetectXSS(WebKit::WebFrame*, const WebKit::WebURL& insecureURL, bool didBlockEntirePage);
+ void assignIdentifierToRequest(WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLRequest&);
+ void willRequestResource(WebKit::WebFrame*, const WebKit::WebCachedURLRequest&);
+ void willSendRequest(WebKit::WebFrame*, unsigned identifier, WebKit::WebURLRequest&, const WebKit::WebURLResponse& redirectResponse);
+ void didReceiveResponse(WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLResponse&);
+ void didFinishResourceLoad(WebKit::WebFrame*, unsigned identifier);
+ void didFailResourceLoad(WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLError&);
private:
WebTestInterfaces* m_testInterfaces;
WebTestDelegate* m_delegate;
WebKit::WebRect m_paintRect;
+ std::map<unsigned, std::string> m_resourceIdentifierMap;
};
// Use this template to inject methods into your WebViewClient/WebFrameClient
@@ -329,6 +342,36 @@
WebTestProxyBase::didDetectXSS(frame, insecureURL, didBlockEntirePage);
Base::didDetectXSS(frame, insecureURL, didBlockEntirePage);
}
+ virtual void assignIdentifierToRequest(WebKit::WebFrame* frame, unsigned identifier, const WebKit::WebURLRequest& request)
+ {
+ WebTestProxyBase::assignIdentifierToRequest(frame, identifier, request);
+ Base::assignIdentifierToRequest(frame, identifier, request);
+ }
+ virtual void willRequestResource(WebKit::WebFrame* frame, const WebKit::WebCachedURLRequest& request)
+ {
+ WebTestProxyBase::willRequestResource(frame, request);
+ Base::willRequestResource(frame, request);
+ }
+ virtual void willSendRequest(WebKit::WebFrame* frame, unsigned identifier, WebKit::WebURLRequest& request, const WebKit::WebURLResponse& redirectResponse)
+ {
+ WebTestProxyBase::willSendRequest(frame, identifier, request, redirectResponse);
+ Base::willSendRequest(frame, identifier, request, redirectResponse);
+ }
+ virtual void didReceiveResponse(WebKit::WebFrame* frame, unsigned identifier, const WebKit::WebURLResponse& response)
+ {
+ WebTestProxyBase::didReceiveResponse(frame, identifier, response);
+ Base::didReceiveResponse(frame, identifier, response);
+ }
+ virtual void didFinishResourceLoad(WebKit::WebFrame* frame, unsigned identifier)
+ {
+ WebTestProxyBase::didFinishResourceLoad(frame, identifier);
+ Base::didFinishResourceLoad(frame, identifier);
+ }
+ virtual void didFailResourceLoad(WebKit::WebFrame* frame, unsigned identifier, const WebKit::WebURLError& error)
+ {
+ WebTestProxyBase::didFailResourceLoad(frame, identifier, error);
+ Base::didFailResourceLoad(frame, identifier, error);
+ }
};
}
Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestRunner.h (139233 => 139234)
--- trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestRunner.h 2013-01-09 21:44:08 UTC (rev 139233)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestRunner.h 2013-01-09 21:44:18 UTC (rev 139234)
@@ -58,6 +58,9 @@
virtual bool shouldDumpTitleChanges() const { return false; }
virtual bool shouldDumpCreateView() const { return false; }
virtual bool canOpenWindows() const { return false; }
+ virtual bool shouldDumpResourceLoadCallbacks() const { return false; }
+ virtual bool shouldDumpResourceRequestCallbacks() const { return false; }
+ virtual bool shouldDumpResourceResponseMIMETypes() const { return false; }
};
}
Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp (139233 => 139234)
--- trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp 2013-01-09 21:44:08 UTC (rev 139233)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp 2013-01-09 21:44:18 UTC (rev 139234)
@@ -144,6 +144,9 @@
bindMethod("dumpTitleChanges", &TestRunner::dumpTitleChanges);
bindMethod("dumpCreateView", &TestRunner::dumpCreateView);
bindMethod("setCanOpenWindows", &TestRunner::setCanOpenWindows);
+ bindMethod("dumpResourceLoadCallbacks", &TestRunner::dumpResourceLoadCallbacks);
+ bindMethod("dumpResourceRequestCallbacks", &TestRunner::dumpResourceRequestCallbacks);
+ bindMethod("dumpResourceResponseMIMETypes", &TestRunner::dumpResourceResponseMIMETypes);
// The following methods interact with the WebTestProxy.
bindMethod("sendWebIntentResponse", &TestRunner::sendWebIntentResponse);
@@ -220,6 +223,9 @@
m_dumpTitleChanges = false;
m_dumpCreateView = false;
m_canOpenWindows = false;
+ m_dumpResourceLoadCallbacks = false;
+ m_dumpResourceRequestCallbacks = false;
+ m_dumpResourceResponseMIMETypes = false;
m_globalFlag.set(false);
m_platformName.set("chromium");
@@ -312,6 +318,21 @@
return m_canOpenWindows;
}
+bool TestRunner::shouldDumpResourceLoadCallbacks() const
+{
+ return m_testIsRunning && m_dumpResourceLoadCallbacks;
+}
+
+bool TestRunner::shouldDumpResourceRequestCallbacks() const
+{
+ return m_testIsRunning && m_dumpResourceRequestCallbacks;
+}
+
+bool TestRunner::shouldDumpResourceResponseMIMETypes() const
+{
+ return m_testIsRunning && m_dumpResourceResponseMIMETypes;
+}
+
void TestRunner::setTabKeyCyclesThroughElements(const CppArgumentList& arguments, CppVariant* result)
{
if (arguments.size() > 0 && arguments[0].isBool())
@@ -1089,6 +1110,24 @@
result->setNull();
}
+void TestRunner::dumpResourceLoadCallbacks(const CppArgumentList&, CppVariant* result)
+{
+ m_dumpResourceLoadCallbacks = true;
+ result->setNull();
+}
+
+void TestRunner::dumpResourceRequestCallbacks(const CppArgumentList&, CppVariant* result)
+{
+ m_dumpResourceRequestCallbacks = true;
+ result->setNull();
+}
+
+void TestRunner::dumpResourceResponseMIMETypes(const CppArgumentList&, CppVariant* result)
+{
+ m_dumpResourceResponseMIMETypes = true;
+ result->setNull();
+}
+
void TestRunner::workerThreadCount(CppVariant* result)
{
result->set(static_cast<int>(WebWorkerInfo::dedicatedWorkerCount()));
Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.h (139233 => 139234)
--- trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.h 2013-01-09 21:44:08 UTC (rev 139233)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.h 2013-01-09 21:44:18 UTC (rev 139234)
@@ -76,6 +76,9 @@
virtual bool shouldDumpTitleChanges() const OVERRIDE;
virtual bool shouldDumpCreateView() const OVERRIDE;
virtual bool canOpenWindows() const OVERRIDE;
+ virtual bool shouldDumpResourceLoadCallbacks() const OVERRIDE;
+ virtual bool shouldDumpResourceRequestCallbacks() const OVERRIDE;
+ virtual bool shouldDumpResourceResponseMIMETypes() const OVERRIDE;
protected:
// FIXME: make these private once the move from DRTTestRunner to TestRunner
@@ -241,6 +244,21 @@
void setCanOpenWindows(const CppArgumentList&, CppVariant*);
+ // This function sets a flag that tells the test_shell to dump a descriptive
+ // line for each resource load callback. It takes no arguments, and ignores
+ // any that may be present.
+ void dumpResourceLoadCallbacks(const CppArgumentList&, CppVariant*);
+
+ // This function sets a flag that tells the test_shell to print a line of
+ // descriptive text for each element that requested a resource. It takes no
+ // arguments, and ignores any that may be present.
+ void dumpResourceRequestCallbacks(const CppArgumentList&, CppVariant*);
+
+ // This function sets a flag that tells the test_shell to dump the MIME type
+ // for each resource that was loaded. It takes no arguments, and ignores any
+ // that may be present.
+ void dumpResourceResponseMIMETypes(const CppArgumentList&, CppVariant*);
+
///////////////////////////////////////////////////////////////////////////
// Methods interacting with the WebTestProxy
@@ -331,6 +349,18 @@
// setCanOpenWindows().
bool m_canOpenWindows;
+ // If true, the test_shell will output a descriptive line for each resource
+ // load callback.
+ bool m_dumpResourceLoadCallbacks;
+
+ // If true, the test_shell will output a descriptive line for each resource
+ // request callback.
+ bool m_dumpResourceRequestCallbacks;
+
+ // If true, the test_shell will output the MIME type for each resource that
+ // was loaded.
+ bool m_dumpResourceResponseMIMETypes;
+
// WAV audio data is stored here.
WebKit::WebArrayBufferView m_audioData;
Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp (139233 => 139234)
--- trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp 2013-01-09 21:44:08 UTC (rev 139233)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp 2013-01-09 21:44:18 UTC (rev 139234)
@@ -34,6 +34,7 @@
#include "WebAccessibilityController.h"
#include "WebAccessibilityNotification.h"
#include "WebAccessibilityObject.h"
+#include "WebCachedURLRequest.h"
#include "WebElement.h"
#include "WebEventSender.h"
#include "WebFrame.h"
@@ -48,6 +49,7 @@
#include "WebView.h"
#include "platform/WebCString.h"
#include "platform/WebURLRequest.h"
+#include "platform/WebURLResponse.h"
#include <wtf/StringExtras.h>
using namespace WebKit;
@@ -141,6 +143,36 @@
delegate->printMessage(string("Frame with user gesture \"") + (isUserGesture ? "true" : "false") + "\"" + msg);
}
+// Used to write a platform neutral file:/// URL by taking the
+// filename and its directory. (e.g., converts
+// "file:///tmp/foo/bar.txt" to just "bar.txt").
+string descriptionSuitableForTestResult(const string& url)
+{
+ if (url.empty() || string::npos == url.find("file://"))
+ return url;
+
+ size_t pos = url.rfind('/');
+ if (pos == string::npos || !pos)
+ return "ERROR:" + url;
+ pos = url.rfind('/', pos - 1);
+ if (pos == string::npos)
+ return "ERROR:" + url;
+
+ return url.substr(pos + 1);
+}
+
+void printResponseDescription(WebTestDelegate* delegate, const WebURLResponse& response)
+{
+ if (response.isNull()) {
+ delegate->printMessage("(null)");
+ return;
+ }
+ string url = ""
+ char data[100];
+ snprintf(data, sizeof(data), "%d", response. httpStatusCode());
+ delegate->printMessage(string("<NSURLResponse ") + descriptionSuitableForTestResult(url) + ", http status code " + data + ">");
+}
+
string URLDescription(const GURL& url)
{
if (url.SchemeIs("file"))
@@ -170,6 +202,12 @@
m_delegate = delegate;
}
+void WebTestProxyBase::reset()
+{
+ m_paintRect = WebRect();
+ m_resourceIdentifierMap.clear();
+}
+
void WebTestProxyBase::setPaintRect(const WebRect& rect)
{
m_paintRect = rect;
@@ -609,4 +647,102 @@
m_delegate->printMessage("didDetectXSS\n");
}
+void WebTestProxyBase::assignIdentifierToRequest(WebFrame*, unsigned identifier, const WebKit::WebURLRequest& request)
+{
+ if (m_testInterfaces->testRunner() && m_testInterfaces->testRunner()->shouldDumpResourceLoadCallbacks()) {
+ ASSERT(m_resourceIdentifierMap.find(identifier) == m_resourceIdentifierMap.end());
+ m_resourceIdentifierMap[identifier] = descriptionSuitableForTestResult(request.url().spec());
+ }
}
+
+void WebTestProxyBase::willRequestResource(WebFrame* frame, const WebKit::WebCachedURLRequest& request)
+{
+ if (m_testInterfaces->testRunner() && m_testInterfaces->testRunner()->shouldDumpResourceRequestCallbacks()) {
+ printFrameDescription(m_delegate, frame);
+ WebElement element = request.initiatorElement();
+ if (!element.isNull()) {
+ m_delegate->printMessage(" - element with ");
+ if (element.hasAttribute("id"))
+ m_delegate->printMessage(string("id '") + element.getAttribute("id").utf8().data() + "'");
+ else
+ m_delegate->printMessage("no id");
+ } else
+ m_delegate->printMessage(string(" - ") + request.initiatorName().utf8().data());
+ m_delegate->printMessage(string(" requested '") + URLDescription(request.urlRequest().url()).c_str() + "'\n");
+ }
+}
+
+void WebTestProxyBase::willSendRequest(WebFrame*, unsigned identifier, WebKit::WebURLRequest& request, const WebKit::WebURLResponse& redirectResponse)
+{
+ // Need to use GURL for host() and SchemeIs()
+ GURL url = ""
+ string requestURL = url.possibly_invalid_spec();
+
+ GURL mainDocumentURL = request.firstPartyForCookies();
+
+ if (m_testInterfaces->testRunner() && m_testInterfaces->testRunner()->shouldDumpResourceLoadCallbacks()) {
+ if (m_resourceIdentifierMap.find(identifier) == m_resourceIdentifierMap.end())
+ m_delegate->printMessage("<unknown>");
+ else
+ m_delegate->printMessage(m_resourceIdentifierMap[identifier]);
+ m_delegate->printMessage(" - willSendRequest <NSURLRequest URL ");
+ m_delegate->printMessage(descriptionSuitableForTestResult(requestURL).c_str());
+ m_delegate->printMessage(", main document URL ");
+ m_delegate->printMessage(URLDescription(mainDocumentURL).c_str());
+ m_delegate->printMessage(", http method ");
+ m_delegate->printMessage(request.httpMethod().utf8().data());
+ m_delegate->printMessage("> redirectResponse ");
+ printResponseDescription(m_delegate, redirectResponse);
+ m_delegate->printMessage("\n");
+ }
+}
+
+void WebTestProxyBase::didReceiveResponse(WebFrame*, unsigned identifier, const WebKit::WebURLResponse& response)
+{
+ if (m_testInterfaces->testRunner() && m_testInterfaces->testRunner()->shouldDumpResourceLoadCallbacks()) {
+ if (m_resourceIdentifierMap.find(identifier) == m_resourceIdentifierMap.end())
+ m_delegate->printMessage("<unknown>");
+ else
+ m_delegate->printMessage(m_resourceIdentifierMap[identifier]);
+ m_delegate->printMessage(" - didReceiveResponse ");
+ printResponseDescription(m_delegate, response);
+ m_delegate->printMessage("\n");
+ }
+ if (m_testInterfaces->testRunner() && m_testInterfaces->testRunner()->shouldDumpResourceResponseMIMETypes()) {
+ GURL url = ""
+ WebString mimeType = response.mimeType();
+ m_delegate->printMessage(url.ExtractFileName());
+ m_delegate->printMessage(" has MIME type ");
+ // Simulate NSURLResponse's mapping of empty/unknown MIME types to application/octet-stream
+ m_delegate->printMessage(mimeType.isEmpty() ? "application/octet-stream" : mimeType.utf8().data());
+ m_delegate->printMessage("\n");
+ }
+}
+
+void WebTestProxyBase::didFinishResourceLoad(WebFrame*, unsigned identifier)
+{
+ if (m_testInterfaces->testRunner() && m_testInterfaces->testRunner()->shouldDumpResourceLoadCallbacks()) {
+ if (m_resourceIdentifierMap.find(identifier) == m_resourceIdentifierMap.end())
+ m_delegate->printMessage("<unknown>");
+ else
+ m_delegate->printMessage(m_resourceIdentifierMap[identifier]);
+ m_delegate->printMessage(" - didFinishLoading\n");
+ }
+ m_resourceIdentifierMap.erase(identifier);
+}
+
+void WebTestProxyBase::didFailResourceLoad(WebFrame*, unsigned identifier, const WebKit::WebURLError& error)
+{
+ if (m_testInterfaces->testRunner() && m_testInterfaces->testRunner()->shouldDumpResourceLoadCallbacks()) {
+ if (m_resourceIdentifierMap.find(identifier) == m_resourceIdentifierMap.end())
+ m_delegate->printMessage("<unknown>");
+ else
+ m_delegate->printMessage(m_resourceIdentifierMap[identifier]);
+ m_delegate->printMessage(" - didFailLoadingWithError: ");
+ m_delegate->printMessage(m_delegate->makeURLErrorDescription(error));
+ m_delegate->printMessage("\n");
+ }
+ m_resourceIdentifierMap.erase(identifier);
+}
+
+}
Modified: trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp (139233 => 139234)
--- trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp 2013-01-09 21:44:08 UTC (rev 139233)
+++ trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp 2013-01-09 21:44:18 UTC (rev 139234)
@@ -126,24 +126,6 @@
return filename;
}
-// Used to write a platform neutral file:/// URL by taking the
-// filename and its directory. (e.g., converts
-// "file:///tmp/foo/bar.txt" to just "bar.txt").
-static string descriptionSuitableForTestResult(const string& url)
-{
- if (url.empty() || string::npos == url.find("file://"))
- return url;
-
- size_t pos = url.rfind('/');
- if (pos == string::npos || !pos)
- return "ERROR:" + url;
- pos = url.rfind('/', pos - 1);
- if (pos == string::npos)
- return "ERROR:" + url;
-
- return url.substr(pos + 1);
-}
-
// Get a debugging string from a WebNavigationType.
static const char* webNavigationTypeToString(WebNavigationType type)
{
@@ -171,18 +153,6 @@
return url.possibly_invalid_spec();
}
-static void printResponseDescription(const WebURLResponse& response)
-{
- if (response.isNull()) {
- fputs("(null)", stdout);
- return;
- }
- string url = ""
- printf("<NSURLResponse %s, http status code %d>",
- descriptionSuitableForTestResult(url).c_str(),
- response.httpStatusCode());
-}
-
static void printNodeDescription(const WebNode& node, int exception)
{
if (exception) {
@@ -914,19 +884,6 @@
updateForCommittedLoad(frame, isNewNavigation);
}
-void WebViewHost::assignIdentifierToRequest(WebFrame*, unsigned identifier, const WebURLRequest& request)
-{
- if (!m_shell->shouldDumpResourceLoadCallbacks())
- return;
- ASSERT(!m_resourceIdentifierMap.contains(identifier));
- m_resourceIdentifierMap.set(identifier, descriptionSuitableForTestResult(request.url().spec()));
-}
-
-void WebViewHost::removeIdentifierForRequest(unsigned identifier)
-{
- m_resourceIdentifierMap.remove(identifier);
-}
-
static void blockRequest(WebURLRequest& request)
{
request.setURL(WebURL());
@@ -942,23 +899,6 @@
return host == "255.255.255.255";
}
-void WebViewHost::willRequestResource(WebKit::WebFrame* frame, const WebKit::WebCachedURLRequest& request)
-{
- if (m_shell->shouldDumpResourceRequestCallbacks()) {
- printFrameDescription(frame);
- WebElement element = request.initiatorElement();
- if (!element.isNull()) {
- printf(" - element with ");
- if (element.hasAttribute("id"))
- printf("id '%s'", element.getAttribute("id").utf8().data());
- else
- printf("no id");
- } else
- printf(" - %s", request.initiatorName().utf8().data());
- printf(" requested '%s'\n", URLDescription(request.urlRequest().url()).c_str());
- }
-}
-
void WebViewHost::willSendRequest(WebFrame* frame, unsigned identifier, WebURLRequest& request, const WebURLResponse& redirectResponse)
{
// Need to use GURL for host() and SchemeIs()
@@ -966,16 +906,6 @@
string requestURL = url.possibly_invalid_spec();
GURL mainDocumentURL = request.firstPartyForCookies();
- if (testRunner()->shouldDumpResourceLoadCallbacks()) {
- printResourceDescription(identifier);
- printf(" - willSendRequest <NSURLRequest URL %s, main document URL %s,"
- " http method %s> redirectResponse ",
- descriptionSuitableForTestResult(requestURL).c_str(),
- URLDescription(mainDocumentURL).c_str(),
- request.httpMethod().utf8().data());
- printResponseDescription(redirectResponse);
- fputs("\n", stdout);
- }
request.setExtraData(webkit_support::CreateWebURLRequestExtraData(frame->document().referrerPolicy()));
@@ -1009,44 +939,6 @@
request.setURL(webkit_support::RewriteLayoutTestsURL(request.url().spec()));
}
-void WebViewHost::didReceiveResponse(WebFrame*, unsigned identifier, const WebURLResponse& response)
-{
- if (m_shell->shouldDumpResourceLoadCallbacks()) {
- printResourceDescription(identifier);
- fputs(" - didReceiveResponse ", stdout);
- printResponseDescription(response);
- fputs("\n", stdout);
- }
- if (m_shell->shouldDumpResourceResponseMIMETypes()) {
- GURL url = ""
- WebString mimeType = response.mimeType();
- printf("%s has MIME type %s\n",
- url.ExtractFileName().c_str(),
- // Simulate NSURLResponse's mapping of empty/unknown MIME types to application/octet-stream
- mimeType.isEmpty() ? "application/octet-stream" : mimeType.utf8().data());
- }
-}
-
-void WebViewHost::didFinishResourceLoad(WebFrame*, unsigned identifier)
-{
- if (m_shell->shouldDumpResourceLoadCallbacks()) {
- printResourceDescription(identifier);
- fputs(" - didFinishLoading\n", stdout);
- }
- removeIdentifierForRequest(identifier);
-}
-
-void WebViewHost::didFailResourceLoad(WebFrame*, unsigned identifier, const WebURLError& error)
-{
- if (m_shell->shouldDumpResourceLoadCallbacks()) {
- printResourceDescription(identifier);
- fputs(" - didFailLoadingWithError: ", stdout);
- fputs(webkit_support::MakeURLErrorDescription(error).c_str(), stdout);
- fputs("\n", stdout);
- }
- removeIdentifierForRequest(identifier);
-}
-
void WebViewHost::openFileSystem(WebFrame* frame, WebFileSystem::Type type, long long size, bool create, WebFileSystemCallbacks* callbacks)
{
webkit_support::OpenFileSystem(frame, type, size, create, callbacks);
@@ -1161,6 +1053,11 @@
return &m_currentRequest;
}
+std::string WebViewHost::makeURLErrorDescription(const WebKit::WebURLError& error)
+{
+ return webkit_support::MakeURLErrorDescription(error);
+}
+
// Public functions -----------------------------------------------------------
WebViewHost::WebViewHost(TestShell* shell)
@@ -1255,7 +1152,6 @@
m_navigationController = adoptPtr(new TestNavigationController(this));
m_pendingExtraData.clear();
- m_resourceIdentifierMap.clear();
m_clearHeaders.clear();
m_editCommandName.clear();
m_editCommandValue.clear();
@@ -1272,7 +1168,7 @@
m_windowRect = WebRect();
// m_proxy is not set when reset() is invoked from the constructor.
if (m_proxy)
- proxy()->setPaintRect(WebRect());
+ proxy()->reset();
if (m_webWidget) {
webView()->mainFrame()->setName(WebString());
@@ -1475,12 +1371,6 @@
printf("frame \"%s\"", name8.c_str());
}
-void WebViewHost::printResourceDescription(unsigned identifier)
-{
- ResourceMap::iterator it = m_resourceIdentifierMap.find(identifier);
- printf("%s", it != m_resourceIdentifierMap.end() ? it->value.c_str() : "<unknown>");
-}
-
void WebViewHost::setPendingExtraData(PassOwnPtr<TestShellExtraData> extraData)
{
m_pendingExtraData = extraData;
Modified: trunk/Tools/DumpRenderTree/chromium/WebViewHost.h (139233 => 139234)
--- trunk/Tools/DumpRenderTree/chromium/WebViewHost.h 2013-01-09 21:44:08 UTC (rev 139233)
+++ trunk/Tools/DumpRenderTree/chromium/WebViewHost.h 2013-01-09 21:44:18 UTC (rev 139234)
@@ -148,6 +148,7 @@
virtual void applyPreferences() OVERRIDE;
virtual void setCurrentWebIntentRequest(const WebKit::WebIntentRequest&) OVERRIDE;
virtual WebKit::WebIntentRequest* currentWebIntentRequest() OVERRIDE;
+ virtual std::string makeURLErrorDescription(const WebKit::WebURLError&) OVERRIDE;
// NavigationHost
virtual bool navigate(const TestNavigationEntry&, bool reload);
@@ -254,13 +255,7 @@
virtual void didFailLoad(WebKit::WebFrame*, const WebKit::WebURLError&);
virtual void didFinishLoad(WebKit::WebFrame*);
virtual void didNavigateWithinPage(WebKit::WebFrame*, bool isNewNavigation);
- virtual void assignIdentifierToRequest(WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLRequest&);
- virtual void removeIdentifierForRequest(unsigned identifier);
- virtual void willRequestResource(WebKit::WebFrame*, const WebKit::WebCachedURLRequest&);
virtual void willSendRequest(WebKit::WebFrame*, unsigned identifier, WebKit::WebURLRequest&, const WebKit::WebURLResponse&);
- virtual void didReceiveResponse(WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLResponse&);
- virtual void didFinishResourceLoad(WebKit::WebFrame*, unsigned identifier);
- virtual void didFailResourceLoad(WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLError&);
virtual void openFileSystem(WebKit::WebFrame*, WebKit::WebFileSystem::Type, long long size, bool create, WebKit::WebFileSystemCallbacks*);
virtual void deleteFileSystem(WebKit::WebFrame*, WebKit::WebFileSystem::Type, WebKit::WebFileSystemCallbacks*);
virtual bool willCheckAndDispatchMessageEvent(
@@ -363,11 +358,6 @@
OwnPtr<TestShellExtraData> m_pendingExtraData;
- // Maps resource identifiers to a descriptive string.
- typedef HashMap<unsigned, std::string> ResourceMap;
- ResourceMap m_resourceIdentifierMap;
- void printResourceDescription(unsigned identifier);
-
WebKit::WebCursorInfo m_currentCursor;
bool m_hasWindow;