diff options
author | Steve Block <steveblock@google.com> | 2009-10-08 17:19:54 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2009-10-20 00:41:58 +0100 |
commit | 231d4e3152a9c27a73b6ac7badbe6be673aa3ddf (patch) | |
tree | a6c7e2d6cd7bfa7011cc39abbb436142d7a4a7c8 /WebKitTools/DumpRenderTree | |
parent | e196732677050bd463301566a68a643b6d14b907 (diff) | |
download | external_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.zip external_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.tar.gz external_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.tar.bz2 |
Merge webkit.org at R49305 : Automatic merge by git.
Change-Id: I8968561bc1bfd72b8923b7118d3728579c6dbcc7
Diffstat (limited to 'WebKitTools/DumpRenderTree')
59 files changed, 4592 insertions, 602 deletions
diff --git a/WebKitTools/DumpRenderTree/AccessibilityController.cpp b/WebKitTools/DumpRenderTree/AccessibilityController.cpp index 6556f91..af1daf6 100644 --- a/WebKitTools/DumpRenderTree/AccessibilityController.cpp +++ b/WebKitTools/DumpRenderTree/AccessibilityController.cpp @@ -52,8 +52,28 @@ void AccessibilityController::makeWindowObject(JSContextRef context, JSObjectRef JSObjectSetProperty(context, windowObject, accessibilityControllerStr.get(), accessibilityControllerObject, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception); } +static JSValueRef logFocusEventsCallback(JSContextRef ctx, JSObjectRef, JSObjectRef thisObject, size_t, const JSValueRef[], JSValueRef*) +{ + AccessibilityController* controller = static_cast<AccessibilityController*>(JSObjectGetPrivate(thisObject)); + controller->setLogFocusEvents(true); + return JSValueMakeUndefined(ctx); +} + +static JSValueRef logScrollingStartEventsCallback(JSContextRef ctx, JSObjectRef, JSObjectRef thisObject, size_t, const JSValueRef[], JSValueRef*) +{ + AccessibilityController* controller = static_cast<AccessibilityController*>(JSObjectGetPrivate(thisObject)); + controller->setLogScrollingStartEvents(true); + return JSValueMakeUndefined(ctx); +} + JSClassRef AccessibilityController::getJSClass() { + static JSStaticFunction staticFunctions[] = { + { "logFocusEvents", logFocusEventsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "logScrollingStartEvents", logScrollingStartEventsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } + }; + static JSStaticValue staticValues[] = { { "focusedElement", getFocusedElementCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "rootElement", getRootElementCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, @@ -61,10 +81,16 @@ JSClassRef AccessibilityController::getJSClass() }; static JSClassDefinition classDefinition = { - 0, kJSClassAttributeNone, "AccessibilityController", 0, staticValues, 0, + 0, kJSClassAttributeNone, "AccessibilityController", 0, staticValues, staticFunctions, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static JSClassRef accessibilityControllerClass = JSClassCreate(&classDefinition); return accessibilityControllerClass; } + +void AccessibilityController::resetToConsistentState() +{ + setLogFocusEvents(false); + setLogScrollingStartEvents(false); +} diff --git a/WebKitTools/DumpRenderTree/AccessibilityController.h b/WebKitTools/DumpRenderTree/AccessibilityController.h index 0af6613..a10e8be 100644 --- a/WebKitTools/DumpRenderTree/AccessibilityController.h +++ b/WebKitTools/DumpRenderTree/AccessibilityController.h @@ -27,6 +27,9 @@ #define AccessibilityController_h #include <JavaScriptCore/JSObjectRef.h> +#if PLATFORM(WIN) +#include <windows.h> +#endif class AccessibilityUIElement; @@ -41,8 +44,18 @@ public: AccessibilityUIElement rootElement(); AccessibilityUIElement focusedElement(); + void setLogFocusEvents(bool); + void setLogScrollingStartEvents(bool); + + void resetToConsistentState(); + private: static JSClassRef getJSClass(); + +#if PLATFORM(WIN) + HWINEVENTHOOK m_focusEventHook; + HWINEVENTHOOK m_scrollingStartEventHook; +#endif }; #endif // AccessibilityController_h diff --git a/WebKitTools/DumpRenderTree/AccessibilityUIElement.cpp b/WebKitTools/DumpRenderTree/AccessibilityUIElement.cpp index 8a92766..5958ccb 100644 --- a/WebKitTools/DumpRenderTree/AccessibilityUIElement.cpp +++ b/WebKitTools/DumpRenderTree/AccessibilityUIElement.cpp @@ -140,6 +140,18 @@ static JSValueRef boundsForRangeCallback(JSContextRef context, JSObjectRef funct return JSValueMakeString(context, boundsDescription.get()); } +static JSValueRef stringForRangeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + unsigned location = UINT_MAX, length = 0; + if (argumentCount == 2) { + location = JSValueToNumber(context, arguments[0], exception); + length = JSValueToNumber(context, arguments[1], exception); + } + + JSRetainPtr<JSStringRef> stringDescription(Adopt, toAXElement(thisObject)->stringForRange(location, length)); + return JSValueMakeString(context, stringDescription.get()); +} + static JSValueRef childAtIndexCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { int indexNumber = -1; @@ -190,7 +202,8 @@ static JSValueRef attributeValueCallback(JSContextRef context, JSObjectRef funct JSStringRef attribute = NULL; if (argumentCount == 1) attribute = JSValueToStringCopy(context, arguments[0], exception); - JSValueRef result = JSValueMakeString(context, toAXElement(thisObject)->attributeValue(attribute)); + JSRetainPtr<JSStringRef> attributeValue(Adopt, toAXElement(thisObject)->attributeValue(attribute)); + JSValueRef result = JSValueMakeString(context, attributeValue.get()); if (attribute) JSStringRelease(attribute); return result; @@ -250,6 +263,12 @@ static JSValueRef getRoleCallback(JSContextRef context, JSObjectRef thisObject, return JSValueMakeString(context, role.get()); } +static JSValueRef getSubroleCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) +{ + JSRetainPtr<JSStringRef> role(Adopt, toAXElement(thisObject)->subrole()); + return JSValueMakeString(context, role.get()); +} + static JSValueRef getTitleCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) { JSRetainPtr<JSStringRef> title(Adopt, toAXElement(thisObject)->title()); @@ -363,6 +382,7 @@ JSClassRef AccessibilityUIElement::getJSClass() { static JSStaticValue staticValues[] = { { "role", getRoleCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "subrole", getSubroleCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "title", getTitleCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "description", getDescriptionCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "language", getLanguageCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, @@ -392,6 +412,7 @@ JSClassRef AccessibilityUIElement::getJSClass() { "parameterizedAttributeNames", parameterizedAttributeNamesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "lineForIndex", lineForIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "boundsForRange", boundsForRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "stringForRange", stringForRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "childAtIndex", childAtIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "elementAtPoint", elementAtPointCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "attributesOfColumnHeaders", attributesOfColumnHeadersCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, diff --git a/WebKitTools/DumpRenderTree/AccessibilityUIElement.h b/WebKitTools/DumpRenderTree/AccessibilityUIElement.h index d0b63c3..fffdad8 100644 --- a/WebKitTools/DumpRenderTree/AccessibilityUIElement.h +++ b/WebKitTools/DumpRenderTree/AccessibilityUIElement.h @@ -86,6 +86,7 @@ public: bool isAttributeSettable(JSStringRef attribute); bool isActionSupported(JSStringRef action); JSStringRef role(); + JSStringRef subrole(); JSStringRef title(); JSStringRef description(); JSStringRef language(); @@ -119,6 +120,7 @@ public: int lineForIndex(int); JSStringRef boundsForRange(unsigned location, unsigned length); void setSelectedTextRange(unsigned location, unsigned length); + JSStringRef stringForRange(unsigned location, unsigned length); // Table-specific AccessibilityUIElement cellForColumnAndRow(unsigned column, unsigned row); diff --git a/WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj b/WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj index fd2c0d9..06f0599 100644 --- a/WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj +++ b/WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj @@ -35,6 +35,8 @@ 1AC6C84A0D07638600CD3161 /* PluginObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC6C7800D07589B00CD3161 /* PluginObject.cpp */; }; 1AC6C84B0D07638600CD3161 /* TestObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC6C7810D07589B00CD3161 /* TestObject.cpp */; }; 23BCB8900EA57623003C6289 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23BCB88F0EA57623003C6289 /* OpenGL.framework */; }; + 5185F6B210714E07007AA393 /* HistoryDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5185F69F10714A57007AA393 /* HistoryDelegate.mm */; }; + 5185F6B310714E12007AA393 /* HistoryDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 5185F69E10714A57007AA393 /* HistoryDelegate.h */; }; 5DB9AC970F722C3600684641 /* AHEM____.TTF in Copy Font Files */ = {isa = PBXBuildFile; fileRef = AA7F10C20CB3C1030003BDC9 /* AHEM____.TTF */; }; 5DB9AC980F722C3600684641 /* WebKitWeightWatcher100.ttf in Copy Font Files */ = {isa = PBXBuildFile; fileRef = 375F09710DAC3CB600C8B4E5 /* WebKitWeightWatcher100.ttf */; }; 5DB9AC990F722C3600684641 /* WebKitWeightWatcher200.ttf in Copy Font Files */ = {isa = PBXBuildFile; fileRef = 375F09720DAC3CB600C8B4E5 /* WebKitWeightWatcher200.ttf */; }; @@ -189,6 +191,8 @@ 375F09770DAC3CB600C8B4E5 /* WebKitWeightWatcher700.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = WebKitWeightWatcher700.ttf; path = fonts/WebKitWeightWatcher700.ttf; sourceTree = "<group>"; }; 375F09780DAC3CB600C8B4E5 /* WebKitWeightWatcher800.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = WebKitWeightWatcher800.ttf; path = fonts/WebKitWeightWatcher800.ttf; sourceTree = "<group>"; }; 375F09790DAC3CB600C8B4E5 /* WebKitWeightWatcher900.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = WebKitWeightWatcher900.ttf; path = fonts/WebKitWeightWatcher900.ttf; sourceTree = "<group>"; }; + 5185F69E10714A57007AA393 /* HistoryDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HistoryDelegate.h; path = mac/HistoryDelegate.h; sourceTree = "<group>"; }; + 5185F69F10714A57007AA393 /* HistoryDelegate.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; name = HistoryDelegate.mm; path = mac/HistoryDelegate.mm; sourceTree = "<group>"; }; 8465E2C60FFA8DF2003B8342 /* PixelDumpSupport.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 30; path = PixelDumpSupport.cpp; sourceTree = "<group>"; }; 9335435F03D75502008635CE /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = WebKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 933BF5A90F93FA5C000F0441 /* PlainTextController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlainTextController.h; path = mac/PlainTextController.h; sourceTree = "<group>"; }; @@ -388,6 +392,8 @@ BCA18B580C9B08C200114369 /* EditingDelegate.mm */, BCA18B590C9B08C200114369 /* FrameLoadDelegate.h */, BCA18B5A0C9B08C200114369 /* FrameLoadDelegate.mm */, + 5185F69E10714A57007AA393 /* HistoryDelegate.h */, + 5185F69F10714A57007AA393 /* HistoryDelegate.mm */, BCA18B5B0C9B08C200114369 /* PolicyDelegate.h */, BCA18B5C0C9B08C200114369 /* PolicyDelegate.mm */, BCA18B5D0C9B08C200114369 /* ResourceLoadDelegate.h */, @@ -531,6 +537,7 @@ BCA18B690C9B08C200114369 /* UIDelegate.h in Headers */, BC9D90250C97472E0099A4A3 /* WorkQueue.h in Headers */, BC9D90260C97472E0099A4A3 /* WorkQueueItem.h in Headers */, + 5185F6B310714E12007AA393 /* HistoryDelegate.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -696,6 +703,7 @@ BCA18B6A0C9B08C200114369 /* UIDelegate.mm in Sources */, BC9D90240C97472E0099A4A3 /* WorkQueue.cpp in Sources */, BCA18B260C9B015C00114369 /* WorkQueueItemMac.mm in Sources */, + 5185F6B210714E07007AA393 /* HistoryDelegate.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/LayoutTestController.cpp index 2a0871f..1f34325 100644 --- a/WebKitTools/DumpRenderTree/LayoutTestController.cpp +++ b/WebKitTools/DumpRenderTree/LayoutTestController.cpp @@ -33,26 +33,28 @@ #include "WorkQueueItem.h" #include <JavaScriptCore/JSObjectRef.h> #include <JavaScriptCore/JSRetainPtr.h> +#include <stdio.h> #include <wtf/Assertions.h> #include <wtf/MathExtras.h> +#include <wtf/RefPtr.h> LayoutTestController::LayoutTestController(const std::string& testPathOrURL, const std::string& expectedPixelHash) - : m_dumpAsText(false) - , m_dumpAsPDF(false) + : m_dumpAsPDF(false) + , m_dumpAsText(false) , m_dumpBackForwardList(false) , m_dumpChildFrameScrollPositions(false) , m_dumpChildFramesAsText(false) - , m_dumpDatabaseCallbacks(false) , m_dumpDOMAsWebArchive(false) + , m_dumpDatabaseCallbacks(false) + , m_dumpEditingCallbacks(false) + , m_dumpFrameLoadCallbacks(false) + , m_dumpResourceLoadCallbacks(false) + , m_dumpResourceResponseMIMETypes(false) , m_dumpSelectionRect(false) , m_dumpSourceAsWebArchive(false) , m_dumpStatusCallbacks(false) , m_dumpTitleChanges(false) - , m_dumpEditingCallbacks(false) - , m_dumpResourceLoadCallbacks(false) - , m_dumpResourceResponseMIMETypes(false) , m_dumpWillCacheResponse(false) - , m_dumpFrameLoadCallbacks(false) , m_callCloseOnWebViews(true) , m_canOpenWindows(false) , m_closeRemainingWindowsWhenComplete(true) @@ -63,7 +65,10 @@ LayoutTestController::LayoutTestController(const std::string& testPathOrURL, con , m_waitToDump(false) , m_willSendRequestReturnsNullOnRedirect(false) , m_windowIsKey(true) + , m_alwaysAcceptCookies(false) , m_globalFlag(false) + , m_isGeolocationPermissionSet(false) + , m_geolocationPermission(false) , m_testPathOrURL(testPathOrURL) , m_expectedPixelHash(expectedPixelHash) { @@ -71,17 +76,17 @@ LayoutTestController::LayoutTestController(const std::string& testPathOrURL, con // Static Functions -static JSValueRef dumpAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +static JSValueRef dumpAsPDFCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); - controller->setDumpAsText(true); + controller->setDumpAsPDF(true); return JSValueMakeUndefined(context); } -static JSValueRef dumpAsPDFCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +static JSValueRef dumpAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); - controller->setDumpAsPDF(true); + controller->setDumpAsText(true); return JSValueMakeUndefined(context); } @@ -127,6 +132,13 @@ static JSValueRef dumpEditingCallbacksCallback(JSContextRef context, JSObjectRef return JSValueMakeUndefined(context); } +static JSValueRef dumpFrameLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + controller->setDumpFrameLoadCallbacks(true); + return JSValueMakeUndefined(context); +} + static JSValueRef dumpResourceLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); @@ -362,6 +374,19 @@ static JSValueRef execCommandCallback(JSContextRef context, JSObjectRef function return JSValueMakeUndefined(context); } +static JSValueRef grantDesktopNotificationPermissionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + // Has Windows implementation + if (argumentCount < 1) + return JSValueMakeUndefined(context); + + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + + controller->grantDesktopNotificationPermission(JSValueToStringCopy(context, arguments[0], NULL)); + + return JSValueMakeUndefined(context); +} + static JSValueRef isCommandEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has Mac implementation. @@ -377,6 +402,22 @@ static JSValueRef isCommandEnabledCallback(JSContextRef context, JSObjectRef fun return JSValueMakeBoolean(context, controller->isCommandEnabled(name.get())); } +static JSValueRef overridePreferenceCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + if (argumentCount < 2) + return JSValueMakeUndefined(context); + + JSRetainPtr<JSStringRef> key(Adopt, JSValueToStringCopy(context, arguments[0], exception)); + ASSERT(!*exception); + JSRetainPtr<JSStringRef> value(Adopt, JSValueToStringCopy(context, arguments[1], exception)); + ASSERT(!*exception); + + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + controller->overridePreference(key.get(), value.get()); + + return JSValueMakeUndefined(context); +} + static JSValueRef keepWebHistoryCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation @@ -505,6 +546,18 @@ static JSValueRef setAcceptsEditingCallback(JSContextRef context, JSObjectRef fu return JSValueMakeUndefined(context); } +static JSValueRef setAlwaysAcceptCookiesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + // Has mac & windows implementation + if (argumentCount < 1) + return JSValueMakeUndefined(context); + + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + controller->setAlwaysAcceptCookies(JSValueToBoolean(context, arguments[0])); + + return JSValueMakeUndefined(context); +} + static JSValueRef setAppCacheMaximumSizeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation @@ -521,6 +574,46 @@ static JSValueRef setAppCacheMaximumSizeCallback(JSContextRef context, JSObjectR } +static JSValueRef setAuthenticationPasswordCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + // Has mac & windows implementation + if (argumentCount < 1) + return JSValueMakeUndefined(context); + + JSRetainPtr<JSStringRef> password(Adopt, JSValueToStringCopy(context, arguments[0], exception)); + ASSERT(!*exception); + + size_t maxLength = JSStringGetMaximumUTF8CStringSize(password.get()); + char* passwordBuffer = new char[maxLength + 1]; + JSStringGetUTF8CString(password.get(), passwordBuffer, maxLength + 1); + + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + controller->setAuthenticationPassword(passwordBuffer); + delete[] passwordBuffer; + + return JSValueMakeUndefined(context); +} + +static JSValueRef setAuthenticationUsernameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + // Has mac & windows implementation + if (argumentCount < 1) + return JSValueMakeUndefined(context); + + JSRetainPtr<JSStringRef> username(Adopt, JSValueToStringCopy(context, arguments[0], exception)); + ASSERT(!*exception); + + size_t maxLength = JSStringGetMaximumUTF8CStringSize(username.get()); + char* usernameBuffer = new char[maxLength + 1]; + JSStringGetUTF8CString(username.get(), usernameBuffer, maxLength + 1); + + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + controller->setAuthenticationUsername(usernameBuffer); + delete[] usernameBuffer; + + return JSValueMakeUndefined(context); +} + static JSValueRef setAuthorAndUserStylesEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation @@ -577,7 +670,71 @@ static JSValueRef setDatabaseQuotaCallback(JSContextRef context, JSObjectRef fun controller->setDatabaseQuota(static_cast<unsigned long long>(quota)); return JSValueMakeUndefined(context); +} + +static JSValueRef setMockGeolocationPositionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + if (argumentCount < 3) + return JSValueMakeUndefined(context); + + LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + controller->setMockGeolocationPosition(JSValueToNumber(context, arguments[0], NULL), // latitude + JSValueToNumber(context, arguments[1], NULL), // longitude + JSValueToNumber(context, arguments[2], NULL)); // accuracy + + return JSValueMakeUndefined(context); +} + +static JSValueRef setMockGeolocationErrorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + if (argumentCount < 2) + return JSValueMakeUndefined(context); + + int code = JSValueToNumber(context, arguments[0], NULL); + JSRetainPtr<JSStringRef> message(Adopt, JSValueToStringCopy(context, arguments[1], exception)); + ASSERT(!*exception); + + LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + controller->setMockGeolocationError(code, message.get()); + + return JSValueMakeUndefined(context); +} + +static JSValueRef setGeolocationPermissionCallback(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)); + controller->setGeolocationPermission(JSValueToBoolean(context, arguments[0])); + + return JSValueMakeUndefined(context); +} + +static JSValueRef setHandlesAuthenticationChallengesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + // Has mac & windows implementation + if (argumentCount < 1) + return JSValueMakeUndefined(context); + + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + controller->setHandlesAuthenticationChallenges(JSValueToBoolean(context, arguments[0])); + + return JSValueMakeUndefined(context); +} + +static JSValueRef setPOSIXLocaleCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + if (argumentCount < 1) + return JSValueMakeUndefined(context); + + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + JSRetainPtr<JSStringRef> locale(Adopt, JSValueToStringCopy(context, arguments[0], exception)); + ASSERT(!*exception); + controller->setPOSIXLocale(locale.get()); + return JSValueMakeUndefined(context); } static JSValueRef setIconDatabaseEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) @@ -785,6 +942,32 @@ static JSValueRef setStopProvisionalFrameLoadsCallback(JSContextRef context, JSO return JSValueMakeUndefined(context); } +static JSValueRef showWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + controller->showWebInspector(); + return JSValueMakeUndefined(context); +} + +static JSValueRef closeWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + controller->closeWebInspector(); + return JSValueMakeUndefined(context); +} + +static JSValueRef evaluateInWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + double callId = JSValueToNumber(context, arguments[0], exception); + ASSERT(!*exception); + JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[1], exception)); + ASSERT(!*exception); + + controller->evaluateInWebInspector(static_cast<long>(callId), script.get()); + return JSValueMakeUndefined(context); +} + static JSValueRef elementDoesAutoCompleteForElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); @@ -844,6 +1027,51 @@ static JSValueRef waitForPolicyDelegateCallback(JSContextRef context, JSObjectRe return JSValueMakeUndefined(context); } +static JSValueRef whiteListAccessFromOriginCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + if (argumentCount != 4) + return JSValueMakeUndefined(context); + + JSRetainPtr<JSStringRef> sourceOrigin(Adopt, JSValueToStringCopy(context, arguments[0], exception)); + ASSERT(!*exception); + JSRetainPtr<JSStringRef> destinationProtocol(Adopt, JSValueToStringCopy(context, arguments[1], exception)); + ASSERT(!*exception); + JSRetainPtr<JSStringRef> destinationHost(Adopt, JSValueToStringCopy(context, arguments[2], exception)); + ASSERT(!*exception); + bool allowDestinationSubdomains = JSValueToBoolean(context, arguments[3]); + + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + controller->whiteListAccessFromOrigin(sourceOrigin.get(), destinationProtocol.get(), destinationHost.get(), allowDestinationSubdomains); + return JSValueMakeUndefined(context); +} + +static JSValueRef addUserScriptCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + if (argumentCount != 2) + return JSValueMakeUndefined(context); + + JSRetainPtr<JSStringRef> source(Adopt, JSValueToStringCopy(context, arguments[0], exception)); + ASSERT(!*exception); + bool runAtStart = JSValueToBoolean(context, arguments[1]); + + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + controller->addUserScript(source.get(), runAtStart); + return JSValueMakeUndefined(context); +} + +static JSValueRef addUserStyleSheetCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + if (argumentCount != 1) + return JSValueMakeUndefined(context); + + JSRetainPtr<JSStringRef> source(Adopt, JSValueToStringCopy(context, arguments[0], exception)); + ASSERT(!*exception); + + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + controller->addUserStyleSheet(source.get()); + return JSValueMakeUndefined(context); +} + // Static Values static JSValueRef getGlobalFlagCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) @@ -858,6 +1086,12 @@ static JSValueRef getWebHistoryItemCountCallback(JSContextRef context, JSObjectR return JSValueMakeNumber(context, controller->webHistoryItemCount()); } +static JSValueRef getWorkerThreadCountCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) +{ + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + return JSValueMakeNumber(context, controller->workerThreadCount()); +} + static bool setGlobalFlagCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) { LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); @@ -904,6 +1138,7 @@ JSStaticValue* LayoutTestController::staticValues() static JSStaticValue staticValues[] = { { "globalFlag", getGlobalFlagCallback, setGlobalFlagCallback, kJSPropertyAttributeNone }, { "webHistoryItemCount", getWebHistoryItemCountCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "workerThreadCount", getWorkerThreadCountCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { 0, 0, 0, 0 } }; return staticValues; @@ -913,9 +1148,12 @@ JSStaticFunction* LayoutTestController::staticFunctions() { static JSStaticFunction staticFunctions[] = { { "addDisallowedURL", addDisallowedURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "addUserScript", addUserScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "addUserStyleSheet", addUserStyleSheetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "clearAllDatabases", clearAllDatabasesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "clearBackForwardList", clearBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "clearPersistentUserStyleSheet", clearPersistentUserStyleSheetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "closeWebInspector", closeWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "decodeHostName", decodeHostNameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "disableImageLoading", disableImageLoadingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "dispatchPendingLoadRequests", dispatchPendingLoadRequestsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, @@ -927,6 +1165,7 @@ JSStaticFunction* LayoutTestController::staticFunctions() { "dumpDOMAsWebArchive", dumpDOMAsWebArchiveCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "dumpDatabaseCallbacks", dumpDatabaseCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "dumpEditingCallbacks", dumpEditingCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "dumpFrameLoadCallbacks", dumpFrameLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "dumpResourceLoadCallbacks", dumpResourceLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "dumpResourceResponseMIMETypes", dumpResourceResponseMIMETypesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "dumpSelectionRect", dumpSelectionRectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, @@ -936,11 +1175,14 @@ JSStaticFunction* LayoutTestController::staticFunctions() { "dumpWillCacheResponse", dumpWillCacheResponseCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "elementDoesAutoCompleteForElementWithId", elementDoesAutoCompleteForElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "encodeHostName", encodeHostNameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "evaluateInWebInspector", evaluateInWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "execCommand", execCommandCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "grantDesktopNotificationPermission", grantDesktopNotificationPermissionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "isCommandEnabled", isCommandEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "keepWebHistory", keepWebHistoryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "notifyDone", notifyDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "numberOfActiveAnimations", numberOfActiveAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "overridePreference", overridePreferenceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "pathToLocalResource", pathToLocalResourceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "pauseAnimationAtTimeOnElementWithId", pauseAnimationAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "pauseTransitionAtTimeOnElementWithId", pauseTransitionAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, @@ -953,17 +1195,25 @@ JSStaticFunction* LayoutTestController::staticFunctions() { "queueReload", queueReloadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "repaintSweepHorizontally", repaintSweepHorizontallyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setAcceptsEditing", setAcceptsEditingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, - { "setAuthorAndUserStylesEnabled", setAuthorAndUserStylesEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "setAlwaysAcceptCookies", setAlwaysAcceptCookiesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setAppCacheMaximumSize", setAppCacheMaximumSizeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "setAuthenticationPassword", setAuthenticationPasswordCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "setAuthenticationUsername", setAuthenticationUsernameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "setAuthorAndUserStylesEnabled", setAuthorAndUserStylesEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setCallCloseOnWebViews", setCallCloseOnWebViewsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setCanOpenWindows", setCanOpenWindowsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setCacheModel", setCacheModelCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setCloseRemainingWindowsWhenComplete", setCloseRemainingWindowsWhenCompleteCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setCustomPolicyDelegate", setCustomPolicyDelegateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setDatabaseQuota", setDatabaseQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "setGeolocationPermission", setGeolocationPermissionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "setHandlesAuthenticationChallenges", setHandlesAuthenticationChallengesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "setPOSIXLocale", setPOSIXLocaleCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setIconDatabaseEnabled", setIconDatabaseEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setJavaScriptProfilingEnabled", setJavaScriptProfilingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setMainFrameIsFirstResponder", setMainFrameIsFirstResponderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "setMockGeolocationPosition", setMockGeolocationPositionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "setMockGeolocationError", setMockGeolocationErrorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setPersistentUserStyleSheetLocation", setPersistentUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setPopupBlockingEnabled", setPopupBlockingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setPrivateBrowsingEnabled", setPrivateBrowsingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, @@ -977,11 +1227,13 @@ JSStaticFunction* LayoutTestController::staticFunctions() { "setUserStyleSheetLocation", setUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setWillSendRequestReturnsNullOnRedirect", setWillSendRequestReturnsNullOnRedirectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setWindowIsKey", setWindowIsKeyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "showWebInspector", showWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "testOnscreen", testOnscreenCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "testRepaint", testRepaintCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "waitForPolicyDelegate", waitForPolicyDelegateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "waitUntilDone", waitUntilDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "windowCount", windowCountCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "whiteListAccessFromOrigin", whiteListAccessFromOriginCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { 0, 0, 0 } }; @@ -1012,3 +1264,41 @@ void LayoutTestController::queueReload() { WorkQueue::shared()->queue(new ReloadItem); } + +void LayoutTestController::grantDesktopNotificationPermission(JSStringRef origin) +{ + m_desktopNotificationAllowedOrigins.push_back(JSStringRetain(origin)); +} + +bool LayoutTestController::checkDesktopNotificationPermission(JSStringRef origin) +{ + std::vector<JSStringRef>::iterator i; + for (i = m_desktopNotificationAllowedOrigins.begin(); + i != m_desktopNotificationAllowedOrigins.end(); + ++i) { + if (JSStringIsEqual(*i, origin)) + return true; + } + return false; +} + +void LayoutTestController::waitToDumpWatchdogTimerFired() +{ + const char* message = "FAIL: Timed out waiting for notifyDone to be called\n"; + fprintf(stderr, "%s", message); + fprintf(stdout, "%s", message); + notifyDone(); +} + +void LayoutTestController::setGeolocationPermission(bool allow) +{ + m_isGeolocationPermissionSet = true; + m_geolocationPermission = allow; +} + +void LayoutTestController::setPOSIXLocale(JSStringRef locale) +{ + char localeBuf[32]; + JSStringGetUTF8CString(locale, localeBuf, sizeof(localeBuf)); + setlocale(LC_ALL, localeBuf); +} diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.h b/WebKitTools/DumpRenderTree/LayoutTestController.h index 5bc9d61..7c829ef 100644 --- a/WebKitTools/DumpRenderTree/LayoutTestController.h +++ b/WebKitTools/DumpRenderTree/LayoutTestController.h @@ -32,6 +32,7 @@ #include <JavaScriptCore/JSObjectRef.h> #include <wtf/RefCounted.h> #include <string> +#include <vector> class LayoutTestController : public RefCounted<LayoutTestController> { public: @@ -53,6 +54,7 @@ public: bool isCommandEnabled(JSStringRef name); void keepWebHistory(); void notifyDone(); + void overridePreference(JSStringRef key, JSStringRef value); JSStringRef pathToLocalResource(JSContextRef, JSStringRef url); void queueBackNavigation(int howFarBackward); void queueForwardNavigation(int howFarForward); @@ -66,6 +68,8 @@ public: void setCacheModel(int); void setCustomPolicyDelegate(bool setDelegate, bool permissive); void setDatabaseQuota(unsigned long long quota); + void setMockGeolocationPosition(double latitude, double longitude, double accuracy); + void setMockGeolocationError(int code, JSStringRef message); void setIconDatabaseEnabled(bool iconDatabaseEnabled); void setJavaScriptProfilingEnabled(bool profilingEnabled); void setMainFrameIsFirstResponder(bool flag); @@ -81,15 +85,19 @@ public: void setUserStyleSheetLocation(JSStringRef path); void waitForPolicyDelegate(); size_t webHistoryItemCount(); + unsigned workerThreadCount() const; int windowCount(); - bool elementDoesAutoCompleteForElementWithId(JSStringRef id); + void grantDesktopNotificationPermission(JSStringRef origin); + bool checkDesktopNotificationPermission(JSStringRef origin); - bool dumpAsText() const { return m_dumpAsText; } - void setDumpAsText(bool dumpAsText) { m_dumpAsText = dumpAsText; } + bool elementDoesAutoCompleteForElementWithId(JSStringRef id); bool dumpAsPDF() const { return m_dumpAsPDF; } void setDumpAsPDF(bool dumpAsPDF) { m_dumpAsPDF = dumpAsPDF; } + + bool dumpAsText() const { return m_dumpAsText; } + void setDumpAsText(bool dumpAsText) { m_dumpAsText = dumpAsText; } bool dumpBackForwardList() const { return m_dumpBackForwardList; } void setDumpBackForwardList(bool dumpBackForwardList) { m_dumpBackForwardList = dumpBackForwardList; } @@ -103,36 +111,36 @@ public: bool dumpDatabaseCallbacks() const { return m_dumpDatabaseCallbacks; } void setDumpDatabaseCallbacks(bool dumpDatabaseCallbacks) { m_dumpDatabaseCallbacks = dumpDatabaseCallbacks; } - bool dumpStatusCallbacks() const { return m_dumpStatusCallbacks; } - void setDumpStatusCallbacks(bool dumpStatusCallbacks) { m_dumpStatusCallbacks = dumpStatusCallbacks; } - bool dumpDOMAsWebArchive() const { return m_dumpDOMAsWebArchive; } void setDumpDOMAsWebArchive(bool dumpDOMAsWebArchive) { m_dumpDOMAsWebArchive = dumpDOMAsWebArchive; } - bool dumpSelectionRect() const { return m_dumpSelectionRect; } - void setDumpSelectionRect(bool dumpSelectionRect) { m_dumpSelectionRect = dumpSelectionRect; } - - bool dumpSourceAsWebArchive() const { return m_dumpSourceAsWebArchive; } - void setDumpSourceAsWebArchive(bool dumpSourceAsWebArchive) { m_dumpSourceAsWebArchive = dumpSourceAsWebArchive; } - - bool dumpTitleChanges() const { return m_dumpTitleChanges; } - void setDumpTitleChanges(bool dumpTitleChanges) { m_dumpTitleChanges = dumpTitleChanges; } - bool dumpEditingCallbacks() const { return m_dumpEditingCallbacks; } void setDumpEditingCallbacks(bool dumpEditingCallbacks) { m_dumpEditingCallbacks = dumpEditingCallbacks; } + bool dumpFrameLoadCallbacks() const { return m_dumpFrameLoadCallbacks; } + void setDumpFrameLoadCallbacks(bool dumpFrameLoadCallbacks) { m_dumpFrameLoadCallbacks = dumpFrameLoadCallbacks; } + bool dumpResourceLoadCallbacks() const { return m_dumpResourceLoadCallbacks; } void setDumpResourceLoadCallbacks(bool dumpResourceLoadCallbacks) { m_dumpResourceLoadCallbacks = dumpResourceLoadCallbacks; } bool dumpResourceResponseMIMETypes() const { return m_dumpResourceResponseMIMETypes; } void setDumpResourceResponseMIMETypes(bool dumpResourceResponseMIMETypes) { m_dumpResourceResponseMIMETypes = dumpResourceResponseMIMETypes; } - bool dumpWillCacheResponse() const { return m_dumpWillCacheResponse; } - void setDumpWillCacheResponse(bool dumpWillCacheResponse) { m_dumpWillCacheResponse = dumpWillCacheResponse; } + bool dumpSelectionRect() const { return m_dumpSelectionRect; } + void setDumpSelectionRect(bool dumpSelectionRect) { m_dumpSelectionRect = dumpSelectionRect; } - bool dumpFrameLoadCallbacks() const { return m_dumpFrameLoadCallbacks; } - void setDumpFrameLoadCallbacks(bool dumpFrameLoadCallbacks) { m_dumpFrameLoadCallbacks = dumpFrameLoadCallbacks; } + bool dumpSourceAsWebArchive() const { return m_dumpSourceAsWebArchive; } + void setDumpSourceAsWebArchive(bool dumpSourceAsWebArchive) { m_dumpSourceAsWebArchive = dumpSourceAsWebArchive; } + + bool dumpStatusCallbacks() const { return m_dumpStatusCallbacks; } + void setDumpStatusCallbacks(bool dumpStatusCallbacks) { m_dumpStatusCallbacks = dumpStatusCallbacks; } + bool dumpTitleChanges() const { return m_dumpTitleChanges; } + void setDumpTitleChanges(bool dumpTitleChanges) { m_dumpTitleChanges = dumpTitleChanges; } + + bool dumpWillCacheResponse() const { return m_dumpWillCacheResponse; } + void setDumpWillCacheResponse(bool dumpWillCacheResponse) { m_dumpWillCacheResponse = dumpWillCacheResponse; } + bool callCloseOnWebViews() const { return m_callCloseOnWebViews; } void setCallCloseOnWebViews(bool callCloseOnWebViews) { m_callCloseOnWebViews = callCloseOnWebViews; } @@ -156,6 +164,7 @@ public: bool waitToDump() const { return m_waitToDump; } void setWaitToDump(bool waitToDump); + void waitToDumpWatchdogTimerFired(); bool willSendRequestReturnsNullOnRedirect() const { return m_willSendRequestReturnsNullOnRedirect; } void setWillSendRequestReturnsNullOnRedirect(bool returnsNull) { m_willSendRequestReturnsNullOnRedirect = returnsNull; } @@ -163,6 +172,18 @@ public: bool windowIsKey() const { return m_windowIsKey; } void setWindowIsKey(bool windowIsKey); + bool alwaysAcceptCookies() const { return m_alwaysAcceptCookies; } + void setAlwaysAcceptCookies(bool alwaysAcceptCookies); + + bool handlesAuthenticationChallenges() const { return m_handlesAuthenticationChallenges; } + void setHandlesAuthenticationChallenges(bool handlesAuthenticationChallenges) { m_handlesAuthenticationChallenges = handlesAuthenticationChallenges; } + + const std::string& authenticationUsername() const { return m_authenticationUsername; } + void setAuthenticationUsername(std::string username) { m_authenticationUsername = username; } + + const std::string& authenticationPassword() const { return m_authenticationPassword; } + void setAuthenticationPassword(std::string password) { m_authenticationPassword = password; } + bool globalFlag() const { return m_globalFlag; } void setGlobalFlag(bool globalFlag) { m_globalFlag = globalFlag; } @@ -172,24 +193,39 @@ public: bool pauseAnimationAtTimeOnElementWithId(JSStringRef animationName, double time, JSStringRef elementId); bool pauseTransitionAtTimeOnElementWithId(JSStringRef propertyName, double time, JSStringRef elementId); unsigned numberOfActiveAnimations() const; - + + void whiteListAccessFromOrigin(JSStringRef sourceOrigin, JSStringRef destinationProtocol, JSStringRef destinationHost, bool allowDestinationSubdomains); + + void addUserScript(JSStringRef source, bool runAtStart); + void addUserStyleSheet(JSStringRef source); + + void setGeolocationPermission(bool allow); + bool isGeolocationPermissionSet() const { return m_isGeolocationPermissionSet; } + bool geolocationPermission() const { return m_geolocationPermission; } + + void showWebInspector(); + void closeWebInspector(); + void evaluateInWebInspector(long callId, JSStringRef script); + + void setPOSIXLocale(JSStringRef locale); + private: - bool m_dumpAsText; bool m_dumpAsPDF; + bool m_dumpAsText; bool m_dumpBackForwardList; bool m_dumpChildFrameScrollPositions; bool m_dumpChildFramesAsText; - bool m_dumpDatabaseCallbacks; bool m_dumpDOMAsWebArchive; + bool m_dumpDatabaseCallbacks; + bool m_dumpEditingCallbacks; + bool m_dumpFrameLoadCallbacks; + bool m_dumpResourceLoadCallbacks; + bool m_dumpResourceResponseMIMETypes; bool m_dumpSelectionRect; bool m_dumpSourceAsWebArchive; bool m_dumpStatusCallbacks; bool m_dumpTitleChanges; - bool m_dumpEditingCallbacks; - bool m_dumpResourceLoadCallbacks; - bool m_dumpResourceResponseMIMETypes; bool m_dumpWillCacheResponse; - bool m_dumpFrameLoadCallbacks; bool m_callCloseOnWebViews; bool m_canOpenWindows; bool m_closeRemainingWindowsWhenComplete; @@ -200,12 +236,20 @@ private: bool m_waitToDump; // True if waitUntilDone() has been called, but notifyDone() has not yet been called. bool m_willSendRequestReturnsNullOnRedirect; bool m_windowIsKey; - + bool m_alwaysAcceptCookies; bool m_globalFlag; + bool m_isGeolocationPermissionSet; + bool m_geolocationPermission; + bool m_handlesAuthenticationChallenges; + std::string m_authenticationUsername; + std::string m_authenticationPassword; std::string m_testPathOrURL; std::string m_expectedPixelHash; // empty string if no hash + // origins which have been granted desktop notification access + std::vector<JSStringRef> m_desktopNotificationAllowedOrigins; + static JSClassRef getJSClass(); static JSStaticValue* staticValues(); static JSStaticFunction* staticFunctions(); diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/TestObject.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/TestObject.cpp index af60df4..0b32191 100644 --- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/TestObject.cpp +++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/TestObject.cpp @@ -87,7 +87,7 @@ static void initializeIdentifiers(void) browser->getstringidentifiers(testMethodIdentifierNames, NUM_METHOD_IDENTIFIERS, testMethodIdentifiers); } -static NPObject *testAllocate(NPP npp, NPClass *theClass) +static NPObject *testAllocate(NPP /*npp*/, NPClass* /*theClass*/) { NPObject *newInstance = static_cast<NPObject*>(malloc(sizeof(NPObject))); @@ -113,7 +113,7 @@ static bool testHasMethod(NPObject*, NPIdentifier name) return false; } -static bool testInvoke(NPObject* header, NPIdentifier name, const NPVariant* args, uint32_t argCount, NPVariant* result) +static bool testInvoke(NPObject* header, NPIdentifier name, const NPVariant* /*args*/, uint32_t /*argCount*/, NPVariant* /*result*/) { if (name == testMethodIdentifiers[ID_THROW_EXCEPTION_METHOD]) { browser->setexception(header, "test object throwException SUCCESS"); @@ -145,7 +145,7 @@ static bool testGetProperty(NPObject* npobj, NPIdentifier name, NPVariant* resul } -static bool testEnumerate(NPObject *npobj, NPIdentifier **value, uint32_t *count) +static bool testEnumerate(NPObject* /*npobj*/, NPIdentifier **value, uint32_t *count) { *count = NUM_ENUMERATABLE_TEST_IDENTIFIERS; @@ -155,7 +155,7 @@ static bool testEnumerate(NPObject *npobj, NPIdentifier **value, uint32_t *count return true; } -static bool testConstruct(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result) +static bool testConstruct(NPObject* npobj, const NPVariant* /*args*/, uint32_t /*argCount*/, NPVariant* result) { browser->retainobject(npobj); diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/main.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/main.cpp index 704ba09..88618c3 100644 --- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/main.cpp +++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/main.cpp @@ -64,6 +64,8 @@ void NP_Shutdown(void) { } +static void executeScript(const PluginObject* obj, const char* script); + NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char *argn[], char *argv[], NPSavedData *saved) { bool forceCarbon = false; @@ -101,7 +103,8 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, ch for (int i = 0; i < argc; i++) if (strcasecmp(argn[i], "src") == 0) pluginLog(instance, "src: %s", argv[i]); - } + } else if (strcasecmp(argn[i], "cleardocumentduringnew") == 0) + executeScript(obj, "document.body.innerHTML = ''"); } #ifndef NP_NO_CARBON diff --git a/WebKitTools/DumpRenderTree/fonts/WebKit Layout Tests 2.ttf b/WebKitTools/DumpRenderTree/fonts/WebKit Layout Tests 2.ttf Binary files differnew file mode 100644 index 0000000..e732fbc --- /dev/null +++ b/WebKitTools/DumpRenderTree/fonts/WebKit Layout Tests 2.ttf diff --git a/WebKitTools/DumpRenderTree/fonts/WebKit Layout Tests.ttf b/WebKitTools/DumpRenderTree/fonts/WebKit Layout Tests.ttf Binary files differnew file mode 100644 index 0000000..f9f997e --- /dev/null +++ b/WebKitTools/DumpRenderTree/fonts/WebKit Layout Tests.ttf diff --git a/WebKitTools/DumpRenderTree/gtk/AccessibilityControllerGtk.cpp b/WebKitTools/DumpRenderTree/gtk/AccessibilityControllerGtk.cpp index ab92e1d..593f2eb 100644 --- a/WebKitTools/DumpRenderTree/gtk/AccessibilityControllerGtk.cpp +++ b/WebKitTools/DumpRenderTree/gtk/AccessibilityControllerGtk.cpp @@ -61,3 +61,11 @@ AccessibilityUIElement AccessibilityController::rootElement() AtkObject* axObject = gtk_widget_get_accessible(GTK_WIDGET(view)); return AccessibilityUIElement(axObject); } + +void AccessibilityController::setLogFocusEvents(bool) +{ +} + +void AccessibilityController::setLogScrollingStartEvents(bool) +{ +} diff --git a/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp b/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp index be1bbed..9aa31a8 100644 --- a/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp +++ b/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp @@ -67,9 +67,9 @@ void AccessibilityUIElement::getChildren(Vector<AccessibilityUIElement>& childre } } -void AccessibilityUIElement::getChildrenWithRange(Vector<AccessibilityUIElement>& elementVector, unsigned location, unsigned length) +void AccessibilityUIElement::getChildrenWithRange(Vector<AccessibilityUIElement>& elementVector, unsigned start, unsigned end) { - for (unsigned i = location; i < length; i++) { + for (unsigned i = start; i < end; i++) { AtkObject* child = atk_object_ref_accessible_child(ATK_OBJECT(m_element), i); elementVector.append(AccessibilityUIElement(child)); } @@ -94,7 +94,7 @@ AccessibilityUIElement AccessibilityUIElement::elementAtPoint(int x, int y) AccessibilityUIElement AccessibilityUIElement::getChildAtIndex(unsigned index) { Vector<AccessibilityUIElement> children; - getChildrenWithRange(children, index, 1); + getChildrenWithRange(children, index, index + 1); if (children.size() == 1) return children.at(0); @@ -156,6 +156,11 @@ JSStringRef AccessibilityUIElement::role() return JSStringCreateWithUTF8CString(atk_role_get_name(role)); } +JSStringRef AccessibilityUIElement::subrole() +{ + return 0; +} + JSStringRef AccessibilityUIElement::title() { const gchar* name = atk_object_get_name(ATK_OBJECT(m_element)); @@ -377,6 +382,12 @@ JSStringRef AccessibilityUIElement::boundsForRange(unsigned location, unsigned l return JSStringCreateWithCharacters(0, 0); } +JSStringRef AccessibilityUIElement::stringForRange(unsigned, unsigned) +{ + // FIXME: implement + return JSStringCreateWithCharacters(0, 0); +} + AccessibilityUIElement AccessibilityUIElement::cellForColumnAndRow(unsigned column, unsigned row) { // FIXME: implement diff --git a/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp index ac82dd8..6ecd774 100644 --- a/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp +++ b/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp @@ -32,6 +32,7 @@ #include "DumpRenderTree.h" #include "AccessibilityController.h" +#include "EventSender.h" #include "GCController.h" #include "LayoutTestController.h" #include "WorkQueue.h" @@ -43,6 +44,10 @@ #include <wtf/Assertions.h> +#if PLATFORM(X11) +#include <fontconfig/fontconfig.h> +#endif + #include <cassert> #include <getopt.h> #include <stdlib.h> @@ -58,10 +63,12 @@ extern GList* webkit_web_history_item_get_children(WebKitWebHistoryItem*); extern GSList* webkit_web_frame_get_children(WebKitWebFrame* frame); extern gchar* webkit_web_frame_get_inner_text(WebKitWebFrame* frame); extern gchar* webkit_web_frame_dump_render_tree(WebKitWebFrame* frame); +extern guint webkit_web_frame_get_pending_unload_event_count(WebKitWebFrame* frame); extern void webkit_web_settings_add_extra_plugin_directory(WebKitWebView* view, const gchar* directory); extern gchar* webkit_web_frame_get_response_mime_type(WebKitWebFrame* frame); extern void webkit_web_frame_clear_main_frame_name(WebKitWebFrame* frame); extern void webkit_web_view_set_group_name(WebKitWebView* view, const gchar* groupName); +extern void webkit_reset_origin_access_white_lists(); } volatile bool done; @@ -73,6 +80,7 @@ AccessibilityController* axController = 0; LayoutTestController* gLayoutTestController = 0; static GCController* gcController = 0; static WebKitWebView* webView; +static GtkWidget* window; static GtkWidget* container; WebKitWebFrame* mainFrame = 0; WebKitWebFrame* topLoadingFrame = 0; @@ -122,6 +130,41 @@ static void appendString(gchar*& target, gchar* string) g_free(oldString); } +#if PLATFORM(X11) +static void initializeFonts() +{ + static int numFonts = -1; + + // Some tests may add or remove fonts via the @font-face rule. + // If that happens, font config should be re-created to suppress any unwanted change. + FcFontSet* appFontSet = FcConfigGetFonts(0, FcSetApplication); + if (appFontSet && numFonts >= 0 && appFontSet->nfont == numFonts) + return; + + const char* fontDirEnv = g_getenv("WEBKIT_TESTFONTS"); + if (!fontDirEnv) + g_error("WEBKIT_TESTFONTS environment variable is not set, but it should point to the directory " + "containing the fonts you can clone from git://gitorious.org/qtwebkit/testfonts.git\n"); + + GFile* fontDir = g_file_new_for_path(fontDirEnv); + if (!fontDir || !g_file_query_exists(fontDir, NULL)) + g_error("WEBKIT_TESTFONTS environment variable is not set correctly - it should point to the directory " + "containing the fonts you can clone from git://gitorious.org/qtwebkit/testfonts.git\n"); + + FcConfig *config = FcConfigCreate(); + if (!FcConfigParseAndLoad (config, (FcChar8*) FONTS_CONF_FILE, true)) + g_error("Couldn't load font configuration file"); + if (!FcConfigAppFontAddDir (config, (FcChar8*) g_file_get_path(fontDir))) + g_error("Couldn't add font dir!"); + FcConfigSetCurrent(config); + + g_object_unref(fontDir); + + appFontSet = FcConfigGetFonts(config, FcSetApplication); + numFonts = appFontSet->nfont; +} +#endif + static gchar* dumpFramesAsText(WebKitWebFrame* frame) { gchar* result = 0; @@ -262,7 +305,7 @@ static void invalidateAnyPreviousWaitToDumpWatchdog() waitForPolicy = false; } -static void resetWebViewToConsistentStateBeforeTesting() +static void resetDefaultsToConsistentValues() { WebKitWebSettings* settings = webkit_web_view_get_settings(webView); g_object_set(G_OBJECT(settings), @@ -274,12 +317,25 @@ static void resetWebViewToConsistentStateBeforeTesting() "enable-xss-auditor", FALSE, "javascript-can-open-windows-automatically", TRUE, "enable-offline-web-application-cache", TRUE, + "enable-universal-access-from-file-uris", TRUE, + "enable-scripts", TRUE, + "default-font-family", "Times", + "monospace-font-family", "Courier", + "serif-font-family", "Times", + "sans-serif-font-family", "Helvetica", + "default-font-size", 16, + "default-monospace-font-size", 13, + "minimum-font-size", 1, NULL); webkit_web_frame_clear_main_frame_name(mainFrame); WebKitWebInspector* inspector = webkit_web_view_get_inspector(webView); g_object_set(G_OBJECT(inspector), "javascript-profiling-enabled", FALSE, NULL); + + webkit_reset_origin_access_white_lists(); + + setlocale(LC_ALL, ""); } void dump() @@ -354,16 +410,7 @@ static void setDefaultsToConsistentStateValuesForTesting() { gdk_screen_set_resolution(gdk_screen_get_default(), 72.0); - WebKitWebSettings* settings = webkit_web_view_get_settings(webView); - g_object_set(G_OBJECT(settings), - "default-font-family", "Times", - "monospace-font-family", "Courier", - "serif-font-family", "Times", - "sans-serif-font-family", "Helvetica", - "default-font-size", 16, - "default-monospace-font-size", 13, - "minimum-font-size", 1, - NULL); + resetDefaultsToConsistentValues(); /* Disable the default auth dialog for testing */ SoupSession* session = webkit_get_default_session(); @@ -372,6 +419,10 @@ static void setDefaultsToConsistentStateValuesForTesting() #if PLATFORM(X11) webkit_web_settings_add_extra_plugin_directory(webView, TEST_PLUGIN_DIR); #endif + + gchar* databaseDirectory = g_build_filename(g_get_user_data_dir(), "gtkwebkitdrt", "databases", NULL); + webkit_set_web_database_directory_path(databaseDirectory); + g_free(databaseDirectory); } static void runTest(const string& testPathOrURL) @@ -391,7 +442,7 @@ static void runTest(const string& testPathOrURL) gchar* url = autocorrectURL(pathOrURL.c_str()); const string testURL(url); - resetWebViewToConsistentStateBeforeTesting(); + resetDefaultsToConsistentValues(); gLayoutTestController = new LayoutTestController(testURL, expectedPixelHash); topLoadingFrame = 0; @@ -407,8 +458,10 @@ static void runTest(const string& testPathOrURL) bool isSVGW3CTest = (gLayoutTestController->testPathOrURL().find("svg/W3C-SVG-1.1") != string::npos); GtkAllocation size; + size.x = size.y = 0; size.width = isSVGW3CTest ? 480 : maxViewWidth; size.height = isSVGW3CTest ? 360 : maxViewHeight; + gtk_window_resize(GTK_WINDOW(window), size.width, size.height); gtk_widget_size_allocate(container, &size); if (prevTestBFItem) @@ -418,7 +471,12 @@ static void runTest(const string& testPathOrURL) if (prevTestBFItem) g_object_ref(prevTestBFItem); +#if PLATFORM(X11) + initializeFonts(); +#endif + // Focus the web view before loading the test to avoid focusing problems + gtk_widget_grab_focus(GTK_WIDGET(webView)); webkit_web_view_open(webView, url); g_free(url); @@ -462,8 +520,39 @@ static gboolean processWork(void* data) return FALSE; } +static char* getFrameNameSuitableForTestResult(WebKitWebView* view, WebKitWebFrame* frame) +{ + char* frameName = g_strdup(webkit_web_frame_get_name(frame)); + + if (frame == webkit_web_view_get_main_frame(view)) { + // This is a bit strange. Shouldn't web_frame_get_name return NULL? + if (frameName && (frameName[0] != '\0')) { + char* tmp = g_strdup_printf("main frame \"%s\"", frameName); + g_free (frameName); + frameName = tmp; + } else { + g_free(frameName); + frameName = g_strdup("main frame"); + } + } else if (!frameName || (frameName[0] == '\0')) { + g_free(frameName); + frameName = g_strdup("frame (anonymous)"); + } + + return frameName; +} + static void webViewLoadFinished(WebKitWebView* view, WebKitWebFrame* frame, void*) { + if (!done && !gLayoutTestController->dumpFrameLoadCallbacks()) { + guint pendingFrameUnloadEvents = webkit_web_frame_get_pending_unload_event_count(frame); + if (pendingFrameUnloadEvents) { + char* frameName = getFrameNameSuitableForTestResult(view, frame); + printf("%s - has %u onunload handler(s)\n", frameName, pendingFrameUnloadEvents); + g_free(frameName); + } + } + if (frame != topLoadingFrame) return; @@ -492,6 +581,10 @@ static void webViewWindowObjectCleared(WebKitWebView* view, WebKitWebFrame* fram axController->makeWindowObject(context, windowObject, &exception); ASSERT(!exception); + JSStringRef eventSenderStr = JSStringCreateWithUTF8CString("eventSender"); + JSValueRef eventSender = makeEventSender(context); + JSObjectSetProperty(context, windowObject, eventSenderStr, eventSender, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, 0); + JSStringRelease(eventSenderStr); } static gboolean webViewConsoleMessage(WebKitWebView* view, const gchar* message, unsigned int line, const gchar* sourceId, gpointer data) @@ -593,6 +686,23 @@ static gboolean webViewClose(WebKitWebView* view) return TRUE; } +static void databaseQuotaExceeded(WebKitWebView* view, WebKitWebFrame* frame, WebKitWebDatabase *database) +{ + ASSERT(view); + ASSERT(frame); + ASSERT(database); + + WebKitSecurityOrigin* origin = webkit_web_database_get_security_origin(database); + if (gLayoutTestController->dumpDatabaseCallbacks()) { + printf("UI DELEGATE DATABASE CALLBACK: exceededDatabaseQuotaForSecurityOrigin:{%s, %s, %i} database:%s\n", + webkit_security_origin_get_protocol(origin), + webkit_security_origin_get_host(origin), + webkit_security_origin_get_port(origin), + webkit_web_database_get_name(database)); + } + webkit_security_origin_set_web_database_quota(origin, 5 * 1024 * 1024); +} + static WebKitWebView* webViewCreate(WebKitWebView*, WebKitWebFrame*); @@ -617,6 +727,7 @@ static WebKitWebView* createWebView() "signal::status-bar-text-changed", webViewStatusBarTextChanged, 0, "signal::create-web-view", webViewCreate, 0, "signal::close-web-view", webViewClose, 0, + "signal::database-quota-exceeded", databaseQuotaExceeded, 0, NULL); return view; @@ -641,6 +752,11 @@ int main(int argc, char* argv[]) g_thread_init(NULL); gtk_init(&argc, &argv); +#if PLATFORM(X11) + FcInit(); + initializeFonts(); +#endif + struct option options[] = { {"notree", no_argument, &dumpTree, false}, {"pixel-tests", no_argument, &dumpPixels, true}, @@ -657,11 +773,11 @@ int main(int argc, char* argv[]) break; } - GtkWidget* window = gtk_window_new(GTK_WINDOW_POPUP); + window = gtk_window_new(GTK_WINDOW_POPUP); container = GTK_WIDGET(gtk_scrolled_window_new(NULL, NULL)); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(container), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add(GTK_CONTAINER(window), container); - gtk_widget_realize(window); + gtk_widget_show_all(window); webView = createWebView(); gtk_container_add(GTK_CONTAINER(container), GTK_WIDGET(webView)); @@ -699,7 +815,7 @@ int main(int argc, char* argv[]) delete axController; axController = 0; - g_object_unref(webView); + gtk_widget_destroy(window); return 0; } diff --git a/WebKitTools/DumpRenderTree/gtk/EventSender.cpp b/WebKitTools/DumpRenderTree/gtk/EventSender.cpp new file mode 100644 index 0000000..c3c72c1 --- /dev/null +++ b/WebKitTools/DumpRenderTree/gtk/EventSender.cpp @@ -0,0 +1,545 @@ +/* + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2009 Zan Dobersek <zandobersek@gmail.com> + * Copyright (C) 2009 Holger Hans Peter Freyther + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "EventSender.h" + +#include "DumpRenderTree.h" + +#include <JavaScriptCore/JSObjectRef.h> +#include <JavaScriptCore/JSRetainPtr.h> +#include <JavaScriptCore/JSStringRef.h> +#include <webkit/webkitwebframe.h> +#include <webkit/webkitwebview.h> +#include <wtf/ASCIICType.h> +#include <wtf/Platform.h> + +#include <gdk/gdk.h> +#include <gdk/gdkkeysyms.h> +#include <string.h> + +// TODO: Currently drag and drop related code is left out and +// should be merged once we have drag and drop support in WebCore. + +extern "C" { + extern void webkit_web_frame_layout(WebKitWebFrame* frame); +} + +static bool down = false; +static bool dragMode = true; +static bool replayingSavedEvents = false; +static int lastMousePositionX; +static int lastMousePositionY; + +static int lastClickPositionX; +static int lastClickPositionY; +static int clickCount = 0; + +struct DelayedMessage { + GdkEvent event; + gulong delay; + gboolean isDragEvent; +}; + +static DelayedMessage msgQueue[1024]; + +static unsigned endOfQueue; +static unsigned startOfQueue; + +static const float zoomMultiplierRatio = 1.2f; + +static JSValueRef getDragModeCallback(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) +{ + return JSValueMakeBoolean(context, dragMode); +} + +static bool setDragModeCallback(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) +{ + dragMode = JSValueToBoolean(context, value); + return true; +} + +static JSValueRef leapForwardCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + // FIXME: Add proper support for forward leaps + return JSValueMakeUndefined(context); +} + +static JSValueRef contextClickCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + webkit_web_frame_layout(mainFrame); + + WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); + if (!view) + return JSValueMakeUndefined(context); + + GdkEvent event; + memset(&event, 0, sizeof(event)); + event.button.button = 3; + event.button.x = lastMousePositionX; + event.button.y = lastMousePositionY; + event.button.window = GTK_WIDGET(view)->window; + + gboolean return_val; + down = true; + event.type = GDK_BUTTON_PRESS; + g_signal_emit_by_name(view, "button_press_event", &event, &return_val); + + down = false; + event.type = GDK_BUTTON_RELEASE; + g_signal_emit_by_name(view, "button_release_event", &event, &return_val); + + return JSValueMakeUndefined(context); +} + +static void updateClickCount(int /* button */) +{ + // FIXME: take the last clicked button number and the time of last click into account. + if (lastClickPositionX != lastMousePositionX && lastClickPositionY != lastMousePositionY) + clickCount = 1; + else + clickCount++; +} + +static JSValueRef mouseDownCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); + if (!view) + return JSValueMakeUndefined(context); + + down = true; + + GdkEvent event; + memset(&event, 0, sizeof(event)); + event.type = GDK_BUTTON_PRESS; + event.button.button = 1; + event.button.x = lastMousePositionX; + event.button.y = lastMousePositionY; + event.button.window = GTK_WIDGET(view)->window; + + updateClickCount(1); + + if (!msgQueue[endOfQueue].delay) { + webkit_web_frame_layout(mainFrame); + + gboolean return_val; + g_signal_emit_by_name(view, "button_press_event", &event, &return_val); + if (clickCount == 2) { + event.type = GDK_2BUTTON_PRESS; + g_signal_emit_by_name(view, "button_press_event", &event, &return_val); + } + } else { + // replaySavedEvents should have the required logic to make leapForward delays work + msgQueue[endOfQueue++].event = event; + replaySavedEvents(); + } + + return JSValueMakeUndefined(context); +} + +static JSValueRef mouseUpCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + + WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); + if (!view) + return JSValueMakeUndefined(context); + + down = false; + + GdkEvent event; + memset(&event, 0, sizeof(event)); + event.type = GDK_BUTTON_RELEASE; + event.button.button = 1; + event.button.x = lastMousePositionX; + event.button.y = lastMousePositionY; + event.button.window = GTK_WIDGET(view)->window; + + if ((dragMode && !replayingSavedEvents) || msgQueue[endOfQueue].delay) { + msgQueue[endOfQueue].event = event; + msgQueue[endOfQueue++].isDragEvent = true; + replaySavedEvents(); + } else { + webkit_web_frame_layout(mainFrame); + + gboolean return_val; + g_signal_emit_by_name(view, "button_release_event", &event, &return_val); + } + + lastClickPositionX = lastMousePositionX; + lastClickPositionY = lastMousePositionY; + + return JSValueMakeUndefined(context); +} + +static JSValueRef mouseMoveToCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); + if (!view) + return JSValueMakeUndefined(context); + + if (argumentCount < 2) + return JSValueMakeUndefined(context); + + lastMousePositionX = (int)JSValueToNumber(context, arguments[0], exception); + g_return_val_if_fail((!exception || !*exception), JSValueMakeUndefined(context)); + lastMousePositionY = (int)JSValueToNumber(context, arguments[1], exception); + g_return_val_if_fail((!exception || !*exception), JSValueMakeUndefined(context)); + + GdkEvent event; + event.type = GDK_MOTION_NOTIFY; + event.motion.x = lastMousePositionX; + event.motion.y = lastMousePositionY; + event.motion.time = GDK_CURRENT_TIME; + event.motion.window = GTK_WIDGET(view)->window; + + if (dragMode && down && !replayingSavedEvents) { + msgQueue[endOfQueue].event = event; + msgQueue[endOfQueue++].isDragEvent = true; + } else { + webkit_web_frame_layout(mainFrame); + + gboolean return_val; + g_signal_emit_by_name(view, "motion_notify_event", &event, &return_val); + } + + return JSValueMakeUndefined(context); +} + +static JSValueRef mouseWheelToCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); + if (!view) + return JSValueMakeUndefined(context); + + if (argumentCount < 2) + return JSValueMakeUndefined(context); + + int horizontal = (int)JSValueToNumber(context, arguments[0], exception); + g_return_val_if_fail((!exception || !*exception), JSValueMakeUndefined(context)); + int vertical = (int)JSValueToNumber(context, arguments[1], exception); + g_return_val_if_fail((!exception || !*exception), JSValueMakeUndefined(context)); + + // GTK+ doesn't support multiple direction scrolls in the same event! + g_return_val_if_fail((!vertical || !horizontal), JSValueMakeUndefined(context)); + + GdkEvent event; + event.type = GDK_SCROLL; + event.scroll.x = lastMousePositionX; + event.scroll.y = lastMousePositionY; + event.scroll.time = GDK_CURRENT_TIME; + event.scroll.window = GTK_WIDGET(view)->window; + + if (horizontal < 0) + event.scroll.direction = GDK_SCROLL_LEFT; + else if (horizontal > 0) + event.scroll.direction = GDK_SCROLL_RIGHT; + else if (vertical < 0) + event.scroll.direction = GDK_SCROLL_UP; + else if (vertical > 0) + event.scroll.direction = GDK_SCROLL_DOWN; + else + g_assert_not_reached(); + + if (dragMode && down && !replayingSavedEvents) { + msgQueue[endOfQueue].event = event; + msgQueue[endOfQueue++].isDragEvent = true; + } else { + webkit_web_frame_layout(mainFrame); + gtk_main_do_event(&event); + } + + return JSValueMakeUndefined(context); +} + +static JSValueRef beginDragWithFilesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + if (argumentCount < 1) + return JSValueMakeUndefined(context); + + // FIXME: Implement this completely once WebCore has complete drag and drop support + return JSValueMakeUndefined(context); +} + +void replaySavedEvents() +{ + // FIXME: This doesn't deal with forward leaps, but it should. + + WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); + if (!view) + return; + + replayingSavedEvents = true; + + for (unsigned queuePos = 0; queuePos < endOfQueue; queuePos++) { + GdkEvent event = msgQueue[queuePos].event; + gboolean return_val; + + switch (event.type) { + case GDK_BUTTON_RELEASE: + g_signal_emit_by_name(view, "button_release_event", &event, &return_val); + break; + case GDK_BUTTON_PRESS: + g_signal_emit_by_name(view, "button_press_event", &event, &return_val); + break; + case GDK_MOTION_NOTIFY: + g_signal_emit_by_name(view, "motion_notify_event", &event, &return_val); + break; + default: + continue; + } + + startOfQueue++; + } + + int numQueuedMessages = endOfQueue - startOfQueue; + if (!numQueuedMessages) { + startOfQueue = 0; + endOfQueue = 0; + replayingSavedEvents = false; + return; + } + + startOfQueue = 0; + endOfQueue = 0; + + replayingSavedEvents = false; +} + +static JSValueRef keyDownCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + if (argumentCount < 1) + return JSValueMakeUndefined(context); + + static const JSStringRef lengthProperty = JSStringCreateWithUTF8CString("length"); + + webkit_web_frame_layout(mainFrame); + + // handle modifier keys. + int state = 0; + if (argumentCount > 1) { + JSObjectRef modifiersArray = JSValueToObject(context, arguments[1], exception); + if (modifiersArray) { + for (int i = 0; i < JSValueToNumber(context, JSObjectGetProperty(context, modifiersArray, lengthProperty, 0), 0); ++i) { + JSValueRef value = JSObjectGetPropertyAtIndex(context, modifiersArray, i, 0); + JSStringRef string = JSValueToStringCopy(context, value, 0); + if (JSStringIsEqualToUTF8CString(string, "ctrlKey")) + state |= GDK_CONTROL_MASK; + else if (JSStringIsEqualToUTF8CString(string, "shiftKey")) + state |= GDK_SHIFT_MASK; + else if (JSStringIsEqualToUTF8CString(string, "altKey")) + state |= GDK_MOD1_MASK; + + JSStringRelease(string); + } + } + } + + JSStringRef character = JSValueToStringCopy(context, arguments[0], exception); + g_return_val_if_fail((!exception || !*exception), JSValueMakeUndefined(context)); + int gdkKeySym; + if (JSStringIsEqualToUTF8CString(character, "leftArrow")) + gdkKeySym = GDK_Left; + else if (JSStringIsEqualToUTF8CString(character, "rightArrow")) + gdkKeySym = GDK_Right; + else if (JSStringIsEqualToUTF8CString(character, "upArrow")) + gdkKeySym = GDK_Up; + else if (JSStringIsEqualToUTF8CString(character, "downArrow")) + gdkKeySym = GDK_Down; + else if (JSStringIsEqualToUTF8CString(character, "pageUp")) + gdkKeySym = GDK_Page_Up; + else if (JSStringIsEqualToUTF8CString(character, "pageDown")) + gdkKeySym = GDK_Page_Down; + else if (JSStringIsEqualToUTF8CString(character, "home")) + gdkKeySym = GDK_Home; + else if (JSStringIsEqualToUTF8CString(character, "end")) + gdkKeySym = GDK_End; + else if (JSStringIsEqualToUTF8CString(character, "delete")) + gdkKeySym = GDK_BackSpace; + else if (JSStringIsEqualToUTF8CString(character, "F1")) + gdkKeySym = GDK_F1; + else if (JSStringIsEqualToUTF8CString(character, "F2")) + gdkKeySym = GDK_F2; + else if (JSStringIsEqualToUTF8CString(character, "F3")) + gdkKeySym = GDK_F3; + else if (JSStringIsEqualToUTF8CString(character, "F4")) + gdkKeySym = GDK_F4; + else if (JSStringIsEqualToUTF8CString(character, "F5")) + gdkKeySym = GDK_F5; + else if (JSStringIsEqualToUTF8CString(character, "F6")) + gdkKeySym = GDK_F6; + else if (JSStringIsEqualToUTF8CString(character, "F7")) + gdkKeySym = GDK_F7; + else if (JSStringIsEqualToUTF8CString(character, "F8")) + gdkKeySym = GDK_F8; + else if (JSStringIsEqualToUTF8CString(character, "F9")) + gdkKeySym = GDK_F9; + else if (JSStringIsEqualToUTF8CString(character, "F10")) + gdkKeySym = GDK_F10; + else if (JSStringIsEqualToUTF8CString(character, "F11")) + gdkKeySym = GDK_F11; + else if (JSStringIsEqualToUTF8CString(character, "F12")) + gdkKeySym = GDK_F12; + else { + int charCode = JSStringGetCharactersPtr(character)[0]; + if (charCode == '\n' || charCode == '\r') + gdkKeySym = GDK_Return; + else if (charCode == '\t') + gdkKeySym = GDK_Tab; + else if (charCode == '\x8') + gdkKeySym = GDK_BackSpace; + else { + gdkKeySym = gdk_unicode_to_keyval(charCode); + if (WTF::isASCIIUpper(charCode)) + state |= GDK_SHIFT_MASK; + } + } + + JSStringRelease(character); + + WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); + if (!view) + return JSValueMakeUndefined(context); + + // create and send the event + GdkEvent event; + memset(&event, 0, sizeof(event)); + event.key.keyval = gdkKeySym; + event.key.state = state; + event.key.window = GTK_WIDGET(view)->window; + + gboolean return_val; + event.key.type = GDK_KEY_PRESS; + g_signal_emit_by_name(view, "key-press-event", &event.key, &return_val); + + event.key.type = GDK_KEY_RELEASE; + g_signal_emit_by_name(view, "key-release-event", &event.key, &return_val); + + return JSValueMakeUndefined(context); +} + +static JSValueRef textZoomInCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); + if (!view) + return JSValueMakeUndefined(context); + + gfloat currentZoom = webkit_web_view_get_zoom_level(view); + webkit_web_view_set_zoom_level(view, currentZoom * zoomMultiplierRatio); + + return JSValueMakeUndefined(context); +} + +static JSValueRef textZoomOutCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); + if (!view) + return JSValueMakeUndefined(context); + + gfloat currentZoom = webkit_web_view_get_zoom_level(view); + webkit_web_view_set_zoom_level(view, currentZoom / zoomMultiplierRatio); + + return JSValueMakeUndefined(context); +} + +static JSValueRef zoomPageInCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); + if (!view) + return JSValueMakeUndefined(context); + + webkit_web_view_zoom_in(view); + return JSValueMakeUndefined(context); +} + +static JSValueRef zoomPageOutCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); + if (!view) + return JSValueMakeUndefined(context); + + webkit_web_view_zoom_out(view); + return JSValueMakeUndefined(context); +} + +static JSStaticFunction staticFunctions[] = { + { "mouseWheelTo", mouseWheelToCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "contextClick", contextClickCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "mouseDown", mouseDownCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "mouseUp", mouseUpCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "mouseMoveTo", mouseMoveToCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "beginDragWithFiles", beginDragWithFilesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "leapForward", leapForwardCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "keyDown", keyDownCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "textZoomIn", textZoomInCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "textZoomOut", textZoomOutCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "zoomPageIn", zoomPageInCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "zoomPageOut", zoomPageOutCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { 0, 0, 0 } +}; + +static JSStaticValue staticValues[] = { + { "dragMode", getDragModeCallback, setDragModeCallback, kJSPropertyAttributeNone }, + { 0, 0, 0, 0 } +}; + +static JSClassRef getClass(JSContextRef context) +{ + static JSClassRef eventSenderClass = 0; + + if (!eventSenderClass) { + JSClassDefinition classDefinition = { + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + classDefinition.staticFunctions = staticFunctions; + classDefinition.staticValues = staticValues; + + eventSenderClass = JSClassCreate(&classDefinition); + } + + return eventSenderClass; +} + +JSObjectRef makeEventSender(JSContextRef context) +{ + down = false; + dragMode = true; + lastMousePositionX = lastMousePositionY = 0; + lastClickPositionX = lastClickPositionY = 0; + + if (!replayingSavedEvents) { + // This function can be called in the middle of a test, even + // while replaying saved events. Resetting these while doing that + // can break things. + endOfQueue = 0; + startOfQueue = 0; + } + + return JSObjectMake(context, getClass(context), 0); +} diff --git a/WebKitTools/DumpRenderTree/gtk/EventSender.h b/WebKitTools/DumpRenderTree/gtk/EventSender.h new file mode 100644 index 0000000..272e8a9 --- /dev/null +++ b/WebKitTools/DumpRenderTree/gtk/EventSender.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2009 Holger Hans Peter Freyther + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef EventSender_h +#define EventSender_h + +typedef const struct OpaqueJSContext* JSContextRef; +typedef struct OpaqueJSValue* JSObjectRef; + +JSObjectRef makeEventSender(JSContextRef context); +void replaySavedEvents(); + +#endif diff --git a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp index 009cb97..0b4a38f 100644 --- a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp +++ b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp @@ -38,6 +38,8 @@ #include <JavaScriptCore/JSRetainPtr.h> #include <JavaScriptCore/JSStringRef.h> +#include <iostream> +#include <sstream> #include <stdio.h> #include <glib.h> #include <libsoup/soup.h> @@ -48,6 +50,23 @@ bool webkit_web_frame_pause_animation(WebKitWebFrame* frame, const gchar* name, bool webkit_web_frame_pause_transition(WebKitWebFrame* frame, const gchar* name, double time, const gchar* element); unsigned int webkit_web_frame_number_of_active_animations(WebKitWebFrame* frame); void webkit_application_cache_set_maximum_size(unsigned long long size); +unsigned int webkit_worker_thread_count(void); +void webkit_white_list_access_from_origin(const gchar* sourceOrigin, const gchar* destinationProtocol, const gchar* destinationHost, bool allowDestinationSubdomains); +} + +static gchar* copyWebSettingKey(gchar* preferenceKey) +{ + static GHashTable* keyTable; + + if (!keyTable) { + // If you add a pref here, make sure you reset the value in + // DumpRenderTree::resetWebViewToConsistentStateBeforeTesting. + keyTable = g_hash_table_new(g_str_hash, g_str_equal); + g_hash_table_insert(keyTable, g_strdup("WebKitJavaScriptEnabled"), g_strdup("enable-scripts")); + g_hash_table_insert(keyTable, g_strdup("WebKitDefaultFontSize"), g_strdup("default-font-size")); + } + + return g_strdup(static_cast<gchar*>(g_hash_table_lookup(keyTable, preferenceKey))); } LayoutTestController::~LayoutTestController() @@ -110,6 +129,11 @@ size_t LayoutTestController::webHistoryItemCount() return 0; } +unsigned LayoutTestController::workerThreadCount() const +{ + return webkit_worker_thread_count(); +} + void LayoutTestController::notifyDone() { if (m_waitToDump && !topLoadingFrame && !WorkQueue::shared()->count()) @@ -152,6 +176,11 @@ void LayoutTestController::setAcceptsEditing(bool acceptsEditing) webkit_web_view_set_editable(webView, acceptsEditing); } +void LayoutTestController::setAlwaysAcceptCookies(bool alwaysAcceptCookies) +{ + // FIXME: Implement this (and restore the default value before running each test in DumpRenderTree.cpp). +} + void LayoutTestController::setCustomPolicyDelegate(bool setDelegate, bool permissive) { // FIXME: implement @@ -163,6 +192,17 @@ void LayoutTestController::waitForPolicyDelegate() setWaitToDump(true); } +void LayoutTestController::whiteListAccessFromOrigin(JSStringRef sourceOrigin, JSStringRef protocol, JSStringRef host, bool includeSubdomains) +{ + gchar* sourceOriginGChar = JSStringCopyUTF8CString(sourceOrigin); + gchar* protocolGChar = JSStringCopyUTF8CString(protocol); + gchar* hostGChar = JSStringCopyUTF8CString(host); + webkit_white_list_access_from_origin(sourceOriginGChar, protocolGChar, hostGChar, includeSubdomains); + g_free(sourceOriginGChar); + g_free(protocolGChar); + g_free(hostGChar); +} + void LayoutTestController::setMainFrameIsFirstResponder(bool flag) { // FIXME: implement @@ -213,17 +253,14 @@ void LayoutTestController::setSmartInsertDeleteEnabled(bool flag) static gboolean waitToDumpWatchdogFired(void*) { - const char* message = "FAIL: Timed out waiting for notifyDone to be called\n"; - fprintf(stderr, "%s", message); - fprintf(stdout, "%s", message); waitToDumpWatchdog = 0; - dump(); + gLayoutTestController->waitToDumpWatchdogTimerFired(); return FALSE; } void LayoutTestController::setWaitToDump(bool waitUntilDone) { - static const int timeoutSeconds = 10; + static const int timeoutSeconds = 15; m_waitToDump = waitUntilDone; if (m_waitToDump && !waitToDumpWatchdog) @@ -265,6 +302,18 @@ void LayoutTestController::disableImageLoading() // Also need to make sure image loading is re-enabled for each new test. } +void LayoutTestController::setMockGeolocationPosition(double latitude, double longitude, double accuracy) +{ + // FIXME: Implement for Geolocation layout tests. + // See https://bugs.webkit.org/show_bug.cgi?id=28264. +} + +void LayoutTestController::setMockGeolocationError(int code, JSStringRef message) +{ + // FIXME: Implement for Geolocation layout tests. + // See https://bugs.webkit.org/show_bug.cgi?id=28264. +} + void LayoutTestController::setIconDatabaseEnabled(bool flag) { // FIXME: implement @@ -331,12 +380,13 @@ void LayoutTestController::clearPersistentUserStyleSheet() void LayoutTestController::clearAllDatabases() { - // FIXME: implement + webkit_remove_all_web_databases(); } void LayoutTestController::setDatabaseQuota(unsigned long long quota) -{ - // FIXME: implement +{ + WebKitSecurityOrigin* origin = webkit_web_frame_get_security_origin(mainFrame); + webkit_security_origin_set_web_database_quota(origin, quota); } void LayoutTestController::setAppCacheMaximumSize(unsigned long long size) @@ -348,17 +398,91 @@ bool LayoutTestController::pauseAnimationAtTimeOnElementWithId(JSStringRef anima { gchar* name = JSStringCopyUTF8CString(animationName); gchar* element = JSStringCopyUTF8CString(elementId); - return webkit_web_frame_pause_animation(mainFrame, name, time, element); + bool returnValue = webkit_web_frame_pause_animation(mainFrame, name, time, element); + g_free(name); + g_free(element); + return returnValue; } bool LayoutTestController::pauseTransitionAtTimeOnElementWithId(JSStringRef propertyName, double time, JSStringRef elementId) { gchar* name = JSStringCopyUTF8CString(propertyName); gchar* element = JSStringCopyUTF8CString(elementId); - return webkit_web_frame_pause_transition(mainFrame, name, time, element); + bool returnValue = webkit_web_frame_pause_transition(mainFrame, name, time, element); + g_free(name); + g_free(element); + return returnValue; } unsigned LayoutTestController::numberOfActiveAnimations() const { return webkit_web_frame_number_of_active_animations(mainFrame); } + +void LayoutTestController::overridePreference(JSStringRef key, JSStringRef value) +{ + gchar* name = JSStringCopyUTF8CString(key); + gchar* strValue = JSStringCopyUTF8CString(value); + + WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); + ASSERT(view); + + WebKitWebSettings* settings = webkit_web_view_get_settings(view); + gchar* webSettingKey = copyWebSettingKey(name); + + if (webSettingKey) { + GValue stringValue = { 0, { { 0 } } }; + g_value_init(&stringValue, G_TYPE_STRING); + g_value_set_string(&stringValue, const_cast<gchar*>(strValue)); + + WebKitWebSettingsClass* klass = WEBKIT_WEB_SETTINGS_GET_CLASS(settings); + GParamSpec* pspec = g_object_class_find_property(G_OBJECT_CLASS(klass), webSettingKey); + GValue propValue = { 0, { { 0 } } }; + g_value_init(&propValue, pspec->value_type); + + if (g_value_type_transformable(G_TYPE_STRING, pspec->value_type)) { + g_value_transform(const_cast<GValue*>(&stringValue), &propValue); + g_object_set_property(G_OBJECT(settings), webSettingKey, const_cast<GValue*>(&propValue)); + } else if (G_VALUE_HOLDS_BOOLEAN(&propValue)) { + g_object_set(G_OBJECT(settings), webSettingKey, + g_str_equal(g_utf8_strdown(strValue, -1), "true"), + NULL); + } else if (G_VALUE_HOLDS_INT(&propValue)) { + std::string str(strValue); + std::stringstream ss(str); + int val = 0; + if (!(ss >> val).fail()) + g_object_set(G_OBJECT(settings), webSettingKey, val, NULL); + } else + printf("LayoutTestController::overridePreference failed to override preference '%s'.\n", name); + } + + g_free(webSettingKey); + g_free(name); + g_free(strValue); +} + +void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart) +{ + printf("LayoutTestController::addUserScript not implemented.\n"); +} + +void LayoutTestController::addUserStyleSheet(JSStringRef source) +{ + printf("LayoutTestController::addUserStyleSheet not implemented.\n"); +} + +void LayoutTestController::showWebInspector() +{ + // FIXME: Implement this. +} + +void LayoutTestController::closeWebInspector() +{ + // FIXME: Implement this. +} + +void LayoutTestController::evaluateInWebInspector(long callId, JSStringRef script) +{ + // FIXME: Implement this. +} diff --git a/WebKitTools/DumpRenderTree/gtk/TestNetscapePlugin/TestNetscapePlugin.cpp b/WebKitTools/DumpRenderTree/gtk/TestNetscapePlugin/TestNetscapePlugin.cpp index b7d14eb..6c62a7c 100644 --- a/WebKitTools/DumpRenderTree/gtk/TestNetscapePlugin/TestNetscapePlugin.cpp +++ b/WebKitTools/DumpRenderTree/gtk/TestNetscapePlugin/TestNetscapePlugin.cpp @@ -46,13 +46,13 @@ extern "C" { } static NPError -webkit_test_plugin_new_instance(NPMIMEType mimetype, +webkit_test_plugin_new_instance(NPMIMEType /*mimetype*/, NPP instance, - uint16_t mode, + uint16_t /*mode*/, int16_t argc, char *argn[], char *argv[], - NPSavedData *savedData) + NPSavedData* /*savedData*/) { if (browser->version >= 14) { PluginObject* obj = (PluginObject*)browser->createobject(instance, getPluginClass()); @@ -85,7 +85,7 @@ webkit_test_plugin_new_instance(NPMIMEType mimetype, } static NPError -webkit_test_plugin_destroy_instance(NPP instance, NPSavedData **save) +webkit_test_plugin_destroy_instance(NPP instance, NPSavedData** /*save*/) { PluginObject* obj = static_cast<PluginObject*>(instance->pdata); if (obj) { @@ -138,9 +138,9 @@ static void executeScript(const PluginObject* obj, const char* script) static NPError webkit_test_plugin_new_stream(NPP instance, - NPMIMEType type, + NPMIMEType /*type*/, NPStream *stream, - NPBool seekable, + NPBool /*seekable*/, uint16* stype) { PluginObject* obj = static_cast<PluginObject*>(instance->pdata); @@ -160,7 +160,7 @@ webkit_test_plugin_new_stream(NPP instance, } static NPError -webkit_test_plugin_destroy_stream(NPP instance, NPStream *stream, NPError reason) +webkit_test_plugin_destroy_stream(NPP instance, NPStream* /*stream*/, NPError /*reason*/) { PluginObject* obj = (PluginObject*)instance->pdata; @@ -171,28 +171,28 @@ webkit_test_plugin_destroy_stream(NPP instance, NPStream *stream, NPError reason } static void -webkit_test_plugin_stream_as_file(NPP instance, NPStream *stream, const char* fname) +webkit_test_plugin_stream_as_file(NPP /*instance*/, NPStream* /*stream*/, const char* /*fname*/) { } static int32 -webkit_test_plugin_write_ready(NPP instance, NPStream *stream) +webkit_test_plugin_write_ready(NPP /*instance*/, NPStream* /*stream*/) { return 0; } static int32 -webkit_test_plugin_write(NPP instance, - NPStream *stream, - int32_t offset, - int32_t len, - void *buffer) +webkit_test_plugin_write(NPP /*instance*/, + NPStream* /*stream*/, + int32_t /*offset*/, + int32_t /*len*/, + void* /*buffer*/) { return 0; } static void -webkit_test_plugin_print(NPP instance, NPPrint* platformPrint) +webkit_test_plugin_print(NPP /*instance*/, NPPrint* /*platformPrint*/) { } @@ -258,7 +258,7 @@ webkit_test_plugin_get_value(NPP instance, NPPVariable variable, void *value) } static NPError -webkit_test_plugin_set_value(NPP instance, NPNVariable variable, void *value) +webkit_test_plugin_set_value(NPP /*instance*/, NPNVariable /*variable*/, void* /*value*/) { return NPERR_NO_ERROR; } @@ -310,7 +310,7 @@ NP_Shutdown(void) } NPError -NP_GetValue(void *future, NPPVariable variable, void *value) +NP_GetValue(void* /*future*/, NPPVariable variable, void *value) { return webkit_test_plugin_get_value(NULL, variable, value); } diff --git a/WebKitTools/DumpRenderTree/gtk/fonts.conf b/WebKitTools/DumpRenderTree/gtk/fonts.conf new file mode 100644 index 0000000..3540c47 --- /dev/null +++ b/WebKitTools/DumpRenderTree/gtk/fonts.conf @@ -0,0 +1,258 @@ +<?xml version="1.0"?> +<!DOCTYPE fontconfig SYSTEM "fonts.dtd"> +<fontconfig> + +<!-- + Accept deprecated 'mono' alias, replacing it with 'monospace' +--> + <match target="pattern"> + <test qual="any" name="family"> + <string>mono</string> + </test> + <edit name="family" mode="assign"> + <string>monospace</string> + </edit> + </match> + +<!-- + Accept alternate 'sans serif' spelling, replacing it with 'sans-serif' +--> + <match target="pattern"> + <test qual="any" name="family"> + <string>sans serif</string> + </test> + <edit name="family" mode="assign"> + <string>sans-serif</string> + </edit> + </match> + +<!-- + Accept deprecated 'sans' alias, replacing it with 'sans-serif' +--> + <match target="pattern"> + <test qual="any" name="family"> + <string>sans</string> + </test> + <edit name="family" mode="assign"> + <string>sans-serif</string> + </edit> + </match> + + + <config> +<!-- + These are the default Unicode chars that are expected to be blank + in fonts. All other blank chars are assumed to be broken and + won't appear in the resulting charsets + --> + <blank> + <int>0x0020</int> <!-- SPACE --> + <int>0x00A0</int> <!-- NO-BREAK SPACE --> + <int>0x00AD</int> <!-- SOFT HYPHEN --> + <int>0x034F</int> <!-- COMBINING GRAPHEME JOINER --> + <int>0x0600</int> <!-- ARABIC NUMBER SIGN --> + <int>0x0601</int> <!-- ARABIC SIGN SANAH --> + <int>0x0602</int> <!-- ARABIC FOOTNOTE MARKER --> + <int>0x0603</int> <!-- ARABIC SIGN SAFHA --> + <int>0x06DD</int> <!-- ARABIC END OF AYAH --> + <int>0x070F</int> <!-- SYRIAC ABBREVIATION MARK --> + <int>0x115F</int> <!-- HANGUL CHOSEONG FILLER --> + <int>0x1160</int> <!-- HANGUL JUNGSEONG FILLER --> + <int>0x1680</int> <!-- OGHAM SPACE MARK --> + <int>0x17B4</int> <!-- KHMER VOWEL INHERENT AQ --> + <int>0x17B5</int> <!-- KHMER VOWEL INHERENT AA --> + <int>0x180E</int> <!-- MONGOLIAN VOWEL SEPARATOR --> + <int>0x2000</int> <!-- EN QUAD --> + <int>0x2001</int> <!-- EM QUAD --> + <int>0x2002</int> <!-- EN SPACE --> + <int>0x2003</int> <!-- EM SPACE --> + <int>0x2004</int> <!-- THREE-PER-EM SPACE --> + <int>0x2005</int> <!-- FOUR-PER-EM SPACE --> + <int>0x2006</int> <!-- SIX-PER-EM SPACE --> + <int>0x2007</int> <!-- FIGURE SPACE --> + <int>0x2008</int> <!-- PUNCTUATION SPACE --> + <int>0x2009</int> <!-- THIN SPACE --> + <int>0x200A</int> <!-- HAIR SPACE --> + <int>0x200B</int> <!-- ZERO WIDTH SPACE --> + <int>0x200C</int> <!-- ZERO WIDTH NON-JOINER --> + <int>0x200D</int> <!-- ZERO WIDTH JOINER --> + <int>0x200E</int> <!-- LEFT-TO-RIGHT MARK --> + <int>0x200F</int> <!-- RIGHT-TO-LEFT MARK --> + <int>0x2028</int> <!-- LINE SEPARATOR --> + <int>0x2029</int> <!-- PARAGRAPH SEPARATOR --> + <int>0x202A</int> <!-- LEFT-TO-RIGHT EMBEDDING --> + <int>0x202B</int> <!-- RIGHT-TO-LEFT EMBEDDING --> + <int>0x202C</int> <!-- POP DIRECTIONAL FORMATTING --> + <int>0x202D</int> <!-- LEFT-TO-RIGHT OVERRIDE --> + <int>0x202E</int> <!-- RIGHT-TO-LEFT OVERRIDE --> + <int>0x202F</int> <!-- NARROW NO-BREAK SPACE --> + <int>0x205F</int> <!-- MEDIUM MATHEMATICAL SPACE --> + <int>0x2060</int> <!-- WORD JOINER --> + <int>0x2061</int> <!-- FUNCTION APPLICATION --> + <int>0x2062</int> <!-- INVISIBLE TIMES --> + <int>0x2063</int> <!-- INVISIBLE SEPARATOR --> + <int>0x206A</int> <!-- INHIBIT SYMMETRIC SWAPPING --> + <int>0x206B</int> <!-- ACTIVATE SYMMETRIC SWAPPING --> + <int>0x206C</int> <!-- INHIBIT ARABIC FORM SHAPING --> + <int>0x206D</int> <!-- ACTIVATE ARABIC FORM SHAPING --> + <int>0x206E</int> <!-- NATIONAL DIGIT SHAPES --> + <int>0x206F</int> <!-- NOMINAL DIGIT SHAPES --> + <int>0x3000</int> <!-- IDEOGRAPHIC SPACE --> + <int>0x3164</int> <!-- HANGUL FILLER --> + <int>0xFEFF</int> <!-- ZERO WIDTH NO-BREAK SPACE --> + <int>0xFFA0</int> <!-- HALFWIDTH HANGUL FILLER --> + <int>0xFFF9</int> <!-- INTERLINEAR ANNOTATION ANCHOR --> + <int>0xFFFA</int> <!-- INTERLINEAR ANNOTATION SEPARATOR --> + <int>0xFFFB</int> <!-- INTERLINEAR ANNOTATION TERMINATOR --> + </blank> +<!-- + Rescan configuration every 30 seconds when FcFontSetList is called + --> + <rescan> + <int>30</int> + </rescan> + </config> + +<!-- + URW provides metric and shape compatible fonts for these 10 Adobe families. + + However, these fonts are quite ugly and do not render well on-screen, + so we avoid matching them if the application said `anymetrics'; in that + case, a more generic font with different metrics but better appearance + will be used. + --> + <match target="pattern"> + <test name="family"> + <string>Avant Garde</string> + </test> + <test name="anymetrics" qual="all" compare="not_eq"> + <bool>true</bool> + </test> + <edit name="family" mode="append"> + <string>URW Gothic L</string> + </edit> + </match> + <match target="pattern"> + <test name="family"> + <string>Bookman</string> + </test> + <test name="anymetrics" qual="all" compare="not_eq"> + <bool>true</bool> + </test> + <edit name="family" mode="append"> + <string>URW Bookman L</string> + </edit> + </match> + <match target="pattern"> + <test name="family"> + <string>Courier</string> + </test> + <test name="anymetrics" qual="all" compare="not_eq"> + <bool>true</bool> + </test> + <edit name="family" mode="append"> + <string>Nimbus Mono L</string> + </edit> + </match> + <match target="pattern"> + <test name="family"> + <string>Helvetica</string> + </test> + <test name="anymetrics" qual="all" compare="not_eq"> + <bool>true</bool> + </test> + <edit name="family" mode="append"> + <string>Nimbus Sans L</string> + </edit> + </match> + <match target="pattern"> + <test name="family"> + <string>New Century Schoolbook</string> + </test> + <test name="anymetrics" qual="all" compare="not_eq"> + <bool>true</bool> + </test> + <edit name="family" mode="append"> + <string>Century Schoolbook L</string> + </edit> + </match> + <match target="pattern"> + <test name="family"> + <string>Palatino</string> + </test> + <test name="anymetrics" qual="all" compare="not_eq"> + <bool>true</bool> + </test> + <edit name="family" mode="append"> + <string>URW Palladio L</string> + </edit> + </match> + <match target="pattern"> + <test name="family"> + <string>Times</string> + </test> + <test name="anymetrics" qual="all" compare="not_eq"> + <bool>true</bool> + </test> + <edit name="family" mode="append"> + <string>Nimbus Roman No9 L</string> + </edit> + </match> + <match target="pattern"> + <test name="family"> + <string>Zapf Chancery</string> + </test> + <test name="anymetrics" qual="all" compare="not_eq"> + <bool>true</bool> + </test> + <edit name="family" mode="append"> + <string>URW Chancery L</string> + </edit> + </match> + <match target="pattern"> + <test name="family"> + <string>Zapf Dingbats</string> + </test> + <test name="anymetrics" qual="all" compare="not_eq"> + <bool>true</bool> + </test> + <edit name="family" mode="append"> + <string>Dingbats</string> + </edit> + </match> + <match target="pattern"> + <test name="family"> + <string>Symbol</string> + </test> + <test name="anymetrics" qual="all" compare="not_eq"> + <bool>true</bool> + </test> + <edit name="family" mode="append" binding="same"> + <string>Standard Symbols L</string> + </edit> + </match> + +<!-- + Serif faces + --> + <alias> + <family>Nimbus Roman No9 L</family> + <default><family>serif</family></default> + </alias> +<!-- + Sans-serif faces + --> + <alias> + <family>Nimbus Sans L</family> + <default><family>sans-serif</family></default> + </alias> +<!-- + Monospace faces + --> + <alias> + <family>Nimbus Mono L</family> + <default><family>monospace</family></default> + </alias> + + +</fontconfig> diff --git a/WebKitTools/DumpRenderTree/mac/AccessibilityControllerMac.mm b/WebKitTools/DumpRenderTree/mac/AccessibilityControllerMac.mm index a191495..67e0fa4 100644 --- a/WebKitTools/DumpRenderTree/mac/AccessibilityControllerMac.mm +++ b/WebKitTools/DumpRenderTree/mac/AccessibilityControllerMac.mm @@ -53,3 +53,12 @@ AccessibilityUIElement AccessibilityController::rootElement() id accessibilityObject = [[mainFrame frameView] documentView]; return AccessibilityUIElement(accessibilityObject); } + +void AccessibilityController::setLogFocusEvents(bool) +{ +} + +void AccessibilityController::setLogScrollingStartEvents(bool) +{ +} + diff --git a/WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm b/WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm index b2cbb34..375dbad 100644 --- a/WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm +++ b/WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm @@ -311,6 +311,12 @@ JSStringRef AccessibilityUIElement::role() return concatenateAttributeAndValue(@"AXRole", role); } +JSStringRef AccessibilityUIElement::subrole() +{ + NSString* role = descriptionOfValue([m_element accessibilityAttributeValue:NSAccessibilitySubroleAttribute], m_element); + return concatenateAttributeAndValue(@"AXSubrole", role); +} + JSStringRef AccessibilityUIElement::title() { NSString* title = descriptionOfValue([m_element accessibilityAttributeValue:NSAccessibilityTitleAttribute], m_element); @@ -362,7 +368,7 @@ double AccessibilityUIElement::clickPointX() double AccessibilityUIElement::clickPointY() { NSValue* positionValue = [m_element accessibilityAttributeValue:@"AXClickPoint"]; - return static_cast<double>([positionValue pointValue].x); + return static_cast<double>([positionValue pointValue].y); } double AccessibilityUIElement::intValue() @@ -392,7 +398,7 @@ double AccessibilityUIElement::maxValue() JSStringRef AccessibilityUIElement::valueDescription() { NSString* valueDescription = [m_element accessibilityAttributeValue:NSAccessibilityValueDescriptionAttribute]; - if ([valueDescription isKindOfClass:[NSString class]]) + if ([valueDescription isKindOfClass:[NSString class]]) return [valueDescription createJSStringRef]; return 0; } @@ -449,6 +455,16 @@ JSStringRef AccessibilityUIElement::boundsForRange(unsigned location, unsigned l return [boundsDescription createJSStringRef]; } +JSStringRef AccessibilityUIElement::stringForRange(unsigned location, unsigned length) +{ + NSRange range = NSMakeRange(location, length); + id string = [m_element accessibilityAttributeValue:NSAccessibilityStringForRangeParameterizedAttribute forParameter:[NSValue valueWithRange:range]]; + if (![string isKindOfClass:[NSString class]]) + return 0; + + return [string createJSStringRef]; +} + JSStringRef AccessibilityUIElement::attributesOfColumnHeaders() { // not yet defined in AppKit... odd diff --git a/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm b/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm index d49248b..0c33381 100644 --- a/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm +++ b/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm @@ -38,6 +38,7 @@ #import "EditingDelegate.h" #import "EventSendingController.h" #import "FrameLoadDelegate.h" +#import "HistoryDelegate.h" #import "JavaScriptThreading.h" #import "LayoutTestController.h" #import "NavigationController.h" @@ -116,6 +117,7 @@ static FrameLoadDelegate *frameLoadDelegate; static UIDelegate *uiDelegate; static EditingDelegate *editingDelegate; static ResourceLoadDelegate *resourceLoadDelegate; +static HistoryDelegate *historyDelegate; PolicyDelegate *policyDelegate; static int dumpPixels; @@ -354,7 +356,8 @@ static NSString *libraryPathForDumpRenderTree() return [@"~/Library/Application Support/DumpRenderTree" stringByExpandingTildeInPath]; } -static void setDefaultsToConsistentValuesForTesting() +// Called before each test. +static void resetDefaultsToConsistentValues() { // Give some clear to undocumented defaults values static const int NoFontSmoothing = 0; @@ -384,15 +387,10 @@ static void setDefaultsToConsistentValuesForTesting() NSString *path = libraryPathForDumpRenderTree(); [defaults setObject:[path stringByAppendingPathComponent:@"Databases"] forKey:WebDatabaseDirectoryDefaultsKey]; [defaults setObject:[path stringByAppendingPathComponent:@"LocalCache"] forKey:WebKitLocalCacheDefaultsKey]; - NSURLCache *sharedCache = - [[NSURLCache alloc] initWithMemoryCapacity:1024 * 1024 - diskCapacity:0 - diskPath:[path stringByAppendingPathComponent:@"URLCache"]]; - [NSURLCache setSharedURLCache:sharedCache]; - [sharedCache release]; WebPreferences *preferences = [WebPreferences standardPreferences]; + [preferences setAllowUniversalAccessFromFileURLs:YES]; [preferences setStandardFontFamily:@"Times"]; [preferences setFixedFontFamily:@"Courier"]; [preferences setSerifFontFamily:@"Times"]; @@ -410,10 +408,58 @@ static void setDefaultsToConsistentValuesForTesting() [preferences setShouldPrintBackgrounds:YES]; [preferences setCacheModel:WebCacheModelDocumentBrowser]; [preferences setXSSAuditorEnabled:NO]; + [preferences setExperimentalNotificationsEnabled:NO]; + [preferences setExperimentalWebSocketsEnabled:NO]; + + [preferences setPrivateBrowsingEnabled:NO]; + [preferences setAuthorAndUserStylesEnabled:YES]; + [preferences setJavaScriptCanOpenWindowsAutomatically:YES]; + [preferences setOfflineWebApplicationCacheEnabled:YES]; + [preferences setDeveloperExtrasEnabled:NO]; + [preferences setXSSAuditorEnabled:NO]; + [preferences setLoadsImagesAutomatically:YES]; + if (persistentUserStyleSheetLocation) { + [preferences setUserStyleSheetLocation:[NSURL URLWithString:(NSString *)(persistentUserStyleSheetLocation.get())]]; + [preferences setUserStyleSheetEnabled:YES]; + } else + [preferences setUserStyleSheetEnabled:NO]; // The back/forward cache is causing problems due to layouts during transition from one page to another. // So, turn it off for now, but we might want to turn it back on some day. [preferences setUsesPageCache:NO]; + +#if defined(BUILDING_ON_LEOPARD) + // Disable hardware composititing to avoid timeouts and crashes from buggy CoreVideo teardown code. + // https://bugs.webkit.org/show_bug.cgi?id=28845 and rdar://problem/7228836 + SInt32 qtVersion; + OSErr err = Gestalt(gestaltQuickTimeVersion, &qtVersion); + assert(err == noErr); + // Bug 7228836 exists in at least 7.6.3 and 7.6.4, hopefully it will be fixed in 7.6.5. + // FIXME: Once we know the exact versions of QuickTime affected, we can update this check. + if (qtVersion <= 0x07640000) + [preferences setAcceleratedCompositingEnabled:NO]; + else +#endif + [preferences setAcceleratedCompositingEnabled:YES]; + + [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain]; + + setlocale(LC_ALL, ""); +} + +// Called once on DumpRenderTree startup. +static void setDefaultsToConsistentValuesForTesting() +{ + resetDefaultsToConsistentValues(); + + NSString *path = libraryPathForDumpRenderTree(); + NSURLCache *sharedCache = + [[NSURLCache alloc] initWithMemoryCapacity:1024 * 1024 + diskCapacity:0 + diskPath:[path stringByAppendingPathComponent:@"URLCache"]]; + [NSURLCache setSharedURLCache:sharedCache]; + [sharedCache release]; + } static void crashHandler(int sig) @@ -448,6 +494,7 @@ static void allocateGlobalControllers() editingDelegate = [[EditingDelegate alloc] init]; resourceLoadDelegate = [[ResourceLoadDelegate alloc] init]; policyDelegate = [[PolicyDelegate alloc] init]; + historyDelegate = [[HistoryDelegate alloc] init]; } // ObjC++ doens't seem to let me pass NSObject*& sadly. @@ -1033,11 +1080,16 @@ void dump() done = YES; } -static bool shouldLogFrameLoadDelegates(const char *pathOrURL) +static bool shouldLogFrameLoadDelegates(const char* pathOrURL) { return strstr(pathOrURL, "loading/"); } +static bool shouldLogHistoryDelegates(const char* pathOrURL) +{ + return strstr(pathOrURL, "globalhistory/"); +} + static void resetWebViewToConsistentStateBeforeTesting() { WebView *webView = [mainFrame webView]; @@ -1048,29 +1100,19 @@ static void resetWebViewToConsistentStateBeforeTesting() [webView setPolicyDelegate:nil]; [policyDelegate setPermissive:NO]; [policyDelegate setControllerToNotifyDone:0]; + [frameLoadDelegate resetToConsistentState]; [webView _setDashboardBehavior:WebDashboardBehaviorUseBackwardCompatibilityMode to:NO]; [webView _clearMainFrameName]; [[webView undoManager] removeAllActions]; + [WebView _removeAllUserContentFromGroup:[webView groupName]]; - WebPreferences *preferences = [webView preferences]; - [preferences setPrivateBrowsingEnabled:NO]; - [preferences setAuthorAndUserStylesEnabled:YES]; - [preferences setJavaScriptCanOpenWindowsAutomatically:YES]; - [preferences setOfflineWebApplicationCacheEnabled:YES]; - [preferences setDeveloperExtrasEnabled:NO]; - [preferences setXSSAuditorEnabled:NO]; - [preferences setLoadsImagesAutomatically:YES]; - - if (persistentUserStyleSheetLocation) { - [preferences setUserStyleSheetLocation:[NSURL URLWithString:(NSString *)(persistentUserStyleSheetLocation.get())]]; - [preferences setUserStyleSheetEnabled:YES]; - } else - [preferences setUserStyleSheetEnabled:NO]; + resetDefaultsToConsistentValues(); [[mainFrame webView] setSmartInsertDeleteEnabled:YES]; [[[mainFrame webView] inspector] setJavaScriptProfilingEnabled:NO]; [WebView _setUsesTestModeFocusRingColor:YES]; + [WebView _resetOriginAccessWhiteLists]; } static void runTest(const string& testPathOrURL) @@ -1120,6 +1162,11 @@ static void runTest(const string& testPathOrURL) if (shouldLogFrameLoadDelegates(pathOrURL.c_str())) gLayoutTestController->setDumpFrameLoadCallbacks(true); + if (shouldLogHistoryDelegates(pathOrURL.c_str())) + [[mainFrame webView] setHistoryDelegate:historyDelegate]; + else + [[mainFrame webView] setHistoryDelegate:nil]; + if ([WebHistory optionalSharedHistory]) [WebHistory setOptionalSharedHistory:nil]; lastMousePosition = NSZeroPoint; diff --git a/WebKitTools/DumpRenderTree/mac/EventSendingController.mm b/WebKitTools/DumpRenderTree/mac/EventSendingController.mm index 8c7c1c4..1cba53b 100644 --- a/WebKitTools/DumpRenderTree/mac/EventSendingController.mm +++ b/WebKitTools/DumpRenderTree/mac/EventSendingController.mm @@ -506,6 +506,15 @@ static NSEventType eventTypeForMouseButtonAndAction(int button, MouseAction acti eventCharacter = [NSString stringWithCharacters:&ch length:1]; } + // Compare the input string with the function-key names defined by the DOM spec (i.e. "F1",...,"F24"). + // If the input string is a function-key name, set its key code. + for (unsigned i = 1; i <= 24; i++) { + if ([character isEqualToString:[NSString stringWithFormat:@"F%u", i]]) { + const unichar ch = NSF1FunctionKey + (i - 1); + eventCharacter = [NSString stringWithCharacters:&ch length:1]; + } + } + NSString *charactersIgnoringModifiers = eventCharacter; int modifierFlags = 0; diff --git a/WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.h b/WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.h index 6c3cbdb..390a881 100644 --- a/WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.h +++ b/WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.h @@ -36,4 +36,7 @@ class GCController; AccessibilityController* accessibilityController; GCController* gcController; } + +- (void)resetToConsistentState; + @end diff --git a/WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.mm b/WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.mm index 4bf02ed..2838d2e 100644 --- a/WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.mm +++ b/WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.mm @@ -48,6 +48,7 @@ #import <WebKit/WebHTMLViewPrivate.h> #import <WebKit/WebKit.h> #import <WebKit/WebNSURLExtras.h> +#import <WebKit/WebSecurityOriginPrivate.h> #import <wtf/Assertions.h> @interface NSURLRequest (PrivateThingsWeShouldntReallyUse) @@ -123,6 +124,11 @@ dump(); } +- (void)resetToConsistentState +{ + accessibilityController->resetToConsistentState(); +} + - (void)webView:(WebView *)c locationChangeDone:(NSError *)error forDataSource:(WebDataSource *)dataSource { if ([dataSource webFrame] == topLoadingFrame) { @@ -348,4 +354,16 @@ } } +- (void)webViewDidDisplayInsecureContent:(WebView *)sender +{ + if (!done && gLayoutTestController->dumpFrameLoadCallbacks()) + printf ("didDisplayInsecureContent\n"); +} + +- (void)webView:(WebView *)sender didRunInsecureContent:(WebSecurityOrigin *)origin +{ + if (!done && gLayoutTestController->dumpFrameLoadCallbacks()) + printf ("didRunInsecureContent\n"); +} + @end diff --git a/WebKitTools/DumpRenderTree/mac/HistoryDelegate.h b/WebKitTools/DumpRenderTree/mac/HistoryDelegate.h new file mode 100644 index 0000000..c56d203 --- /dev/null +++ b/WebKitTools/DumpRenderTree/mac/HistoryDelegate.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <Cocoa/Cocoa.h> + +@interface HistoryDelegate : NSObject +{ +} + +@end diff --git a/WebKitTools/DumpRenderTree/mac/HistoryDelegate.mm b/WebKitTools/DumpRenderTree/mac/HistoryDelegate.mm new file mode 100644 index 0000000..9e2b836 --- /dev/null +++ b/WebKitTools/DumpRenderTree/mac/HistoryDelegate.mm @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#import "config.h" +#import "HistoryDelegate.h" + +#import "DumpRenderTree.h" +#import "LayoutTestController.h" + +#import <WebKit/WebNavigationData.h> + +@interface NSURL (DRTExtras) +- (NSString *)_drt_descriptionSuitableForTestResult; +@end + +@implementation HistoryDelegate + +- (void)webView:(WebView *)webView didNavigateWithNavigationData:(WebNavigationData *)navigationData inFrame:(WebFrame *)webFrame +{ + NSURL *url = [navigationData url] ? [NSURL URLWithString:[navigationData url]] : nil; + bool hasClientRedirect = [[navigationData clientRedirectSource] length]; + NSHTTPURLResponse *httpResponse = [[navigationData response] isKindOfClass:[NSHTTPURLResponse class]] ? (NSHTTPURLResponse *)[navigationData response] : nil; + bool wasFailure = [navigationData hasSubstituteData] || (httpResponse && [httpResponse statusCode] >= 400); + + printf("WebView navigated to url \"%s\" with title \"%s\" with HTTP equivalent method \"%s\". The navigation was %s and was %s%s.\n", + url ? [[url _drt_descriptionSuitableForTestResult] UTF8String] : "<none>", + [navigationData title] ? [[navigationData title] UTF8String] : "", + [navigationData originalRequest] ? [[[navigationData originalRequest] HTTPMethod] UTF8String] : "", + wasFailure ? "a failure" : "successful", + hasClientRedirect ? "a client redirect from " : "not a client redirect", + hasClientRedirect ? [[navigationData clientRedirectSource] UTF8String] : ""); +} + +- (void)webView:(WebView *)webView didPerformClientRedirectFromURL:(NSString *)sourceURL toURL:(NSString *)destinationURL inFrame:(WebFrame *)webFrame +{ + NSURL *source = [NSURL URLWithString:sourceURL]; + NSURL *dest = [NSURL URLWithString:destinationURL]; + printf("WebView performed a client redirect from \"%s\" to \"%s\".\n", [[source _drt_descriptionSuitableForTestResult] UTF8String], [[dest _drt_descriptionSuitableForTestResult] UTF8String]); +} + +- (void)webView:(WebView *)webView didPerformServerRedirectFromURL:(NSString *)sourceURL toURL:(NSString *)destinationURL inFrame:(WebFrame *)webFrame +{ + NSURL *source = [NSURL URLWithString:sourceURL]; + NSURL *dest = [NSURL URLWithString:destinationURL]; + printf("WebView performed a server redirect from \"%s\" to \"%s\".\n", [[source _drt_descriptionSuitableForTestResult] UTF8String], [[dest _drt_descriptionSuitableForTestResult] UTF8String]); +} + +- (void)webView:(WebView *)webView updateHistoryTitle:(NSString *)title forURL:(NSString *)url +{ + printf("WebView updated the title for history URL \"%s\" to \"%s\".\n", [[[NSURL URLWithString:url]_drt_descriptionSuitableForTestResult] UTF8String], [title UTF8String]); +} + +@end diff --git a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm index 591bb81..233c5fd 100644 --- a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm +++ b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm @@ -51,7 +51,8 @@ #import <WebKit/WebHTMLViewPrivate.h> #import <WebKit/WebHistory.h> #import <WebKit/WebHistoryPrivate.h> -#import <WebKit/WebInspector.h> +#import <WebKit/WebInspectorPrivate.h> +#import <WebKit/WebGeolocationMockPrivate.h> #import <WebKit/WebNSURLExtras.h> #import <WebKit/WebPreferences.h> #import <WebKit/WebPreferencesPrivate.h> @@ -59,6 +60,7 @@ #import <WebKit/WebTypesInternal.h> #import <WebKit/WebView.h> #import <WebKit/WebViewPrivate.h> +#import <WebKit/WebWorkersPrivate.h> #import <wtf/RetainPtr.h> @interface CommandValidationTarget : NSObject <NSValidatedUserInterfaceItem> @@ -163,6 +165,11 @@ size_t LayoutTestController::webHistoryItemCount() return [[[WebHistory optionalSharedHistory] allItems] count]; } +unsigned LayoutTestController::workerThreadCount() const +{ + return [WebWorkersPrivate workerThreadCount]; +} + void LayoutTestController::notifyDone() { if (m_waitToDump && !topLoadingFrame && !WorkQueue::shared()->count()) @@ -192,6 +199,16 @@ void LayoutTestController::setAcceptsEditing(bool newAcceptsEditing) [(EditingDelegate *)[[mainFrame webView] editingDelegate] setAcceptsEditing:newAcceptsEditing]; } +void LayoutTestController::setAlwaysAcceptCookies(bool alwaysAcceptCookies) +{ + if (alwaysAcceptCookies == m_alwaysAcceptCookies) + return; + + m_alwaysAcceptCookies = alwaysAcceptCookies; + NSHTTPCookieAcceptPolicy cookieAcceptPolicy = alwaysAcceptCookies ? NSHTTPCookieAcceptPolicyAlways : NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain; + [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:cookieAcceptPolicy]; +} + void LayoutTestController::setAppCacheMaximumSize(unsigned long long size) { [WebApplicationCache setMaximumSize:size]; @@ -218,6 +235,18 @@ void LayoutTestController::setDatabaseQuota(unsigned long long quota) [origin release]; } +void LayoutTestController::setMockGeolocationPosition(double latitude, double longitude, double accuracy) +{ + [WebGeolocationMock setPosition:latitude:longitude:accuracy]; +} + +void LayoutTestController::setMockGeolocationError(int code, JSStringRef message) +{ + RetainPtr<CFStringRef> messageCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, message)); + NSString *messageNS = (NSString *)messageCF.get(); + [WebGeolocationMock setError:code:messageNS]; +} + void LayoutTestController::setIconDatabaseEnabled(bool iconDatabaseEnabled) { // FIXME: Workaround <rdar://problem/6480108> @@ -293,6 +322,17 @@ void LayoutTestController::dispatchPendingLoadRequests() [[mainFrame webView] _dispatchPendingLoadRequests]; } +void LayoutTestController::overridePreference(JSStringRef key, JSStringRef value) +{ + RetainPtr<CFStringRef> keyCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, key)); + NSString *keyNS = (NSString *)keyCF.get(); + + RetainPtr<CFStringRef> valueCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, value)); + NSString *valueNS = (NSString *)valueCF.get(); + + [[WebPreferences standardPreferences] _setPreferenceForTestWithValue:valueNS forKey:keyNS]; +} + void LayoutTestController::setPersistentUserStyleSheetLocation(JSStringRef jsURL) { RetainPtr<CFStringRef> urlString(AdoptCF, JSStringCopyCFString(0, jsURL)); @@ -320,14 +360,11 @@ void LayoutTestController::setSelectTrailingWhitespaceEnabled(bool flag) [[mainFrame webView] setSelectTrailingWhitespaceEnabled:flag]; } -static const CFTimeInterval waitToDumpWatchdogInterval = 10.0; +static const CFTimeInterval waitToDumpWatchdogInterval = 15.0; static void waitUntilDoneWatchdogFired(CFRunLoopTimerRef timer, void* info) { - const char* message = "FAIL: Timed out waiting for notifyDone to be called\n"; - fprintf(stderr, "%s", message); - fprintf(stdout, "%s", message); - dump(); + gLayoutTestController->waitToDumpWatchdogTimerFired(); } void LayoutTestController::setWaitToDump(bool waitUntilDone) @@ -429,3 +466,45 @@ void LayoutTestController::waitForPolicyDelegate() [policyDelegate setControllerToNotifyDone:this]; [[mainFrame webView] setPolicyDelegate:policyDelegate]; } + +void LayoutTestController::whiteListAccessFromOrigin(JSStringRef sourceOrigin, JSStringRef destinationProtocol, JSStringRef destinationHost, bool allowDestinationSubdomains) +{ + RetainPtr<CFStringRef> sourceOriginCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, sourceOrigin)); + NSString *sourceOriginNS = (NSString *)sourceOriginCF.get(); + RetainPtr<CFStringRef> protocolCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, destinationProtocol)); + NSString *destinationProtocolNS = (NSString *)protocolCF.get(); + RetainPtr<CFStringRef> hostCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, destinationHost)); + NSString *destinationHostNS = (NSString *)hostCF.get(); + [WebView _whiteListAccessFromOrigin:sourceOriginNS destinationProtocol:destinationProtocolNS destinationHost:destinationHostNS allowDestinationSubdomains:allowDestinationSubdomains]; +} + +void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart) +{ + RetainPtr<CFStringRef> sourceCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, source)); + NSString *sourceNS = (NSString *)sourceCF.get(); + [WebView _addUserScriptToGroup:@"org.webkit.DumpRenderTree" source:sourceNS url:nil worldID:1 whitelist:nil blacklist:nil injectionTime:(runAtStart ? WebInjectAtDocumentStart : WebInjectAtDocumentEnd)]; +} + +void LayoutTestController::addUserStyleSheet(JSStringRef source) +{ + RetainPtr<CFStringRef> sourceCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, source)); + NSString *sourceNS = (NSString *)sourceCF.get(); + [WebView _addUserStyleSheetToGroup:@"org.webkit.DumpRenderTree" source:sourceNS url:nil worldID:1 whitelist:nil blacklist:nil]; +} + +void LayoutTestController::showWebInspector() +{ + [[[mainFrame webView] inspector] show:nil]; +} + +void LayoutTestController::closeWebInspector() +{ + [[[mainFrame webView] inspector] close:nil]; +} + +void LayoutTestController::evaluateInWebInspector(long callId, JSStringRef script) +{ + RetainPtr<CFStringRef> scriptCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, script)); + NSString *scriptNS = (NSString *)scriptCF.get(); + [[[mainFrame webView] inspector] evaluateInFrontend:nil callId:callId script:scriptNS]; +} diff --git a/WebKitTools/DumpRenderTree/mac/PerlSupport/DumpRenderTreeSupportTiger.pm b/WebKitTools/DumpRenderTree/mac/PerlSupport/DumpRenderTreeSupportTiger.pm index f0697fc..7b4ea34 100644 --- a/WebKitTools/DumpRenderTree/mac/PerlSupport/DumpRenderTreeSupportTiger.pm +++ b/WebKitTools/DumpRenderTree/mac/PerlSupport/DumpRenderTreeSupportTiger.pm @@ -1,52 +1,54 @@ -# Copyright (C) 2009 Apple Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY -# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -use strict; -use warnings; +# This file was automatically generated by SWIG +package DumpRenderTreeSupport; +require Exporter; +require DynaLoader; +@ISA = qw(Exporter DynaLoader); +package DumpRenderTreeSupportc; +bootstrap DumpRenderTreeSupport; +package DumpRenderTreeSupport; +@EXPORT = qw( ); + +# ---------- BASE METHODS ------------- package DumpRenderTreeSupport; -BEGIN { - use Exporter (); - our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); - $VERSION = 1.00; - @ISA = qw(Exporter); - @EXPORT = qw(&processIsCrashing); - %EXPORT_TAGS = ( ); - @EXPORT_OK = (); +sub TIEHASH { + my ($classname,$obj) = @_; + return bless $obj, $classname; +} + +sub CLEAR { } + +sub FIRSTKEY { } + +sub NEXTKEY { } + +sub FETCH { + my ($self,$field) = @_; + my $member_func = "swig_${field}_get"; + $self->$member_func(); +} + +sub STORE { + my ($self,$field,$newval) = @_; + my $member_func = "swig_${field}_set"; + $self->$member_func($newval); } -our @EXPORT_OK; - -sub processIsCrashing -{ - my $pid = shift; - my $tryingToExit = 0; - open PS, "ps -o state -p $pid |"; - <PS>; # skip header - $tryingToExit = 1 if <PS> =~ /E/; - close PS; - return $tryingToExit; +sub this { + my $ptr = shift; + return tied(%$ptr); } + +# ------- FUNCTION WRAPPERS -------- + +package DumpRenderTreeSupport; + +*processIsCrashing = *DumpRenderTreeSupportc::processIsCrashing; + +# ------- VARIABLE STUBS -------- + +package DumpRenderTreeSupport; + 1; diff --git a/WebKitTools/DumpRenderTree/mac/PerlSupport/DumpRenderTreeSupport_wrapTiger.c b/WebKitTools/DumpRenderTree/mac/PerlSupport/DumpRenderTreeSupport_wrapTiger.c new file mode 100644 index 0000000..f734989 --- /dev/null +++ b/WebKitTools/DumpRenderTree/mac/PerlSupport/DumpRenderTreeSupport_wrapTiger.c @@ -0,0 +1,1167 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.24 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + + +#ifndef SWIG_TEMPLATE_DISAMBIGUATOR +# if defined(__SUNPRO_CC) +# define SWIG_TEMPLATE_DISAMBIGUATOR template +# else +# define SWIG_TEMPLATE_DISAMBIGUATOR +# endif +#endif + +/*********************************************************************** + * swigrun.swg + * + * This file contains generic CAPI SWIG runtime support for pointer + * type checking. + * + ************************************************************************/ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "1" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +#define SWIG_QUOTE_STRING(x) #x +#define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +#define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +#define SWIG_TYPE_TABLE_NAME +#endif + +#include <string.h> + +#ifndef SWIGINLINE +#if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +#else +# define SWIGINLINE +#endif +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the swig runtime code. + In 99.9% of the cases, swig just needs to declare them as 'static'. + + But only do this if is strictly necessary, ie, if you have problems + with your compiler or so. +*/ +#ifndef SWIGRUNTIME +#define SWIGRUNTIME static +#endif +#ifndef SWIGRUNTIMEINLINE +#define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +typedef struct swig_type_info { + const char *name; + swig_converter_func converter; + const char *str; + void *clientdata; + swig_dycast_func dcast; + struct swig_type_info *next; + struct swig_type_info *prev; +} swig_type_info; + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class<int>" == "Class<int >", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return *f1 - *f2; + } + return (l1 - f1) - (l2 - f2); +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = SWIG_TypeNameComp(nb, ne, tb, te) == 0; + if (*ne) ++ne; + } + return equiv; +} + +/* + Register a type mapping with the type-checking +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeRegisterTL(swig_type_info **tl, swig_type_info *ti) { + swig_type_info *tc, *head, *ret, *next; + /* Check to see if this type has already been registered */ + tc = *tl; + while (tc) { + /* check simple type equivalence */ + int typeequiv = (strcmp(tc->name, ti->name) == 0); + /* check full type equivalence, resolving typedefs */ + if (!typeequiv) { + /* only if tc is not a typedef (no '|' on it) */ + if (tc->str && ti->str && !strstr(tc->str,"|")) { + typeequiv = SWIG_TypeEquiv(ti->str,tc->str); + } + } + if (typeequiv) { + /* Already exists in the table. Just add additional types to the list */ + if (ti->clientdata) tc->clientdata = ti->clientdata; + head = tc; + next = tc->next; + goto l1; + } + tc = tc->prev; + } + head = ti; + next = 0; + + /* Place in list */ + ti->prev = *tl; + *tl = ti; + + /* Build linked lists */ + l1: + ret = head; + tc = ti + 1; + /* Patch up the rest of the links */ + while (tc->name) { + head->next = tc; + tc->prev = head; + head = tc; + tc++; + } + if (next) next->prev = head; + head->next = next; + + return ret; +} + +/* + Check the typename +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + swig_type_info *s; + if (!ty) return 0; /* Void pointer */ + s = ty->next; /* First element always just a name */ + do { + if (strcmp(s->name,c) == 0) { + if (s == ty->next) return s; + /* Move s to the top of the linked list */ + s->prev->next = s->next; + if (s->next) { + s->next->prev = s->prev; + } + /* Insert s as second element in the list */ + s->next = ty->next; + if (ty->next) ty->next->prev = s; + ty->next = s; + s->prev = ty; + return s; + } + s = s->next; + } while (s && (s != ty->next)); + return 0; +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_type_info *ty, void *ptr) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Search for a swig_type_info structure +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryTL(swig_type_info *tl, const char *name) { + swig_type_info *ty = tl; + while (ty) { + if (ty->str && (SWIG_TypeEquiv(ty->str,name))) return ty; + if (ty->name && (strcmp(name,ty->name) == 0)) return ty; + ty = ty->prev; + } + return 0; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientDataTL(swig_type_info *tl, swig_type_info *ti, void *clientdata) { + swig_type_info *tc, *equiv; + if (ti->clientdata) return; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + equiv = ti->next; + while (equiv) { + if (!equiv->converter) { + tc = tl; + while (tc) { + if ((strcmp(tc->name, equiv->name) == 0)) + SWIG_TypeClientDataTL(tl,tc,clientdata); + tc = tc->prev; + } + } + equiv = equiv->next; + } +} + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static char hex[17] = "0123456789abcdef"; + unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; + register unsigned char uu; + for (; u != eu; ++u) { + uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + register unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register int d = *(c++); + register unsigned char uu = 0; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + This function will propagate the clientdata field of type to any new + swig_type_info structures that have been added into the list of + equivalent types. It is like calling SWIG_TypeClientData(type, + clientdata) a second time. +*/ +SWIGRUNTIME void +SWIG_PropagateClientDataTL(swig_type_info *tl, swig_type_info *type) { + swig_type_info *equiv = type->next; + swig_type_info *tc; + if (!type->clientdata) return; + while (equiv) { + if (!equiv->converter) { + tc = tl; + while (tc) { + if ((strcmp(tc->name, equiv->name) == 0) && !tc->clientdata) + SWIG_TypeClientDataTL(tl,tc, type->clientdata); + tc = tc->prev; + } + } + equiv = equiv->next; + } +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/*********************************************************************** + * common.swg + * + * This file contains generic SWIG runtime support for pointer + * type checking as well as a few commonly used macros to control + * external linkage. + * + * Author : David Beazley (beazley@cs.uchicago.edu) + * + * Copyright (c) 1999-2000, The University of Chicago + * + * This file may be freely redistributed without license or fee provided + * this copyright message remains intact. + ************************************************************************/ + + +#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if !defined(STATIC_LINKED) +# define SWIGEXPORT(a) __declspec(dllexport) a +# else +# define SWIGEXPORT(a) a +# endif +#else +# define SWIGEXPORT(a) a +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + +/*************************************************************************/ + + +/* The static type info list */ + +static swig_type_info *swig_type_list = 0; +static swig_type_info **swig_type_list_handle = &swig_type_list; + + +/* Register a type mapping with the type-checking */ +static swig_type_info * +SWIG_TypeRegister(swig_type_info *ti) { + return SWIG_TypeRegisterTL(swig_type_list_handle, ti); +} + +/* Search for a swig_type_info structure */ +static swig_type_info * +SWIG_TypeQuery(const char *name) { + return SWIG_TypeQueryTL(*swig_type_list_handle, name); +} + +/* Set the clientdata field for a type */ +static void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + SWIG_TypeClientDataTL(*swig_type_list_handle, ti, clientdata); +} + +/* This function will propagate the clientdata field of type to +* any new swig_type_info structures that have been added into the list +* of equivalent types. It is like calling +* SWIG_TypeClientData(type, clientdata) a second time. +*/ +static void +SWIG_PropagateClientData(swig_type_info *type) { + SWIG_PropagateClientDataTL(*swig_type_list_handle, type); +} + +#ifdef __cplusplus +} +#endif + +/* ---------------------------------------------------------------------- -*- c -*- + * perl5.swg + * + * Perl5 runtime library + * $Header: /cvsroot/swig/SWIG/Lib/perl5/perlrun.swg,v 1.20 2004/11/29 23:13:57 wuzzeb Exp $ + * ----------------------------------------------------------------------------- */ + +#define SWIGPERL +#define SWIGPERL5 +#ifdef __cplusplus +/* Needed on some windows machines---since MS plays funny games with the header files under C++ */ +#include <math.h> +#include <stdlib.h> +extern "C" { +#endif +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +/* Get rid of free and malloc defined by perl */ +#undef free +#undef malloc + +#ifndef pTHX_ +#define pTHX_ +#endif + +#include <string.h> +#ifdef __cplusplus +} +#endif + +/* Macro to call an XS function */ + +#ifdef PERL_OBJECT +# define SWIG_CALLXS(_name) _name(cv,pPerl) +#else +# ifndef MULTIPLICITY +# define SWIG_CALLXS(_name) _name(cv) +# else +# define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv) +# endif +#endif + +/* Contract support */ + +#define SWIG_contract_assert(expr,msg) if (!(expr)) { SWIG_croak(msg); } else + +/* Note: SwigMagicFuncHack is a typedef used to get the C++ compiler to just shut up already */ + +#ifdef PERL_OBJECT +#define MAGIC_PPERL CPerlObj *pPerl = (CPerlObj *) this; +typedef int (CPerlObj::*SwigMagicFunc)(SV *, MAGIC *); + +#ifdef __cplusplus +extern "C" { +#endif +typedef int (CPerlObj::*SwigMagicFuncHack)(SV *, MAGIC *); +#ifdef __cplusplus +} +#endif + +#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b) +#define SWIGCLASS_STATIC +#else +#define MAGIC_PPERL +#define SWIGCLASS_STATIC static +#ifndef MULTIPLICITY +#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b) +typedef int (*SwigMagicFunc)(SV *, MAGIC *); + +#ifdef __cplusplus +extern "C" { +#endif +typedef int (*SwigMagicFuncHack)(SV *, MAGIC *); +#ifdef __cplusplus +} +#endif + + +#else +#define SWIG_MAGIC(a,b) (struct interpreter *interp, SV *a, MAGIC *b) +typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *); +#ifdef __cplusplus +extern "C" { +#endif +typedef int (*SwigMagicFuncHack)(struct interpreter *, SV *, MAGIC *); +#ifdef __cplusplus +} +#endif + +#endif +#endif + +#if defined(WIN32) && defined(PERL_OBJECT) && !defined(PerlIO_exportFILE) +#define PerlIO_exportFILE(fh,fl) (FILE*)(fh) +#endif + +/* Modifications for newer Perl 5.005 releases */ + +#if !defined(PERL_REVISION) || ((PERL_REVISION >= 5) && ((PERL_VERSION < 5) || ((PERL_VERSION == 5) && (PERL_SUBVERSION < 50)))) +# ifndef PL_sv_yes +# define PL_sv_yes sv_yes +# endif +# ifndef PL_sv_undef +# define PL_sv_undef sv_undef +# endif +# ifndef PL_na +# define PL_na na +# endif +#endif + +#include <stdlib.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define SWIG_OWNER 1 +#define SWIG_SHADOW 2 + +/* Common SWIG API */ + +#ifdef PERL_OBJECT +# define SWIG_ConvertPtr(obj, pp, type, flags) \ + SWIG_Perl_ConvertPtr(pPerl, obj, pp, type, flags) +# define SWIG_NewPointerObj(p, type, flags) \ + SWIG_Perl_NewPointerObj(pPerl, p, type, flags) +# define SWIG_MakePackedObj(sv, p, s, type) \ + SWIG_Perl_MakePackedObj(pPerl, sv, p, s, type) +# define SWIG_ConvertPacked(obj, p, s, type, flags) \ + SWIG_Perl_ConvertPacked(pPerl, obj, p, s, type, flags) + +#else +# define SWIG_ConvertPtr(obj, pp, type, flags) \ + SWIG_Perl_ConvertPtr(obj, pp, type, flags) +# define SWIG_NewPointerObj(p, type, flags) \ + SWIG_Perl_NewPointerObj(p, type, flags) +# define SWIG_MakePackedObj(sv, p, s, type) \ + SWIG_Perl_MakePackedObj(sv, p, s, type ) +# define SWIG_ConvertPacked(obj, p, s, type, flags) \ + SWIG_Perl_ConvertPacked(obj, p, s, type, flags) +#endif + +/* Perl-specific API */ +#ifdef PERL_OBJECT +# define SWIG_MakePtr(sv, ptr, type, flags) \ + SWIG_Perl_MakePtr(pPerl, sv, ptr, type, flags) +# define SWIG_SetError(str) \ + SWIG_Perl_SetError(pPerl, str) +#else +# define SWIG_MakePtr(sv, ptr, type, flags) \ + SWIG_Perl_MakePtr(sv, ptr, type, flags) +# define SWIG_SetError(str) \ + SWIG_Perl_SetError(str) +# define SWIG_SetErrorSV(str) \ + SWIG_Perl_SetErrorSV(str) +#endif + +#define SWIG_SetErrorf SWIG_Perl_SetErrorf + + +#ifdef PERL_OBJECT +# define SWIG_MAYBE_PERL_OBJECT CPerlObj *pPerl, +#else +# define SWIG_MAYBE_PERL_OBJECT +#endif + +static swig_type_info ** +SWIG_Perl_GetTypeListHandle() { + static void *type_pointer = (void *)0; + SV *pointer; + + /* first check if pointer already created */ + if (!type_pointer) { + pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, FALSE); + if (pointer && SvOK(pointer)) { + type_pointer = INT2PTR(swig_type_info **, SvIV(pointer)); + } + } + + return (swig_type_info **) type_pointer; +} + +/* + Search for a swig_type_info structure + */ +SWIGRUNTIMEINLINE swig_type_info * +SWIG_Perl_GetTypeList() { + swig_type_info **tlh = SWIG_Perl_GetTypeListHandle(); + return tlh ? *tlh : (swig_type_info*)0; +} + +#define SWIG_Runtime_GetTypeList SWIG_Perl_GetTypeList + +static swig_type_info * +SWIG_Perl_TypeCheckRV(SWIG_MAYBE_PERL_OBJECT SV *rv, swig_type_info *ty) { + swig_type_info *s; + if (!ty) return 0; /* Void pointer */ + s = ty->next; /* First element always just a name */ + do { + if (sv_derived_from(rv, (char *) s->name)) { + if (s == ty->next) return s; + /* Move s to the top of the linked list */ + s->prev->next = s->next; + if (s->next) { + s->next->prev = s->prev; + } + /* Insert s as second element in the list */ + s->next = ty->next; + if (ty->next) ty->next->prev = s; + ty->next = s; + s->prev = ty; + return s; + } + s = s->next; + } while (s && (s != ty->next)); + return 0; +} + +/* Function for getting a pointer value */ + +static int +SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags) { + swig_type_info *tc; + void *voidptr = (void *)0; + + /* If magical, apply more magic */ + if (SvGMAGICAL(sv)) + mg_get(sv); + + /* Check to see if this is an object */ + if (sv_isobject(sv)) { + SV *tsv = (SV*) SvRV(sv); + IV tmp = 0; + if ((SvTYPE(tsv) == SVt_PVHV)) { + MAGIC *mg; + if (SvMAGICAL(tsv)) { + mg = mg_find(tsv,'P'); + if (mg) { + sv = mg->mg_obj; + if (sv_isobject(sv)) { + tmp = SvIV((SV*)SvRV(sv)); + } + } + } else { + return -1; + } + } else { + tmp = SvIV((SV*)SvRV(sv)); + } + voidptr = (void *)tmp; + if (!_t) { + *(ptr) = voidptr; + return 0; + } + } else if (! SvOK(sv)) { /* Check for undef */ + *(ptr) = (void *) 0; + return 0; + } else if (SvTYPE(sv) == SVt_RV) { /* Check for NULL pointer */ + *(ptr) = (void *) 0; + if (!SvROK(sv)) + return 0; + else + return -1; + } else { /* Don't know what it is */ + *(ptr) = (void *) 0; + return -1; + } + if (_t) { + /* Now see if the types match */ + char *_c = HvNAME(SvSTASH(SvRV(sv))); + tc = SWIG_TypeCheck(_c,_t); + if (!tc) { + *ptr = voidptr; + return -1; + } + *ptr = SWIG_TypeCast(tc,voidptr); + return 0; + } + *ptr = voidptr; + return 0; +} + +static void +SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, int flags) { + if (ptr && (flags & SWIG_SHADOW)) { + SV *self; + SV *obj=newSV(0); + HV *hash=newHV(); + HV *stash; + sv_setref_pv(obj, (char *) t->name, ptr); + stash=SvSTASH(SvRV(obj)); + if (flags & SWIG_OWNER) { + HV *hv; + GV *gv=*(GV**)hv_fetch(stash, "OWNER", 5, TRUE); + if (!isGV(gv)) + gv_init(gv, stash, "OWNER", 5, FALSE); + hv=GvHVn(gv); + hv_store_ent(hv, obj, newSViv(1), 0); + } + sv_magic((SV *)hash, (SV *)obj, 'P', Nullch, 0); + SvREFCNT_dec(obj); + self=newRV_noinc((SV *)hash); + sv_setsv(sv, self); + SvREFCNT_dec((SV *)self); + sv_bless(sv, stash); + } + else { + sv_setref_pv(sv, (char *) t->name, ptr); + } +} + +static SWIGINLINE SV * +SWIG_Perl_NewPointerObj(SWIG_MAYBE_PERL_OBJECT void *ptr, swig_type_info *t, int flags) { + SV *result = sv_newmortal(); + SWIG_MakePtr(result, ptr, t, flags); + return result; +} + +static void + SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, int sz, swig_type_info *type) { + char result[1024]; + char *r = result; + if ((2*sz + 1 + strlen(type->name)) > 1000) return; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + strcpy(r,type->name); + sv_setpv(sv, result); +} + +/* Convert a packed value value */ +static int +SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *obj, void *ptr, int sz, swig_type_info *ty, int flags) { + swig_type_info *tc; + const char *c = 0; + + if ((!obj) || (!SvOK(obj))) return -1; + c = SvPV(obj, PL_na); + /* Pointer values must start with leading underscore */ + if (*c != '_') return -1; + c++; + c = SWIG_UnpackData(c,ptr,sz); + if (ty) { + tc = SWIG_TypeCheck(c,ty); + if (!tc) return -1; + } + return 0; +} + +static SWIGINLINE void +SWIG_Perl_SetError(SWIG_MAYBE_PERL_OBJECT const char *error) { + if (error) sv_setpv(perl_get_sv("@", TRUE), error); +} + +static SWIGINLINE void +SWIG_Perl_SetErrorSV(SWIG_MAYBE_PERL_OBJECT SV *error) { + if (error) sv_setsv(perl_get_sv("@", TRUE), error); +} + +static void +SWIG_Perl_SetErrorf(const char *fmt, ...) { + va_list args; + va_start(args, fmt); + sv_vsetpvfn(perl_get_sv("@", TRUE), fmt, strlen(fmt), &args, Null(SV**), 0, Null(bool*)); + va_end(args); +} + +/* Macros for low-level exception handling */ +#define SWIG_fail goto fail +#define SWIG_croak(x) { SWIG_SetError(x); goto fail; } +#define SWIG_croakSV(x) { SWIG_SetErrorSV(x); goto fail; } +/* most preprocessors do not support vararg macros :-( */ +/* #define SWIG_croakf(x...) { SWIG_SetErrorf(x); goto fail; } */ + + +typedef XS(SwigPerlWrapper); +typedef SwigPerlWrapper *SwigPerlWrapperPtr; + +/* Structure for command table */ +typedef struct { + const char *name; + SwigPerlWrapperPtr wrapper; +} swig_command_info; + +/* Information for constant table */ + +#define SWIG_INT 1 +#define SWIG_FLOAT 2 +#define SWIG_STRING 3 +#define SWIG_POINTER 4 +#define SWIG_BINARY 5 + +/* Constant information structure */ +typedef struct swig_constant_info { + int type; + const char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; +} swig_constant_info; + +#ifdef __cplusplus +} +#endif + +/* Structure for variable table */ +typedef struct { + const char *name; + SwigMagicFunc set; + SwigMagicFunc get; + swig_type_info **type; +} swig_variable_info; + +/* Magic variable code */ +#ifndef PERL_OBJECT +#define swig_create_magic(s,a,b,c) _swig_create_magic(s,a,b,c) + #ifndef MULTIPLICITY + static void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) { + #else + static void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *)) { + #endif +#else +# define swig_create_magic(s,a,b,c) _swig_create_magic(pPerl,s,a,b,c) +static void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *)) { +#endif + MAGIC *mg; + sv_magic(sv,sv,'U',(char *) name,strlen(name)); + mg = mg_find(sv,'U'); + mg->mg_virtual = (MGVTBL *) malloc(sizeof(MGVTBL)); + mg->mg_virtual->svt_get = (SwigMagicFuncHack) get; + mg->mg_virtual->svt_set = (SwigMagicFuncHack) set; + mg->mg_virtual->svt_len = 0; + mg->mg_virtual->svt_clear = 0; + mg->mg_virtual->svt_free = 0; +} + + + + + + +#ifdef do_open + #undef do_open +#endif +#ifdef do_close + #undef do_close +#endif +#ifdef scalar + #undef scalar +#endif +#ifdef list + #undef list +#endif +#ifdef apply + #undef apply +#endif +#ifdef convert + #undef convert +#endif +#ifdef Error + #undef Error +#endif +#ifdef form + #undef form +#endif +#ifdef vform + #undef vform +#endif +#ifdef LABEL + #undef LABEL +#endif +#ifdef METHOD + #undef METHOD +#endif +#ifdef Move + #undef Move +#endif +#ifdef yylex + #undef yylex +#endif +#ifdef yyparse + #undef yyparse +#endif +#ifdef yyerror + #undef yyerror +#endif +#ifdef invert + #undef invert +#endif +#ifdef ref + #undef ref +#endif +#ifdef ENTER + #undef ENTER +#endif + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +static swig_type_info *swig_types[1]; + +/* -------- TYPES TABLE (END) -------- */ + +#define SWIG_init boot_DumpRenderTreeSupport + +#define SWIG_name "DumpRenderTreeSupportc::boot_DumpRenderTreeSupport" +#define SWIG_prefix "DumpRenderTreeSupportc::" + +#ifdef __cplusplus +extern "C" +#endif +#ifndef PERL_OBJECT +#ifndef MULTIPLICITY +SWIGEXPORT(void) SWIG_init (CV* cv); +#else +SWIGEXPORT(void) SWIG_init (pTHXo_ CV* cv); +#endif +#else +SWIGEXPORT(void) SWIG_init (CV *cv, CPerlObj *); +#endif + +int processIsCrashing(int); +#ifdef PERL_OBJECT +#define MAGIC_CLASS _wrap_DumpRenderTreeSupport_var:: +class _wrap_DumpRenderTreeSupport_var : public CPerlObj { +public: +#else +#define MAGIC_CLASS +#endif +SWIGCLASS_STATIC int swig_magic_readonly(pTHX_ SV *sv, MAGIC *mg) { + MAGIC_PPERL + sv = sv; mg = mg; + croak("Value is read-only."); + return 0; +} + + +#ifdef PERL_OBJECT +}; +#endif + +#ifdef __cplusplus +extern "C" { +#endif +XS(_wrap_processIsCrashing) { + { + int arg1 ; + int result; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: processIsCrashing(pid);"); + } + arg1 = (int) SvIV(ST(0)); + result = (int)processIsCrashing(arg1); + + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++), (IV) result); + XSRETURN(argvi); + fail: + ; + } + croak(Nullch); +} + + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + + +static swig_type_info *swig_types_initial[] = { +0 +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +static swig_constant_info swig_constants[] = { +{0,0,0,0,0,0} +}; +#ifdef __cplusplus +} +#endif +static swig_variable_info swig_variables[] = { +{0,0,0,0} +}; +static swig_command_info swig_commands[] = { +{"DumpRenderTreeSupportc::processIsCrashing", _wrap_processIsCrashing}, +{0,0} +}; + + +static void SWIG_Perl_SetTypeListHandle(swig_type_info **handle) { + SV *pointer; + + /* create a new pointer */ + pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TRUE); + sv_setiv(pointer, PTR2IV(swig_type_list_handle)); +} + +static swig_type_info ** +SWIG_Perl_LookupTypePointer(swig_type_info **type_list_handle) { + swig_type_info **type_pointer; + + /* first check if module already created */ + type_pointer = SWIG_Perl_GetTypeListHandle(); + if (type_pointer) { + return type_pointer; + } else { + /* create a new module and variable */ + SWIG_Perl_SetTypeListHandle(type_list_handle); + return type_list_handle; + } +} + + +#ifdef __cplusplus +extern "C" +#endif + +XS(SWIG_init) { + dXSARGS; + int i; + static int _init = 0; + if (!_init) { + swig_type_list_handle = SWIG_Perl_LookupTypePointer(swig_type_list_handle); + for (i = 0; swig_types_initial[i]; i++) { + swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]); + } + _init = 1; + } + + /* Install commands */ + for (i = 0; swig_commands[i].name; i++) { + newXS((char*) swig_commands[i].name,swig_commands[i].wrapper, (char*)__FILE__); + } + + /* Install variables */ + for (i = 0; swig_variables[i].name; i++) { + SV *sv; + sv = perl_get_sv((char*) swig_variables[i].name, TRUE | 0x2); + if (swig_variables[i].type) { + SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0); + } else { + sv_setiv(sv,(IV) 0); + } + swig_create_magic(sv, (char *) swig_variables[i].name, swig_variables[i].set, swig_variables[i].get); + } + + /* Install constant */ + for (i = 0; swig_constants[i].type; i++) { + SV *sv; + sv = perl_get_sv((char*)swig_constants[i].name, TRUE | 0x2); + switch(swig_constants[i].type) { + case SWIG_INT: + sv_setiv(sv, (IV) swig_constants[i].lvalue); + break; + case SWIG_FLOAT: + sv_setnv(sv, (double) swig_constants[i].dvalue); + break; + case SWIG_STRING: + sv_setpv(sv, (char *) swig_constants[i].pvalue); + break; + case SWIG_POINTER: + SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype),0); + break; + case SWIG_BINARY: + SWIG_MakePackedObj(sv, swig_constants[i].pvalue, swig_constants[i].lvalue, *(swig_constants[i].ptype)); + break; + default: + break; + } + SvREADONLY_on(sv); + } + + ST(0) = &PL_sv_yes; + XSRETURN(1); +} + diff --git a/WebKitTools/DumpRenderTree/mac/PerlSupport/Makefile b/WebKitTools/DumpRenderTree/mac/PerlSupport/Makefile index 6c97877..56b2ed2 100644 --- a/WebKitTools/DumpRenderTree/mac/PerlSupport/Makefile +++ b/WebKitTools/DumpRenderTree/mac/PerlSupport/Makefile @@ -24,39 +24,45 @@ CONFIGURATION_BUILD_DIR ?= . OUTPUT_DIR=$(CONFIGURATION_BUILD_DIR) -WRAPPER=$(OUTPUT_DIR)/DerivedSources/DumpRenderTree/DumpRenderTreeSupport_wrap.c +WRAPPER_DIR=$(OUTPUT_DIR)/DerivedSources/DumpRenderTree +WRAPPER=$(WRAPPER_DIR)/DumpRenderTreeSupport_wrap.c PERL_MODULE=$(OUTPUT_DIR)/DumpRenderTreeSupport.pm DYLIB=$(OUTPUT_DIR)/DumpRenderTreeSupport.dylib DUMPRENDERTREE=$(OUTPUT_DIR)/DumpRenderTree +PERL=/usr/bin/perl OSX_VERSION=$(shell sw_vers -productVersion | cut -d. -f 2) ifneq "$(OSX_VERSION)" "4" -PERL=/usr/bin/perl + SWIG=/usr/bin/swig all: $(DYLIB) $(PERL_MODULE) $(WRAPPER) $(PERL_MODULE): DumpRenderTreeSupport.c $(DUMPRENDERTREE) - mkdir -p $$(dirname $(WRAPPER)) + mkdir -p $(WRAPPER_DIR) $(SWIG) -o $(WRAPPER) -outdir $(OUTPUT_DIR) -perl -module DumpRenderTreeSupport $< -$(DYLIB): DumpRenderTreeSupport.c $(WRAPPER) - gcc -g -dynamiclib -o $(DYLIB) `$(PERL) -MExtUtils::Embed -eperl_inc` `$(PERL) -MExtUtils::Embed -eldopts` $^ - else -all: $(PERL_MODULE) +all: $(DYLIB) $(PERL_MODULE) + +$(WRAPPER): DumpRenderTreeSupport_wrapTiger.c $(DUMPRENDERTREE) + mkdir -p $(WRAPPER_DIR) + cp DumpRenderTreeSupport_wrapTiger.c $(WRAPPER) -$(PERL_MODULE): DumpRenderTreeSupportTiger.pm - cp $^ $(PERL_MODULE) +$(PERL_MODULE): DumpRenderTreeSupportTiger.pm $(DUMPRENDERTREE) + cp DumpRenderTreeSupportTiger.pm $(PERL_MODULE) endif +$(DYLIB): DumpRenderTreeSupport.c $(WRAPPER) + gcc -g -dynamiclib -o $(DYLIB) `$(PERL) -MExtUtils::Embed -eperl_inc` `$(PERL) -MExtUtils::Embed -eldopts` $^ + clean: rm -f $(WRAPPER) $(PERL_MODULE) $(DYLIB) diff --git a/WebKitTools/DumpRenderTree/mac/ResourceLoadDelegate.mm b/WebKitTools/DumpRenderTree/mac/ResourceLoadDelegate.mm index 0089f7f..3aaba59 100644 --- a/WebKitTools/DumpRenderTree/mac/ResourceLoadDelegate.mm +++ b/WebKitTools/DumpRenderTree/mac/ResourceLoadDelegate.mm @@ -153,6 +153,20 @@ - (void)webView:(WebView *)wv resource:(id)identifier didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)dataSource { + if (!gLayoutTestController->handlesAuthenticationChallenges()) + return; + + const char* user = gLayoutTestController->authenticationUsername().c_str(); + NSString *nsUser = [NSString stringWithFormat:@"%s", user ? user : ""]; + + const char* password = gLayoutTestController->authenticationPassword().c_str(); + NSString *nsPassword = [NSString stringWithFormat:@"%s", password ? password : ""]; + + NSString *string = [NSString stringWithFormat:@"%@ - didReceiveAuthenticationChallenge - Responding with %@:%@", identifier, nsUser, nsPassword]; + printf("%s\n", [string UTF8String]); + + [[challenge sender] useCredential:[NSURLCredential credentialWithUser:nsUser password:nsPassword persistence:NSURLCredentialPersistenceForSession] + forAuthenticationChallenge:challenge]; } - (void)webView:(WebView *)wv resource:(id)identifier didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge fromDataSource:(WebDataSource *)dataSource diff --git a/WebKitTools/DumpRenderTree/mac/UIDelegate.mm b/WebKitTools/DumpRenderTree/mac/UIDelegate.mm index 807ea08..a52d5be 100644 --- a/WebKitTools/DumpRenderTree/mac/UIDelegate.mm +++ b/WebKitTools/DumpRenderTree/mac/UIDelegate.mm @@ -34,6 +34,7 @@ #import "EventSendingController.h" #import "LayoutTestController.h" #import <WebKit/WebFramePrivate.h> +#import <WebKit/WebGeolocationPrivate.h> #import <WebKit/WebHTMLViewPrivate.h> #import <WebKit/WebSecurityOriginPrivate.h> #import <WebKit/WebView.h> @@ -150,6 +151,12 @@ DumpRenderTreeDraggingInfo *draggingInfo = nil; printf("UI DELEGATE STATUS CALLBACK: setStatusText:%s\n", [text UTF8String]); } +- (void)webView:(WebView *)sender frame:(WebFrame *)frame requestGeolocationPermission:(WebGeolocation *)geolocation securityOrigin:(WebSecurityOrigin *)origin +{ + if (gLayoutTestController->isGeolocationPermissionSet()) + [geolocation setIsAllowed:gLayoutTestController->geolocationPermission()]; +} + - (void)dealloc { [draggingInfo release]; diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp index 1afb761..83626ac 100644 --- a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp +++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp @@ -45,6 +45,7 @@ #include <QUrl> #include <QFocusEvent> #include <QFontDatabase> +#include <QNetworkRequest> #include <qwebpage.h> #include <qwebframe.h> @@ -83,9 +84,14 @@ public: bool javaScriptConfirm(QWebFrame *frame, const QString& msg); bool javaScriptPrompt(QWebFrame *frame, const QString& msg, const QString& defaultValue, QString* result); + void resetSettings(); + public slots: bool shouldInterruptJavaScript() { return false; } +protected: + bool acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest& request, NavigationType type); + private slots: void setViewGeometry(const QRect &r) { @@ -100,21 +106,42 @@ private: WebPage::WebPage(QWidget *parent, DumpRenderTree *drt) : QWebPage(parent), m_drt(drt) { - settings()->setFontSize(QWebSettings::MinimumFontSize, 5); - settings()->setFontSize(QWebSettings::MinimumLogicalFontSize, 5); - // To get DRT compliant to some layout tests lets set the default fontsize to 13. - settings()->setFontSize(QWebSettings::DefaultFontSize, 13); - settings()->setFontSize(QWebSettings::DefaultFixedFontSize, 13); - settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true); - settings()->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true); - settings()->setAttribute(QWebSettings::LinksIncludedInFocusChain, false); - settings()->setAttribute(QWebSettings::PluginsEnabled, true); + QWebSettings* globalSettings = QWebSettings::globalSettings(); + + globalSettings->setFontSize(QWebSettings::MinimumFontSize, 5); + globalSettings->setFontSize(QWebSettings::MinimumLogicalFontSize, 5); + globalSettings->setFontSize(QWebSettings::DefaultFontSize, 16); + globalSettings->setFontSize(QWebSettings::DefaultFixedFontSize, 13); + + globalSettings->setAttribute(QWebSettings::JavascriptCanOpenWindows, true); + globalSettings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true); + globalSettings->setAttribute(QWebSettings::LinksIncludedInFocusChain, false); + globalSettings->setAttribute(QWebSettings::PluginsEnabled, true); + globalSettings->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true); + globalSettings->setAttribute(QWebSettings::JavascriptEnabled, true); + globalSettings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false); + globalSettings->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, false); + connect(this, SIGNAL(geometryChangeRequested(const QRect &)), this, SLOT(setViewGeometry(const QRect & ))); setPluginFactory(new TestPlugin(this)); } +void WebPage::resetSettings() +{ + // After each layout test, reset the settings that may have been changed by + // layoutTestController.overridePreference() or similar. + + settings()->resetFontSize(QWebSettings::DefaultFontSize); + + settings()->resetAttribute(QWebSettings::JavascriptCanOpenWindows); + settings()->resetAttribute(QWebSettings::JavascriptEnabled); + settings()->resetAttribute(QWebSettings::PrivateBrowsingEnabled); + settings()->resetAttribute(QWebSettings::LinksIncludedInFocusChain); + settings()->resetAttribute(QWebSettings::OfflineWebApplicationCacheEnabled); +} + QWebPage *WebPage::createWindow(QWebPage::WebWindowType) { return m_drt->createWindow(); @@ -143,12 +170,49 @@ bool WebPage::javaScriptPrompt(QWebFrame*, const QString& msg, const QString& de return true; } +bool WebPage::acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest& request, NavigationType type) +{ + if (m_drt->layoutTestController()->waitForPolicy()) { + QString url = QString::fromUtf8(request.url().toEncoded()); + QString typeDescription; + + switch (type) { + case NavigationTypeLinkClicked: + typeDescription = "link clicked"; + break; + case NavigationTypeFormSubmitted: + typeDescription = "form submitted"; + break; + case NavigationTypeBackOrForward: + typeDescription = "back/forward"; + break; + case NavigationTypeReload: + typeDescription = "reload"; + break; + case NavigationTypeFormResubmitted: + typeDescription = "form resubmitted"; + break; + case NavigationTypeOther: + typeDescription = "other"; + break; + default: + typeDescription = "illegal value"; + } + + fprintf(stdout, "Policy delegate: attempt to load %s with navigation type '%s'\n", + url.toUtf8().constData(), typeDescription.toUtf8().constData()); + m_drt->layoutTestController()->notifyDone(); + } + return QWebPage::acceptNavigationRequest(frame, request, type); +} + DumpRenderTree::DumpRenderTree() : m_dumpPixels(false) , m_stdin(0) , m_notifier(0) { qt_drt_overwritePluginDirectories(); + QWebSettings::enablePersistentStorage(); m_controller = new LayoutTestController(this); connect(m_controller, SIGNAL(done()), this, SLOT(dump())); @@ -168,6 +232,8 @@ DumpRenderTree::DumpRenderTree() SLOT(titleChanged(const QString&))); connect(m_page, SIGNAL(databaseQuotaExceeded(QWebFrame*,QString)), this, SLOT(dumpDatabaseQuota(QWebFrame*,QString))); + connect(m_page, SIGNAL(statusBarMessage(const QString&)), + this, SLOT(statusBarMessage(const QString&))); m_eventSender = new EventSender(m_page); m_textInputController = new TextInputController(m_page); @@ -210,6 +276,8 @@ void DumpRenderTree::resetToConsistentStateBeforeTesting() m_page->blockSignals(false); m_page->mainFrame()->setZoomFactor(1.0); + + static_cast<WebPage*>(m_page)->resetSettings(); qt_drt_clearFrameName(m_page->mainFrame()); WorkQueue::shared()->clear(); @@ -217,6 +285,9 @@ void DumpRenderTree::resetToConsistentStateBeforeTesting() //WorkQueue::shared()->setFrozen(false); m_controller->reset(); + QWebSecurityOrigin::resetOriginAccessWhiteLists(); + + setlocale(LC_ALL, ""); } void DumpRenderTree::open(const QUrl& aurl) @@ -463,6 +534,14 @@ void DumpRenderTree::dumpDatabaseQuota(QWebFrame* frame, const QString& dbName) origin.setDatabaseQuota(5 * 1024 * 1024); } +void DumpRenderTree::statusBarMessage(const QString& message) +{ + if (!m_controller->shouldDumpStatusCallbacks()) + return; + + printf("UI DELEGATE STATUS CALLBACK: setStatusText:%s\n", message.toUtf8().constData()); +} + QWebPage *DumpRenderTree::createWindow() { if (!m_controller->canOpenWindows()) diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.h b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.h index 28ae1b6..c5b4801 100644 --- a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.h +++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.h @@ -88,6 +88,7 @@ public Q_SLOTS: void titleChanged(const QString &s); void connectFrame(QWebFrame *frame); void dumpDatabaseQuota(QWebFrame* frame, const QString& dbName); + void statusBarMessage(const QString& message); Q_SIGNALS: void quit(); diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro index ca97ed5..0daf8bd 100644 --- a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro +++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro @@ -9,8 +9,8 @@ DESTDIR = ../../../bin CONFIG += link_pkgconfig PKGCONFIG += fontconfig -QT = core gui -macx: QT += xml network +QT = core gui network +macx: QT += xml HEADERS = WorkQueue.h WorkQueueItem.h DumpRenderTree.h jsobjects.h testplugin.h SOURCES = WorkQueue.cpp DumpRenderTree.cpp main.cpp jsobjects.cpp testplugin.cpp @@ -22,3 +22,5 @@ unix:!mac { lessThan(QT_MINOR_VERSION, 4) { DEFINES += QT_BEGIN_NAMESPACE="" QT_END_NAMESPACE="" } + +DEFINES+=USE_SYSTEM_MALLOC diff --git a/WebKitTools/DumpRenderTree/qt/ImageDiff.cpp b/WebKitTools/DumpRenderTree/qt/ImageDiff.cpp index 6aebced..704ca13 100644 --- a/WebKitTools/DumpRenderTree/qt/ImageDiff.cpp +++ b/WebKitTools/DumpRenderTree/qt/ImageDiff.cpp @@ -119,7 +119,7 @@ int main(int argc, char* argv[]) difference = 0; } else { difference = round(difference * 100) / 100; - difference = qMax(difference, 0.01); + difference = qMax(difference, qreal(0.01)); } if (!count) { diff --git a/WebKitTools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro b/WebKitTools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro index 686fbc1..7f502f8 100644 --- a/WebKitTools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro +++ b/WebKitTools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro @@ -1,14 +1,35 @@ TEMPLATE = lib -TARGET = TestNetscapePlugin +TARGET = TestNetscapePlugIn + VPATH = ../../gtk/TestNetscapePlugin ../../TestNetscapePlugIn.subproj include(../../../../WebKit.pri) + DESTDIR = $$OUTPUT_DIR/lib/plugins + +mac { + CONFIG += plugin + CONFIG += plugin_bundle + QMAKE_INFO_PLIST = ../../TestNetscapePlugIn.subproj/Info.plist + QMAKE_PLUGIN_BUNDLE_NAME = $$TARGET + QMAKE_BUNDLE_LOCATION += "Contents/MacOS" + + !build_pass:CONFIG += build_all + debug_and_release:TARGET = $$qtLibraryTarget($$TARGET) +} + INCLUDEPATH += ../../../../JavaScriptCore \ ../../gtk/TestNetscapePlugin/ForwardingHeaders \ ../../gtk/TestNetscapePlugin/ForwardingHeaders/WebKit \ ../../../../WebCore \ ../../../../WebCore/bridge \ ../../TestNetscapePlugIn.subproj -SOURCES = TestNetscapePlugin.cpp \ - PluginObject.cpp \ - TestObject.cpp \ + +SOURCES = PluginObject.cpp \ + TestObject.cpp + +mac { + SOURCES += ../../TestNetscapePlugIn.subproj/main.cpp + LIBS += -framework Carbon +} else { + SOURCES += ../../gtk/TestNetscapePlugin/TestNetscapePlugin.cpp +} diff --git a/WebKitTools/DumpRenderTree/qt/jsobjects.cpp b/WebKitTools/DumpRenderTree/qt/jsobjects.cpp index 7e5e168..b2d8528 100644 --- a/WebKitTools/DumpRenderTree/qt/jsobjects.cpp +++ b/WebKitTools/DumpRenderTree/qt/jsobjects.cpp @@ -27,19 +27,20 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <jsobjects.h> -#include <qwebpage.h> -#include <qwebhistory.h> -#include <qwebframe.h> -#include <qwebsecurityorigin.h> -#include <qwebdatabase.h> -#include <qevent.h> + +#include "DumpRenderTree.h" +#include "WorkQueue.h" +#include "WorkQueueItem.h" + #include <qapplication.h> #include <qevent.h> #include <qtimer.h> +#include <qwebdatabase.h> +#include <qwebframe.h> +#include <qwebhistory.h> +#include <qwebpage.h> +#include <qwebsecurityorigin.h> -#include "DumpRenderTree.h" -#include "WorkQueueItem.h" -#include "WorkQueue.h" extern void qt_dump_editing_callbacks(bool b); extern void qt_dump_resource_load_callbacks(bool b); extern void qt_drt_setJavaScriptProfilingEnabled(QWebFrame*, bool enabled); @@ -47,7 +48,7 @@ extern bool qt_drt_pauseAnimation(QWebFrame*, const QString &name, double time, extern bool qt_drt_pauseTransitionOfProperty(QWebFrame*, const QString &name, double time, const QString &elementId); extern int qt_drt_numberOfActiveAnimations(QWebFrame*); -QWebFrame *findFrameNamed(const QString &frameName, QWebFrame *frame) +QWebFrame* findFrameNamed(const QString &frameName, QWebFrame* frame) { if (frame->frameName() == frameName) return frame; @@ -64,7 +65,7 @@ bool LoadItem::invoke() const //qDebug() << ">>>LoadItem::invoke"; Q_ASSERT(m_webPage); - QWebFrame *frame = 0; + QWebFrame* frame = 0; const QString t = target(); if (t.isEmpty()) frame = m_webPage->mainFrame(); @@ -128,11 +129,12 @@ void LayoutTestController::reset() m_waitForDone = false; m_dumpTitleChanges = false; m_dumpDatabaseCallbacks = false; + m_dumpStatusCallbacks = false; m_timeoutTimer.stop(); m_topLoadingFrame = 0; + m_waitForPolicy = false; qt_dump_editing_callbacks(false); qt_dump_resource_load_callbacks(false); - QWebSettings::globalSettings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, false); } void LayoutTestController::processWork() @@ -151,6 +153,12 @@ void LayoutTestController::maybeDump(bool success) { Q_ASSERT(sender() == m_topLoadingFrame); + // as the function is called on loadFinished, the test might + // already have dumped and thus no longer be active, thus + // bail out here. + if (!m_isLoading) + return; + m_topLoadingFrame = 0; WorkQueue::shared()->setFrozen(true); // first complete load freezes the queue for the rest of this test @@ -180,6 +188,8 @@ void LayoutTestController::notifyDone() m_timeoutTimer.stop(); emit done(); m_isLoading = false; + m_waitForDone = false; + m_waitForPolicy = false; } int LayoutTestController::windowCount() @@ -237,7 +247,7 @@ void LayoutTestController::queueScript(const QString &url) void LayoutTestController::provisionalLoad() { - QWebFrame *frame = qobject_cast<QWebFrame*>(sender()); + QWebFrame* frame = qobject_cast<QWebFrame*>(sender()); if (!m_topLoadingFrame && m_isLoading) m_topLoadingFrame = frame; } @@ -247,9 +257,8 @@ void LayoutTestController::timerEvent(QTimerEvent *ev) if (ev->timerId() == m_timeoutTimer.timerId()) { qDebug() << ">>>>>>>>>>>>> timeout"; notifyDone(); - } else { + } else QObject::timerEvent(ev); - } } QString LayoutTestController::encodeHostName(const QString &host) @@ -279,14 +288,19 @@ void LayoutTestController::setFixedContentsSize(int width, int height) void LayoutTestController::setPrivateBrowsingEnabled(bool enable) { - QWebSettings::globalSettings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, enable); + m_drt->webPage()->settings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, enable); +} + +void LayoutTestController::setPopupBlockingEnabled(bool enable) +{ + m_drt->webPage()->settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, !enable); } bool LayoutTestController::pauseAnimationAtTimeOnElementWithId(const QString &animationName, double time, const QString &elementId) { - QWebFrame *frame = m_drt->webPage()->mainFrame(); + QWebFrame* frame = m_drt->webPage()->mainFrame(); Q_ASSERT(frame); return qt_drt_pauseAnimation(frame, animationName, time, elementId); } @@ -295,14 +309,14 @@ bool LayoutTestController::pauseTransitionAtTimeOnElementWithId(const QString &p double time, const QString &elementId) { - QWebFrame *frame = m_drt->webPage()->mainFrame(); + QWebFrame* frame = m_drt->webPage()->mainFrame(); Q_ASSERT(frame); return qt_drt_pauseTransitionOfProperty(frame, propertyName, time, elementId); } unsigned LayoutTestController::numberOfActiveAnimations() const { - QWebFrame *frame = m_drt->webPage()->mainFrame(); + QWebFrame* frame = m_drt->webPage()->mainFrame(); Q_ASSERT(frame); return qt_drt_numberOfActiveAnimations(frame); } @@ -330,23 +344,88 @@ void LayoutTestController::clearAllDatabases() QWebDatabase::removeAllDatabases(); } +void LayoutTestController::whiteListAccessFromOrigin(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains) +{ + QWebSecurityOrigin::whiteListAccessFromOrigin(sourceOrigin, destinationProtocol, destinationHost, allowDestinationSubdomains); +} + +void LayoutTestController::waitForPolicyDelegate() +{ + m_waitForPolicy = true; + waitUntilDone(); +} + +void LayoutTestController::overridePreference(const QString& name, const QVariant& value) +{ + QWebSettings* settings = m_topLoadingFrame->page()->settings(); + + if (name == "WebKitJavaScriptEnabled") + settings->setAttribute(QWebSettings::JavascriptEnabled, value.toBool()); + else if (name == "WebKitTabToLinksPreferenceKey") + settings->setAttribute(QWebSettings::LinksIncludedInFocusChain, value.toBool()); + else if (name == "WebKitOfflineWebApplicationCacheEnabled") + settings->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, value.toBool()); + else if (name == "WebKitDefaultFontSize") + settings->setFontSize(QWebSettings::DefaultFontSize, value.toInt()); +} + EventSender::EventSender(QWebPage *parent) : QObject(parent) { m_page = parent; } -void EventSender::mouseDown() -{ +void EventSender::mouseDown(int button) +{ + Qt::MouseButton mouseButton; + switch (button) { + case 0: + mouseButton = Qt::LeftButton; + break; + case 1: + mouseButton = Qt::MidButton; + break; + case 2: + mouseButton = Qt::RightButton; + break; + case 3: + // fast/events/mouse-click-events expects the 4th button to be treated as the middle button + mouseButton = Qt::MidButton; + break; + default: + mouseButton = Qt::LeftButton; + break; + } + // qDebug() << "EventSender::mouseDown" << frame; - QMouseEvent event(QEvent::MouseButtonPress, m_mousePos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); + QMouseEvent event(QEvent::MouseButtonPress, m_mousePos, mouseButton, mouseButton, Qt::NoModifier); QApplication::sendEvent(m_page, &event); } -void EventSender::mouseUp() -{ +void EventSender::mouseUp(int button) +{ + Qt::MouseButton mouseButton; + switch (button) { + case 0: + mouseButton = Qt::LeftButton; + break; + case 1: + mouseButton = Qt::MidButton; + break; + case 2: + mouseButton = Qt::RightButton; + break; + case 3: + // fast/events/mouse-click-events expects the 4th button to be treated as the middle button + mouseButton = Qt::MidButton; + break; + default: + mouseButton = Qt::LeftButton; + break; + } + // qDebug() << "EventSender::mouseUp" << frame; - QMouseEvent event(QEvent::MouseButtonRelease, m_mousePos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); + QMouseEvent event(QEvent::MouseButtonRelease, m_mousePos, mouseButton, mouseButton, Qt::NoModifier); QApplication::sendEvent(m_page, &event); } @@ -440,17 +519,71 @@ void EventSender::keyDown(const QString &string, const QStringList &modifiers) s = QString(); code = Qt::Key_Home; modifs = 0; - } else { + } else code = string.unicode()->toUpper().unicode(); + } else { + qDebug() << ">>>>>>>>> keyDown" << string; + + if (string.startsWith(QLatin1Char('F')) && string.count() <= 3) { + s = s.mid(1); + int functionKey = s.toInt(); + Q_ASSERT(functionKey >= 1 && functionKey <= 35); + code = Qt::Key_F1 + (functionKey - 1); + // map special keycode strings used by the tests to something that works for Qt/X11 + } else if (string == QLatin1String("leftArrow")) { + s = QString(); + code = Qt::Key_Left; + } else if (string == QLatin1String("rightArrow")) { + s = QString(); + code = Qt::Key_Right; + } else if (string == QLatin1String("upArrow")) { + s = QString(); + code = Qt::Key_Up; + } else if (string == QLatin1String("downArrow")) { + s = QString(); + code = Qt::Key_Down; + } else if (string == QLatin1String("pageUp")) { + s = QString(); + code = Qt::Key_PageUp; + } else if (string == QLatin1String("pageDown")) { + s = QString(); + code = Qt::Key_PageDown; + } else if (string == QLatin1String("home")) { + s = QString(); + code = Qt::Key_Home; + } else if (string == QLatin1String("end")) { + s = QString(); + code = Qt::Key_End; + } else if (string == QLatin1String("delete")) { + s = QString(); + code = Qt::Key_Delete; } } QKeyEvent event(QEvent::KeyPress, code, modifs, s); QApplication::sendEvent(m_page, &event); + QKeyEvent event2(QEvent::KeyRelease, code, modifs, s); + QApplication::sendEvent(m_page, &event2); +} + +void EventSender::contextClick() +{ + QMouseEvent event(QEvent::MouseButtonPress, m_mousePos, Qt::RightButton, Qt::RightButton, Qt::NoModifier); + QApplication::sendEvent(m_page, &event); + QMouseEvent event2(QEvent::MouseButtonRelease, m_mousePos, Qt::RightButton, Qt::RightButton, Qt::NoModifier); + QApplication::sendEvent(m_page, &event2); +} + +void EventSender::scheduleAsynchronousClick() +{ + QMouseEvent* event = new QMouseEvent(QEvent::MouseButtonPress, m_mousePos, Qt::LeftButton, Qt::RightButton, Qt::NoModifier); + QApplication::postEvent(m_page, event); + QMouseEvent* event2 = new QMouseEvent(QEvent::MouseButtonRelease, m_mousePos, Qt::LeftButton, Qt::RightButton, Qt::NoModifier); + QApplication::postEvent(m_page, event2); } -QWebFrame *EventSender::frameUnderMouse() const +QWebFrame* EventSender::frameUnderMouse() const { - QWebFrame *frame = m_page->mainFrame(); + QWebFrame* frame = m_page->mainFrame(); redo: QList<QWebFrame*> children = frame->childFrames(); @@ -478,81 +611,81 @@ void TextInputController::doCommand(const QString &command) if (command == "moveBackwardAndModifySelection:") { modifiers |= Qt::ShiftModifier; keycode = Qt::Key_Left; - } else if(command =="moveDown:") { + } else if (command =="moveDown:") { keycode = Qt::Key_Down; - } else if(command =="moveDownAndModifySelection:") { + } else if (command =="moveDownAndModifySelection:") { modifiers |= Qt::ShiftModifier; keycode = Qt::Key_Down; - } else if(command =="moveForward:") { + } else if (command =="moveForward:") { keycode = Qt::Key_Right; - } else if(command =="moveForwardAndModifySelection:") { + } else if (command =="moveForwardAndModifySelection:") { modifiers |= Qt::ShiftModifier; keycode = Qt::Key_Right; - } else if(command =="moveLeft:") { + } else if (command =="moveLeft:") { keycode = Qt::Key_Left; - } else if(command =="moveLeftAndModifySelection:") { + } else if (command =="moveLeftAndModifySelection:") { modifiers |= Qt::ShiftModifier; keycode = Qt::Key_Left; - } else if(command =="moveRight:") { + } else if (command =="moveRight:") { keycode = Qt::Key_Right; - } else if(command =="moveRightAndModifySelection:") { + } else if (command =="moveRightAndModifySelection:") { modifiers |= Qt::ShiftModifier; keycode = Qt::Key_Right; - } else if(command =="moveToBeginningOfDocument:") { + } else if (command =="moveToBeginningOfDocument:") { modifiers |= Qt::ControlModifier; keycode = Qt::Key_Home; - } else if(command =="moveToBeginningOfLine:") { + } else if (command =="moveToBeginningOfLine:") { keycode = Qt::Key_Home; -// } else if(command =="moveToBeginningOfParagraph:") { - } else if(command =="moveToEndOfDocument:") { +// } else if (command =="moveToBeginningOfParagraph:") { + } else if (command =="moveToEndOfDocument:") { modifiers |= Qt::ControlModifier; keycode = Qt::Key_End; - } else if(command =="moveToEndOfLine:") { + } else if (command =="moveToEndOfLine:") { keycode = Qt::Key_End; -// } else if(command =="moveToEndOfParagraph:") { - } else if(command =="moveUp:") { +// } else if (command =="moveToEndOfParagraph:") { + } else if (command =="moveUp:") { keycode = Qt::Key_Up; - } else if(command =="moveUpAndModifySelection:") { + } else if (command =="moveUpAndModifySelection:") { modifiers |= Qt::ShiftModifier; keycode = Qt::Key_Up; - } else if(command =="moveWordBackward:") { + } else if (command =="moveWordBackward:") { modifiers |= Qt::ControlModifier; keycode = Qt::Key_Up; - } else if(command =="moveWordBackwardAndModifySelection:") { + } else if (command =="moveWordBackwardAndModifySelection:") { modifiers |= Qt::ShiftModifier; modifiers |= Qt::ControlModifier; keycode = Qt::Key_Left; - } else if(command =="moveWordForward:") { + } else if (command =="moveWordForward:") { modifiers |= Qt::ControlModifier; keycode = Qt::Key_Right; - } else if(command =="moveWordForwardAndModifySelection:") { + } else if (command =="moveWordForwardAndModifySelection:") { modifiers |= Qt::ControlModifier; modifiers |= Qt::ShiftModifier; keycode = Qt::Key_Right; - } else if(command =="moveWordLeft:") { + } else if (command =="moveWordLeft:") { modifiers |= Qt::ControlModifier; keycode = Qt::Key_Left; - } else if(command =="moveWordRight:") { + } else if (command =="moveWordRight:") { modifiers |= Qt::ControlModifier; keycode = Qt::Key_Left; - } else if(command =="moveWordRightAndModifySelection:") { + } else if (command =="moveWordRightAndModifySelection:") { modifiers |= Qt::ShiftModifier; modifiers |= Qt::ControlModifier; keycode = Qt::Key_Right; - } else if(command =="moveWordLeftAndModifySelection:") { + } else if (command =="moveWordLeftAndModifySelection:") { modifiers |= Qt::ShiftModifier; modifiers |= Qt::ControlModifier; keycode = Qt::Key_Left; - } else if(command =="pageDown:") { - keycode = Qt::Key_PageDown; - } else if(command =="pageUp:") { - keycode = Qt::Key_PageUp; - } else if(command == "deleteWordBackward:") { + } else if (command =="pageDown:") { + keycode = Qt::Key_PageDown; + } else if (command =="pageUp:") { + keycode = Qt::Key_PageUp; + } else if (command == "deleteWordBackward:") { modifiers |= Qt::ControlModifier; keycode = Qt::Key_Backspace; - } else if(command == "deleteBackward:") { + } else if (command == "deleteBackward:") { keycode = Qt::Key_Backspace; - } else if(command == "deleteForward:") { + } else if (command == "deleteForward:") { keycode = Qt::Key_Delete; } QKeyEvent event(QEvent::KeyPress, keycode, modifiers); diff --git a/WebKitTools/DumpRenderTree/qt/jsobjects.h b/WebKitTools/DumpRenderTree/qt/jsobjects.h index 8e6dd20..c076bb9 100644 --- a/WebKitTools/DumpRenderTree/qt/jsobjects.h +++ b/WebKitTools/DumpRenderTree/qt/jsobjects.h @@ -53,9 +53,11 @@ public: bool shouldDumpBackForwardList() const { return m_dumpBackForwardList; } bool shouldDumpChildrenAsText() const { return m_dumpChildrenAsText; } bool shouldDumpDatabaseCallbacks() const { return m_dumpDatabaseCallbacks; } + bool shouldDumpStatusCallbacks() const { return m_dumpStatusCallbacks; } bool shouldWaitUntilDone() const { return m_waitForDone; } bool canOpenWindows() const { return m_canOpenWindows; } bool shouldDumpTitleChanges() const { return m_dumpTitleChanges; } + bool waitForPolicy() const { return m_waitForPolicy; } void reset(); @@ -70,6 +72,7 @@ public slots: void dumpAsText() { m_textDump = true; } void dumpChildFramesAsText() { m_dumpChildrenAsText = true; } void dumpDatabaseCallbacks() { m_dumpDatabaseCallbacks = true; } + void dumpStatusCallbacks() { m_dumpStatusCallbacks = true; } void setCanOpenWindows() { m_canOpenWindows = true; } void waitUntilDone(); void notifyDone(); @@ -93,16 +96,23 @@ public slots: void setJavaScriptProfilingEnabled(bool enable); void setFixedContentsSize(int width, int height); void setPrivateBrowsingEnabled(bool enable); + void setPopupBlockingEnabled(bool enable); bool pauseAnimationAtTimeOnElementWithId(const QString &animationName, double time, const QString &elementId); bool pauseTransitionAtTimeOnElementWithId(const QString &propertyName, double time, const QString &elementId); unsigned numberOfActiveAnimations() const; + + void whiteListAccessFromOrigin(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains); + void dispatchPendingLoadRequests(); void disableImageLoading(); void setDatabaseQuota(int size); void clearAllDatabases(); + void waitForPolicyDelegate(); + void overridePreference(const QString& name, const QVariant& value); + private slots: void processWork(); @@ -115,6 +125,9 @@ private: bool m_waitForDone; bool m_dumpTitleChanges; bool m_dumpDatabaseCallbacks; + bool m_dumpStatusCallbacks; + bool m_waitForPolicy; + QBasicTimer m_timeoutTimer; QWebFrame *m_topLoadingFrame; WebCore::DumpRenderTree *m_drt; @@ -130,12 +143,14 @@ public: EventSender(QWebPage *parent); public slots: - void mouseDown(); - void mouseUp(); + void mouseDown(int button = 0); + void mouseUp(int button = 0); void mouseMoveTo(int x, int y); void leapForward(int ms); void keyDown(const QString &string, const QStringList &modifiers=QStringList()); void clearKillRing() {} + void contextClick(); + void scheduleAsynchronousClick(); private: QPoint m_mousePos; diff --git a/WebKitTools/DumpRenderTree/win/AccessibilityControllerWin.cpp b/WebKitTools/DumpRenderTree/win/AccessibilityControllerWin.cpp index b6e45f2..ac64efb 100644 --- a/WebKitTools/DumpRenderTree/win/AccessibilityControllerWin.cpp +++ b/WebKitTools/DumpRenderTree/win/AccessibilityControllerWin.cpp @@ -32,13 +32,19 @@ #include <WebCore/COMPtr.h> #include <WebKit/WebKit.h> #include <oleacc.h> +#include <string> + +using namespace std; AccessibilityController::AccessibilityController() + : m_focusEventHook(0) + , m_scrollingStartEventHook(0) { } AccessibilityController::~AccessibilityController() { + setLogFocusEvents(false); } AccessibilityUIElement AccessibilityController::focusedElement() @@ -82,3 +88,76 @@ AccessibilityUIElement AccessibilityController::rootElement() return rootAccessible; } + +static void CALLBACK logEventProc(HWINEVENTHOOK hWinEventHook, DWORD event, HWND hwnd, LONG idObject, LONG idChild, DWORD, DWORD) +{ + // Get the accessible object for this event. + COMPtr<IAccessible> parentObject; + + VARIANT vChild; + VariantInit(&vChild); + + HRESULT hr = AccessibleObjectFromEvent(hwnd, idObject, idChild, &parentObject, &vChild); + ASSERT(SUCCEEDED(hr)); + + // Get the name of the focused element, and log it to stdout. + BSTR nameBSTR; + hr = parentObject->get_accName(vChild, &nameBSTR); + ASSERT(SUCCEEDED(hr)); + wstring name(nameBSTR, ::SysStringLen(nameBSTR)); + SysFreeString(nameBSTR); + + switch (event) { + case EVENT_OBJECT_FOCUS: + printf("Received focus event for object '%S'.\n", name.c_str()); + break; + + case EVENT_SYSTEM_SCROLLINGSTART: + printf("Received scrolling start event for object '%S'.\n", name.c_str()); + break; + + default: + printf("Received unknown event for object '%S'.\n", name.c_str()); + break; + } +} + +void AccessibilityController::setLogFocusEvents(bool logFocusEvents) +{ + if (!!m_focusEventHook == logFocusEvents) + return; + + if (!logFocusEvents) { + UnhookWinEvent(m_focusEventHook); + m_focusEventHook = 0; + return; + } + + // Ensure that accessibility is initialized for the WebView by querying for + // the root accessible object. + rootElement(); + + m_focusEventHook = SetWinEventHook(EVENT_OBJECT_FOCUS, EVENT_OBJECT_FOCUS, GetModuleHandle(0), logEventProc, GetCurrentProcessId(), 0, WINEVENT_INCONTEXT); + + ASSERT(m_focusEventHook); +} + +void AccessibilityController::setLogScrollingStartEvents(bool logScrollingStartEvents) +{ + if (!!m_scrollingStartEventHook == logScrollingStartEvents) + return; + + if (!logScrollingStartEvents) { + UnhookWinEvent(m_scrollingStartEventHook); + m_scrollingStartEventHook = 0; + return; + } + + // Ensure that accessibility is initialized for the WebView by querying for + // the root accessible object. + rootElement(); + + m_scrollingStartEventHook = SetWinEventHook(EVENT_SYSTEM_SCROLLINGSTART, EVENT_SYSTEM_SCROLLINGSTART, GetModuleHandle(0), logEventProc, GetCurrentProcessId(), 0, WINEVENT_INCONTEXT); + + ASSERT(m_scrollingStartEventHook); +} diff --git a/WebKitTools/DumpRenderTree/win/AccessibilityUIElementWin.cpp b/WebKitTools/DumpRenderTree/win/AccessibilityUIElementWin.cpp index cfcfc54..de3d9ff 100644 --- a/WebKitTools/DumpRenderTree/win/AccessibilityUIElementWin.cpp +++ b/WebKitTools/DumpRenderTree/win/AccessibilityUIElementWin.cpp @@ -157,6 +157,11 @@ JSStringRef AccessibilityUIElement::role() return JSStringCreateWithCharacters(roleText, _tcslen(roleText)); } +JSStringRef AccessibilityUIElement::subrole() +{ + return 0; +} + JSStringRef AccessibilityUIElement::title() { BSTR titleBSTR; @@ -325,6 +330,11 @@ JSStringRef AccessibilityUIElement::boundsForRange(unsigned location, unsigned l return JSStringCreateWithCharacters(0, 0); } +JSStringRef AccessibilityUIElement::stringForRange(unsigned, unsigned) +{ + return JSStringCreateWithCharacters(0, 0); +} + AccessibilityUIElement AccessibilityUIElement::cellForColumnAndRow(unsigned column, unsigned row) { return 0; diff --git a/WebKitTools/DumpRenderTree/win/DRTDesktopNotificationPresenter.cpp b/WebKitTools/DumpRenderTree/win/DRTDesktopNotificationPresenter.cpp new file mode 100644 index 0000000..b18b724 --- /dev/null +++ b/WebKitTools/DumpRenderTree/win/DRTDesktopNotificationPresenter.cpp @@ -0,0 +1,144 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "DRTDesktopNotificationPresenter.h" + +#include "DumpRenderTree.h" +#include "LayoutTestController.h" +#include <JavaScriptCore/JSStringRef.h> +#include <JavaScriptCore/JSStringRefBSTR.h> +#include <WebCore/NotificationPresenter.h> + +DRTDesktopNotificationPresenter::DRTDesktopNotificationPresenter() + : m_refCount(1) {} + +HRESULT STDMETHODCALLTYPE DRTDesktopNotificationPresenter::QueryInterface(REFIID riid, void** ppvObject) +{ + *ppvObject = 0; + if (IsEqualGUID(riid, IID_IUnknown)) + *ppvObject = static_cast<DRTDesktopNotificationPresenter*>(this); + else if (IsEqualGUID(riid, IID_IWebDesktopNotificationsDelegate)) + *ppvObject = static_cast<DRTDesktopNotificationPresenter*>(this); + else + return E_NOINTERFACE; + + AddRef(); + return S_OK; +} + +ULONG STDMETHODCALLTYPE DRTDesktopNotificationPresenter::AddRef() +{ + return ++m_refCount; +} + +ULONG STDMETHODCALLTYPE DRTDesktopNotificationPresenter::Release() +{ + ULONG newRef = --m_refCount; + if (!newRef) + delete(this); + + return newRef; +} + +HRESULT STDMETHODCALLTYPE DRTDesktopNotificationPresenter::showDesktopNotification( + /* [in] */ IWebDesktopNotification* notification) +{ + BSTR title, text, url; + BOOL html; + + if (!notification->isHTML(&html) && html) { + notification->contentsURL(&url); + printf("DESKTOP NOTIFICATION: contents at %S\n", url ? url : L""); + } else { + notification->iconURL(&url); + notification->title(&title); + notification->text(&text); + printf("DESKTOP NOTIFICATION: icon %S, title %S, text %S\n", + url ? url : L"", + title ? title : L"", + text ? text : L""); + } + + // In this stub implementation, the notification is displayed immediately; + // we dispatch the display event to mimic that. + notification->notifyDisplay(); + + return S_OK; +} + +HRESULT STDMETHODCALLTYPE DRTDesktopNotificationPresenter::cancelDesktopNotification( + /* [in] */ IWebDesktopNotification* notification) +{ + BSTR identifier; + BOOL html; + notification->isHTML(&html); + if (html) + notification->contentsURL(&identifier); + else + notification->title(&identifier); + + printf("DESKTOP NOTIFICATION CLOSED: %S\n", identifier ? identifier : L""); + notification->notifyClose(false); + + return S_OK; +} + +HRESULT STDMETHODCALLTYPE DRTDesktopNotificationPresenter::notificationDestroyed( + /* [in] */ IWebDesktopNotification* notification) +{ + // Since in these tests events happen immediately, we don't hold on to + // Notification pointers. So there's no cleanup to do. + return S_OK; +} + +HRESULT STDMETHODCALLTYPE DRTDesktopNotificationPresenter::checkNotificationPermission( + /* [in] */ BSTR origin, + /* [out, retval] */ int* result) +{ +#if ENABLE(NOTIFICATIONS) + JSStringRef jsOrigin = JSStringCreateWithBSTR(origin); + bool allowed = ::gLayoutTestController->checkDesktopNotificationPermission(jsOrigin); + + if (allowed) + *result = WebCore::NotificationPresenter::PermissionAllowed; + else + *result = WebCore::NotificationPresenter::PermissionDenied; + + JSStringRelease(jsOrigin); +#endif + return S_OK; +} + +HRESULT STDMETHODCALLTYPE DRTDesktopNotificationPresenter::requestNotificationPermission( + /* [in] */ BSTR origin) +{ + printf("DESKTOP NOTIFICATION PERMISSION REQUESTED: %S\n", origin ? origin : L""); + return S_OK; +} diff --git a/WebKitTools/DumpRenderTree/win/DRTDesktopNotificationPresenter.h b/WebKitTools/DumpRenderTree/win/DRTDesktopNotificationPresenter.h new file mode 100644 index 0000000..5679845 --- /dev/null +++ b/WebKitTools/DumpRenderTree/win/DRTDesktopNotificationPresenter.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef DRTDesktopNotificationPresenter_h +#define DRTDesktopNotificationPresenter_h + +#include <WebKit/WebKit.h> +#include <wtf/OwnPtr.h> +#include <windef.h> + +class DRTDesktopNotificationPresenter : public IWebDesktopNotificationsDelegate { +public: + DRTDesktopNotificationPresenter(); + + // IUnknown + virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); + virtual ULONG STDMETHODCALLTYPE AddRef(void); + virtual ULONG STDMETHODCALLTYPE Release(void); + + // IWebDesktopNotificationsDelegate + virtual HRESULT STDMETHODCALLTYPE showDesktopNotification( + /* [in] */ IWebDesktopNotification* notification); + + virtual HRESULT STDMETHODCALLTYPE cancelDesktopNotification( + /* [in] */ IWebDesktopNotification* notification); + + virtual HRESULT STDMETHODCALLTYPE notificationDestroyed( + /* [in] */ IWebDesktopNotification* notification); + + virtual HRESULT STDMETHODCALLTYPE checkNotificationPermission( + /* [in] */ BSTR origin, + /* [out, retval] */ int* result); + + virtual HRESULT STDMETHODCALLTYPE requestNotificationPermission( + /* [in] */ BSTR origin); + +private: + ULONG m_refCount; +}; + +#endif diff --git a/WebKitTools/DumpRenderTree/win/DraggingInfo.h b/WebKitTools/DumpRenderTree/win/DraggingInfo.h index 2ead457..98982bc 100644 --- a/WebKitTools/DumpRenderTree/win/DraggingInfo.h +++ b/WebKitTools/DumpRenderTree/win/DraggingInfo.h @@ -36,6 +36,7 @@ public: DraggingInfo(IDataObject* object, IDropSource* source) : m_object(object) , m_source(source) + , m_performedDropEffect(DROPEFFECT_NONE) { m_object->AddRef(); m_source->AddRef(); @@ -54,9 +55,13 @@ public: IDataObject* dataObject() const { return m_object; } IDropSource* dropSource() const { return m_source; } + DWORD performedDropEffect() const { return m_performedDropEffect; } + void setPerformedDropEffect(DWORD effect) { m_performedDropEffect = effect; } + private: IDataObject* m_object; IDropSource* m_source; + DWORD m_performedDropEffect; }; #endif // !defined(DraggingInfo_h) diff --git a/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp index d262826..7e013a7 100644 --- a/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp +++ b/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp @@ -50,14 +50,19 @@ #include <wtf/RetainPtr.h> #include <wtf/Vector.h> #include <windows.h> -#if PLATFORM(CFNETWORK) -#include <CFNetwork/CFURLCachePriv.h> -#endif #include <CoreFoundation/CoreFoundation.h> #include <JavaScriptCore/JavaScriptCore.h> #include <WebKit/WebKit.h> #include <WebKit/WebKitCOMAPI.h> +#if USE(CFNETWORK) +#include <CFNetwork/CFURLCachePriv.h> +#endif + +#if USE(CFNETWORK) +#include <CFNetwork/CFHTTPCookiesPriv.h> +#endif + using namespace std; #ifndef NDEBUG @@ -108,6 +113,25 @@ void setPersistentUserStyleSheetLocation(CFStringRef url) persistentUserStyleSheetLocation = url; } +bool setAlwaysAcceptCookies(bool alwaysAcceptCookies) +{ +#if USE(CFNETWORK) + COMPtr<IWebCookieManager> cookieManager; + if (FAILED(WebKitCreateInstance(CLSID_WebCookieManager, 0, IID_IWebCookieManager, reinterpret_cast<void**>(&cookieManager)))) + return false; + CFHTTPCookieStorageRef cookieStorage = 0; + if (FAILED(cookieManager->cookieStorage(&cookieStorage)) || !cookieStorage) + return false; + + WebKitCookieStorageAcceptPolicy cookieAcceptPolicy = alwaysAcceptCookies ? WebKitCookieStorageAcceptPolicyAlways : WebKitCookieStorageAcceptPolicyOnlyFromMainDocumentDomain; + CFHTTPCookieStorageSetCookieAcceptPolicy(cookieStorage, cookieAcceptPolicy); + return true; +#else + // FIXME: Implement! + return false; +#endif +} + wstring urlSuitableForTestResult(const wstring& url) { if (!url.c_str() || url.find(L"file://") == wstring::npos) @@ -657,6 +681,72 @@ static bool shouldLogFrameLoadDelegates(const char* pathOrURL) return strstr(pathOrURL, "/loading/") || strstr(pathOrURL, "\\loading\\"); } +static void resetDefaultsToConsistentValues(IWebPreferences* preferences) +{ +#ifdef USE_MAC_FONTS + static BSTR standardFamily = SysAllocString(TEXT("Times")); + static BSTR fixedFamily = SysAllocString(TEXT("Courier")); + static BSTR sansSerifFamily = SysAllocString(TEXT("Helvetica")); + static BSTR cursiveFamily = SysAllocString(TEXT("Apple Chancery")); + static BSTR fantasyFamily = SysAllocString(TEXT("Papyrus")); +#else + static BSTR standardFamily = SysAllocString(TEXT("Times New Roman")); + static BSTR fixedFamily = SysAllocString(TEXT("Courier New")); + static BSTR sansSerifFamily = SysAllocString(TEXT("Arial")); + static BSTR cursiveFamily = SysAllocString(TEXT("Comic Sans MS")); // Not actually cursive, but it's what IE and Firefox use. + static BSTR fantasyFamily = SysAllocString(TEXT("Times New Roman")); +#endif + + preferences->setStandardFontFamily(standardFamily); + preferences->setFixedFontFamily(fixedFamily); + preferences->setSerifFontFamily(standardFamily); + preferences->setSansSerifFontFamily(sansSerifFamily); + preferences->setCursiveFontFamily(cursiveFamily); + preferences->setFantasyFontFamily(fantasyFamily); + + preferences->setAutosaves(FALSE); + preferences->setDefaultFontSize(16); + preferences->setDefaultFixedFontSize(13); + preferences->setMinimumFontSize(1); + preferences->setJavaEnabled(FALSE); + preferences->setPlugInsEnabled(TRUE); + preferences->setDOMPasteAllowed(TRUE); + preferences->setEditableLinkBehavior(WebKitEditableLinkOnlyLiveWithShiftKey); + preferences->setFontSmoothing(FontSmoothingTypeStandard); + preferences->setUsesPageCache(FALSE); + preferences->setPrivateBrowsingEnabled(FALSE); + preferences->setJavaScriptCanOpenWindowsAutomatically(TRUE); + preferences->setJavaScriptEnabled(TRUE); + preferences->setTabsToLinks(FALSE); + preferences->setShouldPrintBackgrounds(TRUE); + preferences->setLoadsImagesAutomatically(TRUE); + + if (persistentUserStyleSheetLocation) { + Vector<wchar_t> urlCharacters(CFStringGetLength(persistentUserStyleSheetLocation.get())); + CFStringGetCharacters(persistentUserStyleSheetLocation.get(), CFRangeMake(0, CFStringGetLength(persistentUserStyleSheetLocation.get())), (UniChar *)urlCharacters.data()); + BSTR url = SysAllocStringLen(urlCharacters.data(), urlCharacters.size()); + preferences->setUserStyleSheetLocation(url); + SysFreeString(url); + preferences->setUserStyleSheetEnabled(TRUE); + } else + preferences->setUserStyleSheetEnabled(FALSE); + + COMPtr<IWebPreferencesPrivate> prefsPrivate(Query, preferences); + if (prefsPrivate) { + prefsPrivate->setAllowUniversalAccessFromFileURLs(TRUE); + prefsPrivate->setAuthorAndUserStylesEnabled(TRUE); + prefsPrivate->setDeveloperExtrasEnabled(FALSE); + prefsPrivate->setExperimentalNotificationsEnabled(TRUE); + prefsPrivate->setExperimentalWebSocketsEnabled(FALSE); + prefsPrivate->setShouldPaintNativeControls(FALSE); // FIXME - need to make DRT pass with Windows native controls <http://bugs.webkit.org/show_bug.cgi?id=25592> + prefsPrivate->setXSSAuditorEnabled(FALSE); + prefsPrivate->setOfflineWebApplicationCacheEnabled(TRUE); + } + setAlwaysAcceptCookies(false); + + setlocale(LC_ALL, ""); +} + static void resetWebViewToConsistentStateBeforeTesting() { COMPtr<IWebView> webView; @@ -673,30 +763,10 @@ static void resetWebViewToConsistentStateBeforeTesting() webIBActions->resetPageZoom(0); } + COMPtr<IWebPreferences> preferences; - if (SUCCEEDED(webView->preferences(&preferences))) { - preferences->setPrivateBrowsingEnabled(FALSE); - preferences->setJavaScriptCanOpenWindowsAutomatically(TRUE); - preferences->setLoadsImagesAutomatically(TRUE); - - if (persistentUserStyleSheetLocation) { - Vector<wchar_t> urlCharacters(CFStringGetLength(persistentUserStyleSheetLocation.get())); - CFStringGetCharacters(persistentUserStyleSheetLocation.get(), CFRangeMake(0, CFStringGetLength(persistentUserStyleSheetLocation.get())), (UniChar *)urlCharacters.data()); - BSTR url = SysAllocStringLen(urlCharacters.data(), urlCharacters.size()); - preferences->setUserStyleSheetLocation(url); - SysFreeString(url); - preferences->setUserStyleSheetEnabled(TRUE); - } else - preferences->setUserStyleSheetEnabled(FALSE); - - COMPtr<IWebPreferencesPrivate> prefsPrivate(Query, preferences); - if (prefsPrivate) { - prefsPrivate->setAuthorAndUserStylesEnabled(TRUE); - prefsPrivate->setDeveloperExtrasEnabled(FALSE); - prefsPrivate->setShouldPaintNativeControls(FALSE); // FIXME - need to make DRT pass with Windows native controls <http://bugs.webkit.org/show_bug.cgi?id=25592> - prefsPrivate->setXSSAuditorEnabled(FALSE); - } - } + if (SUCCEEDED(webView->preferences(&preferences))) + resetDefaultsToConsistentValues(preferences.get()); COMPtr<IWebViewEditing> viewEditing; if (SUCCEEDED(webView->QueryInterface(&viewEditing))) @@ -715,8 +785,11 @@ static void resetWebViewToConsistentStateBeforeTesting() SetFocus(viewWindow); webViewPrivate->clearMainFrameName(); + webViewPrivate->resetOriginAccessWhiteLists(); sharedUIDelegate->resetUndoManager(); + + sharedFrameLoadDelegate->resetToConsistentState(); } static void runTest(const string& testPathOrURL) @@ -830,44 +903,6 @@ exit: return; } -static void initializePreferences(IWebPreferences* preferences) -{ -#ifdef USE_MAC_FONTS - BSTR standardFamily = SysAllocString(TEXT("Times")); - BSTR fixedFamily = SysAllocString(TEXT("Courier")); - BSTR sansSerifFamily = SysAllocString(TEXT("Helvetica")); - BSTR cursiveFamily = SysAllocString(TEXT("Apple Chancery")); - BSTR fantasyFamily = SysAllocString(TEXT("Papyrus")); -#else - BSTR standardFamily = SysAllocString(TEXT("Times New Roman")); - BSTR fixedFamily = SysAllocString(TEXT("Courier New")); - BSTR sansSerifFamily = SysAllocString(TEXT("Arial")); - BSTR cursiveFamily = SysAllocString(TEXT("Comic Sans MS")); // Not actually cursive, but it's what IE and Firefox use. - BSTR fantasyFamily = SysAllocString(TEXT("Times New Roman")); -#endif - - preferences->setStandardFontFamily(standardFamily); - preferences->setFixedFontFamily(fixedFamily); - preferences->setSerifFontFamily(standardFamily); - preferences->setSansSerifFontFamily(sansSerifFamily); - preferences->setCursiveFontFamily(cursiveFamily); - preferences->setFantasyFontFamily(fantasyFamily); - - preferences->setAutosaves(FALSE); - preferences->setJavaEnabled(FALSE); - preferences->setPlugInsEnabled(TRUE); - preferences->setDOMPasteAllowed(TRUE); - preferences->setEditableLinkBehavior(WebKitEditableLinkOnlyLiveWithShiftKey); - preferences->setFontSmoothing(FontSmoothingTypeStandard); - preferences->setUsesPageCache(FALSE); - - SysFreeString(standardFamily); - SysFreeString(fixedFamily); - SysFreeString(sansSerifFamily); - SysFreeString(cursiveFamily); - SysFreeString(fantasyFamily); -} - static Boolean pthreadEqualCallback(const void* value1, const void* value2) { return (Boolean)pthread_equal(*(pthread_t*)value1, *(pthread_t*)value2); @@ -1052,18 +1087,12 @@ IWebView* createWebViewAndOffscreenWindow(HWND* webViewWindow) if (FAILED(webView->setResourceLoadDelegate(sharedResourceLoadDelegate.get()))) return 0; - COMPtr<IWebPreferences> preferences; - if (FAILED(webView->preferences(&preferences))) - return 0; - - initializePreferences(preferences.get()); - openWindows().append(hostWindow); windowToWebViewMap().set(hostWindow, webView); return webView; } -#if PLATFORM(CFNETWORK) +#if USE(CFNETWORK) RetainPtr<CFURLCacheRef> sharedCFURLCache() { HMODULE module = GetModuleHandle(TEXT("CFNetwork_debug.dll")); @@ -1138,7 +1167,7 @@ int main(int argc, char* argv[]) standardPreferencesPrivate->setShouldPaintNativeControls(FALSE); standardPreferences->setJavaScriptEnabled(TRUE); standardPreferences->setDefaultFontSize(16); - + COMPtr<IWebView> webView(AdoptCOM, createWebViewAndOffscreenWindow(&webViewWindow)); if (!webView) return -1; @@ -1153,7 +1182,7 @@ int main(int argc, char* argv[]) if (FAILED(webView->mainFrame(&frame))) return -1; -#if PLATFORM(CFNETWORK) +#if USE(CFNETWORK) RetainPtr<CFURLCacheRef> urlCache = sharedCFURLCache(); CFURLCacheRemoveAllCachedResponses(urlCache.get()); #endif diff --git a/WebKitTools/DumpRenderTree/win/DumpRenderTree.vcproj b/WebKitTools/DumpRenderTree/win/DumpRenderTree.vcproj index b1bd3ab..dea2467 100644 --- a/WebKitTools/DumpRenderTree/win/DumpRenderTree.vcproj +++ b/WebKitTools/DumpRenderTree/win/DumpRenderTree.vcproj @@ -23,7 +23,7 @@ >
<Tool
Name="VCPreBuildEventTool"
- CommandLine="set PATH=%SystemDrive%\cygwin\bin;%PATH%
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"

mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree"
mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders"
mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders\wtf"

xcopy /y /d "$(ProjectDir)\..\ForwardingHeaders\wtf\*.h" "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders\wtf"
"
+ CommandLine="%SystemDrive%\cygwin\bin\which.exe bash
if errorlevel 1 set PATH=%SystemDrive%\cygwin\bin;%PATH%
cmd /c
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"

mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree"
mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders"
mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders\wtf"

xcopy /y /d "$(ProjectDir)\..\ForwardingHeaders\wtf\*.h" "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders\wtf"
"
/>
<Tool
Name="VCCustomBuildTool"
@@ -55,7 +55,7 @@ />
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="JavaScriptCore$(WebKitDLLConfigSuffix).lib WebKitGUID$(WebKitConfigSuffix).lib WebKit$(WebKitDLLConfigSuffix).lib CoreGraphics$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib CFNetwork$(LibraryConfigSuffix).lib pthreadVC2$(LibraryConfigSuffix).lib gdi32.lib ole32.lib oleaut32.lib user32.lib shlwapi.lib oleacc.lib"
+ AdditionalDependencies="JavaScriptCore$(WebKitDLLConfigSuffix).lib WebKitGUID$(WebKitConfigSuffix).lib WebKit$(WebKitDLLConfigSuffix).lib CoreGraphics$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib CFNetwork$(LibraryConfigSuffix).lib pthreadVC2$(LibraryConfigSuffix).lib gdi32.lib ole32.lib oleaut32.lib user32.lib shlwapi.lib oleacc.lib comsuppw.lib"
AdditionalLibraryDirectories=""
DelayLoadDLLs=""
SubSystem="1"
@@ -96,7 +96,7 @@ >
<Tool
Name="VCPreBuildEventTool"
- CommandLine="set PATH=%SystemDrive%\cygwin\bin;%PATH%
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"

mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree"
mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders"
mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders\wtf"

xcopy /y /d "$(ProjectDir)\..\ForwardingHeaders\wtf\*.h" "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders\wtf"
"
+ CommandLine="%SystemDrive%\cygwin\bin\which.exe bash
if errorlevel 1 set PATH=%SystemDrive%\cygwin\bin;%PATH%
cmd /c
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"

mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree"
mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders"
mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders\wtf"

xcopy /y /d "$(ProjectDir)\..\ForwardingHeaders\wtf\*.h" "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders\wtf"
"
/>
<Tool
Name="VCCustomBuildTool"
@@ -128,7 +128,7 @@ />
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="JavaScriptCore$(WebKitDLLConfigSuffix).lib WebKitGUID$(WebKitConfigSuffix).lib WebKit$(WebKitDLLConfigSuffix).lib CoreGraphics$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib CFNetwork$(LibraryConfigSuffix).lib pthreadVC2$(LibraryConfigSuffix).lib gdi32.lib ole32.lib oleaut32.lib user32.lib shlwapi.lib oleacc.lib"
+ AdditionalDependencies="JavaScriptCore$(WebKitDLLConfigSuffix).lib WebKitGUID$(WebKitConfigSuffix).lib WebKit$(WebKitDLLConfigSuffix).lib CoreGraphics$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib CFNetwork$(LibraryConfigSuffix).lib pthreadVC2$(LibraryConfigSuffix).lib gdi32.lib ole32.lib oleaut32.lib user32.lib shlwapi.lib oleacc.lib comsuppw.lib"
AdditionalLibraryDirectories=""
DelayLoadDLLs=""
SubSystem="1"
@@ -168,7 +168,7 @@ >
<Tool
Name="VCPreBuildEventTool"
- CommandLine="set PATH=%SystemDrive%\cygwin\bin;%PATH%
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"

mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree"
mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders"
mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders\wtf"

xcopy /y /d "$(ProjectDir)\..\ForwardingHeaders\wtf\*.h" "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders\wtf"
"
+ CommandLine="%SystemDrive%\cygwin\bin\which.exe bash
if errorlevel 1 set PATH=%SystemDrive%\cygwin\bin;%PATH%
cmd /c
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"

mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree"
mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders"
mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders\wtf"

xcopy /y /d "$(ProjectDir)\..\ForwardingHeaders\wtf\*.h" "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders\wtf"
"
/>
<Tool
Name="VCCustomBuildTool"
@@ -200,7 +200,7 @@ />
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="JavaScriptCore$(WebKitDLLConfigSuffix).lib WebKitGUID$(WebKitConfigSuffix).lib WebKit$(WebKitDLLConfigSuffix).lib CoreGraphics$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib CFNetwork$(LibraryConfigSuffix).lib pthreadVC2$(LibraryConfigSuffix).lib gdi32.lib ole32.lib oleaut32.lib user32.lib shlwapi.lib oleacc.lib"
+ AdditionalDependencies="JavaScriptCore$(WebKitDLLConfigSuffix).lib WebKitGUID$(WebKitConfigSuffix).lib WebKit$(WebKitDLLConfigSuffix).lib CoreGraphics$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib CFNetwork$(LibraryConfigSuffix).lib pthreadVC2$(LibraryConfigSuffix).lib gdi32.lib ole32.lib oleaut32.lib user32.lib shlwapi.lib oleacc.lib comsuppw.lib"
AdditionalLibraryDirectories=""
DelayLoadDLLs=""
SubSystem="1"
@@ -234,12 +234,12 @@ <Configuration
Name="Debug_Cairo|Win32"
ConfigurationType="1"
- InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug.vsprops;$(WebKitLibrariesDir)\tools\vsprops\WinCairo.vsprops"
+ InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug_wincairo.vsprops;$(WebKitLibrariesDir)\tools\vsprops\WinCairo.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
- CommandLine="set PATH=%SystemDrive%\cygwin\bin;%PATH%
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"

mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree"
mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders"
mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders\wtf"

xcopy /y /d "$(ProjectDir)\..\ForwardingHeaders\wtf\*.h" "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders\wtf"
"
+ CommandLine="%SystemDrive%\cygwin\bin\which.exe bash
if errorlevel 1 set PATH=%SystemDrive%\cygwin\bin;%PATH%
cmd /c
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"

mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree"
mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders"
mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders\wtf"

xcopy /y /d "$(ProjectDir)\..\ForwardingHeaders\wtf\*.h" "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders\wtf"
"
/>
<Tool
Name="VCCustomBuildTool"
@@ -271,7 +271,7 @@ />
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="JavaScriptCore$(WebKitDLLConfigSuffix).lib WebKitGUID$(WebKitConfigSuffix).lib WebKit$(WebKitDLLConfigSuffix).lib CFLite_Debug.lib cairo.lib jpeg.lib libpng.lib libcurl_imp.lib pthreadVC2$(LibraryConfigSuffix).lib gdi32.lib ole32.lib oleaut32.lib user32.lib shlwapi.lib oleacc.lib"
+ AdditionalDependencies="JavaScriptCore$(WebKitDLLConfigSuffix).lib WebKitGUID$(WebKitConfigSuffix).lib WebKit$(WebKitDLLConfigSuffix).lib CFLite_Debug.lib cairo.lib libjpeg.lib libpng.lib libcurl_imp.lib pthreadVC2$(LibraryConfigSuffix).lib gdi32.lib ole32.lib oleaut32.lib user32.lib shlwapi.lib oleacc.lib comsuppw.lib"
AdditionalLibraryDirectories=""
DelayLoadDLLs=""
SubSystem="1"
@@ -312,7 +312,7 @@ >
<Tool
Name="VCPreBuildEventTool"
- CommandLine="set PATH=%SystemDrive%\cygwin\bin;%PATH%
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"

mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree"
mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders"
mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders\wtf"

xcopy /y /d "$(ProjectDir)\..\ForwardingHeaders\wtf\*.h" "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders\wtf"
"
+ CommandLine="%SystemDrive%\cygwin\bin\which.exe bash
if errorlevel 1 set PATH=%SystemDrive%\cygwin\bin;%PATH%
cmd /c
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"

mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree"
mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders"
mkdir 2>NUL "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders\wtf"

xcopy /y /d "$(ProjectDir)\..\ForwardingHeaders\wtf\*.h" "$(WebKitOutputDir)\include\DumpRenderTree\ForwardingHeaders\wtf"
"
/>
<Tool
Name="VCCustomBuildTool"
@@ -344,7 +344,7 @@ />
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="JavaScriptCore$(WebKitDLLConfigSuffix).lib WebKitGUID$(WebKitConfigSuffix).lib WebKit$(WebKitDLLConfigSuffix).lib CFLite.lib cairo.lib jpeg.lib libpng.lib libcurl_imp.lib pthreadVC2$(LibraryConfigSuffix).lib gdi32.lib ole32.lib oleaut32.lib user32.lib shlwapi.lib oleacc.lib"
+ AdditionalDependencies="JavaScriptCore$(WebKitDLLConfigSuffix).lib WebKitGUID$(WebKitConfigSuffix).lib WebKit$(WebKitDLLConfigSuffix).lib CFLite.lib cairo.lib libjpeg.lib libpng.lib libcurl_imp.lib pthreadVC2$(LibraryConfigSuffix).lib gdi32.lib ole32.lib oleaut32.lib user32.lib shlwapi.lib oleacc.lib comsuppw.lib"
AdditionalLibraryDirectories=""
DelayLoadDLLs=""
SubSystem="1"
@@ -432,6 +432,14 @@ Name="Delegates"
>
<File
+ RelativePath=".\DRTDesktopNotificationPresenter.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\DRTDesktopNotificationPresenter.h"
+ >
+ </File>
+ <File
RelativePath=".\EditingDelegate.cpp"
>
</File>
diff --git a/WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h b/WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h index bf9b123..6eb468d 100644 --- a/WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h +++ b/WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h @@ -53,6 +53,7 @@ typedef HashMap<HWND, COMPtr<IWebView> > WindowToWebViewMap; WindowToWebViewMap& windowToWebViewMap(); void setPersistentUserStyleSheetLocation(CFStringRef); +bool setAlwaysAcceptCookies(bool alwaysAcceptCookies); extern UINT_PTR waitToDumpWatchdog; diff --git a/WebKitTools/DumpRenderTree/win/EventSender.cpp b/WebKitTools/DumpRenderTree/win/EventSender.cpp index ca897fb..721b238 100644 --- a/WebKitTools/DumpRenderTree/win/EventSender.cpp +++ b/WebKitTools/DumpRenderTree/win/EventSender.cpp @@ -151,7 +151,30 @@ static JSValueRef mouseDownCallback(JSContextRef context, JSObjectRef function, framePrivate->layout(); down = true; - MSG msg = makeMsg(webViewWindow, WM_LBUTTONDOWN, 0, MAKELPARAM(lastMousePosition.x, lastMousePosition.y)); + int mouseType = WM_LBUTTONDOWN; + if (argumentCount == 1) { + int mouseNumber = JSValueToNumber(context, arguments[0], exception); + switch (mouseNumber) { + case 0: + mouseType = WM_LBUTTONDOWN; + break; + case 1: + mouseType = WM_MBUTTONDOWN; + break; + case 2: + mouseType = WM_RBUTTONDOWN; + break; + case 3: + // fast/events/mouse-click-events expects the 4th button has event.button = 1, so send an WM_BUTTONDOWN + mouseType = WM_MBUTTONDOWN; + break; + default: + mouseType = WM_LBUTTONDOWN; + break; + } + } + + MSG msg = makeMsg(webViewWindow, mouseType, 0, MAKELPARAM(lastMousePosition.x, lastMousePosition.y)); if (!msgQueue[endOfQueue].delay) dispatchMessage(&msg); else { @@ -196,18 +219,42 @@ static void doMouseUp(MSG msg) if (hr == DRAGDROP_S_DROP && effect != DROPEFFECT_NONE) { DWORD effect = 0; webViewDropTarget->Drop(draggingInfo->dataObject(), 0, pointl(screenPoint), &effect); + draggingInfo->setPerformedDropEffect(effect); } else webViewDropTarget->DragLeave(); - delete draggingInfo; - draggingInfo = 0; + // Reset didDragEnter so that another drag started within the same frame works properly. + didDragEnter = false; } } } static JSValueRef mouseUpCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { - MSG msg = makeMsg(webViewWindow, WM_LBUTTONUP, 0, MAKELPARAM(lastMousePosition.x, lastMousePosition.y)); + int mouseType = WM_LBUTTONUP; + if (argumentCount == 1) { + int mouseNumber = JSValueToNumber(context, arguments[0], exception); + switch (mouseNumber) { + case 0: + mouseType = WM_LBUTTONUP; + break; + case 1: + mouseType = WM_MBUTTONUP; + break; + case 2: + mouseType = WM_RBUTTONUP; + break; + case 3: + // fast/events/mouse-click-events expects the 4th button has event.button = 1, so send an WM_MBUTTONUP + mouseType = WM_MBUTTONUP; + break; + default: + mouseType = WM_LBUTTONUP; + break; + } + } + + MSG msg = makeMsg(webViewWindow, mouseType, 0, MAKELPARAM(lastMousePosition.x, lastMousePosition.y)); if ((dragMode && !replayingSavedEvents) || msgQueue[endOfQueue].delay) { msgQueue[endOfQueue++].msg = msg; @@ -277,12 +324,16 @@ void replaySavedEvents() msg = msgQueue[startOfQueue++].msg; switch (msg.message) { case WM_LBUTTONUP: + case WM_RBUTTONUP: + case WM_MBUTTONUP: doMouseUp(msg); break; case WM_MOUSEMOVE: doMouseMove(msg); break; case WM_LBUTTONDOWN: + case WM_RBUTTONDOWN: + case WM_MBUTTONDOWN: dispatchMessage(&msg); break; default: @@ -317,12 +368,16 @@ void replaySavedEvents() msg = msgQueue[startOfQueue++].msg; switch (msg.message) { case WM_LBUTTONUP: + case WM_RBUTTONUP: + case WM_MBUTTONUP: doMouseUp(msg); break; case WM_MOUSEMOVE: doMouseMove(msg); break; case WM_LBUTTONDOWN: + case WM_RBUTTONDOWN: + case WM_MBUTTONDOWN: dispatchMessage(&msg); break; default: diff --git a/WebKitTools/DumpRenderTree/win/FrameLoadDelegate.cpp b/WebKitTools/DumpRenderTree/win/FrameLoadDelegate.cpp index 5f0e02b..939090a 100644 --- a/WebKitTools/DumpRenderTree/win/FrameLoadDelegate.cpp +++ b/WebKitTools/DumpRenderTree/win/FrameLoadDelegate.cpp @@ -76,8 +76,7 @@ string descriptionSuitableForTestResult(IWebFrame* webFrame) string frameName = (webFrame == mainFrame) ? "main frame" : "frame"; frameName += " \"" + BSTRtoString(frameNameBSTR) + "\""; - SysFreeString(frameNameBSTR); - + SysFreeString(frameNameBSTR); return frameName; } @@ -101,6 +100,8 @@ HRESULT STDMETHODCALLTYPE FrameLoadDelegate::QueryInterface(REFIID riid, void** *ppvObject = static_cast<IWebFrameLoadDelegate*>(this); else if (IsEqualGUID(riid, IID_IWebFrameLoadDelegatePrivate)) *ppvObject = static_cast<IWebFrameLoadDelegatePrivate*>(this); + else if (IsEqualGUID(riid, IID_IWebFrameLoadDelegatePrivate2)) + *ppvObject = static_cast<IWebFrameLoadDelegatePrivate2*>(this); else return E_NOINTERFACE; @@ -180,6 +181,9 @@ HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didReceiveTitle( /* [in] */ BSTR title, /* [in] */ IWebFrame *frame) { + if (!done && gLayoutTestController->dumpFrameLoadCallbacks()) + printf("%s - didReceiveTitle: %S\n", descriptionSuitableForTestResult(frame).c_str(), title); + if (::gLayoutTestController->dumpTitleChanges() && !done) printf("TITLE CHANGED: %S\n", title ? title : L""); return S_OK; @@ -196,6 +200,11 @@ void FrameLoadDelegate::processWork() dump(); } +void FrameLoadDelegate::resetToConsistentState() +{ + m_accessibilityController->resetToConsistentState(); +} + static void CALLBACK processWorkTimer(HWND, UINT, UINT_PTR id, DWORD) { ::KillTimer(0, id); @@ -346,3 +355,23 @@ HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didFirstVisuallyNonEmptyLayoutInFra { return S_OK; } + +HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didDisplayInsecureContent( + /* [in] */ IWebView *sender) +{ + if (!done && gLayoutTestController->dumpFrameLoadCallbacks()) + printf("didDisplayInsecureContent\n"); + + return S_OK; +} + +HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didRunInsecureContent( + /* [in] */ IWebView *sender, + /* [in] */ IWebSecurityOrigin *origin) +{ + if (!done && gLayoutTestController->dumpFrameLoadCallbacks()) + printf("didRunInsecureContent\n"); + + return S_OK; +} + diff --git a/WebKitTools/DumpRenderTree/win/FrameLoadDelegate.h b/WebKitTools/DumpRenderTree/win/FrameLoadDelegate.h index 526e1b4..56325e2 100644 --- a/WebKitTools/DumpRenderTree/win/FrameLoadDelegate.h +++ b/WebKitTools/DumpRenderTree/win/FrameLoadDelegate.h @@ -35,13 +35,15 @@ class AccessibilityController; class GCController; -class FrameLoadDelegate : public IWebFrameLoadDelegate, public IWebFrameLoadDelegatePrivate { +class FrameLoadDelegate : public IWebFrameLoadDelegate, public IWebFrameLoadDelegatePrivate2 { public: FrameLoadDelegate(); virtual ~FrameLoadDelegate(); void processWork(); + void resetToConsistentState(); + // IUnknown virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); virtual ULONG STDMETHODCALLTYPE AddRef(void); @@ -131,6 +133,14 @@ public: /* [in] */ IWebView *sender, /* [in] */ IWebFrame *frame); + // IWebFrameLoadDelegatePrivate2 + virtual HRESULT STDMETHODCALLTYPE didDisplayInsecureContent( + /* [in] */ IWebView *sender); + + virtual HRESULT STDMETHODCALLTYPE didRunInsecureContent( + /* [in] */ IWebView *sender, + /* [in] */ IWebSecurityOrigin *origin); + protected: void locationChangeDone(IWebError*, IWebFrame*); diff --git a/WebKitTools/DumpRenderTree/win/ImageDiff.vcproj b/WebKitTools/DumpRenderTree/win/ImageDiff.vcproj index 8d79717..37bddeb 100644 --- a/WebKitTools/DumpRenderTree/win/ImageDiff.vcproj +++ b/WebKitTools/DumpRenderTree/win/ImageDiff.vcproj @@ -1,230 +1,230 @@ -<?xml version="1.0" encoding="Windows-1252"?> -<VisualStudioProject - ProjectType="Visual C++" - Version="8.00" - Name="ImageDiff" - ProjectGUID="{59CC0547-70AC-499C-9B19-EC01C6F61137}" - RootNamespace="ImageDiff" - > - <Platforms> - <Platform - Name="Win32" - /> - </Platforms> - <ToolFiles> - </ToolFiles> - <Configurations> - <Configuration - Name="Debug|Win32" - ConfigurationType="1" - InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug.vsprops" - CharacterSet="2" - > - <Tool - Name="VCPreBuildEventTool" - CommandLine="set PATH=%SystemDrive%\cygwin\bin;%PATH%
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"
" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - AdditionalIncludeDirectories=""$(WebKitOutputDir)\include";"$(WebKitOutputDir)\include\private";"$(WebKitOutputDir)\include\WebCore\ForwardingHeaders";"$(WebKitLibrariesDir)\include";"$(WebKitLibrariesDir)\include\private";"$(WebKitLibrariesDir)\Include\CoreFoundation\OSXCompatibilityHeaders";"$(WebKitLibrariesDir)\Include\CoreFoundation\OSXCompatibilityHeaders\GNUCompatibility"" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - AdditionalDependencies="CoreGraphics$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib" - AdditionalLibraryDirectories="" - SubSystem="1" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCWebDeploymentTool" - /> - <Tool - Name="VCPostBuildEventTool" - CommandLine="if exist "$(WebKitOutputDir)\buildfailed" del "$(WebKitOutputDir)\buildfailed"

mkdir 2>NUL "$(WebKitOutputDir)\bin"

if not defined ARCHIVE_BUILD (if defined PRODUCTION exit /b)

if not exist "$(WebKitLibrariesDir)\bin\CoreFoundation$(LibraryConfigSuffix).dll" exit /b

xcopy /y /d "$(WebKitLibrariesDir)\bin\CoreFoundation$(LibraryConfigSuffix).dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\CoreFoundation$(LibraryConfigSuffix).pdb" "$(WebKitOutputDir)\bin"
xcopy /y /d /e /i "$(WebKitLibrariesDir)\bin\CoreFoundation.resources" "$(WebKitOutputDir)\bin\CoreFoundation.resources"
xcopy /y /d /e /i "$(WebKitLibrariesDir)\bin\CharacterSets" "$(WebKitOutputDir)\bin\CharacterSets"
xcopy /y /d "$(WebKitLibrariesDir)\bin\CoreGraphics$(LibraryConfigSuffix).dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\CoreGraphics$(LibraryConfigSuffix).pdb" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\icudt38.dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\icudt38$(LibraryConfigSuffix).dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\icuin38$(LibraryConfigSuffix).dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\icuin38$(LibraryConfigSuffix).pdb" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\icuuc38$(LibraryConfigSuffix).dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\icuuc38$(LibraryConfigSuffix).pdb" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\zlib1$(LibraryConfigSuffix).dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\zlib1$(LibraryConfigSuffix).pdb" "$(WebKitOutputDir)\bin"
" - /> - </Configuration> - <Configuration - Name="Release|Win32" - ConfigurationType="1" - InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\release.vsprops" - CharacterSet="2" - WholeProgramOptimization="1" - > - <Tool - Name="VCPreBuildEventTool" - CommandLine="set PATH=%SystemDrive%\cygwin\bin;%PATH%
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"
" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - AdditionalIncludeDirectories=""$(WebKitOutputDir)\include";"$(WebKitOutputDir)\include\private";"$(WebKitOutputDir)\include\WebCore\ForwardingHeaders";"$(WebKitLibrariesDir)\include";"$(WebKitLibrariesDir)\include\private";"$(WebKitLibrariesDir)\Include\CoreFoundation\OSXCompatibilityHeaders";"$(WebKitLibrariesDir)\Include\CoreFoundation\OSXCompatibilityHeaders\GNUCompatibility"" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - AdditionalDependencies="CoreGraphics$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib" - AdditionalLibraryDirectories="" - SubSystem="1" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCWebDeploymentTool" - /> - <Tool - Name="VCPostBuildEventTool" - CommandLine="if exist "$(WebKitOutputDir)\buildfailed" del "$(WebKitOutputDir)\buildfailed"

mkdir 2>NUL "$(WebKitOutputDir)\bin"

if not defined ARCHIVE_BUILD (if defined PRODUCTION exit /b)

if not exist "$(WebKitLibrariesDir)\bin\CoreFoundation$(LibraryConfigSuffix).dll" exit /b

xcopy /y /d "$(WebKitLibrariesDir)\bin\CoreFoundation$(LibraryConfigSuffix).dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\CoreFoundation$(LibraryConfigSuffix).pdb" "$(WebKitOutputDir)\bin"
xcopy /y /d /e /i "$(WebKitLibrariesDir)\bin\CoreFoundation.resources" "$(WebKitOutputDir)\bin\CoreFoundation.resources"
xcopy /y /d /e /i "$(WebKitLibrariesDir)\bin\CharacterSets" "$(WebKitOutputDir)\bin\CharacterSets"
xcopy /y /d "$(WebKitLibrariesDir)\bin\CoreGraphics$(LibraryConfigSuffix).dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\CoreGraphics$(LibraryConfigSuffix).pdb" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\icudt38.dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\icudt38$(LibraryConfigSuffix).dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\icuin38$(LibraryConfigSuffix).dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\icuin38$(LibraryConfigSuffix).pdb" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\icuuc38$(LibraryConfigSuffix).dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\icuuc38$(LibraryConfigSuffix).pdb" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\zlib1$(LibraryConfigSuffix).dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\zlib1$(LibraryConfigSuffix).pdb" "$(WebKitOutputDir)\bin"
" - /> - </Configuration> - <Configuration - Name="Debug_Internal|Win32" - ConfigurationType="1" - InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug_internal.vsprops" - CharacterSet="2" - > - <Tool - Name="VCPreBuildEventTool" - CommandLine="set PATH=%SystemDrive%\cygwin\bin;%PATH%
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"
" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - AdditionalIncludeDirectories=""$(WebKitOutputDir)\include";"$(WebKitOutputDir)\include\private";"$(WebKitOutputDir)\include\WebCore\ForwardingHeaders";"$(WebKitLibrariesDir)\include";"$(WebKitLibrariesDir)\include\private";"$(WebKitLibrariesDir)\Include\CoreFoundation\OSXCompatibilityHeaders";"$(WebKitLibrariesDir)\Include\CoreFoundation\OSXCompatibilityHeaders\GNUCompatibility"" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - AdditionalDependencies="CoreGraphics$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib" - AdditionalLibraryDirectories="" - SubSystem="1" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCWebDeploymentTool" - /> - <Tool - Name="VCPostBuildEventTool" - CommandLine="if exist "$(WebKitOutputDir)\buildfailed" del "$(WebKitOutputDir)\buildfailed"

mkdir 2>NUL "$(WebKitOutputDir)\bin"

if not defined ARCHIVE_BUILD (if defined PRODUCTION exit /b)

if not exist "$(WebKitLibrariesDir)\bin\CoreFoundation$(LibraryConfigSuffix).dll" exit /b

xcopy /y /d "$(WebKitLibrariesDir)\bin\CoreFoundation$(LibraryConfigSuffix).dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\CoreFoundation$(LibraryConfigSuffix).pdb" "$(WebKitOutputDir)\bin"
xcopy /y /d /e /i "$(WebKitLibrariesDir)\bin\CoreFoundation.resources" "$(WebKitOutputDir)\bin\CoreFoundation.resources"
xcopy /y /d /e /i "$(WebKitLibrariesDir)\bin\CharacterSets" "$(WebKitOutputDir)\bin\CharacterSets"
xcopy /y /d "$(WebKitLibrariesDir)\bin\CoreGraphics$(LibraryConfigSuffix).dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\CoreGraphics$(LibraryConfigSuffix).pdb" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\icudt38.dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\icudt38$(LibraryConfigSuffix).dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\icuin38$(LibraryConfigSuffix).dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\icuin38$(LibraryConfigSuffix).pdb" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\icuuc38$(LibraryConfigSuffix).dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\icuuc38$(LibraryConfigSuffix).pdb" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\zlib1$(LibraryConfigSuffix).dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\zlib1$(LibraryConfigSuffix).pdb" "$(WebKitOutputDir)\bin"
" - /> - </Configuration> - </Configurations> - <References> - </References> - <Files> - <File - RelativePath="..\cg\ImageDiffCG.cpp" - > - </File> - </Files> - <Globals> - </Globals> -</VisualStudioProject> +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="ImageDiff"
+ ProjectGUID="{59CC0547-70AC-499C-9B19-EC01C6F61137}"
+ RootNamespace="ImageDiff"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug.vsprops"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ CommandLine="%SystemDrive%\cygwin\bin\which.exe bash
if errorlevel 1 set PATH=%SystemDrive%\cygwin\bin;%PATH%
cmd /c
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"
"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=""$(WebKitOutputDir)\include";"$(WebKitOutputDir)\include\private";"$(WebKitOutputDir)\include\WebCore\ForwardingHeaders";"$(WebKitLibrariesDir)\include";"$(WebKitLibrariesDir)\include\private";"$(WebKitLibrariesDir)\Include\CoreFoundation\OSXCompatibilityHeaders";"$(WebKitLibrariesDir)\Include\CoreFoundation\OSXCompatibilityHeaders\GNUCompatibility""
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="CoreGraphics$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib"
+ AdditionalLibraryDirectories=""
+ SubSystem="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="if exist "$(WebKitOutputDir)\buildfailed" del "$(WebKitOutputDir)\buildfailed"

mkdir 2>NUL "$(WebKitOutputDir)\bin"

if not defined ARCHIVE_BUILD (if defined PRODUCTION exit /b)

if not exist "$(WebKitLibrariesDir)\bin\CoreFoundation$(LibraryConfigSuffix).dll" exit /b

xcopy /y /d "$(WebKitLibrariesDir)\bin\CoreFoundation$(LibraryConfigSuffix).dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\CoreFoundation$(LibraryConfigSuffix).pdb" "$(WebKitOutputDir)\bin"
xcopy /y /d /e /i "$(WebKitLibrariesDir)\bin\CoreFoundation.resources" "$(WebKitOutputDir)\bin\CoreFoundation.resources"
xcopy /y /d "$(WebKitLibrariesDir)\bin\CoreGraphics$(LibraryConfigSuffix).dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\CoreGraphics$(LibraryConfigSuffix).pdb" "$(WebKitOutputDir)\bin"
"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\release.vsprops"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ CommandLine="%SystemDrive%\cygwin\bin\which.exe bash
if errorlevel 1 set PATH=%SystemDrive%\cygwin\bin;%PATH%
cmd /c
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"
"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=""$(WebKitOutputDir)\include";"$(WebKitOutputDir)\include\private";"$(WebKitOutputDir)\include\WebCore\ForwardingHeaders";"$(WebKitLibrariesDir)\include";"$(WebKitLibrariesDir)\include\private";"$(WebKitLibrariesDir)\Include\CoreFoundation\OSXCompatibilityHeaders";"$(WebKitLibrariesDir)\Include\CoreFoundation\OSXCompatibilityHeaders\GNUCompatibility""
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="CoreGraphics$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib"
+ AdditionalLibraryDirectories=""
+ SubSystem="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="if exist "$(WebKitOutputDir)\buildfailed" del "$(WebKitOutputDir)\buildfailed"

mkdir 2>NUL "$(WebKitOutputDir)\bin"

if not defined ARCHIVE_BUILD (if defined PRODUCTION exit /b)

if not exist "$(WebKitLibrariesDir)\bin\CoreFoundation$(LibraryConfigSuffix).dll" exit /b

xcopy /y /d "$(WebKitLibrariesDir)\bin\CoreFoundation$(LibraryConfigSuffix).dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\CoreFoundation$(LibraryConfigSuffix).pdb" "$(WebKitOutputDir)\bin"
xcopy /y /d /e /i "$(WebKitLibrariesDir)\bin\CoreFoundation.resources" "$(WebKitOutputDir)\bin\CoreFoundation.resources"
xcopy /y /d "$(WebKitLibrariesDir)\bin\CoreGraphics$(LibraryConfigSuffix).dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\CoreGraphics$(LibraryConfigSuffix).pdb" "$(WebKitOutputDir)\bin"
"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug_Internal|Win32"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug_internal.vsprops"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ CommandLine="%SystemDrive%\cygwin\bin\which.exe bash
if errorlevel 1 set PATH=%SystemDrive%\cygwin\bin;%PATH%
cmd /c
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"
"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=""$(WebKitOutputDir)\include";"$(WebKitOutputDir)\include\private";"$(WebKitOutputDir)\include\WebCore\ForwardingHeaders";"$(WebKitLibrariesDir)\include";"$(WebKitLibrariesDir)\include\private";"$(WebKitLibrariesDir)\Include\CoreFoundation\OSXCompatibilityHeaders";"$(WebKitLibrariesDir)\Include\CoreFoundation\OSXCompatibilityHeaders\GNUCompatibility""
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="CoreGraphics$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib"
+ AdditionalLibraryDirectories=""
+ SubSystem="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="if exist "$(WebKitOutputDir)\buildfailed" del "$(WebKitOutputDir)\buildfailed"

mkdir 2>NUL "$(WebKitOutputDir)\bin"

if not defined ARCHIVE_BUILD (if defined PRODUCTION exit /b)

if not exist "$(WebKitLibrariesDir)\bin\CoreFoundation$(LibraryConfigSuffix).dll" exit /b

xcopy /y /d "$(WebKitLibrariesDir)\bin\CoreFoundation$(LibraryConfigSuffix).dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\CoreFoundation$(LibraryConfigSuffix).pdb" "$(WebKitOutputDir)\bin"
xcopy /y /d /e /i "$(WebKitLibrariesDir)\bin\CoreFoundation.resources" "$(WebKitOutputDir)\bin\CoreFoundation.resources"
xcopy /y /d "$(WebKitLibrariesDir)\bin\CoreGraphics$(LibraryConfigSuffix).dll" "$(WebKitOutputDir)\bin"
xcopy /y /d "$(WebKitLibrariesDir)\bin\CoreGraphics$(LibraryConfigSuffix).pdb" "$(WebKitOutputDir)\bin"
"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath="..\cg\ImageDiffCG.cpp"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp index 7a80bab..cf3ac85 100644 --- a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp +++ b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp @@ -34,21 +34,22 @@ #include "PolicyDelegate.h" #include "WorkQueue.h" #include "WorkQueueItem.h" -#include <WebCore/COMPtr.h> -#include <wtf/Platform.h> -#include <wtf/RetainPtr.h> -#include <wtf/Vector.h> +#include <CoreFoundation/CoreFoundation.h> #include <JavaScriptCore/Assertions.h> -#include <JavaScriptCore/JavaScriptCore.h> #include <JavaScriptCore/JSRetainPtr.h> #include <JavaScriptCore/JSStringRefBSTR.h> +#include <JavaScriptCore/JavaScriptCore.h> +#include <WebCore/COMPtr.h> #include <WebKit/WebKit.h> #include <WebKit/WebKitCOMAPI.h> -#include <string> -#include <CoreFoundation/CoreFoundation.h> +#include <comutil.h> #include <shlwapi.h> #include <shlguid.h> #include <shobjidl.h> +#include <string> +#include <wtf/Platform.h> +#include <wtf/RetainPtr.h> +#include <wtf/Vector.h> using std::string; using std::wstring; @@ -183,6 +184,17 @@ size_t LayoutTestController::webHistoryItemCount() return count; } +unsigned LayoutTestController::workerThreadCount() const +{ + COMPtr<IWebWorkersPrivate> workers; + if (FAILED(WebKitCreateInstance(CLSID_WebWorkersPrivate, 0, __uuidof(workers), reinterpret_cast<void**>(&workers)))) + return 0; + unsigned count; + if (FAILED(workers->workerThreadCount(&count))) + return 0; + return count; +} + void LayoutTestController::notifyDone() { // Same as on mac. This can be shared. @@ -260,6 +272,16 @@ void LayoutTestController::setAcceptsEditing(bool acceptsEditing) editingDelegate->setAcceptsEditing(acceptsEditing); } +void LayoutTestController::setAlwaysAcceptCookies(bool alwaysAcceptCookies) +{ + if (alwaysAcceptCookies == m_alwaysAcceptCookies) + return; + + if (!::setAlwaysAcceptCookies(alwaysAcceptCookies)) + return; + m_alwaysAcceptCookies = alwaysAcceptCookies; +} + void LayoutTestController::setAuthorAndUserStylesEnabled(bool flag) { COMPtr<IWebView> webView; @@ -290,6 +312,18 @@ void LayoutTestController::setCustomPolicyDelegate(bool setDelegate, bool permis webView->setPolicyDelegate(0); } +void LayoutTestController::setMockGeolocationPosition(double latitude, double longitude, double accuracy) +{ + // FIXME: Implement for Geolocation layout tests. + // See https://bugs.webkit.org/show_bug.cgi?id=28264. +} + +void LayoutTestController::setMockGeolocationError(int code, JSStringRef message) +{ + // FIXME: Implement for Geolocation layout tests. + // See https://bugs.webkit.org/show_bug.cgi?id=28264. +} + void LayoutTestController::setIconDatabaseEnabled(bool iconDatabaseEnabled) { // See also <rdar://problem/6480108> @@ -615,14 +649,11 @@ void LayoutTestController::setSelectTrailingWhitespaceEnabled(bool flag) viewEditing->setSelectTrailingWhitespaceEnabled(flag ? TRUE : FALSE); } -static const CFTimeInterval waitToDumpWatchdogInterval = 10.0; +static const CFTimeInterval waitToDumpWatchdogInterval = 15.0; static void CALLBACK waitUntilDoneWatchdogFired(HWND, UINT, UINT_PTR, DWORD) { - const char* message = "FAIL: Timed out waiting for notifyDone to be called\n"; - fprintf(stderr, message); - fprintf(stdout, message); - dump(); + gLayoutTestController->waitToDumpWatchdogTimerFired(); } void LayoutTestController::setWaitToDump(bool waitUntilDone) @@ -707,9 +738,38 @@ void LayoutTestController::clearAllDatabases() databaseManager->deleteAllDatabases(); } +void LayoutTestController::overridePreference(JSStringRef key, JSStringRef value) +{ + COMPtr<IWebView> webView; + if (FAILED(frame->webView(&webView))) + return; + + COMPtr<IWebPreferences> preferences; + if (FAILED(webView->preferences(&preferences))) + return; + + COMPtr<IWebPreferencesPrivate> prefsPrivate(Query, preferences); + if (!prefsPrivate) + return; + + BSTR keyBSTR = JSStringCopyBSTR(key); + BSTR valueBSTR = JSStringCopyBSTR(value); + prefsPrivate->setPreferenceForTest(keyBSTR, valueBSTR); + SysFreeString(keyBSTR); + SysFreeString(valueBSTR); +} + void LayoutTestController::setDatabaseQuota(unsigned long long quota) { - printf("ERROR: LayoutTestController::setDatabaseQuota() not implemented\n"); + COMPtr<IWebDatabaseManager> databaseManager; + COMPtr<IWebDatabaseManager> tmpDatabaseManager; + + if (FAILED(WebKitCreateInstance(CLSID_WebDatabaseManager, 0, IID_IWebDatabaseManager, (void**)&tmpDatabaseManager))) + return; + if (FAILED(tmpDatabaseManager->sharedWebDatabaseManager(&databaseManager))) + return; + + databaseManager->setQuota(TEXT("file:///"), quota); } void LayoutTestController::setAppCacheMaximumSize(unsigned long long size) @@ -779,3 +839,76 @@ unsigned LayoutTestController::numberOfActiveAnimations() const return number; } + +static _bstr_t bstrT(JSStringRef jsString) +{ + // The false parameter tells the _bstr_t constructor to adopt the BSTR we pass it. + return _bstr_t(JSStringCopyBSTR(jsString), false); +} + +void LayoutTestController::whiteListAccessFromOrigin(JSStringRef sourceOrigin, JSStringRef destinationProtocol, JSStringRef destinationHost, bool allowDestinationSubdomains) +{ + COMPtr<IWebViewPrivate> webView; + if (FAILED(WebKitCreateInstance(__uuidof(WebView), 0, __uuidof(webView), reinterpret_cast<void**>(&webView)))) + return; + + webView->whiteListAccessFromOrigin(bstrT(sourceOrigin).GetBSTR(), bstrT(destinationProtocol).GetBSTR(), bstrT(destinationHost).GetBSTR(), allowDestinationSubdomains); +} + +void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart) +{ + COMPtr<IWebViewPrivate> webView; + if (FAILED(WebKitCreateInstance(__uuidof(WebView), 0, __uuidof(webView), reinterpret_cast<void**>(&webView)))) + return; + + webView->addUserScriptToGroup(_bstr_t(L"org.webkit.DumpRenderTree").GetBSTR(), 1, bstrT(source).GetBSTR(), 0, 0, 0, 0, 0, runAtStart ? WebInjectAtDocumentStart : WebInjectAtDocumentEnd); +} + + +void LayoutTestController::addUserStyleSheet(JSStringRef source) +{ + COMPtr<IWebViewPrivate> webView; + if (FAILED(WebKitCreateInstance(__uuidof(WebView), 0, __uuidof(webView), reinterpret_cast<void**>(&webView)))) + return; + + webView->addUserStyleSheetToGroup(_bstr_t(L"org.webkit.DumpRenderTree").GetBSTR(), 1, bstrT(source).GetBSTR(), 0, 0, 0, 0, 0); +} + +void LayoutTestController::showWebInspector() +{ + COMPtr<IWebViewPrivate> webView; + if (FAILED(WebKitCreateInstance(__uuidof(WebView), 0, __uuidof(webView), reinterpret_cast<void**>(&webView)))) + return; + + COMPtr<IWebInspector> inspector; + if (SUCCEEDED(webView->inspector(&inspector))) + inspector->show(); +} + +void LayoutTestController::closeWebInspector() +{ + COMPtr<IWebViewPrivate> webView; + if (FAILED(WebKitCreateInstance(__uuidof(WebView), 0, __uuidof(webView), reinterpret_cast<void**>(&webView)))) + return; + + COMPtr<IWebInspector> inspector; + if (SUCCEEDED(webView->inspector(&inspector))) + inspector->close(); +} + +void LayoutTestController::evaluateInWebInspector(long callId, JSStringRef script) +{ + COMPtr<IWebViewPrivate> webView; + if (FAILED(WebKitCreateInstance(__uuidof(WebView), 0, __uuidof(webView), reinterpret_cast<void**>(&webView)))) + return; + + COMPtr<IWebInspector> inspector; + if (FAILED(webView->inspector(&inspector))) + return; + + COMPtr<IWebInspectorPrivate> inspectorPrivate(Query, inspector); + if (!inspectorPrivate) + return; + + inspectorPrivate->evaluateInFrontend(callId, bstrT(script).GetBSTR()); +} diff --git a/WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.cpp b/WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.cpp index 06476e7..0edf69b 100644 --- a/WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.cpp +++ b/WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.cpp @@ -31,10 +31,13 @@ #include "DumpRenderTree.h" #include "LayoutTestController.h" +#include <comutil.h> +#include <WebKit/WebKitCOMAPI.h> #include <wtf/HashMap.h> #include <wtf/Vector.h> #include <sstream> + using std::wstring; using std::wiostream; @@ -251,6 +254,33 @@ HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::willSendRequest( return S_OK; } +HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::didReceiveAuthenticationChallenge( + /* [in] */ IWebView *webView, + /* [in] */ unsigned long identifier, + /* [in] */ IWebURLAuthenticationChallenge *challenge, + /* [in] */ IWebDataSource *dataSource) +{ + if (!gLayoutTestController->handlesAuthenticationChallenges()) + return E_FAIL; + + const char* user = gLayoutTestController->authenticationUsername().c_str(); + const char* password = gLayoutTestController->authenticationPassword().c_str(); + + printf("%S - didReceiveAuthenticationChallenge - Responding with %s:%s\n", descriptionSuitableForTestResult(identifier).c_str(), user, password); + + COMPtr<IWebURLAuthenticationChallengeSender> sender; + if (!challenge || FAILED(challenge->sender(&sender))) + return E_FAIL; + + COMPtr<IWebURLCredential> credential; + if (FAILED(WebKitCreateInstance(CLSID_WebURLCredential, 0, IID_IWebURLCredential, (void**)&credential))) + return E_FAIL; + credential->initWithUser(_bstr_t(user), _bstr_t(password), WebURLCredentialPersistenceForSession); + + sender->useCredential(credential.get(), challenge); + return S_OK; +} + HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::didReceiveResponse( /* [in] */ IWebView* webView, /* [in] */ unsigned long identifier, diff --git a/WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.h b/WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.h index c708147..924727b 100644 --- a/WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.h +++ b/WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.h @@ -60,7 +60,7 @@ public: /* [in] */ IWebView *webView, /* [in] */ unsigned long identifier, /* [in] */ IWebURLAuthenticationChallenge *challenge, - /* [in] */ IWebDataSource *dataSource) { return E_NOTIMPL; } + /* [in] */ IWebDataSource *dataSource); virtual HRESULT STDMETHODCALLTYPE didCancelAuthenticationChallenge( /* [in] */ IWebView *webView, diff --git a/WebKitTools/DumpRenderTree/win/TestNetscapePlugin/TestNetscapePlugin.vcproj b/WebKitTools/DumpRenderTree/win/TestNetscapePlugin/TestNetscapePlugin.vcproj index 5ccd6ce..0e0918d 100644 --- a/WebKitTools/DumpRenderTree/win/TestNetscapePlugin/TestNetscapePlugin.vcproj +++ b/WebKitTools/DumpRenderTree/win/TestNetscapePlugin/TestNetscapePlugin.vcproj @@ -23,7 +23,7 @@ >
<Tool
Name="VCPreBuildEventTool"
- CommandLine="set PATH=%SystemDrive%\cygwin\bin;%PATH%
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"
"
+ CommandLine="%SystemDrive%\cygwin\bin\which.exe bash
if errorlevel 1 set PATH=%SystemDrive%\cygwin\bin;%PATH%
cmd /c
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"
"
/>
<Tool
Name="VCCustomBuildTool"
@@ -93,7 +93,7 @@ >
<Tool
Name="VCPreBuildEventTool"
- CommandLine="set PATH=%SystemDrive%\cygwin\bin;%PATH%
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"
"
+ CommandLine="%SystemDrive%\cygwin\bin\which.exe bash
if errorlevel 1 set PATH=%SystemDrive%\cygwin\bin;%PATH%
cmd /c
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"
"
/>
<Tool
Name="VCCustomBuildTool"
@@ -162,7 +162,7 @@ >
<Tool
Name="VCPreBuildEventTool"
- CommandLine="set PATH=%SystemDrive%\cygwin\bin;%PATH%
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"
"
+ CommandLine="%SystemDrive%\cygwin\bin\which.exe bash
if errorlevel 1 set PATH=%SystemDrive%\cygwin\bin;%PATH%
cmd /c
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"
"
/>
<Tool
Name="VCCustomBuildTool"
@@ -224,6 +224,75 @@ CommandLine="if exist "$(WebKitOutputDir)\buildfailed" del "$(WebKitOutputDir)\buildfailed""
/>
</Configuration>
+ <Configuration
+ Name="Debug_Cairo|Win32"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug_wincairo.vsprops"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ CommandLine="%SystemDrive%\cygwin\bin\which.exe bash
if errorlevel 1 set PATH=%SystemDrive%\cygwin\bin;%PATH%
cmd /c
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"
"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=""$(WebKitOutputDir)\Include";"$(WebKitOutputDir)\Include\JavaScriptCore";"$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders";"$(ProjectDir)..\..\TestNetscapePlugin.subproj";"$(WebKitLibrariesDir)\include";"$(WebKitLibrariesDir)\include\CoreFoundation\OSXCompatibilityHeaders";"$(WebKitLibrariesDir)\include\CoreFoundation\OSXCompatibilityHeaders\GNUCompatibility""
+ PreprocessorDefinitions="_USRDLL;TESTNETSCAPEPLUGIN_EXPORTS;snprintf=_snprintf"
+ DisableSpecificWarnings="4819"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories=""
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)\$(ProjectName)$(WebKitConfigSuffix)\np$(ProjectName)$(WebKitConfigSuffix).dll"
+ ModuleDefinitionFile="TestNetscapePlugin$(WebKitConfigSuffix).def"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="if exist "$(WebKitOutputDir)\buildfailed" del "$(WebKitOutputDir)\buildfailed""
+ />
+ </Configuration>
</Configurations>
<References>
</References>
diff --git a/WebKitTools/DumpRenderTree/win/UIDelegate.cpp b/WebKitTools/DumpRenderTree/win/UIDelegate.cpp index 63f5441..b78fd3e 100755 --- a/WebKitTools/DumpRenderTree/win/UIDelegate.cpp +++ b/WebKitTools/DumpRenderTree/win/UIDelegate.cpp @@ -33,6 +33,7 @@ #include "DraggingInfo.h" #include "EventSender.h" #include "LayoutTestController.h" +#include "DRTDesktopNotificationPresenter.h" #include <WebCore/COMPtr.h> #include <wtf/Platform.h> @@ -155,6 +156,7 @@ void DRTUndoManager::undo() UIDelegate::UIDelegate() : m_refCount(1) , m_undoManager(new DRTUndoManager) + , m_desktopNotifications(new DRTDesktopNotificationPresenter) { m_frame.bottom = 0; m_frame.top = 0; @@ -174,6 +176,8 @@ HRESULT STDMETHODCALLTYPE UIDelegate::QueryInterface(REFIID riid, void** ppvObje *ppvObject = static_cast<IWebUIDelegate*>(this); else if (IsEqualGUID(riid, IID_IWebUIDelegate)) *ppvObject = static_cast<IWebUIDelegate*>(this); + else if (IsEqualGUID(riid, IID_IWebUIDelegate2)) + *ppvObject = static_cast<IWebUIDelegate2*>(this); else if (IsEqualGUID(riid, IID_IWebUIDelegatePrivate)) *ppvObject = static_cast<IWebUIDelegatePrivate*>(this); else @@ -499,6 +503,11 @@ HRESULT STDMETHODCALLTYPE UIDelegate::doDragDrop( draggingInfo = new DraggingInfo(object, source); replaySavedEvents(); + if (draggingInfo) { + *performedEffect = draggingInfo->performedDropEffect(); + delete draggingInfo; + draggingInfo = 0; + } return S_OK; } @@ -561,6 +570,20 @@ HRESULT STDMETHODCALLTYPE UIDelegate::exceededDatabaseQuota( /* [in] */ IWebSecurityOrigin *origin, /* [in] */ BSTR databaseIdentifier) { + BSTR protocol; + BSTR host; + unsigned short port; + + origin->protocol(&protocol); + origin->host(&host); + origin->port(&port); + + if (!done && gLayoutTestController->dumpDatabaseCallbacks()) + printf("UI DELEGATE DATABASE CALLBACK: exceededDatabaseQuotaForSecurityOrigin:{%S, %S, %i} database:%S\n", protocol, host, port, databaseIdentifier); + + SysFreeString(protocol); + SysFreeString(host); + static const unsigned long long defaultQuota = 5 * 1024 * 1024; origin->setQuota(defaultQuota); @@ -604,3 +627,9 @@ HRESULT STDMETHODCALLTYPE UIDelegate::setStatusText(IWebView*, BSTR text) printf("UI DELEGATE STATUS CALLBACK: setStatusText:%S\n", text ? text : L""); return S_OK; } + +HRESULT STDMETHODCALLTYPE UIDelegate::desktopNotificationsDelegate(IWebDesktopNotificationsDelegate** result) +{ + m_desktopNotifications.copyRefTo(result); + return S_OK; +} diff --git a/WebKitTools/DumpRenderTree/win/UIDelegate.h b/WebKitTools/DumpRenderTree/win/UIDelegate.h index 853031f..436e31a 100755 --- a/WebKitTools/DumpRenderTree/win/UIDelegate.h +++ b/WebKitTools/DumpRenderTree/win/UIDelegate.h @@ -29,13 +29,15 @@ #ifndef UIDelegate_h #define UIDelegate_h +#include <WebCore/COMPtr.h> #include <WebKit/WebKit.h> #include <wtf/OwnPtr.h> #include <windef.h> class DRTUndoManager; +class DRTDesktopNotificationPresenter; -class UIDelegate : public IWebUIDelegate, IWebUIDelegatePrivate { +class UIDelegate : public IWebUIDelegate2, IWebUIDelegatePrivate { public: UIDelegate(); @@ -326,20 +328,11 @@ public: protected: // IWebUIDelegatePrivate - virtual HRESULT STDMETHODCALLTYPE webViewResizerRect( - /* [in] */ IWebView *sender, - /* [retval][out] */ RECT *rect) { return E_NOTIMPL; } + virtual HRESULT STDMETHODCALLTYPE unused1() { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE webViewSendResizeMessage( - /* [in] */ UINT uMsg, - /* [in] */ WPARAM wParam, - /* [in] */ LPARAM lParam) { return E_NOTIMPL; } + virtual HRESULT STDMETHODCALLTYPE unused2() { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE webViewDrawResizer( - /* [in] */ IWebView *sender, - /* [in] */ HDC dc, - /* [in] */ BOOL overlapsContent, - /* [in] */ RECT *rect) { return E_NOTIMPL; } + virtual HRESULT STDMETHODCALLTYPE unused3() { return E_NOTIMPL; } virtual HRESULT STDMETHODCALLTYPE webViewScrolled( /* [in] */ IWebView *sender) { return E_NOTIMPL; } @@ -399,11 +392,16 @@ protected: virtual HRESULT STDMETHODCALLTYPE webViewDidInvalidate( /* [in] */ IWebView *sender); + virtual HRESULT STDMETHODCALLTYPE desktopNotificationsDelegate( + /* [out] */ IWebDesktopNotificationsDelegate** result); + ULONG m_refCount; private: RECT m_frame; OwnPtr<DRTUndoManager> m_undoManager; + + COMPtr<IWebDesktopNotificationsDelegate> m_desktopNotifications; }; #endif diff --git a/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp b/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp index fa7e541..bfe1d99 100644 --- a/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp +++ b/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp @@ -100,6 +100,11 @@ void LayoutTestController::setAcceptsEditing(bool acceptsEditing) { } +void LayoutTestController::setAlwaysAcceptCookies(bool alwaysAcceptCookies) +{ + // FIXME: Implement this (and restore the default value before running each test in DumpRenderTree.cpp). +} + void LayoutTestController::setCustomPolicyDelegate(bool, bool) { // FIXME: implement @@ -217,6 +222,12 @@ unsigned LayoutTestController::numberOfActiveAnimations() const return 0; } +unsigned LayoutTestController::workerThreadCount() const +{ + // FIXME: implement + return 0; +} + void LayoutTestController::setSelectTrailingWhitespaceEnabled(bool flag) { // FIXME: implement @@ -228,6 +239,18 @@ bool LayoutTestController::pauseTransitionAtTimeOnElementWithId(JSStringRef prop return false; } +void LayoutTestController::setMockGeolocationPosition(double latitude, double longitude, double accuracy) +{ + // FIXME: Implement for Geolocation layout tests. + // See https://bugs.webkit.org/show_bug.cgi?id=28264. +} + +void LayoutTestController::setMockGeolocationError(int code, JSStringRef message) +{ + // FIXME: Implement for Geolocation layout tests. + // See https://bugs.webkit.org/show_bug.cgi?id=28264. +} + void LayoutTestController::setIconDatabaseEnabled(bool iconDatabaseEnabled) { // FIXME: implement @@ -260,3 +283,33 @@ void LayoutTestController::waitForPolicyDelegate() { // FIXME: Implement this. } + +void LayoutTestController::overridePreference(JSStringRef /* key */, JSStringRef /* value */) +{ + // FIXME: implement +} + +void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart) +{ + printf("LayoutTestController::addUserScript not implemented.\n"); +} + +void LayoutTestController::addUserStyleSheet(JSStringRef source) +{ + printf("LayoutTestController::addUserStyleSheet not implemented.\n"); +} + +void LayoutTestController::showWebInspector() +{ + // FIXME: Implement this. +} + +void LayoutTestController::closeWebInspector() +{ + // FIXME: Implement this. +} + +void LayoutTestController::evaluateInWebInspector(long callId, JSStringRef script) +{ + // FIXME: Implement this. +} |