diff options
Diffstat (limited to 'WebKitTools/DumpRenderTree')
35 files changed, 457 insertions, 124 deletions
diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/LayoutTestController.cpp index d98164b..52b539c 100644 --- a/WebKitTools/DumpRenderTree/LayoutTestController.cpp +++ b/WebKitTools/DumpRenderTree/LayoutTestController.cpp @@ -41,7 +41,8 @@ #include <wtf/RefPtr.h> LayoutTestController::LayoutTestController(const std::string& testPathOrURL, const std::string& expectedPixelHash) - : m_dumpAsPDF(false) + : m_dumpApplicationCacheDelegateCallbacks(false) + , m_dumpAsPDF(false) , m_dumpAsText(false) , m_dumpBackForwardList(false) , m_dumpChildFrameScrollPositions(false) @@ -92,6 +93,13 @@ PassRefPtr<LayoutTestController> LayoutTestController::create(const std::string& // Static Functions +static JSValueRef dumpApplicationCacheDelegateCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + controller->setDumpApplicationCacheDelegateCallbacks(true); + return JSValueMakeUndefined(context); +} + static JSValueRef dumpAsPDFCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); @@ -310,6 +318,15 @@ static JSValueRef callShouldCloseOnWebViewCallback(JSContextRef context, JSObjec return JSValueMakeBoolean(context, controller->callShouldCloseOnWebView()); } +static JSValueRef clearAllApplicationCachesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + // Has mac implementation + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + controller->clearAllApplicationCaches(); + + return JSValueMakeUndefined(context); +} + static JSValueRef clearAllDatabasesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation @@ -842,7 +859,21 @@ static JSValueRef setAppCacheMaximumSizeCallback(JSContextRef context, JSObjectR controller->setAppCacheMaximumSize(static_cast<unsigned long long>(size)); return JSValueMakeUndefined(context); +} + +static JSValueRef setApplicationCacheOriginQuotaCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + // Has mac implementation + if (argumentCount < 1) + return JSValueMakeUndefined(context); + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + + double size = JSValueToNumber(context, arguments[0], NULL); + if (!isnan(size)) + controller->setApplicationCacheOriginQuota(static_cast<unsigned long long>(size)); + + return JSValueMakeUndefined(context); } static JSValueRef setAuthenticationPasswordCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) @@ -1019,6 +1050,20 @@ static JSValueRef setMockGeolocationErrorCallback(JSContextRef context, JSObject return JSValueMakeUndefined(context); } +static JSValueRef setMockSpeechInputResultCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + if (argumentCount < 1) + return JSValueMakeUndefined(context); + + JSRetainPtr<JSStringRef> result(Adopt, JSValueToStringCopy(context, arguments[0], exception)); + ASSERT(!*exception); + + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + controller->setMockSpeechInputResult(result.get()); + + return JSValueMakeUndefined(context); +} + static JSValueRef setNewWindowsCopyBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation @@ -1763,6 +1808,7 @@ JSStaticFunction* LayoutTestController::staticFunctions() { "apiTestNewWindowDataLoadBaseURL", apiTestNewWindowDataLoadBaseURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "apiTestGoToCurrentBackForwardItem", apiTestGoToCurrentBackForwardItemCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "callShouldCloseOnWebView", callShouldCloseOnWebViewCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "clearAllApplicationCaches", clearAllApplicationCachesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "clearAllDatabases", clearAllDatabasesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "clearBackForwardList", clearBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "clearPersistentUserStyleSheet", clearPersistentUserStyleSheetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, @@ -1772,6 +1818,7 @@ JSStaticFunction* LayoutTestController::staticFunctions() { "disableImageLoading", disableImageLoadingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "dispatchPendingLoadRequests", dispatchPendingLoadRequestsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "display", displayCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "dumpApplicationCacheDelegateCallbacks", dumpApplicationCacheDelegateCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "dumpAsText", dumpAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "dumpBackForwardList", dumpBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "dumpChildFrameScrollPositions", dumpChildFrameScrollPositionsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, @@ -1826,7 +1873,8 @@ JSStaticFunction* LayoutTestController::staticFunctions() { "setAllowUniversalAccessFromFileURLs", setAllowUniversalAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setAllowFileAccessFromFileURLs", setAllowFileAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setAlwaysAcceptCookies", setAlwaysAcceptCookiesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, - { "setAppCacheMaximumSize", setAppCacheMaximumSizeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "setAppCacheMaximumSize", setAppCacheMaximumSizeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "setApplicationCacheOriginQuota", setApplicationCacheOriginQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setAuthenticationPassword", setAuthenticationPasswordCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setAuthenticationUsername", setAuthenticationUsernameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setAuthorAndUserStylesEnabled", setAuthorAndUserStylesEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, @@ -1848,6 +1896,7 @@ JSStaticFunction* LayoutTestController::staticFunctions() { "setMockDeviceOrientation", setMockDeviceOrientationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setMockGeolocationError", setMockGeolocationErrorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setMockGeolocationPosition", setMockGeolocationPositionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "setMockSpeechInputResult", setMockSpeechInputResultCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setNewWindowsCopyBackForwardList", setNewWindowsCopyBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setPOSIXLocale", setPOSIXLocaleCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setPersistentUserStyleSheetLocation", setPersistentUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, @@ -1941,7 +1990,7 @@ void LayoutTestController::waitToDumpWatchdogTimerFired() notifyDone(); } -void LayoutTestController::setGeolocationPermission(bool allow) +void LayoutTestController::setGeolocationPermissionCommon(bool allow) { m_isGeolocationPermissionSet = true; m_geolocationPermission = allow; diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.h b/WebKitTools/DumpRenderTree/LayoutTestController.h index 39cc3fb..f76870b 100644 --- a/WebKitTools/DumpRenderTree/LayoutTestController.h +++ b/WebKitTools/DumpRenderTree/LayoutTestController.h @@ -45,6 +45,7 @@ public: void makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception); void addDisallowedURL(JSStringRef url); + void clearAllApplicationCaches(); void clearAllDatabases(); void clearBackForwardList(); void clearPersistentUserStyleSheet(); @@ -79,6 +80,7 @@ public: void setAllowUniversalAccessFromFileURLs(bool); void setAllowFileAccessFromFileURLs(bool); void setAppCacheMaximumSize(unsigned long long quota); + void setApplicationCacheOriginQuota(unsigned long long quota); void setAuthorAndUserStylesEnabled(bool); void setCacheModel(int); void setCustomPolicyDelegate(bool setDelegate, bool permissive); @@ -91,6 +93,7 @@ public: void setMockDeviceOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma); void setMockGeolocationError(int code, JSStringRef message); void setMockGeolocationPosition(double latitude, double longitude, double accuracy); + void setMockSpeechInputResult(JSStringRef result); void setPersistentUserStyleSheetLocation(JSStringRef path); void setPluginsEnabled(bool flag); void setPopupBlockingEnabled(bool flag); @@ -126,6 +129,9 @@ public: bool generatePixelResults() const { return m_generatePixelResults; } void setGeneratePixelResults(bool generatePixelResults) { m_generatePixelResults = generatePixelResults; } + bool dumpApplicationCacheDelegateCallbacks() const { return m_dumpApplicationCacheDelegateCallbacks; } + void setDumpApplicationCacheDelegateCallbacks(bool dumpCallbacks) { m_dumpApplicationCacheDelegateCallbacks = dumpCallbacks; } + bool dumpBackForwardList() const { return m_dumpBackForwardList; } void setDumpBackForwardList(bool dumpBackForwardList) { m_dumpBackForwardList = dumpBackForwardList; } @@ -287,6 +293,9 @@ public: private: LayoutTestController(const std::string& testPathOrURL, const std::string& expectedPixelHash); + void setGeolocationPermissionCommon(bool allow); + + bool m_dumpApplicationCacheDelegateCallbacks; bool m_dumpAsPDF; bool m_dumpAsText; bool m_dumpBackForwardList; diff --git a/WebKitTools/DumpRenderTree/chromium/CppVariant.h b/WebKitTools/DumpRenderTree/chromium/CppVariant.h index d34a163..3aa5abb 100644 --- a/WebKitTools/DumpRenderTree/chromium/CppVariant.h +++ b/WebKitTools/DumpRenderTree/chromium/CppVariant.h @@ -42,8 +42,8 @@ #ifndef CppVariant_h #define CppVariant_h -#include "base/basictypes.h" #include "public/WebBindings.h" +#include "webkit/support/webkit_support.h" #include <string> #include <wtf/Vector.h> diff --git a/WebKitTools/DumpRenderTree/chromium/DRTDevToolsAgent.cpp b/WebKitTools/DumpRenderTree/chromium/DRTDevToolsAgent.cpp index 0ff77a0..b05fe21 100644 --- a/WebKitTools/DumpRenderTree/chromium/DRTDevToolsAgent.cpp +++ b/WebKitTools/DumpRenderTree/chromium/DRTDevToolsAgent.cpp @@ -36,7 +36,6 @@ #include "public/WebCString.h" #include "public/WebDevToolsAgent.h" -#include "public/WebDevToolsMessageData.h" #include "public/WebString.h" #include "public/WebView.h" #include "webkit/support/webkit_support.h" @@ -55,12 +54,17 @@ DRTDevToolsAgent::DRTDevToolsAgent() WebDevToolsAgent::setMessageLoopDispatchHandler(&DRTDevToolsAgent::dispatchMessageLoop); } +void DRTDevToolsAgent::reset() +{ + m_callMethodFactory.RevokeAll(); +} + void DRTDevToolsAgent::setWebView(WebView* webView) { m_webView = webView; } -void DRTDevToolsAgent::sendMessageToFrontend(const WebDevToolsMessageData& data) +void DRTDevToolsAgent::sendMessageToInspectorFrontend(const WebKit::WebString& data) { if (m_drtDevToolsClient) m_drtDevToolsClient->asyncCall(DRTDevToolsCallArgs(data)); @@ -100,7 +104,7 @@ void DRTDevToolsAgent::call(const DRTDevToolsCallArgs &args) { WebDevToolsAgent* agent = webDevToolsAgent(); if (agent) - agent->dispatchMessageFromFrontend(args.m_data); + agent->dispatchOnInspectorBackend(args.m_data); if (DRTDevToolsCallArgs::callsCount() == 1 && m_drtDevToolsClient) m_drtDevToolsClient->allMessagesProcessed(); } @@ -121,7 +125,7 @@ void DRTDevToolsAgent::attach(DRTDevToolsClient* client) agent->attach(); } -void DRTDevToolsAgent::detach(DRTDevToolsClient* client) +void DRTDevToolsAgent::detach() { ASSERT(m_drtDevToolsClient); WebDevToolsAgent* agent = webDevToolsAgent(); @@ -130,6 +134,12 @@ void DRTDevToolsAgent::detach(DRTDevToolsClient* client) m_drtDevToolsClient = 0; } +void DRTDevToolsAgent::frontendLoaded() { + WebDevToolsAgent* agent = webDevToolsAgent(); + if (agent) + agent->frontendLoaded(); +} + bool DRTDevToolsAgent::setTimelineProfilingEnabled(bool enabled) { WebDevToolsAgent* agent = webDevToolsAgent(); diff --git a/WebKitTools/DumpRenderTree/chromium/DRTDevToolsAgent.h b/WebKitTools/DumpRenderTree/chromium/DRTDevToolsAgent.h index 37fc119..df52866 100644 --- a/WebKitTools/DumpRenderTree/chromium/DRTDevToolsAgent.h +++ b/WebKitTools/DumpRenderTree/chromium/DRTDevToolsAgent.h @@ -52,11 +52,12 @@ class DRTDevToolsAgent : public WebKit::WebDevToolsAgentClient public: DRTDevToolsAgent(); virtual ~DRTDevToolsAgent() {} + void reset(); void setWebView(WebKit::WebView*); // WebDevToolsAgentClient implementation. - virtual void sendMessageToFrontend(const WebKit::WebDevToolsMessageData&); + virtual void sendMessageToInspectorFrontend(const WebKit::WebString&); virtual int hostIdentifier() { return m_routingID; } virtual void forceRepaint(); virtual void runtimeFeatureStateChanged(const WebKit::WebString& feature, bool enabled); @@ -67,7 +68,8 @@ public: void asyncCall(const DRTDevToolsCallArgs&); void attach(DRTDevToolsClient*); - void detach(DRTDevToolsClient*); + void detach(); + void frontendLoaded(); bool evaluateInWebInspector(long callID, const std::string& script); bool setTimelineProfilingEnabled(bool enable); diff --git a/WebKitTools/DumpRenderTree/chromium/DRTDevToolsCallArgs.h b/WebKitTools/DumpRenderTree/chromium/DRTDevToolsCallArgs.h index e4a3d48..b1ac2ec 100644 --- a/WebKitTools/DumpRenderTree/chromium/DRTDevToolsCallArgs.h +++ b/WebKitTools/DumpRenderTree/chromium/DRTDevToolsCallArgs.h @@ -31,22 +31,15 @@ #ifndef DRTDevToolsCallArgs_h #define DRTDevToolsCallArgs_h -#include "public/WebDevToolsMessageData.h" #include "public/WebString.h" #include <wtf/Assertions.h> class DRTDevToolsCallArgs { public: - DRTDevToolsCallArgs(const WebKit::WebDevToolsMessageData& data) + DRTDevToolsCallArgs(const WebKit::WebString& data) : m_data(data) { ++m_callsCount; - - // The same behaviour as we have in case of IPC. - for (size_t i = 0; i < m_data.arguments.size(); ++i) { - if (m_data.arguments[i].isNull()) - m_data.arguments[i] = WebKit::WebString::fromUTF8(""); - } } DRTDevToolsCallArgs(const DRTDevToolsCallArgs& args) @@ -63,7 +56,7 @@ public: static int callsCount() { return m_callsCount; } - WebKit::WebDevToolsMessageData m_data; + WebKit::WebString m_data; private: static int m_callsCount; diff --git a/WebKitTools/DumpRenderTree/chromium/DRTDevToolsClient.cpp b/WebKitTools/DumpRenderTree/chromium/DRTDevToolsClient.cpp index e14f008..42f3724 100644 --- a/WebKitTools/DumpRenderTree/chromium/DRTDevToolsClient.cpp +++ b/WebKitTools/DumpRenderTree/chromium/DRTDevToolsClient.cpp @@ -61,10 +61,20 @@ DRTDevToolsClient::~DRTDevToolsClient() // m_drtDevToolsAgent and we should clean pending requests a bit earlier. m_callMethodFactory.RevokeAll(); if (m_drtDevToolsAgent) - m_drtDevToolsAgent->detach(this); + m_drtDevToolsAgent->detach(); } -void DRTDevToolsClient::sendMessageToAgent(const WebDevToolsMessageData& data) +void DRTDevToolsClient::reset() +{ + m_callMethodFactory.RevokeAll(); +} + +void DRTDevToolsClient::sendFrontendLoaded() { + if (m_drtDevToolsAgent) + m_drtDevToolsAgent->frontendLoaded(); +} + +void DRTDevToolsClient::sendMessageToBackend(const WebString& data) { if (m_drtDevToolsAgent) m_drtDevToolsAgent->asyncCall(DRTDevToolsCallArgs(data)); @@ -103,7 +113,7 @@ void DRTDevToolsClient::asyncCall(const DRTDevToolsCallArgs& args) void DRTDevToolsClient::call(const DRTDevToolsCallArgs& args) { - m_webDevToolsFrontend->dispatchMessageFromAgent(args.m_data); + m_webDevToolsFrontend->dispatchOnInspectorFrontend(args.m_data); if (DRTDevToolsCallArgs::callsCount() == 1) allMessagesProcessed(); } diff --git a/WebKitTools/DumpRenderTree/chromium/DRTDevToolsClient.h b/WebKitTools/DumpRenderTree/chromium/DRTDevToolsClient.h index f08644b..37b1e9d 100644 --- a/WebKitTools/DumpRenderTree/chromium/DRTDevToolsClient.h +++ b/WebKitTools/DumpRenderTree/chromium/DRTDevToolsClient.h @@ -53,9 +53,11 @@ class DRTDevToolsClient : public WebKit::WebDevToolsFrontendClient public: DRTDevToolsClient(DRTDevToolsAgent*, WebKit::WebView*); virtual ~DRTDevToolsClient(); + void reset(); // WebDevToolsFrontendClient implementation - virtual void sendMessageToAgent(const WebKit::WebDevToolsMessageData&); + virtual void sendFrontendLoaded(); + virtual void sendMessageToBackend(const WebKit::WebString&); virtual void sendDebuggerCommandToAgent(const WebKit::WebString& command); virtual void activateWindow(); diff --git a/WebKitTools/DumpRenderTree/chromium/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/chromium/DumpRenderTree.cpp index 2885cf6..726e412 100644 --- a/WebKitTools/DumpRenderTree/chromium/DumpRenderTree.cpp +++ b/WebKitTools/DumpRenderTree/chromium/DumpRenderTree.cpp @@ -36,8 +36,6 @@ using namespace std; -void platformInit(); - static const char optionComplexText[] = "--complex-text"; static const char optionDumpAllPixels[] = "--dump-all-pixels"; static const char optionNotree[] = "--notree"; @@ -48,6 +46,7 @@ static const char optionTree[] = "--tree"; static const char optionPixelTestsWithName[] = "--pixel-tests="; static const char optionTestShell[] = "--test-shell"; static const char optionAllowExternalPages[] = "--allow-external-pages"; +static const char optionStartupDialog[] = "--testshell-startup-dialog"; static void runTest(TestShell& shell, TestParams& params, const string& testName, bool testShellMode) { @@ -91,6 +90,7 @@ int main(int argc, char* argv[]) bool serverMode = false; bool testShellMode = false; bool allowExternalPages = false; + bool startupDialog = false; for (int i = 1; i < argc; ++i) { string argument(argv[i]); if (argument == "-") @@ -107,6 +107,8 @@ int main(int argc, char* argv[]) serverMode = true; } else if (argument == optionAllowExternalPages) allowExternalPages = true; + else if (argument == optionStartupDialog) + startupDialog = true; else if (argument.size() && argument[0] == '-') fprintf(stderr, "Unknown option: %s\n", argv[i]); else @@ -117,6 +119,9 @@ int main(int argc, char* argv[]) return EXIT_FAILURE; } + if (startupDialog) + openStartupDialog(); + { // Explicit scope for the TestShell instance. TestShell shell(testShellMode); shell.setAllowExternalPages(allowExternalPages); diff --git a/WebKitTools/DumpRenderTree/chromium/EventSender.cpp b/WebKitTools/DumpRenderTree/chromium/EventSender.cpp index 4e84c96..bb3c07f 100644 --- a/WebKitTools/DumpRenderTree/chromium/EventSender.cpp +++ b/WebKitTools/DumpRenderTree/chromium/EventSender.cpp @@ -45,7 +45,6 @@ #include "TestShell.h" #include "base/keyboard_codes.h" -#include "base/time.h" #include "public/WebDragData.h" #include "public/WebDragOperation.h" #include "public/WebPoint.h" @@ -124,7 +123,7 @@ static uint32 timeOffsetMs = 0; static double getCurrentEventTimeSec() { - return (TimeTicks::Now().ToInternalValue() / Time::kMicrosecondsPerMillisecond + timeOffsetMs) / 1000.0; + return (webkit_support::GetCurrentTimeInMillisecond() + timeOffsetMs) / 1000.0; } static void advanceEventTime(int32_t deltaMs) @@ -324,6 +323,7 @@ void EventSender::reset() timeOffsetMs = 0; touchModifiers = 0; touchPoints.clear(); + m_methodFactory.RevokeAll(); } WebView* EventSender::webview() diff --git a/WebKitTools/DumpRenderTree/chromium/ImageDiff.cpp b/WebKitTools/DumpRenderTree/chromium/ImageDiff.cpp index 27e9946..d1adc3d 100644 --- a/WebKitTools/DumpRenderTree/chromium/ImageDiff.cpp +++ b/WebKitTools/DumpRenderTree/chromium/ImageDiff.cpp @@ -321,12 +321,12 @@ static bool writeFile(const char* outFile, const unsigned char* data, size_t dat { FILE* file = fopen(outFile, "wb"); if (!file) { - fprintf(stderr, "ImageDiff: Unable to create file \"%s\"\n", file); + fprintf(stderr, "ImageDiff: Unable to create file \"%s\"\n", outFile); return false; } if (dataSize != fwrite(data, 1, dataSize, file)) { fclose(file); - fprintf(stderr, "ImageDiff: Unable to write data to file \"%s\"\n", file); + fprintf(stderr, "ImageDiff: Unable to write data to file \"%s\"\n", outFile); return false; } fclose(file); diff --git a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp index cd27c18..e82a65e 100644 --- a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp +++ b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp @@ -47,6 +47,7 @@ #include "public/WebSecurityPolicy.h" #include "public/WebSettings.h" #include "public/WebSize.h" +#include "public/WebSpeechInputControllerMock.h" #include "public/WebURL.h" #include "public/WebView.h" #include "webkit/support/webkit_support.h" @@ -154,6 +155,8 @@ LayoutTestController::LayoutTestController(TestShell* shell) bindMethod("setCallCloseOnWebViews", &LayoutTestController::setCallCloseOnWebViews); bindMethod("setPrivateBrowsingEnabled", &LayoutTestController::setPrivateBrowsingEnabled); bindMethod("setUseDashboardCompatibilityMode", &LayoutTestController::setUseDashboardCompatibilityMode); + bindMethod("clearAllApplicationCaches", &LayoutTestController::clearAllApplicationCaches); + bindMethod("setApplicationCacheOriginQuota", &LayoutTestController::setApplicationCacheOriginQuota); bindMethod("setJavaScriptCanAccessClipboard", &LayoutTestController::setJavaScriptCanAccessClipboard); bindMethod("setXSSAuditorEnabled", &LayoutTestController::setXSSAuditorEnabled); @@ -172,6 +175,7 @@ LayoutTestController::LayoutTestController(TestShell* shell) bindMethod("setMockGeolocationPosition", &LayoutTestController::setMockGeolocationPosition); bindMethod("setMockGeolocationError", &LayoutTestController::setMockGeolocationError); bindMethod("abortModal", &LayoutTestController::abortModal); + bindMethod("setMockSpeechInputResult", &LayoutTestController::setMockSpeechInputResult); // The fallback method is called when an unknown method is invoked. bindFallbackMethod(&LayoutTestController::fallbackMethod); @@ -510,6 +514,7 @@ void LayoutTestController::reset() else m_closeRemainingWindows = true; m_workQueue.reset(); + m_timeoutFactory.RevokeAll(); } void LayoutTestController::locationChangeDone() @@ -648,6 +653,18 @@ void LayoutTestController::setUseDashboardCompatibilityMode(const CppArgumentLis result->setNull(); } +void LayoutTestController::clearAllApplicationCaches(const CppArgumentList&, CppVariant* result) +{ + // FIXME: implement to support Application Cache Quotas. + result->setNull(); +} + +void LayoutTestController::setApplicationCacheOriginQuota(const CppArgumentList&, CppVariant* result) +{ + // FIXME: implement to support Application Cache Quotas. + result->setNull(); +} + void LayoutTestController::setScrollbarPolicy(const CppArgumentList&, CppVariant* result) { // FIXME: implement. @@ -1355,3 +1372,19 @@ void LayoutTestController::abortModal(const CppArgumentList& arguments, CppVaria { result->setNull(); } + +void LayoutTestController::setMockSpeechInputResult(const CppArgumentList& arguments, CppVariant* result) +{ + result->setNull(); + if (arguments.size() < 1 || !arguments[0].isString()) + return; + + m_speechInputControllerMock->setMockRecognitionResult(cppVariantToWebString(arguments[0])); +} + +WebKit::WebSpeechInputController* LayoutTestController::speechInputController(WebKit::WebSpeechInputListener* listener) +{ + if (!m_speechInputControllerMock.get()) + m_speechInputControllerMock.set(WebSpeechInputControllerMock::create(listener)); + return m_speechInputControllerMock.get(); +} diff --git a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h index 6748352..fb91544 100644 --- a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h +++ b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h @@ -46,6 +46,13 @@ #include "public/WebString.h" #include "public/WebURL.h" #include <wtf/Deque.h> +#include <wtf/OwnPtr.h> + +namespace WebKit { +class WebSpeechInputController; +class WebSpeechInputControllerMock; +class WebSpeechInputListener; +} class TestShell; @@ -250,6 +257,11 @@ public: void addOriginAccessWhitelistEntry(const CppArgumentList&, CppVariant*); void removeOriginAccessWhitelistEntry(const CppArgumentList&, CppVariant*); + // Clears all Application Caches. + void clearAllApplicationCaches(const CppArgumentList&, CppVariant*); + // Sets the Application Quota for the localhost origin. + void setApplicationCacheOriginQuota(const CppArgumentList&, CppVariant*); + // Clears all databases. void clearAllDatabases(const CppArgumentList&, CppVariant*); // Sets the default quota for all origins @@ -293,10 +305,14 @@ public: // Empty stub method to keep parity with object model exposed by global LayoutTestController. void abortModal(const CppArgumentList&, CppVariant*); + // Speech input related functions. + void setMockSpeechInputResult(const CppArgumentList&, CppVariant*); + public: // The following methods are not exposed to JavaScript. void setWorkQueueFrozen(bool frozen) { m_workQueue.setFrozen(frozen); } + WebKit::WebSpeechInputController* speechInputController(WebKit::WebSpeechInputListener*); bool shouldDumpAsText() { return m_dumpAsText; } bool shouldDumpEditingCallbacks() { return m_dumpEditingCallbacks; } bool shouldDumpFrameLoadCallbacks() { return m_dumpFrameLoadCallbacks; } @@ -467,6 +483,8 @@ private: CppVariant m_webHistoryItemCount; WebKit::WebURL m_userStyleSheetLocation; + + OwnPtr<WebKit::WebSpeechInputControllerMock> m_speechInputControllerMock; }; #endif // LayoutTestController_h diff --git a/WebKitTools/DumpRenderTree/chromium/MockSpellCheck.h b/WebKitTools/DumpRenderTree/chromium/MockSpellCheck.h index 8c2ba92..c680340 100644 --- a/WebKitTools/DumpRenderTree/chromium/MockSpellCheck.h +++ b/WebKitTools/DumpRenderTree/chromium/MockSpellCheck.h @@ -73,7 +73,7 @@ private: bool initializeIfNeeded(); // A table that consists of misspelled words. - HashMap<WebCore::String, bool> m_misspelledWords; + HashMap<WTF::String, bool> m_misspelledWords; // A flag representing whether or not this object is initialized. bool m_initialized; diff --git a/WebKitTools/DumpRenderTree/chromium/NotificationPresenter.h b/WebKitTools/DumpRenderTree/chromium/NotificationPresenter.h index f30862f..5c7a400 100644 --- a/WebKitTools/DumpRenderTree/chromium/NotificationPresenter.h +++ b/WebKitTools/DumpRenderTree/chromium/NotificationPresenter.h @@ -61,10 +61,10 @@ private: TestShell* m_shell; // Set of allowed origins. - HashSet<WebCore::String> m_allowedOrigins; + HashSet<WTF::String> m_allowedOrigins; // Map of active replacement IDs to the titles of those notifications - HashMap<WebCore::String, WebCore::String> m_replacements; + HashMap<WTF::String, WTF::String> m_replacements; }; #endif // NotificationPresenter_h diff --git a/WebKitTools/DumpRenderTree/chromium/TestNavigationController.cpp b/WebKitTools/DumpRenderTree/chromium/TestNavigationController.cpp index 8b4f954..9653c07 100644 --- a/WebKitTools/DumpRenderTree/chromium/TestNavigationController.cpp +++ b/WebKitTools/DumpRenderTree/chromium/TestNavigationController.cpp @@ -40,6 +40,17 @@ using namespace std; // ---------------------------------------------------------------------------- // TestNavigationEntry +PassRefPtr<TestNavigationEntry> TestNavigationEntry::create() +{ + return adoptRef(new TestNavigationEntry); +} + +PassRefPtr<TestNavigationEntry> TestNavigationEntry::create( + int pageID, const WebURL& url, const WebString& title, const WebString& targetFrame) +{ + return adoptRef(new TestNavigationEntry(pageID, url, title, targetFrame)); +} + TestNavigationEntry::TestNavigationEntry() : m_pageID(-1) {} @@ -136,7 +147,7 @@ TestNavigationEntry* TestNavigationController::lastCommittedEntry() const TestNavigationEntry* TestNavigationController::activeEntry() const { - TestNavigationEntry* entry = m_pendingEntry; + TestNavigationEntry* entry = m_pendingEntry.get(); if (!entry) entry = lastCommittedEntry(); return entry; @@ -182,14 +193,14 @@ void TestNavigationController::didNavigateToEntry(TestNavigationEntry* entry) m_entries[existingEntryIndex].get() : 0; if (!existingEntry) { // No existing entry, then simply ignore this navigation! - } else if (existingEntry == m_pendingEntry) { + } else if (existingEntry == m_pendingEntry.get()) { // The given entry might provide a new URL... e.g., navigating back to a // page in session history could have resulted in a new client redirect. existingEntry->setURL(entry->URL()); existingEntry->setContentState(entry->contentState()); m_lastCommittedEntryIndex = m_pendingEntryIndex; m_pendingEntryIndex = -1; - m_pendingEntry = 0; + m_pendingEntry.clear(); } else if (m_pendingEntry && m_pendingEntry->pageID() == -1 && GURL(m_pendingEntry->URL()) == GURL(existingEntry->URL().spec())) { // Not a new navigation @@ -206,15 +217,12 @@ void TestNavigationController::didNavigateToEntry(TestNavigationEntry* entry) m_lastCommittedEntryIndex = existingEntryIndex; } - delete entry; updateMaxPageID(); } void TestNavigationController::discardPendingEntry() { - if (m_pendingEntryIndex == -1) - delete m_pendingEntry; - m_pendingEntry = 0; + m_pendingEntry.clear(); m_pendingEntryIndex = -1; } @@ -231,7 +239,7 @@ void TestNavigationController::insertEntry(TestNavigationEntry* entry) } } - m_entries.append(linked_ptr<TestNavigationEntry>(entry)); + m_entries.append(RefPtr<TestNavigationEntry>(entry)); m_lastCommittedEntryIndex = static_cast<int>(m_entries.size()) - 1; updateMaxPageID(); } @@ -250,10 +258,10 @@ void TestNavigationController::navigateToPendingEntry(bool reload) // For session history navigations only the pending_entry_index_ is set. if (!m_pendingEntry) { ASSERT(m_pendingEntryIndex != -1); - m_pendingEntry = m_entries[m_pendingEntryIndex].get(); + m_pendingEntry = m_entries[m_pendingEntryIndex]; } - if (m_host->navigate(*m_pendingEntry, reload)) { + if (m_host->navigate(*m_pendingEntry.get(), reload)) { // Note: this is redundant if navigation completed synchronously because // DidNavigateToEntry call this as well. updateMaxPageID(); diff --git a/WebKitTools/DumpRenderTree/chromium/TestNavigationController.h b/WebKitTools/DumpRenderTree/chromium/TestNavigationController.h index bd3c2f4..d75c3bf 100644 --- a/WebKitTools/DumpRenderTree/chromium/TestNavigationController.h +++ b/WebKitTools/DumpRenderTree/chromium/TestNavigationController.h @@ -31,13 +31,14 @@ #ifndef TestNavigationController_h #define TestNavigationController_h -#include "base/basictypes.h" -#include "base/linked_ptr.h" #include "public/WebDataSource.h" #include "public/WebHistoryItem.h" #include "public/WebString.h" #include "public/WebURL.h" +#include "webkit/support/webkit_support.h" #include <string> +#include <wtf/RefCounted.h> +#include <wtf/RefPtr.h> #include <wtf/Vector.h> // Associated with browser-initated navigations to hold tracking data. @@ -56,16 +57,17 @@ public: }; // Stores one back/forward navigation state for the test shell. -class TestNavigationEntry: public Noncopyable { +class TestNavigationEntry: public RefCounted<TestNavigationEntry> { public: - TestNavigationEntry(); - TestNavigationEntry(int pageID, - const WebKit::WebURL&, - const WebKit::WebString& title, - const WebKit::WebString& targetFrame); + static PassRefPtr<TestNavigationEntry> create(); + static PassRefPtr<TestNavigationEntry> create( + int pageID, + const WebKit::WebURL&, + const WebKit::WebString& title, + const WebKit::WebString& targetFrame); // Virtual to allow test_shell to extend the class. - ~TestNavigationEntry(); + virtual ~TestNavigationEntry(); // Set / Get the URI void setURL(const WebKit::WebURL& url) { m_url = url; } @@ -86,6 +88,12 @@ public: const WebKit::WebString& targetFrame() const { return m_targetFrame; } private: + TestNavigationEntry(); + TestNavigationEntry(int pageID, + const WebKit::WebURL&, + const WebKit::WebString& title, + const WebKit::WebString& targetFrame); + // Describes the current page that the tab represents. This is not relevant // for all tab contents types. int32_t m_pageID; @@ -120,8 +128,7 @@ public: // Causes the controller to go to the specified index. void goToIndex(int); - // Causes the controller to load the specified entry. The controller - // assumes ownership of the entry. + // Causes the controller to load the specified entry. // NOTE: Do not pass an entry that the controller already owns! void loadEntry(TestNavigationEntry*); @@ -156,9 +163,9 @@ public: // Returns the index of the last committed entry. int lastCommittedEntryIndex() const { return m_lastCommittedEntryIndex; } - // Used to inform us of a navigation being committed for a tab. We will take - // ownership of the entry. Any entry located forward to the current entry will - // be deleted. The new entry becomes the current entry. + // Used to inform us of a navigation being committed for a tab. Any entry + // located forward to the current entry will be deleted. The new entry + // becomes the current entry. void didNavigateToEntry(TestNavigationEntry*); // Used to inform us to discard its pending entry. @@ -180,14 +187,14 @@ private: void updateMaxPageID(); // List of NavigationEntry for this tab - typedef Vector<linked_ptr<TestNavigationEntry> > NavigationEntryList; + typedef Vector<RefPtr<TestNavigationEntry> > NavigationEntryList; typedef NavigationEntryList::iterator NavigationEntryListIterator; NavigationEntryList m_entries; // An entry we haven't gotten a response for yet. This will be discarded // when we navigate again. It's used only so we know what the currently // displayed tab is. - TestNavigationEntry* m_pendingEntry; + RefPtr<TestNavigationEntry> m_pendingEntry; // currently visible entry int m_lastCommittedEntryIndex; diff --git a/WebKitTools/DumpRenderTree/chromium/TestShell.cpp b/WebKitTools/DumpRenderTree/chromium/TestShell.cpp index 507f084..64c20b0 100644 --- a/WebKitTools/DumpRenderTree/chromium/TestShell.cpp +++ b/WebKitTools/DumpRenderTree/chromium/TestShell.cpp @@ -35,10 +35,8 @@ #include "DRTDevToolsClient.h" #include "LayoutTestController.h" #include "WebViewHost.h" -#include "base/md5.h" // FIXME: Wrap by webkit_support. #include "base/string16.h" #include "gfx/codec/png_codec.h" // FIXME: Remove dependecy. WebCore/platform/image-encoder is better? -#include "net/base/escape.h" // FIXME: Remove dependency. #include "public/WebDataSource.h" #include "public/WebDocument.h" #include "public/WebElement.h" @@ -48,6 +46,7 @@ #include "public/WebScriptController.h" #include "public/WebSettings.h" #include "public/WebSize.h" +#include "public/WebSpeechInputControllerMock.h" #include "public/WebString.h" #include "public/WebURLRequest.h" #include "public/WebURLResponse.h" @@ -58,6 +57,7 @@ #include <algorithm> #include <cctype> #include <vector> +#include <wtf/MD5.h> using namespace WebKit; using namespace std; @@ -278,6 +278,9 @@ void TestShell::resetTestController() m_eventSender->reset(); m_webViewHost->reset(); m_notificationPresenter->reset(); + m_drtDevToolsAgent->reset(); + if (m_drtDevToolsClient) + m_drtDevToolsClient->reset(); } void TestShell::loadURL(const WebURL& url) @@ -422,7 +425,7 @@ static string dumpHistoryItem(const WebHistoryItem& item, int indent, bool isCur url.replace(0, pos + layoutTestsPatternSize, fileTestPrefix); } else if (!url.find(dataUrlPattern)) { // URL-escape data URLs to match results upstream. - string path = EscapePath(url.substr(dataUrlPatternSize)); + string path = webkit_support::EscapePath(url.substr(dataUrlPatternSize)); url.replace(dataUrlPatternSize, url.length(), path); } @@ -585,13 +588,18 @@ void TestShell::dumpImage(skia::PlatformCanvas* canvas) const // some images that are the pixel identical on windows and other platforms // but have different MD5 sums. At this point, rebaselining all the windows // tests is too much of a pain, so we just check in different baselines. - MD5Context ctx; - MD5Init(&ctx); - MD5Update(&ctx, sourceBitmap.getPixels(), sourceBitmap.getSize()); - - MD5Digest digest; - MD5Final(&digest, &ctx); - string md5hash = MD5DigestToBase16(digest); + MD5 digester; + Vector<uint8_t, 16> digestValue; + digester.addBytes(reinterpret_cast<const uint8_t*>(sourceBitmap.getPixels()), sourceBitmap.getSize()); + digester.checksum(digestValue); + string md5hash; + md5hash.reserve(16 * 2); + for (unsigned i = 0; i < 16; ++i) { + char hex[3]; + // Use "x", not "X". The string must be lowercased. + sprintf(hex, "%02x", digestValue[i]); + md5hash.append(hex); + } // Only encode and dump the png if the hashes don't match. Encoding the image // is really expensive. diff --git a/WebKitTools/DumpRenderTree/chromium/TestShell.h b/WebKitTools/DumpRenderTree/chromium/TestShell.h index 0615552..47261a3 100644 --- a/WebKitTools/DumpRenderTree/chromium/TestShell.h +++ b/WebKitTools/DumpRenderTree/chromium/TestShell.h @@ -185,5 +185,6 @@ private: }; void platformInit(int*, char***); +void openStartupDialog(); #endif // TestShell_h diff --git a/WebKitTools/DumpRenderTree/chromium/TestShellGtk.cpp b/WebKitTools/DumpRenderTree/chromium/TestShellGtk.cpp index a9d374c..56ee618 100644 --- a/WebKitTools/DumpRenderTree/chromium/TestShellGtk.cpp +++ b/WebKitTools/DumpRenderTree/chromium/TestShellGtk.cpp @@ -194,3 +194,12 @@ void platformInit(int* argc, char*** argv) setupFontconfig(); } + +void openStartupDialog() +{ + GtkWidget* dialog = gtk_message_dialog_new( + 0, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Attach to me?"); + gtk_window_set_title(GTK_WINDOW(dialog), "DumpRenderTree"); + gtk_dialog_run(GTK_DIALOG(dialog)); // Runs a nested message loop. + gtk_widget_destroy(dialog); +} diff --git a/WebKitTools/DumpRenderTree/chromium/TestShellMac.mm b/WebKitTools/DumpRenderTree/chromium/TestShellMac.mm index 19cfd07..71d990e 100644 --- a/WebKitTools/DumpRenderTree/chromium/TestShellMac.mm +++ b/WebKitTools/DumpRenderTree/chromium/TestShellMac.mm @@ -127,3 +127,13 @@ void TestShell::waitTestFinished() void platformInit(int*, char***) { } + +void openStartupDialog() +{ + // FIXME: This code doesn't work. Need NSApplication event loop? + NSAlert* alert = [[[NSAlert alloc] init] autorelease]; + alert.messageText = @"Attach to me?"; + alert.informativeText = @"This would probably be a good time to attach your debugger."; + [alert addButtonWithTitle:@"OK"]; + [alert runModal]; +} diff --git a/WebKitTools/DumpRenderTree/chromium/TestShellWin.cpp b/WebKitTools/DumpRenderTree/chromium/TestShellWin.cpp index 72f800c..0d818c4 100644 --- a/WebKitTools/DumpRenderTree/chromium/TestShellWin.cpp +++ b/WebKitTools/DumpRenderTree/chromium/TestShellWin.cpp @@ -149,3 +149,8 @@ void platformInit(int*, char***) } // We don't need to release the font explicitly. } + +void openStartupDialog() +{ + ::MessageBox(0, L"Attach to me?", L"DumpRenderTree", MB_OK); +} diff --git a/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp b/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp index c57aeb5..a145bf9 100644 --- a/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp +++ b/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp @@ -35,7 +35,6 @@ #include "TestNavigationController.h" #include "TestShell.h" #include "TestWebWorker.h" -#include "net/base/net_errors.h" // FIXME: can we remove this? #include "public/WebCString.h" #include "public/WebConsoleMessage.h" #include "public/WebContextMenuData.h" @@ -166,35 +165,6 @@ static void printResponseDescription(const WebURLResponse& response) response.httpStatusCode()); } -static void printErrorDescription(const WebURLError& error) -{ - string domain = error.domain.utf8(); - int code = error.reason; - - if (domain == net::kErrorDomain) { - domain = "NSURLErrorDomain"; - switch (error.reason) { - case net::ERR_ABORTED: - code = -999; - break; - case net::ERR_UNSAFE_PORT: - // Our unsafe port checking happens at the network stack level, but we - // make this translation here to match the behavior of stock WebKit. - domain = "WebKitErrorDomain"; - code = 103; - break; - case net::ERR_ADDRESS_INVALID: - case net::ERR_ADDRESS_UNREACHABLE: - code = -1004; - break; - } - } else - LOG_ERROR("Unknown error domain"); - - printf("<NSError domain %s, code %d, failing URL \"%s\">", - domain.c_str(), code, error.unreachableURL.spec().data()); -} - static void printNodeDescription(const WebNode& node, int exception) { if (exception) { @@ -531,6 +501,11 @@ WebKit::WebGeolocationService* WebViewHost::geolocationService() return m_geolocationServiceMock.get(); } +WebSpeechInputController* WebViewHost::speechInputController(WebKit::WebSpeechInputListener* listener) +{ + return m_shell->layoutTestController()->speechInputController(listener); +} + // WebWidgetClient ----------------------------------------------------------- void WebViewHost::didInvalidateRect(const WebRect& rect) @@ -715,11 +690,7 @@ WebURLError WebViewHost::cannotHandleRequestError(WebFrame*, const WebURLRequest WebURLError WebViewHost::cancelledError(WebFrame*, const WebURLRequest& request) { - WebURLError error; - error.domain = WebString::fromUTF8(net::kErrorDomain); - error.reason = net::ERR_ABORTED; - error.unreachableURL = request.url(); - return error; + return webkit_support::CreateCancelledError(request); } void WebViewHost::unableToImplementPolicyWithError(WebFrame* frame, const WebURLError& error) @@ -960,7 +931,7 @@ void WebViewHost::didFailResourceLoad(WebFrame*, unsigned identifier, const WebU if (m_shell->shouldDumpResourceLoadCallbacks()) { printResourceDescription(identifier); fputs(" - didFailLoadingWithError: ", stdout); - printErrorDescription(error); + fputs(webkit_support::MakeURLErrorDescription(error).c_str(), stdout); fputs("\n", stdout); } m_resourceIdentifierMap.remove(identifier); @@ -1081,7 +1052,7 @@ void WebViewHost::loadURLForFrame(const WebURL& url, const WebString& frameName) if (!url.isValid()) return; TestShell::resizeWindowForTest(this, url); - navigationController()->loadEntry(new TestNavigationEntry(-1, url, WebString(), frameName)); + navigationController()->loadEntry(TestNavigationEntry::create(-1, url, WebString(), frameName).get()); } bool WebViewHost::navigate(const TestNavigationEntry& entry, bool reload) @@ -1180,7 +1151,7 @@ void WebViewHost::updateURL(WebFrame* frame) WebDataSource* ds = frame->dataSource(); ASSERT(ds); const WebURLRequest& request = ds->request(); - OwnPtr<TestNavigationEntry> entry(new TestNavigationEntry); + RefPtr<TestNavigationEntry> entry(TestNavigationEntry::create()); // The referrer will be empty on https->http transitions. It // would be nice if we could get the real referrer from somewhere. @@ -1194,7 +1165,7 @@ void WebViewHost::updateURL(WebFrame* frame) if (!historyItem.isNull()) entry->setContentState(historyItem); - navigationController()->didNavigateToEntry(entry.leakPtr()); + navigationController()->didNavigateToEntry(entry.get()); updateAddressBar(frame->view()); m_lastPageIdUpdated = max(m_lastPageIdUpdated, m_pageId); } @@ -1207,7 +1178,7 @@ void WebViewHost::updateSessionHistory(WebFrame* frame) if (m_pageId == -1) return; - TestNavigationEntry* entry = static_cast<TestNavigationEntry*>(navigationController()->entryWithPageID(m_pageId)); + TestNavigationEntry* entry = navigationController()->entryWithPageID(m_pageId); if (!entry) return; diff --git a/WebKitTools/DumpRenderTree/chromium/WebViewHost.h b/WebKitTools/DumpRenderTree/chromium/WebViewHost.h index 1e51be7..d95c59f 100644 --- a/WebKitTools/DumpRenderTree/chromium/WebViewHost.h +++ b/WebKitTools/DumpRenderTree/chromium/WebViewHost.h @@ -46,6 +46,8 @@ class TestShell; namespace WebKit { class WebFrame; class WebGeolocationServiceMock; +class WebSpeechInputController; +class WebSpeechInputListener; class WebURL; struct WebRect; struct WebURLError; @@ -83,8 +85,8 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient, void loadURLForFrame(const WebKit::WebURL&, const WebKit::WebString& frameName); TestNavigationController* navigationController() { return m_navigationController.get(); } - void addClearHeader(const WebCore::String& header) { m_clearHeaders.add(header); } - const HashSet<WebCore::String>& clearHeaders() const { return m_clearHeaders; } + void addClearHeader(const WTF::String& header) { m_clearHeaders.add(header); } + const HashSet<WTF::String>& clearHeaders() const { return m_clearHeaders; } // NavigationHost virtual bool navigate(const TestNavigationEntry&, bool reload); @@ -126,6 +128,7 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient, virtual void focusAccessibilityObject(const WebKit::WebAccessibilityObject&); virtual WebKit::WebNotificationPresenter* notificationPresenter(); virtual WebKit::WebGeolocationService* geolocationService(); + virtual WebKit::WebSpeechInputController* speechInputController(WebKit::WebSpeechInputListener*); // WebKit::WebWidgetClient virtual void didInvalidateRect(const WebKit::WebRect&); @@ -259,7 +262,7 @@ private: bool m_selectTrailingWhitespaceEnabled; // Set of headers to clear in willSendRequest. - HashSet<WebCore::String> m_clearHeaders; + HashSet<WTF::String> m_clearHeaders; // true if we should block any redirects bool m_blocksRedirects; diff --git a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp index 2aece10..b0c1cba 100644 --- a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp +++ b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp @@ -60,6 +60,8 @@ int webkit_web_frame_page_number_for_element_by_id(WebKitWebFrame* frame, const int webkit_web_frame_number_of_pages(WebKitWebFrame* frame, float pageWidth, float pageHeight); void webkit_web_inspector_execute_script(WebKitWebInspector* inspector, long callId, const gchar* script); gchar* webkit_web_frame_marker_text_for_list_item(WebKitWebFrame* frame, JSContextRef context, JSValueRef nodeObject); +void webkit_web_view_execute_core_command_by_name(WebKitWebView* webView, const gchar* name, const gchar* value); +gboolean webkit_web_view_is_command_enabled(WebKitWebView* webView, const gchar* name); } static gchar* copyWebSettingKey(gchar* preferenceKey) @@ -460,6 +462,18 @@ void LayoutTestController::setMockGeolocationError(int code, JSStringRef message // See https://bugs.webkit.org/show_bug.cgi?id=28264. } +void LayoutTestController::setGeolocationPermission(bool allow) +{ + // FIXME: Implement for Geolocation layout tests. + setGeolocationPermissionCommon(allow); +} + +void LayoutTestController::setMockSpeechInputResult(JSStringRef result) +{ + // FIXME: Implement for speech input layout tests. + // See https://bugs.webkit.org/show_bug.cgi?id=39485. +} + void LayoutTestController::setIconDatabaseEnabled(bool flag) { // FIXME: implement @@ -504,18 +518,30 @@ bool LayoutTestController::elementDoesAutoCompleteForElementWithId(JSStringRef i void LayoutTestController::execCommand(JSStringRef name, JSStringRef value) { - // FIXME: implement + WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); + ASSERT(view); + + gchar* cName = JSStringCopyUTF8CString(name); + gchar* cValue = JSStringCopyUTF8CString(value); + webkit_web_view_execute_core_command_by_name(view, cName, cValue); + g_free(cName); + g_free(cValue); } -void LayoutTestController::setCacheModel(int) +bool LayoutTestController::isCommandEnabled(JSStringRef name) { - // FIXME: implement + WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); + ASSERT(view); + + gchar* cName = JSStringCopyUTF8CString(name); + gboolean result = webkit_web_view_is_command_enabled(view, cName); + g_free(cName); + return result; } -bool LayoutTestController::isCommandEnabled(JSStringRef /*name*/) +void LayoutTestController::setCacheModel(int) { // FIXME: implement - return false; } void LayoutTestController::setPersistentUserStyleSheetLocation(JSStringRef jsURL) @@ -528,6 +554,16 @@ void LayoutTestController::clearPersistentUserStyleSheet() // FIXME: implement } +void LayoutTestController::clearAllApplicationCaches() +{ + // FIXME: implement to support Application Cache quotas. +} + +void LayoutTestController::setApplicationCacheOriginQuota(unsigned long long quota) +{ + // FIXME: implement to support Application Cache quotas. +} + void LayoutTestController::clearAllDatabases() { webkit_remove_all_web_databases(); diff --git a/WebKitTools/DumpRenderTree/mac/EventSendingController.mm b/WebKitTools/DumpRenderTree/mac/EventSendingController.mm index 77999bd..9031c63 100644 --- a/WebKitTools/DumpRenderTree/mac/EventSendingController.mm +++ b/WebKitTools/DumpRenderTree/mac/EventSendingController.mm @@ -449,13 +449,13 @@ static int buildModifierFlags(const WebScriptObject* modifiers) NSView *subView = [[mainFrame webView] hitTest:[event locationInWindow]]; if (subView) { if (leftMouseButtonDown) { - [subView mouseDragged:event]; if (draggingInfo) { // Per NSDragging.h: draggingSources may not implement draggedImage:movedTo: if ([[draggingInfo draggingSource] respondsToSelector:@selector(draggedImage:movedTo:)]) [[draggingInfo draggingSource] draggedImage:[draggingInfo draggedImage] movedTo:lastMousePosition]; [[mainFrame webView] draggingUpdated:draggingInfo]; - } + } else + [subView mouseDragged:event]; } else [subView mouseMoved:event]; } diff --git a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm index 7db7fff..c0eb722 100644 --- a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm +++ b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm @@ -33,6 +33,7 @@ #import "EditingDelegate.h" #import "MockGeolocationProvider.h" #import "PolicyDelegate.h" +#import "UIDelegate.h" #import "WorkQueue.h" #import "WorkQueueItem.h" #import <Foundation/Foundation.h> @@ -60,6 +61,7 @@ #import <WebKit/WebKitErrors.h> #import <WebKit/WebPreferences.h> #import <WebKit/WebPreferencesPrivate.h> +#import <WebKit/WebQuotaManager.h> #import <WebKit/WebScriptWorld.h> #import <WebKit/WebSecurityOriginPrivate.h> #import <WebKit/WebTypesInternal.h> @@ -123,6 +125,11 @@ bool LayoutTestController::callShouldCloseOnWebView() return [[mainFrame webView] shouldClose]; } +void LayoutTestController::clearAllApplicationCaches() +{ + [WebApplicationCache deleteAllApplicationCaches]; +} + void LayoutTestController::clearAllDatabases() { [[WebDatabaseManager sharedWebDatabaseManager] deleteAllDatabases]; @@ -293,6 +300,13 @@ void LayoutTestController::setAppCacheMaximumSize(unsigned long long size) [WebApplicationCache setMaximumSize:size]; } +void LayoutTestController::setApplicationCacheOriginQuota(unsigned long long quota) +{ + WebSecurityOrigin *origin = [[WebSecurityOrigin alloc] initWithURL:[NSURL URLWithString:@"http://127.0.0.1:8000"]]; + [[origin applicationCacheQuotaManager] setQuota:quota]; + [origin release]; +} + void LayoutTestController::setAuthorAndUserStylesEnabled(bool flag) { [[[mainFrame webView] preferences] setAuthorAndUserStylesEnabled:flag]; @@ -310,7 +324,7 @@ void LayoutTestController::setCustomPolicyDelegate(bool setDelegate, bool permis void LayoutTestController::setDatabaseQuota(unsigned long long quota) { WebSecurityOrigin *origin = [[WebSecurityOrigin alloc] initWithURL:[NSURL URLWithString:@"file:///"]]; - [origin setQuota:quota]; + [[origin databaseQuotaManager] setQuota:quota]; [origin release]; } @@ -342,6 +356,18 @@ void LayoutTestController::setMockGeolocationError(int code, JSStringRef message [[MockGeolocationProvider shared] setError:error]; } +void LayoutTestController::setGeolocationPermission(bool allow) +{ + setGeolocationPermissionCommon(allow); + [[[mainFrame webView] UIDelegate] didSetMockGeolocationPermission]; +} + +void LayoutTestController::setMockSpeechInputResult(JSStringRef result) +{ + // FIXME: Implement for speech input layout tests. + // See https://bugs.webkit.org/show_bug.cgi?id=39485. +} + void LayoutTestController::setIconDatabaseEnabled(bool iconDatabaseEnabled) { // FIXME: Workaround <rdar://problem/6480108> diff --git a/WebKitTools/DumpRenderTree/mac/MockGeolocationProvider.mm b/WebKitTools/DumpRenderTree/mac/MockGeolocationProvider.mm index 55d7257..e03cae2 100644 --- a/WebKitTools/DumpRenderTree/mac/MockGeolocationProvider.mm +++ b/WebKitTools/DumpRenderTree/mac/MockGeolocationProvider.mm @@ -74,6 +74,9 @@ - (void)registerWebView:(WebView *)webView { _registeredViews.add(webView); + + if (!_timer) + _timer = [NSTimer scheduledTimerWithTimeInterval:0 target:self selector:@selector(timerFired) userInfo:0 repeats:NO]; } - (void)unregisterWebView:(WebView *)webView diff --git a/WebKitTools/DumpRenderTree/mac/UIDelegate.h b/WebKitTools/DumpRenderTree/mac/UIDelegate.h index da472d6..a8017ad 100644 --- a/WebKitTools/DumpRenderTree/mac/UIDelegate.h +++ b/WebKitTools/DumpRenderTree/mac/UIDelegate.h @@ -32,6 +32,10 @@ @private NSRect m_frame; + NSMutableSet *m_pendingGeolocationPermissionListeners; + NSTimer *m_timer; } +- (void)didSetMockGeolocationPermission; + @end diff --git a/WebKitTools/DumpRenderTree/mac/UIDelegate.mm b/WebKitTools/DumpRenderTree/mac/UIDelegate.mm index 3dc378a..f9afdb1 100644 --- a/WebKitTools/DumpRenderTree/mac/UIDelegate.mm +++ b/WebKitTools/DumpRenderTree/mac/UIDelegate.mm @@ -33,8 +33,10 @@ #import "DumpRenderTreeDraggingInfo.h" #import "EventSendingController.h" #import "LayoutTestController.h" +#import <WebKit/WebApplicationCache.h> #import <WebKit/WebFramePrivate.h> #import <WebKit/WebHTMLViewPrivate.h> +#import <WebKit/WebQuotaManager.h> #import <WebKit/WebSecurityOriginPrivate.h> #import <WebKit/WebUIDelegatePrivate.h> #import <WebKit/WebView.h> @@ -155,12 +157,24 @@ DumpRenderTreeDraggingInfo *draggingInfo = nil; - (void)webView:(WebView *)sender frame:(WebFrame *)frame exceededDatabaseQuotaForSecurityOrigin:(WebSecurityOrigin *)origin database:(NSString *)databaseIdentifier { - if (!done && gLayoutTestController->dumpDatabaseCallbacks()) + if (!done && gLayoutTestController->dumpDatabaseCallbacks()) { printf("UI DELEGATE DATABASE CALLBACK: exceededDatabaseQuotaForSecurityOrigin:{%s, %s, %i} database:%s\n", [[origin protocol] UTF8String], [[origin host] UTF8String], [origin port], [databaseIdentifier UTF8String]); + } static const unsigned long long defaultQuota = 5 * 1024 * 1024; - [origin setQuota:defaultQuota]; + [[origin databaseQuotaManager] setQuota:defaultQuota]; +} + +- (void)webView:(WebView *)sender exceededApplicationCacheOriginQuotaForSecurityOrigin:(WebSecurityOrigin *)origin +{ + if (!done && gLayoutTestController->dumpApplicationCacheDelegateCallbacks()) { + printf("UI DELEGATE APPLICATION CACHE CALLBACK: exceededApplicationCacheOriginQuotaForSecurityOrigin:{%s, %s, %i}\n", + [[origin protocol] UTF8String], [[origin host] UTF8String], [origin port]); + } + + static const unsigned long long defaultOriginQuota = [WebApplicationCache defaultOriginQuota]; + [[origin applicationCacheQuotaManager] setQuota:defaultOriginQuota]; } - (void)webView:(WebView *)sender setStatusText:(NSString *)text @@ -171,13 +185,43 @@ DumpRenderTreeDraggingInfo *draggingInfo = nil; - (void)webView:(WebView *)webView decidePolicyForGeolocationRequestFromOrigin:(WebSecurityOrigin *)origin frame:(WebFrame *)frame listener:(id<WebGeolocationPolicyListener>)listener { - // FIXME: If mock permission isn't set yet, we should send the response asynchronously. - if (gLayoutTestController->isGeolocationPermissionSet() && gLayoutTestController->geolocationPermission()) + if (!gLayoutTestController->isGeolocationPermissionSet()) { + if (!m_pendingGeolocationPermissionListeners) + m_pendingGeolocationPermissionListeners = [[NSMutableSet set] retain]; + [m_pendingGeolocationPermissionListeners addObject:listener]; + return; + } + + if (gLayoutTestController->geolocationPermission()) [listener allow]; else [listener deny]; } +- (void)didSetMockGeolocationPermission +{ + ASSERT(gLayoutTestController->isGeolocationPermissionSet()); + if (m_pendingGeolocationPermissionListeners && !m_timer) + m_timer = [NSTimer scheduledTimerWithTimeInterval:0 target:self selector:@selector(timerFired) userInfo:0 repeats:NO]; +} + +- (void)timerFired +{ + ASSERT(gLayoutTestController->isGeolocationPermissionSet()); + m_timer = 0; + NSEnumerator* enumerator = [m_pendingGeolocationPermissionListeners objectEnumerator]; + id<WebGeolocationPolicyListener> listener; + while ((listener = [enumerator nextObject])) { + if (gLayoutTestController->geolocationPermission()) + [listener allow]; + else + [listener deny]; + } + [m_pendingGeolocationPermissionListeners removeAllObjects]; + [m_pendingGeolocationPermissionListeners release]; + m_pendingGeolocationPermissionListeners = nil; +} + - (BOOL)webView:(WebView *)sender shouldHaltPlugin:(DOMNode *)pluginNode { return NO; @@ -193,6 +237,8 @@ DumpRenderTreeDraggingInfo *draggingInfo = nil; { [draggingInfo release]; draggingInfo = nil; + [m_pendingGeolocationPermissionListeners release]; + m_pendingGeolocationPermissionListeners = nil; [super dealloc]; } diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro index b66eb5d..63554b2 100644 --- a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro +++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro @@ -13,7 +13,7 @@ INCLUDEPATH += ../../../JavaScriptCore/ForwardingHeaders INCLUDEPATH += $$BASEDIR DESTDIR = ../../../bin -!win32:!symbian { +unix:!mac { CONFIG += link_pkgconfig PKGCONFIG += fontconfig } diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp index ca51f1b..e682fd0 100644 --- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp +++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp @@ -494,6 +494,16 @@ void LayoutTestController::dispatchPendingLoadRequests() // FIXME: Implement for testing fix for 6727495 } +void LayoutTestController::clearAllApplicationCaches() +{ + // FIXME: implement to support Application Cache quotas. +} + +void LayoutTestController::setApplicationCacheOriginQuota(unsigned long long quota) +{ + // FIXME: implement to support Application Cache quotas. +} + void LayoutTestController::setDatabaseQuota(int size) { if (!m_topLoadingFrame) @@ -705,6 +715,12 @@ void LayoutTestController::setMockGeolocationPosition(double latitude, double lo DumpRenderTreeSupportQt::setMockGeolocationPosition(latitude, longitude, accuracy); } +void LayoutTestController::setMockSpeechInputResult(const QString& result) +{ + // FIXME: Implement for speech input layout tests. + // See https://bugs.webkit.org/show_bug.cgi?id=39485. +} + void LayoutTestController::evaluateScriptInIsolatedWorld(int worldID, const QString& script) { DumpRenderTreeSupportQt::evaluateScriptInIsolatedWorld(m_drt->webPage()->mainFrame(), worldID, script); diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h index 1dee6ce..f9986b1 100644 --- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h +++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h @@ -174,6 +174,9 @@ public slots: void dispatchPendingLoadRequests(); void disableImageLoading(); + void clearAllApplicationCaches(); + void setApplicationCacheOriginQuota(unsigned long long quota); + void setDatabaseQuota(int size); void clearAllDatabases(); void setIconDatabaseEnabled(bool enable); @@ -205,6 +208,8 @@ public slots: bool isGeolocationPermissionSet() const { return m_isGeolocationPermissionSet; } bool geolocationPermission() const { return m_geolocationPermission; } + void setMockSpeechInputResult(const QString& result); + // Empty stub method to keep parity with object model exposed by global LayoutTestController. void abortModal() {} diff --git a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp index 6519a97..31bc6ce 100644 --- a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp +++ b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp @@ -393,6 +393,18 @@ void LayoutTestController::setMockGeolocationError(int code, JSStringRef message // See https://bugs.webkit.org/show_bug.cgi?id=28264. } +void LayoutTestController::setGeolocationPermission(bool allow) +{ + // FIXME: Implement for Geolocation layout tests. + setGeolocationPermissionCommon(allow); +} + +void LayoutTestController::setMockSpeechInputResult(JSStringRef result) +{ + // FIXME: Implement for speech input layout tests. + // See https://bugs.webkit.org/show_bug.cgi?id=39485. +} + void LayoutTestController::setIconDatabaseEnabled(bool iconDatabaseEnabled) { // See also <rdar://problem/6480108> @@ -888,6 +900,16 @@ bool LayoutTestController::isCommandEnabled(JSStringRef /*name*/) return false; } +void LayoutTestController::clearAllApplicationCaches() +{ + // FIXME: implement to support Application Cache quotas. +} + +void LayoutTestController::setApplicationCacheOriginQuota(unsigned long long quota) +{ + // FIXME: implement to support Application Cache quotas. +} + void LayoutTestController::clearAllDatabases() { COMPtr<IWebDatabaseManager> databaseManager; diff --git a/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp b/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp index fd6b2d2..7c80ff2 100644 --- a/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp +++ b/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp @@ -228,6 +228,16 @@ void LayoutTestController::clearPersistentUserStyleSheet() // FIXME: implement } +void LayoutTestController::clearAllApplicationCaches() +{ + // FIXME: implement to support Application Cache quotas. +} + +void LayoutTestController::setApplicationCacheOriginQuota(unsigned long long quota) +{ + // FIXME: implement to support Application Cache quotas. +} + void LayoutTestController::clearAllDatabases() { // FIXME: implement @@ -289,6 +299,18 @@ void LayoutTestController::setMockGeolocationError(int code, JSStringRef message // See https://bugs.webkit.org/show_bug.cgi?id=28264. } +void LayoutTestController::setGeolocationPermission(bool allow) +{ + // FIXME: Implement for Geolocation layout tests. + setGeolocationPermissionCommon(allow); +} + +void LayoutTestController::setMockSpeechInputResult(JSStringRef result) +{ + // FIXME: Implement for speech input layout tests. + // See https://bugs.webkit.org/show_bug.cgi?id=39485. +} + void LayoutTestController::setIconDatabaseEnabled(bool iconDatabaseEnabled) { // FIXME: implement |