diff options
Diffstat (limited to 'WebKitTools/DumpRenderTree')
51 files changed, 1202 insertions, 311 deletions
diff --git a/WebKitTools/DumpRenderTree/AccessibilityUIElement.cpp b/WebKitTools/DumpRenderTree/AccessibilityUIElement.cpp index 52d238d..87be335 100644 --- a/WebKitTools/DumpRenderTree/AccessibilityUIElement.cpp +++ b/WebKitTools/DumpRenderTree/AccessibilityUIElement.cpp @@ -204,6 +204,15 @@ static JSValueRef childAtIndexCallback(JSContextRef context, JSObjectRef functio return AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->getChildAtIndex(indexNumber)); } +static JSValueRef selectedChildAtIndexCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + int indexNumber = -1; + if (argumentCount == 1) + indexNumber = JSValueToNumber(context, arguments[0], exception); + + return AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->selectedChildAtIndex(indexNumber)); +} + static JSValueRef linkedUIElementAtIndexCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { int indexNumber = -1; @@ -260,6 +269,17 @@ static JSValueRef isEqualCallback(JSContextRef context, JSObjectRef function, JS return JSValueMakeBoolean(context, toAXElement(thisObject)->isEqual(toAXElement(otherElement))); } +static JSValueRef setSelectedChildCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + JSObjectRef element = 0; + if (argumentCount == 1) + element = JSValueToObject(context, arguments[0], exception); + + toAXElement(thisObject)->setSelectedChild(toAXElement(element)); + + return JSValueMakeUndefined(context); +} + static JSValueRef elementAtPointCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { int x = 0; @@ -695,6 +715,11 @@ static JSValueRef speakCallback(JSContextRef context, JSObjectRef thisObject, JS return JSValueMakeString(context, speakString.get()); } +static JSValueRef selectedChildrenCountCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) +{ + return JSValueMakeNumber(context, toAXElement(thisObject)->selectedChildrenCount()); +} + static JSValueRef getHasPopupCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef*) { return JSValueMakeBoolean(context, toAXElement(thisObject)->hasPopup()); @@ -757,6 +782,9 @@ static JSValueRef removeNotificationListenerCallback(JSContextRef context, JSObj #if !PLATFORM(MAC) JSStringRef AccessibilityUIElement::speak() { return 0; } JSStringRef AccessibilityUIElement::rangeForLine(int line) { return 0; } +void AccessibilityUIElement::setSelectedChild(AccessibilityUIElement*) const { } +unsigned AccessibilityUIElement::selectedChildrenCount() const { return 0; } +AccessibilityUIElement AccessibilityUIElement::selectedChildAtIndex(unsigned) const { return 0; } #endif #if !SUPPORTS_AX_TEXTMARKERS @@ -860,6 +888,7 @@ JSClassRef AccessibilityUIElement::getJSClass() { "ariaDropEffects", getARIADropEffectsCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "isIgnored", isIgnoredCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "speak", speakCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "selectedChildrenCount", selectedChildrenCountCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { 0, 0, 0, 0 } }; @@ -920,6 +949,8 @@ JSClassRef AccessibilityUIElement::getJSClass() { "accessibilityElementForTextMarker", accessibilityElementForTextMarkerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "textMarkerRangeLength", textMarkerRangeLengthCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "textMarkerForPoint", textMarkerForPointCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "setSelectedChild", setSelectedChildCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "selectedChildAtIndex", selectedChildAtIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { 0, 0, 0 } }; diff --git a/WebKitTools/DumpRenderTree/AccessibilityUIElement.h b/WebKitTools/DumpRenderTree/AccessibilityUIElement.h index 9311dfd..3120e65 100644 --- a/WebKitTools/DumpRenderTree/AccessibilityUIElement.h +++ b/WebKitTools/DumpRenderTree/AccessibilityUIElement.h @@ -130,9 +130,14 @@ public: JSStringRef selectedTextRange(); bool isEnabled(); bool isRequired() const; + bool isSelected() const; bool isSelectable() const; bool isMultiSelectable() const; + void setSelectedChild(AccessibilityUIElement*) const; + unsigned selectedChildrenCount() const; + AccessibilityUIElement selectedChildAtIndex(unsigned) const; + bool isExpanded() const; bool isChecked() const; bool isVisible() const; diff --git a/WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj b/WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj index 51d8e7f..bf0aebf 100644 --- a/WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj +++ b/WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj @@ -48,7 +48,8 @@ 29CFBA2E12273A1000BC30C0 /* AccessibilityTextMarkerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 29CFBA2D12273A1000BC30C0 /* AccessibilityTextMarkerMac.mm */; }; 3713EDE2115BE19300705720 /* ColorBits-A.png in Copy Font Files */ = {isa = PBXBuildFile; fileRef = 3713EDDF115BE16F00705720 /* ColorBits-A.png */; }; 3713EDE3115BE19300705720 /* ColorBits.ttf in Copy Font Files */ = {isa = PBXBuildFile; fileRef = 3713EDE0115BE16F00705720 /* ColorBits.ttf */; }; - 4437730E125CBC3600AAE02C /* WebArchiveDumpSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = 44A997830FCDE86400580F10 /* WebArchiveDumpSupport.mm */; }; + 440590711268453800CFD48D /* WebArchiveDumpSupportMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 440590701268453800CFD48D /* WebArchiveDumpSupportMac.mm */; }; + 4437730E125CBC3600AAE02C /* WebArchiveDumpSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 44A997830FCDE86400580F10 /* WebArchiveDumpSupport.cpp */; }; 4437730F125CBC4D00AAE02C /* WebArchiveDumpSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 44A997820FCDE86400580F10 /* WebArchiveDumpSupport.h */; }; 5185F6B210714E07007AA393 /* HistoryDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5185F69F10714A57007AA393 /* HistoryDelegate.mm */; }; 5185F6B310714E12007AA393 /* HistoryDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 5185F69E10714A57007AA393 /* HistoryDelegate.h */; }; @@ -131,6 +132,7 @@ BCD08B710E1059D200A7D0C1 /* AccessibilityControllerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCD08B700E1059D200A7D0C1 /* AccessibilityControllerMac.mm */; }; BCF6C6500C98E9C000AC063E /* GCController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCF6C64F0C98E9C000AC063E /* GCController.cpp */; }; C06F9ABC1267A7060058E1F6 /* PassDifferentNPPStruct.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C06F9ABB1267A7060058E1F6 /* PassDifferentNPPStruct.cpp */; }; + C0EC3C9C12787F0500939164 /* NullNPPGetValuePointer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0EC3C9B12787F0500939164 /* NullNPPGetValuePointer.cpp */; }; E1B7816511AF31B7007E1BC2 /* MockGeolocationProvider.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1B7808711AF1669007E1BC2 /* MockGeolocationProvider.mm */; }; E1B7816711AF31C3007E1BC2 /* MockGeolocationProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = E1B7808511AF1643007E1BC2 /* MockGeolocationProvider.h */; }; /* End PBXBuildFile section */ @@ -223,11 +225,12 @@ 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>"; }; - 44A997820FCDE86400580F10 /* WebArchiveDumpSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebArchiveDumpSupport.h; path = mac/WebArchiveDumpSupport.h; sourceTree = "<group>"; }; - 44A997830FCDE86400580F10 /* WebArchiveDumpSupport.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebArchiveDumpSupport.mm; path = mac/WebArchiveDumpSupport.mm; sourceTree = "<group>"; }; + 440590701268453800CFD48D /* WebArchiveDumpSupportMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebArchiveDumpSupportMac.mm; path = mac/WebArchiveDumpSupportMac.mm; sourceTree = "<group>"; }; + 44A997820FCDE86400580F10 /* WebArchiveDumpSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebArchiveDumpSupport.h; path = cf/WebArchiveDumpSupport.h; sourceTree = "<group>"; }; + 44A997830FCDE86400580F10 /* WebArchiveDumpSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebArchiveDumpSupport.cpp; path = cf/WebArchiveDumpSupport.cpp; 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>"; }; + 8465E2C60FFA8DF2003B8342 /* PixelDumpSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; 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>"; }; 933BF5AA0F93FA5C000F0441 /* PlainTextController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PlainTextController.mm; path = mac/PlainTextController.mm; sourceTree = "<group>"; }; @@ -247,14 +250,14 @@ AE8257EF08D22389000507AB /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; }; B5A7526708AF4A4A00138E45 /* ImageDiff */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ImageDiff; sourceTree = BUILT_PRODUCTS_DIR; }; B5A752A108AF5D1F00138E45 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = /System/Library/Frameworks/QuartzCore.framework; sourceTree = "<absolute>"; }; - BC0131D80C9772010087317D /* LayoutTestController.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 30; path = LayoutTestController.cpp; sourceTree = "<group>"; }; + BC0131D80C9772010087317D /* LayoutTestController.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutTestController.cpp; sourceTree = "<group>"; }; BC0131D90C9772010087317D /* LayoutTestController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = LayoutTestController.h; sourceTree = "<group>"; }; BC0E24DE0E2D9451001B6BC2 /* AccessibilityUIElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityUIElement.h; sourceTree = "<group>"; }; BC0E24DF0E2D9451001B6BC2 /* AccessibilityUIElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityUIElement.cpp; sourceTree = "<group>"; }; BC0E26140E2DA4C6001B6BC2 /* AccessibilityUIElementMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AccessibilityUIElementMac.mm; path = mac/AccessibilityUIElementMac.mm; sourceTree = "<group>"; }; BC4741290D038A4C0072B006 /* JavaScriptThreading.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JavaScriptThreading.h; sourceTree = "<group>"; }; BC4741400D038A570072B006 /* JavaScriptThreadingPthreads.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JavaScriptThreadingPthreads.cpp; path = pthreads/JavaScriptThreadingPthreads.cpp; sourceTree = "<group>"; }; - BC9D90210C97472D0099A4A3 /* WorkQueue.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 30; path = WorkQueue.cpp; sourceTree = "<group>"; }; + BC9D90210C97472D0099A4A3 /* WorkQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = WorkQueue.cpp; sourceTree = "<group>"; }; BC9D90220C97472E0099A4A3 /* WorkQueue.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WorkQueue.h; sourceTree = "<group>"; }; BC9D90230C97472E0099A4A3 /* WorkQueueItem.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WorkQueueItem.h; sourceTree = "<group>"; }; BCA18B210C9B014B00114369 /* GCControllerMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = GCControllerMac.mm; path = mac/GCControllerMac.mm; sourceTree = "<group>"; }; @@ -293,7 +296,7 @@ BCB282F40CFA7450007E533E /* DebugRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xcconfig; name = DebugRelease.xcconfig; path = mac/Configurations/DebugRelease.xcconfig; sourceTree = "<group>"; }; BCB283D80CFA7AFD007E533E /* ImageDiff.xcconfig */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xcconfig; name = ImageDiff.xcconfig; path = mac/Configurations/ImageDiff.xcconfig; sourceTree = "<group>"; }; BCB283DE0CFA7C20007E533E /* TestNetscapePlugIn.xcconfig */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xcconfig; name = TestNetscapePlugIn.xcconfig; path = mac/Configurations/TestNetscapePlugIn.xcconfig; sourceTree = "<group>"; }; - BCB284880CFA8202007E533E /* PixelDumpSupportCG.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 30; name = PixelDumpSupportCG.cpp; path = cg/PixelDumpSupportCG.cpp; sourceTree = "<group>"; }; + BCB284880CFA8202007E533E /* PixelDumpSupportCG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = PixelDumpSupportCG.cpp; path = cg/PixelDumpSupportCG.cpp; sourceTree = "<group>"; }; BCB284890CFA8202007E533E /* PixelDumpSupportCG.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = PixelDumpSupportCG.h; path = cg/PixelDumpSupportCG.h; sourceTree = "<group>"; }; BCB2848A0CFA820F007E533E /* PixelDumpSupport.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PixelDumpSupport.h; sourceTree = "<group>"; }; BCB2848C0CFA8221007E533E /* PixelDumpSupportMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = PixelDumpSupportMac.mm; path = mac/PixelDumpSupportMac.mm; sourceTree = "<group>"; }; @@ -302,8 +305,9 @@ BCD08A580E10496B00A7D0C1 /* AccessibilityController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityController.h; sourceTree = "<group>"; }; BCD08B390E1057EF00A7D0C1 /* AccessibilityController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityController.cpp; sourceTree = "<group>"; }; BCD08B700E1059D200A7D0C1 /* AccessibilityControllerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AccessibilityControllerMac.mm; path = mac/AccessibilityControllerMac.mm; sourceTree = "<group>"; }; - BCF6C64F0C98E9C000AC063E /* GCController.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 30; path = GCController.cpp; sourceTree = "<group>"; }; + BCF6C64F0C98E9C000AC063E /* GCController.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = GCController.cpp; sourceTree = "<group>"; }; C06F9ABB1267A7060058E1F6 /* PassDifferentNPPStruct.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PassDifferentNPPStruct.cpp; sourceTree = "<group>"; }; + C0EC3C9B12787F0500939164 /* NullNPPGetValuePointer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NullNPPGetValuePointer.cpp; sourceTree = "<group>"; }; E1B7808511AF1643007E1BC2 /* MockGeolocationProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MockGeolocationProvider.h; path = mac/MockGeolocationProvider.h; sourceTree = "<group>"; }; E1B7808711AF1669007E1BC2 /* MockGeolocationProvider.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MockGeolocationProvider.mm; path = mac/MockGeolocationProvider.mm; sourceTree = "<group>"; }; /* End PBXFileReference section */ @@ -365,7 +369,8 @@ A8D79CE80FC28B2C004AC8FE /* DumpRenderTreeFileDraggingSource.h */, A8D79CE90FC28B2C004AC8FE /* DumpRenderTreeFileDraggingSource.m */, 44A997820FCDE86400580F10 /* WebArchiveDumpSupport.h */, - 44A997830FCDE86400580F10 /* WebArchiveDumpSupport.mm */, + 44A997830FCDE86400580F10 /* WebArchiveDumpSupport.cpp */, + 440590701268453800CFD48D /* WebArchiveDumpSupportMac.mm */, BC9D90210C97472D0099A4A3 /* WorkQueue.cpp */, BC9D90220C97472E0099A4A3 /* WorkQueue.h */, BC9D90230C97472E0099A4A3 /* WorkQueueItem.h */, @@ -459,6 +464,7 @@ 1A215A7511F26072008AD0F5 /* DocumentOpenInDestroyStream.cpp */, 1A24BAA8120734EE00FBB059 /* NPRuntimeObjectFromDestroyedPlugin.cpp */, 1AC77DCE120605B6005C19EF /* NPRuntimeRemoveProperty.cpp */, + C0EC3C9B12787F0500939164 /* NullNPPGetValuePointer.cpp */, C06F9ABB1267A7060058E1F6 /* PassDifferentNPPStruct.cpp */, 1AD9D2FD12028409001A70D1 /* PluginScriptableNPObjectInvokeDefault.cpp */, ); @@ -697,7 +703,14 @@ isa = PBXProject; buildConfigurationList = 149C29C308902C6D008A9EFC /* Build configuration list for PBXProject "DumpRenderTree" */; compatibilityVersion = "Xcode 2.4"; + developmentRegion = English; hasScannedForEncodings = 1; + knownRegions = ( + English, + Japanese, + French, + German, + ); mainGroup = 08FB7794FE84155DC02AAC07 /* DumpRenderTree */; productRefGroup = 9340995508540CAF007F3BC8 /* Products */; projectDirPath = ""; @@ -737,6 +750,7 @@ 1AC77DCF120605B6005C19EF /* NPRuntimeRemoveProperty.cpp in Sources */, 1A24BAA9120734EE00FBB059 /* NPRuntimeObjectFromDestroyedPlugin.cpp in Sources */, C06F9ABC1267A7060058E1F6 /* PassDifferentNPPStruct.cpp in Sources */, + C0EC3C9C12787F0500939164 /* NullNPPGetValuePointer.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -775,7 +789,8 @@ BCA18B680C9B08C200114369 /* ResourceLoadDelegate.mm in Sources */, BCA18B490C9B02C400114369 /* TextInputController.m in Sources */, BCA18B6A0C9B08C200114369 /* UIDelegate.mm in Sources */, - 4437730E125CBC3600AAE02C /* WebArchiveDumpSupport.mm in Sources */, + 4437730E125CBC3600AAE02C /* WebArchiveDumpSupport.cpp in Sources */, + 440590711268453800CFD48D /* WebArchiveDumpSupportMac.mm in Sources */, BC9D90240C97472E0099A4A3 /* WorkQueue.cpp in Sources */, BCA18B260C9B015C00114369 /* WorkQueueItemMac.mm in Sources */, 5185F6B210714E07007AA393 /* HistoryDelegate.mm in Sources */, diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/LayoutTestController.cpp index b5cc874..9619389 100644 --- a/WebKitTools/DumpRenderTree/LayoutTestController.cpp +++ b/WebKitTools/DumpRenderTree/LayoutTestController.cpp @@ -51,6 +51,7 @@ LayoutTestController::LayoutTestController(const std::string& testPathOrURL, con , m_dumpDatabaseCallbacks(false) , m_dumpEditingCallbacks(false) , m_dumpFrameLoadCallbacks(false) + , m_dumpUserGestureInFrameLoadCallbacks(false) , m_dumpHistoryDelegateCallbacks(false) , m_dumpResourceLoadCallbacks(false) , m_dumpResourceResponseMIMETypes(false) @@ -167,6 +168,13 @@ static JSValueRef dumpFrameLoadCallbacksCallback(JSContextRef context, JSObjectR return JSValueMakeUndefined(context); } +static JSValueRef dumpUserGestureInFrameLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + controller->setDumpUserGestureInFrameLoadCallbacks(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)); @@ -1070,14 +1078,17 @@ static JSValueRef setMockGeolocationErrorCallback(JSContextRef context, JSObject static JSValueRef setMockSpeechInputResultCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { - if (argumentCount < 1) + if (argumentCount < 2) return JSValueMakeUndefined(context); JSRetainPtr<JSStringRef> result(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); + JSRetainPtr<JSStringRef> language(Adopt, JSValueToStringCopy(context, arguments[1], exception)); + ASSERT(!*exception); + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); - controller->setMockSpeechInputResult(result.get()); + controller->setMockSpeechInputResult(result.get(), language.get()); return JSValueMakeUndefined(context); } @@ -1889,6 +1900,7 @@ JSStaticFunction* LayoutTestController::staticFunctions() { "dumpDatabaseCallbacks", dumpDatabaseCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "dumpEditingCallbacks", dumpEditingCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "dumpFrameLoadCallbacks", dumpFrameLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "dumpUserGestureInFrameLoadCallbacks", dumpUserGestureInFrameLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "dumpResourceLoadCallbacks", dumpResourceLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "dumpResourceResponseMIMETypes", dumpResourceResponseMIMETypesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "dumpSelectionRect", dumpSelectionRectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.h b/WebKitTools/DumpRenderTree/LayoutTestController.h index 689e114..b61860b 100644 --- a/WebKitTools/DumpRenderTree/LayoutTestController.h +++ b/WebKitTools/DumpRenderTree/LayoutTestController.h @@ -94,7 +94,7 @@ public: void setMockDeviceOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma); void setMockGeolocationError(int code, JSStringRef message); void setMockGeolocationPosition(double latitude, double longitude, double accuracy); - void setMockSpeechInputResult(JSStringRef result); + void setMockSpeechInputResult(JSStringRef result, JSStringRef language); void setPersistentUserStyleSheetLocation(JSStringRef path); void setPluginsEnabled(bool flag); void setPopupBlockingEnabled(bool flag); @@ -154,6 +154,9 @@ public: bool dumpFrameLoadCallbacks() const { return m_dumpFrameLoadCallbacks; } void setDumpFrameLoadCallbacks(bool dumpFrameLoadCallbacks) { m_dumpFrameLoadCallbacks = dumpFrameLoadCallbacks; } + + bool dumpUserGestureInFrameLoadCallbacks() const { return m_dumpUserGestureInFrameLoadCallbacks; } + void setDumpUserGestureInFrameLoadCallbacks(bool dumpUserGestureInFrameLoadCallbacks) { m_dumpUserGestureInFrameLoadCallbacks = dumpUserGestureInFrameLoadCallbacks; } bool dumpHistoryDelegateCallbacks() const { return m_dumpHistoryDelegateCallbacks; } void setDumpHistoryDelegateCallbacks(bool dumpHistoryDelegateCallbacks) { m_dumpHistoryDelegateCallbacks = dumpHistoryDelegateCallbacks; } @@ -311,6 +314,7 @@ private: bool m_dumpDatabaseCallbacks; bool m_dumpEditingCallbacks; bool m_dumpFrameLoadCallbacks; + bool m_dumpUserGestureInFrameLoadCallbacks; bool m_dumpHistoryDelegateCallbacks; bool m_dumpResourceLoadCallbacks; bool m_dumpResourceResponseMIMETypes; diff --git a/WebKitTools/DumpRenderTree/PixelDumpSupport.cpp b/WebKitTools/DumpRenderTree/PixelDumpSupport.cpp index b5a5146..352eaaa 100644 --- a/WebKitTools/DumpRenderTree/PixelDumpSupport.cpp +++ b/WebKitTools/DumpRenderTree/PixelDumpSupport.cpp @@ -27,9 +27,10 @@ */ #include "config.h" +#include "PixelDumpSupport.h" + #include "DumpRenderTree.h" #include "LayoutTestController.h" -#include "PixelDumpSupport.h" #include <cstdio> #include <wtf/Assertions.h> #include <wtf/RefPtr.h> diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp index 1df1c76..db73a9d 100644 --- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp +++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp @@ -103,6 +103,7 @@ static NPObject* pluginAllocate(NPP npp, NPClass*); static void pluginDeallocate(NPObject*); NPNetscapeFuncs* browser; +NPPluginFuncs* pluginFunctions; static NPClass pluginClass = { NP_CLASS_STRUCT_VERSION, diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.h b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.h index 6c30578..99d5bf6 100644 --- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.h +++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.h @@ -38,6 +38,7 @@ class PluginTest; extern NPNetscapeFuncs *browser; +extern NPPluginFuncs* pluginFunctions; typedef struct { NPObject header; diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp index d435a2e..e41e6e5 100644 --- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp +++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp @@ -26,6 +26,7 @@ #include "PluginTest.h" #include <assert.h> +#include <string.h> using namespace std; extern NPNetscapeFuncs *browser; @@ -49,6 +50,11 @@ PluginTest::~PluginTest() { } +NPError PluginTest::NPP_Destroy(NPSavedData**) +{ + return NPERR_NO_ERROR; +} + NPError PluginTest::NPP_DestroyStream(NPStream *stream, NPReason reason) { return NPERR_NO_ERROR; @@ -65,6 +71,11 @@ NPError PluginTest::NPP_SetWindow(NPP, NPWindow*) return NPERR_NO_ERROR; } +void PluginTest::NPN_InvalidateRect(NPRect* invalidRect) +{ + browser->invalidaterect(m_npp, invalidRect); +} + NPIdentifier PluginTest::NPN_GetStringIdentifier(const NPUTF8 *name) { return browser->getstringidentifier(name); @@ -90,6 +101,30 @@ bool PluginTest::NPN_RemoveProperty(NPObject* npObject, NPIdentifier propertyNam return browser->removeproperty(m_npp, npObject, propertyName); } +static void executeScript(NPP npp, const char* script) +{ + NPObject* windowScriptObject; + browser->getvalue(npp, NPNVWindowNPObject, &windowScriptObject); + + NPString npScript; + npScript.UTF8Characters = script; + npScript.UTF8Length = strlen(script); + + NPVariant browserResult; + browser->evaluate(npp, windowScriptObject, &npScript, &browserResult); + browser->releasevariantvalue(&browserResult); +} + +void PluginTest::waitUntilDone() +{ + executeScript(m_npp, "layoutTestController.waitUntilDone()"); +} + +void PluginTest::notifyDone() +{ + executeScript(m_npp, "layoutTestController.notifyDone()"); +} + void PluginTest::registerCreateTestFunction(const string& identifier, CreateTestFunction createTestFunction) { assert(!createTestFunctions().count(identifier)); diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h index cbc7934..0497764 100644 --- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h +++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h @@ -55,11 +55,13 @@ public: virtual ~PluginTest(); // NPP functions. + virtual NPError NPP_Destroy(NPSavedData**); virtual NPError NPP_DestroyStream(NPStream* stream, NPReason reason); virtual NPError NPP_GetValue(NPPVariable, void* value); virtual NPError NPP_SetWindow(NPP, NPWindow*); // NPN functions. + void NPN_InvalidateRect(NPRect* invalidRect); NPIdentifier NPN_GetStringIdentifier(const NPUTF8* name); NPIdentifier NPN_GetIntIdentifier(int32_t intid); NPError NPN_GetValue(NPNVariable, void* value); @@ -88,6 +90,9 @@ protected: const std::string& identifier() const { return m_identifier; } + void waitUntilDone(); + void notifyDone(); + // NPObject helper template. template<typename T> struct Object : NPObject { public: diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/NullNPPGetValuePointer.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/NullNPPGetValuePointer.cpp new file mode 100644 index 0000000..9e4e976 --- /dev/null +++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/NullNPPGetValuePointer.cpp @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2010 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. 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 INC. 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 "PluginTest.h" + +#include "PluginObject.h" + +using namespace std; + +// Passing null for our NPP_GetValue function pointer should not crash. + +class NullNPPGetValuePointer : public PluginTest { +public: + NullNPPGetValuePointer(NPP, const string& identifier); + +private: + virtual NPError NPP_Destroy(NPSavedData**); + virtual NPError NPP_GetValue(NPPVariable, void* value); + + NPP_GetValueProcPtr m_originalNPPGetValuePointer; +}; + +static PluginTest::Register<NullNPPGetValuePointer> registrar("null-npp-getvalue-pointer"); + +NullNPPGetValuePointer::NullNPPGetValuePointer(NPP npp, const string& identifier) + : PluginTest(npp, identifier) + , m_originalNPPGetValuePointer(pluginFunctions->getvalue) +{ + // Be sneaky and null out the getvalue pointer the browser is holding. This simulates a plugin + // that doesn't implement NPP_GetValue (like Shockwave Director 10.3 on Windows). Note that if + // WebKit copies the NPPluginFuncs struct this technique will have no effect and WebKit will + // call into our NPP_GetValue implementation. + pluginFunctions->getvalue = 0; +} + +NPError NullNPPGetValuePointer::NPP_Destroy(NPSavedData**) +{ + // Set the NPP_GetValue pointer back the way it was before we mucked with it so we don't mess + // up future uses of the plugin module. + pluginFunctions->getvalue = m_originalNPPGetValuePointer; + return NPERR_NO_ERROR; +} + +NPError NullNPPGetValuePointer::NPP_GetValue(NPPVariable, void*) +{ + pluginLog(m_npp, "NPP_GetValue was called but should not have been. Maybe WebKit copied the NPPluginFuncs struct, which would invalidate this test."); + return NPERR_GENERIC_ERROR; +} diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/NPNInvalidateRectInvalidatesWindow.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/NPNInvalidateRectInvalidatesWindow.cpp new file mode 100644 index 0000000..90ea54d --- /dev/null +++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/NPNInvalidateRectInvalidatesWindow.cpp @@ -0,0 +1,203 @@ +/* + * Copyright (C) 2010 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. 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 INC. 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 "PluginTest.h" + +#include "PluginObject.h" + +using namespace std; + +// NPN_InvalidateRect should invalidate the plugin's HWND. + +static const wchar_t instancePointerProperty[] = L"org.webkit.TestNetscapePlugin.NPNInvalidateRectInvalidatesWindow.InstancePointer"; + +class TemporaryWindowMover { +public: + TemporaryWindowMover(HWND); + ~TemporaryWindowMover(); + + bool moveSucceeded() const { return m_moveSucceeded; } + +private: + static const UINT standardSetWindowPosFlags = SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER; + bool m_moveSucceeded; + HWND m_window; + RECT m_savedWindowRect; +}; + +TemporaryWindowMover::TemporaryWindowMover(HWND window) + : m_window(window) +{ + m_moveSucceeded = false; + + if (!::GetWindowRect(m_window, &m_savedWindowRect)) + return; + + if (!::SetWindowPos(m_window, 0, 0, 0, 0, 0, SWP_SHOWWINDOW | standardSetWindowPosFlags)) + return; + + m_moveSucceeded = true; +}; + +TemporaryWindowMover::~TemporaryWindowMover() +{ + if (!m_moveSucceeded) + return; + + ::SetWindowPos(m_window, 0, m_savedWindowRect.left, m_savedWindowRect.top, 0, 0, SWP_HIDEWINDOW | standardSetWindowPosFlags); +} + +class NPNInvalidateRectInvalidatesWindow : public PluginTest { +public: + NPNInvalidateRectInvalidatesWindow(NPP, const string& identifier); + ~NPNInvalidateRectInvalidatesWindow(); + +private: + static LRESULT CALLBACK wndProc(HWND, UINT message, WPARAM, LPARAM); + + void onPaint(); + void testInvalidateRect(); + + virtual NPError NPP_SetWindow(NPP, NPWindow*); + + HWND m_window; + WNDPROC m_originalWndProc; + TemporaryWindowMover* m_windowMover; +}; + +NPNInvalidateRectInvalidatesWindow::NPNInvalidateRectInvalidatesWindow(NPP npp, const string& identifier) + : PluginTest(npp, identifier) + , m_window(0) + , m_originalWndProc(0) + , m_windowMover(0) +{ +} + +NPNInvalidateRectInvalidatesWindow::~NPNInvalidateRectInvalidatesWindow() +{ + delete m_windowMover; +} + +NPError NPNInvalidateRectInvalidatesWindow::NPP_SetWindow(NPP instance, NPWindow* window) +{ + HWND newWindow = reinterpret_cast<HWND>(window->window); + if (newWindow == m_window) + return NPERR_NO_ERROR; + + if (m_window) { + ::RemovePropW(m_window, instancePointerProperty); + ::SetWindowLongPtr(m_window, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(m_originalWndProc)); + m_originalWndProc = 0; + } + + m_window = newWindow; + if (!m_window) + return NPERR_NO_ERROR; + + m_originalWndProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtrW(m_window, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(wndProc))); + ::SetPropW(m_window, instancePointerProperty, this); + + // The test harness's window (the one that contains the WebView) is off-screen and hidden. + // We need to move it on-screen and make it visible in order for the plugin's window to + // accumulate an update region when the DWM is disabled. + + HWND testHarnessWindow = ::GetAncestor(m_window, GA_ROOT); + if (!testHarnessWindow) { + pluginLog(instance, "Failed to get test harness window"); + return NPERR_GENERIC_ERROR; + } + + m_windowMover = new TemporaryWindowMover(testHarnessWindow); + if (!m_windowMover->moveSucceeded()) { + pluginLog(instance, "Failed to move test harness window on-screen"); + return NPERR_GENERIC_ERROR; + } + + // Wait until we receive a WM_PAINT message to ensure that the window is on-screen before we do + // the NPN_InvalidateRect test. + waitUntilDone(); + return NPERR_NO_ERROR; +} + +LRESULT NPNInvalidateRectInvalidatesWindow::wndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + NPNInvalidateRectInvalidatesWindow* instance = reinterpret_cast<NPNInvalidateRectInvalidatesWindow*>(::GetPropW(hwnd, instancePointerProperty)); + + if (message == WM_PAINT) + instance->onPaint(); + + return ::CallWindowProcW(instance->m_originalWndProc, hwnd, message, wParam, lParam); +} + +void NPNInvalidateRectInvalidatesWindow::onPaint() +{ + testInvalidateRect(); + notifyDone(); + delete m_windowMover; + m_windowMover = 0; +} + +void NPNInvalidateRectInvalidatesWindow::testInvalidateRect() +{ + RECT clientRect; + if (!::GetClientRect(m_window, &clientRect)) { + pluginLog(m_npp, "::GetClientRect failed"); + return; + } + + if (::IsRectEmpty(&clientRect)) { + pluginLog(m_npp, "Plugin's HWND has not been sized when NPP_SetWindow is called"); + return; + } + + // Clear the invalid region. + if (!::ValidateRect(m_window, 0)) { + pluginLog(m_npp, "::ValidateRect failed"); + return; + } + + // Invalidate our lower-right quadrant. + NPRect rectToInvalidate; + rectToInvalidate.left = (clientRect.right - clientRect.left) / 2; + rectToInvalidate.top = (clientRect.bottom - clientRect.top) / 2; + rectToInvalidate.right = clientRect.right; + rectToInvalidate.bottom = clientRect.bottom; + NPN_InvalidateRect(&rectToInvalidate); + + RECT invalidRect; + if (!::GetUpdateRect(m_window, &invalidRect, FALSE)) { + pluginLog(m_npp, "::GetUpdateRect failed"); + return; + } + + if (invalidRect.left != rectToInvalidate.left || invalidRect.top != rectToInvalidate.top || invalidRect.right != rectToInvalidate.right || invalidRect.bottom != rectToInvalidate.bottom) { + pluginLog(m_npp, "Expected invalid rect {left=%u, top=%u, right=%u, bottom=%u}, but got {left=%d, top=%d, right=%d, bottom=%d}", rectToInvalidate.left, rectToInvalidate.top, rectToInvalidate.right, rectToInvalidate.bottom, invalidRect.left, invalidRect.top, invalidRect.right, invalidRect.bottom); + return; + } + + pluginLog(m_npp, "Plugin's HWND has been invalidated as expected"); +} + +static PluginTest::Register<NPNInvalidateRectInvalidatesWindow> registrar("npn-invalidate-rect-invalidates-window"); diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/main.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/main.cpp index e240c42..e5246c4 100644 --- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/main.cpp +++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/main.cpp @@ -26,6 +26,7 @@ #include "PluginObject.h" #include "PluginTest.h" +#include <cstdlib> #include <string> #if !defined(NP_NO_CARBON) && defined(QD_HEADERS_ARE_PRIVATE) && QD_HEADERS_ARE_PRIVATE @@ -54,9 +55,17 @@ static inline int strcasecmp(const char* s1, const char* s2) #define STDCALL #endif +extern "C" { +NPError STDCALL NP_GetEntryPoints(NPPluginFuncs *pluginFuncs); +} + // Entry points extern "C" -NPError STDCALL NP_Initialize(NPNetscapeFuncs *browserFuncs) +NPError STDCALL NP_Initialize(NPNetscapeFuncs *browserFuncs +#ifdef XP_UNIX + , NPPluginFuncs *pluginFuncs +#endif + ) { initializeWasCalled = true; @@ -67,7 +76,12 @@ NPError STDCALL NP_Initialize(NPNetscapeFuncs *browserFuncs) #endif browser = browserFuncs; + +#ifdef XP_UNIX + return NP_GetEntryPoints(pluginFuncs); +#else return NPERR_NO_ERROR; +#endif } extern "C" @@ -81,6 +95,8 @@ NPError STDCALL NP_GetEntryPoints(NPPluginFuncs *pluginFuncs) CRASH(); #endif + pluginFunctions = pluginFuncs; + pluginFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR; pluginFuncs->size = sizeof(pluginFuncs); pluginFuncs->newp = NPP_New; @@ -246,7 +262,12 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc obj->pluginTest = PluginTest::create(instance, testIdentifier); +#ifdef XP_UNIX + // On Unix, plugins only get events if they are windowless. + return browser->setvalue(instance, NPPVpluginWindowBool, 0); +#else return NPERR_NO_ERROR; +#endif } NPError NPP_Destroy(NPP instance, NPSavedData **save) @@ -281,6 +302,8 @@ NPError NPP_Destroy(NPP instance, NPSavedData **save) CFRelease(obj->coreAnimationLayer); #endif + obj->pluginTest->NPP_Destroy(save); + browser->releaseobject(&obj->header); } return NPERR_NO_ERROR; @@ -574,6 +597,17 @@ void NPP_URLNotify(NPP instance, const char *url, NPReason reason, void *notifyD NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value) { +#ifdef XP_UNIX + if (variable == NPPVpluginNameString) { + *((char **)value) = const_cast<char*>("WebKit Test PlugIn"); + return NPERR_NO_ERROR; + } + if (variable == NPPVpluginDescriptionString) { + *((char **)value) = const_cast<char*>("Simple Netscape plug-in that handles test content for WebKit"); + return NPERR_NO_ERROR; + } +#endif + PluginObject* obj = static_cast<PluginObject*>(instance->pdata); // First, check if the PluginTest object supports getting this value. @@ -598,7 +632,7 @@ NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value) return NPERR_NO_ERROR; } #endif - + return NPERR_GENERIC_ERROR; } @@ -614,3 +648,17 @@ NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value) return NPERR_GENERIC_ERROR; } } + +#ifdef XP_UNIX +extern "C" +const char* NP_GetMIMEDescription(void) +{ + return "application/x-webkit-test-netscape:testnetscape:test netscape content"; +} + +extern "C" +NPError NP_GetValue(NPP instance, NPPVariable variable, void* value) +{ + return NPP_GetValue(instance, variable, value); +} +#endif diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj index cdd7729..74042bc 100644 --- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj +++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj @@ -383,6 +383,10 @@ >
</File>
<File
+ RelativePath="..\Tests\NullNPPGetValuePointer.cpp"
+ >
+ </File>
+ <File
RelativePath="..\Tests\PassDifferentNPPStruct.cpp"
>
</File>
@@ -398,6 +402,10 @@ >
</File>
<File
+ RelativePath="..\Tests\win\NPNInvalidateRectInvalidatesWindow.cpp"
+ >
+ </File>
+ <File
RelativePath="..\Tests\win\WindowGeometryInitializedBeforeSetWindow.cpp"
>
</File>
diff --git a/WebKitTools/DumpRenderTree/cf/WebArchiveDumpSupport.cpp b/WebKitTools/DumpRenderTree/cf/WebArchiveDumpSupport.cpp new file mode 100644 index 0000000..4d77454 --- /dev/null +++ b/WebKitTools/DumpRenderTree/cf/WebArchiveDumpSupport.cpp @@ -0,0 +1,229 @@ +/* + * Copyright (C) 2007, 2008, 2009, 2010 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 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. + */ + +#import "WebArchiveDumpSupport.h" + +#import <CoreFoundation/CoreFoundation.h> +#import <CFNetwork/CFNetwork.h> +#import <wtf/RetainPtr.h> + +extern "C" { + +CFURLRef CFURLResponseGetURL(CFURLResponseRef response); +CFStringRef CFURLResponseGetMIMEType(CFURLResponseRef response); +CFStringRef CFURLResponseGetTextEncodingName(CFURLResponseRef response); +SInt64 CFURLResponseGetExpectedContentLength(CFURLResponseRef response); +CFHTTPMessageRef CFURLResponseGetHTTPResponse(CFURLResponseRef response); + +CFTypeID CFURLResponseGetTypeID(void); + +} + +static void convertMIMEType(CFMutableStringRef mimeType) +{ +#ifdef BUILDING_ON_LEOPARD + // Workaround for <rdar://problem/5539824> on Leopard + if (CFStringCompare(mimeType, CFSTR("text/xml"), kCFCompareAnchored | kCFCompareCaseInsensitive) == kCFCompareEqualTo) + CFStringReplaceAll(mimeType, CFSTR("application/xml")); +#endif + // Workaround for <rdar://problem/6234318> with Dashcode 2.0 + if (CFStringCompare(mimeType, CFSTR("application/x-javascript"), kCFCompareAnchored | kCFCompareCaseInsensitive) == kCFCompareEqualTo) + CFStringReplaceAll(mimeType, CFSTR("text/javascript")); +} + +static void convertWebResourceDataToString(CFMutableDictionaryRef resource) +{ + CFMutableStringRef mimeType = (CFMutableStringRef)CFDictionaryGetValue(resource, CFSTR("WebResourceMIMEType")); + CFStringLowercase(mimeType, CFLocaleGetSystem()); + convertMIMEType(mimeType); + + CFArrayRef supportedMIMETypes = supportedNonImageMIMETypes(); + if (CFStringHasPrefix(mimeType, CFSTR("text/")) || CFArrayContainsValue(supportedMIMETypes, CFRangeMake(0, CFArrayGetCount(supportedMIMETypes)), mimeType)) { + CFStringRef textEncodingName = static_cast<CFStringRef>(CFDictionaryGetValue(resource, CFSTR("WebResourceTextEncodingName"))); + CFStringEncoding stringEncoding; + if (textEncodingName && CFStringGetLength(textEncodingName)) + stringEncoding = CFStringConvertIANACharSetNameToEncoding(textEncodingName); + else + stringEncoding = kCFStringEncodingUTF8; + + CFDataRef data = static_cast<CFDataRef>(CFDictionaryGetValue(resource, CFSTR("WebResourceData"))); + RetainPtr<CFStringRef> dataAsString(AdoptCF, CFStringCreateFromExternalRepresentation(kCFAllocatorDefault, data, stringEncoding)); + if (dataAsString) + CFDictionarySetValue(resource, CFSTR("WebResourceData"), dataAsString.get()); + } +} + +static void normalizeHTTPResponseHeaderFields(CFMutableDictionaryRef fields) +{ + // Normalize headers + if (CFDictionaryContainsKey(fields, CFSTR("Date"))) + CFDictionarySetValue(fields, CFSTR("Date"), CFSTR("Sun, 16 Nov 2008 17:00:00 GMT")); + if (CFDictionaryContainsKey(fields, CFSTR("Last-Modified"))) + CFDictionarySetValue(fields, CFSTR("Last-Modified"), CFSTR("Sun, 16 Nov 2008 16:55:00 GMT")); + if (CFDictionaryContainsKey(fields, CFSTR("Etag"))) + CFDictionarySetValue(fields, CFSTR("Etag"), CFSTR("\"301925-21-45c7d72d3e780\"")); + if (CFDictionaryContainsKey(fields, CFSTR("Server"))) + CFDictionarySetValue(fields, CFSTR("Server"), CFSTR("Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7l PHP/5.2.6")); + + // Remove headers + CFDictionaryRemoveValue(fields, CFSTR("Connection")); + CFDictionaryRemoveValue(fields, CFSTR("Keep-Alive")); +} + +static void normalizeWebResourceURL(CFMutableStringRef webResourceURL) +{ + static CFIndex fileUrlLength = CFStringGetLength(CFSTR("file://")); + CFRange layoutTestsWebArchivePathRange = CFStringFind(webResourceURL, CFSTR("/LayoutTests/"), kCFCompareBackwards); + if (layoutTestsWebArchivePathRange.location == kCFNotFound) + return; + CFRange currentWorkingDirectoryRange = CFRangeMake(fileUrlLength, layoutTestsWebArchivePathRange.location - fileUrlLength); + CFStringReplace(webResourceURL, currentWorkingDirectoryRange, CFSTR("")); +} + +static void convertWebResourceResponseToDictionary(CFMutableDictionaryRef propertyList) +{ + CFDataRef responseData = static_cast<CFDataRef>(CFDictionaryGetValue(propertyList, CFSTR("WebResourceResponse"))); // WebResourceResponseKey in WebResource.m + if (CFGetTypeID(responseData) != CFDataGetTypeID()) + return; + + RetainPtr<CFURLResponseRef> response(AdoptCF, createCFURLResponseFromResponseData(responseData)); + if (!response) + return; + + RetainPtr<CFMutableDictionaryRef> responseDictionary(AdoptCF, CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); + + RetainPtr<CFMutableStringRef> urlString(AdoptCF, CFStringCreateMutableCopy(kCFAllocatorDefault, 0, CFURLGetString(CFURLResponseGetURL(response.get())))); + normalizeWebResourceURL(urlString.get()); + CFDictionarySetValue(responseDictionary.get(), CFSTR("URL"), urlString.get()); + + RetainPtr<CFMutableStringRef> mimeTypeString(AdoptCF, CFStringCreateMutableCopy(kCFAllocatorDefault, 0, CFURLResponseGetMIMEType(response.get()))); + convertMIMEType(mimeTypeString.get()); + CFDictionarySetValue(responseDictionary.get(), CFSTR("MIMEType"), mimeTypeString.get()); + + CFStringRef textEncodingName = CFURLResponseGetTextEncodingName(response.get()); + if (textEncodingName) + CFDictionarySetValue(responseDictionary.get(), CFSTR("textEncodingName"), textEncodingName); + + SInt64 expectedContentLength = CFURLResponseGetExpectedContentLength(response.get()); + RetainPtr<CFNumberRef> expectedContentLengthNumber(AdoptCF, CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &expectedContentLength)); + CFDictionarySetValue(responseDictionary.get(), CFSTR("expectedContentLength"), expectedContentLengthNumber.get()); + + if (CFHTTPMessageRef httpMessage = CFURLResponseGetHTTPResponse(response.get())) { + RetainPtr<CFDictionaryRef> allHeaders(AdoptCF, CFHTTPMessageCopyAllHeaderFields(httpMessage)); + RetainPtr<CFMutableDictionaryRef> allHeaderFields(AdoptCF, CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, allHeaders.get())); + normalizeHTTPResponseHeaderFields(allHeaderFields.get()); + CFDictionarySetValue(responseDictionary.get(), CFSTR("allHeaderFields"), allHeaderFields.get()); + + CFIndex statusCode = CFHTTPMessageGetResponseStatusCode(httpMessage); + RetainPtr<CFNumberRef> statusCodeNumber(AdoptCF, CFNumberCreate(kCFAllocatorDefault, kCFNumberCFIndexType, &statusCode)); + CFDictionarySetValue(responseDictionary.get(), CFSTR("statusCode"), statusCodeNumber.get()); + } + + CFDictionarySetValue(propertyList, CFSTR("WebResourceResponse"), responseDictionary.get()); +} + +static CFComparisonResult compareResourceURLs(const void *val1, const void *val2, void *context) +{ + CFStringRef url1 = static_cast<CFStringRef>(CFDictionaryGetValue(static_cast<CFDictionaryRef>(val1), CFSTR("WebResourceURL"))); + CFStringRef url2 = static_cast<CFStringRef>(CFDictionaryGetValue(static_cast<CFDictionaryRef>(val2), CFSTR("WebResourceURL"))); + + return CFStringCompare(url1, url2, kCFCompareAnchored); +} + +CFStringRef createXMLStringFromWebArchiveData(CFDataRef webArchiveData) +{ + CFErrorRef error = 0; + CFPropertyListFormat format = kCFPropertyListBinaryFormat_v1_0; + +#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD) + CFIndex bytesCount = CFDataGetLength(webArchiveData); + RetainPtr<CFReadStreamRef> readStream(AdoptCF, CFReadStreamCreateWithBytesNoCopy(kCFAllocatorDefault, CFDataGetBytePtr(webArchiveData), bytesCount, kCFAllocatorNull)); + CFReadStreamOpen(readStream.get()); + RetainPtr<CFMutableDictionaryRef> propertyList(AdoptCF, (CFMutableDictionaryRef)CFPropertyListCreateFromStream(kCFAllocatorDefault, readStream.get(), bytesCount, kCFPropertyListMutableContainersAndLeaves, &format, 0)); + CFReadStreamClose(readStream.get()); +#else + RetainPtr<CFMutableDictionaryRef> propertyList(AdoptCF, (CFMutableDictionaryRef)CFPropertyListCreateWithData(kCFAllocatorDefault, webArchiveData, kCFPropertyListMutableContainersAndLeaves, &format, &error)); +#endif + + if (!propertyList) { + if (error) + return CFErrorCopyDescription(error); + return static_cast<CFStringRef>(CFRetain(CFSTR("An unknown error occurred converting data to property list."))); + } + + RetainPtr<CFMutableArrayRef> resources(AdoptCF, CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks)); + CFArrayAppendValue(resources.get(), propertyList.get()); + + while (CFArrayGetCount(resources.get())) { + RetainPtr<CFMutableDictionaryRef> resourcePropertyList = (CFMutableDictionaryRef)CFArrayGetValueAtIndex(resources.get(), 0); + CFArrayRemoveValueAtIndex(resources.get(), 0); + + CFMutableDictionaryRef mainResource = (CFMutableDictionaryRef)CFDictionaryGetValue(resourcePropertyList.get(), CFSTR("WebMainResource")); + normalizeWebResourceURL((CFMutableStringRef)CFDictionaryGetValue(mainResource, CFSTR("WebResourceURL"))); + convertWebResourceDataToString(mainResource); + + // Add subframeArchives to list for processing + CFMutableArrayRef subframeArchives = (CFMutableArrayRef)CFDictionaryGetValue(resourcePropertyList.get(), CFSTR("WebSubframeArchives")); // WebSubframeArchivesKey in WebArchive.m + if (subframeArchives) + CFArrayAppendArray(resources.get(), subframeArchives, CFRangeMake(0, CFArrayGetCount(subframeArchives))); + + CFMutableArrayRef subresources = (CFMutableArrayRef)CFDictionaryGetValue(resourcePropertyList.get(), CFSTR("WebSubresources")); // WebSubresourcesKey in WebArchive.m + if (!subresources) + continue; + + CFIndex subresourcesCount = CFArrayGetCount(subresources); + for (CFIndex i = 0; i < subresourcesCount; ++i) { + CFMutableDictionaryRef subresourcePropertyList = (CFMutableDictionaryRef)CFArrayGetValueAtIndex(subresources, i); + normalizeWebResourceURL((CFMutableStringRef)CFDictionaryGetValue(subresourcePropertyList, CFSTR("WebResourceURL"))); + convertWebResourceResponseToDictionary(subresourcePropertyList); + convertWebResourceDataToString(subresourcePropertyList); + } + + // Sort the subresources so they're always in a predictable order for the dump + CFArraySortValues(subresources, CFRangeMake(0, CFArrayGetCount(subresources)), compareResourceURLs, 0); + } + + error = 0; + +#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD) + RetainPtr<CFDataRef> xmlData(AdoptCF, CFPropertyListCreateXMLData(kCFAllocatorDefault, propertyList.get())); +#else + RetainPtr<CFDataRef> xmlData(AdoptCF, CFPropertyListCreateData(kCFAllocatorDefault, propertyList.get(), kCFPropertyListXMLFormat_v1_0, 0, &error)); +#endif + + if (!xmlData) { + if (error) + return CFErrorCopyDescription(error); + return static_cast<CFStringRef>(CFRetain(CFSTR("An unknown error occurred converting property list to data."))); + } + + RetainPtr<CFStringRef> xmlString(AdoptCF, CFStringCreateFromExternalRepresentation(kCFAllocatorDefault, xmlData.get(), kCFStringEncodingUTF8)); + RetainPtr<CFMutableStringRef> string(AdoptCF, CFStringCreateMutableCopy(kCFAllocatorDefault, 0, xmlString.get())); + + // Replace "Apple Computer" with "Apple" in the DTD declaration. + CFStringFindAndReplace(string.get(), CFSTR("-//Apple Computer//"), CFSTR("-//Apple//"), CFRangeMake(0, CFStringGetLength(string.get())), 0); + + return string.releaseRef(); +} diff --git a/WebKitTools/DumpRenderTree/mac/WebArchiveDumpSupport.h b/WebKitTools/DumpRenderTree/cf/WebArchiveDumpSupport.h index 8654dd5..08d9c45 100644 --- a/WebKitTools/DumpRenderTree/mac/WebArchiveDumpSupport.h +++ b/WebKitTools/DumpRenderTree/cf/WebArchiveDumpSupport.h @@ -26,9 +26,16 @@ #ifndef WebArchiveDumpSupport_h #define WebArchiveDumpSupport_h -@class NSString; -@class WebArchive; +#include <CoreFoundation/CoreFoundation.h> -NSString *serializeWebArchiveToXML(WebArchive *webArchive); +typedef struct _CFURLResponse* CFURLResponseRef; + +CFStringRef createXMLStringFromWebArchiveData(CFDataRef webArchiveData); + +#pragma mark - +#pragma mark Platform-specific methods + +CFURLResponseRef createCFURLResponseFromResponseData(CFDataRef responseData); +CFArrayRef supportedNonImageMIMETypes(); #endif /* WebArchiveDumpSupport_h */ diff --git a/WebKitTools/DumpRenderTree/chromium/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/chromium/DumpRenderTree.cpp index 72c0c3c..3bbba98 100644 --- a/WebKitTools/DumpRenderTree/chromium/DumpRenderTree.cpp +++ b/WebKitTools/DumpRenderTree/chromium/DumpRenderTree.cpp @@ -32,6 +32,7 @@ #include "TestShell.h" #include "webkit/support/webkit_support.h" +#include <v8/include/v8.h> #include <wtf/Vector.h> using namespace std; @@ -51,6 +52,9 @@ static const char optionCheckLayoutTestSystemDeps[] = "--check-layout-test-sys-d static const char optionEnableAcceleratedCompositing[] = "--enable-accelerated-compositing"; static const char optionEnableAccelerated2DCanvas[] = "--enable-accelerated-2d-canvas"; +static const char optionMultipleLoads[] = "--multiple-loads="; +static const char optionJavaScriptFlags[] = "--js-flags="; + static void runTest(TestShell& shell, TestParams& params, const string& testName, bool testShellMode) { int oldTimeoutMsec = shell.layoutTestTimeout(); @@ -78,8 +82,14 @@ static void runTest(TestShell& shell, TestParams& params, const string& testName } params.testUrl = webkit_support::CreateURLForPathOrURL(pathOrURL); webkit_support::SetCurrentDirectoryForFileURL(params.testUrl); - shell.resetTestController(); - shell.runFileTest(params); + for (int i = 0; i < shell.loadCount(); i++) { + string javaScriptFlags = shell.javaScriptFlagsForLoad(i); + v8::V8::SetFlagsFromString(javaScriptFlags.data(), static_cast<int>(javaScriptFlags.size())); + bool isLastLoad = (i == (shell.loadCount() - 1)); + shell.setDumpWhenFinished(isLastLoad); + shell.resetTestController(); + shell.runFileTest(params); + } shell.setLayoutTestTimeout(oldTimeoutMsec); } @@ -96,6 +106,8 @@ int main(int argc, char* argv[]) bool startupDialog = false; bool acceleratedCompositingEnabled = false; bool accelerated2DCanvasEnabled = false; + int loadCount = 1; + string javaScriptFlags; for (int i = 1; i < argc; ++i) { string argument(argv[i]); if (argument == "-") @@ -120,7 +132,12 @@ int main(int argc, char* argv[]) acceleratedCompositingEnabled = true; else if (argument == optionEnableAccelerated2DCanvas) accelerated2DCanvasEnabled = true; - else if (argument.size() && argument[0] == '-') + else if (!argument.find(optionMultipleLoads)) { + string multipleLoadsStr = argument.substr(strlen(optionMultipleLoads)); + loadCount = atoi(multipleLoadsStr.c_str()); + } else if (!argument.find(optionJavaScriptFlags)) { + javaScriptFlags = argument.substr(strlen(optionJavaScriptFlags)); + } else if (argument.size() && argument[0] == '-') fprintf(stderr, "Unknown option: %s\n", argv[i]); else tests.append(argument); @@ -129,6 +146,30 @@ int main(int argc, char* argv[]) fprintf(stderr, "--pixel-tests with --test-shell requires a file name.\n"); return EXIT_FAILURE; } + if (loadCount < 1) { + fprintf(stderr, "--multiple-loads requires a positive numeric argument.\n"); + return EXIT_FAILURE; + } + + // The test runner might send a quoted string which needs to be unquoted before further processing. + if (javaScriptFlags.length() > 1 && javaScriptFlags[0] == '"' && javaScriptFlags[javaScriptFlags.length() - 1] == '"') + javaScriptFlags = javaScriptFlags.substr(1, javaScriptFlags.length() - 2); + // Split the JavaScript flags into a list. + Vector<string> flagsList; + size_t start = 0; + while (true) { + size_t commaPos = javaScriptFlags.find_first_of(',', start); + string flags; + if (commaPos == string::npos) + flags = javaScriptFlags.substr(start, javaScriptFlags.length() - start); + else { + flags = javaScriptFlags.substr(start, commaPos - start); + start = commaPos + 1; + } + flagsList.append(flags); + if (commaPos == string::npos) + break; + } if (startupDialog) openStartupDialog(); @@ -138,6 +179,8 @@ int main(int argc, char* argv[]) shell.setAllowExternalPages(allowExternalPages); shell.setAcceleratedCompositingEnabled(acceleratedCompositingEnabled); shell.setAccelerated2dCanvasEnabled(accelerated2DCanvasEnabled); + shell.setLoadCount(loadCount); + shell.setJavaScriptFlags(flagsList); if (serverMode && !tests.size()) { params.printSeparators = true; char testString[2048]; // 2048 is the same as the sizes of other platforms. diff --git a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp index 82fd085..d713b04 100644 --- a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp +++ b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp @@ -94,6 +94,7 @@ LayoutTestController::LayoutTestController(TestShell* shell) bindMethod("dumpDatabaseCallbacks", &LayoutTestController::dumpDatabaseCallbacks); bindMethod("dumpEditingCallbacks", &LayoutTestController::dumpEditingCallbacks); bindMethod("dumpFrameLoadCallbacks", &LayoutTestController::dumpFrameLoadCallbacks); + bindMethod("dumpUserGestureInFrameLoadCallbacks", &LayoutTestController::dumpUserGestureInFrameLoadCallbacks); bindMethod("dumpResourceLoadCallbacks", &LayoutTestController::dumpResourceLoadCallbacks); bindMethod("dumpResourceResponseMIMETypes", &LayoutTestController::dumpResourceResponseMIMETypes); bindMethod("dumpSelectionRect", &LayoutTestController::dumpSelectionRect); @@ -288,6 +289,12 @@ void LayoutTestController::dumpFrameLoadCallbacks(const CppArgumentList&, CppVar result->setNull(); } +void LayoutTestController::dumpUserGestureInFrameLoadCallbacks(const CppArgumentList&, CppVariant* result) +{ + m_dumpUserGestureInFrameLoadCallbacks = true; + result->setNull(); +} + void LayoutTestController::dumpResourceLoadCallbacks(const CppArgumentList&, CppVariant* result) { m_dumpResourceLoadCallbacks = true; @@ -522,6 +529,7 @@ void LayoutTestController::reset() m_dumpAsText = false; m_dumpEditingCallbacks = false; m_dumpFrameLoadCallbacks = false; + m_dumpUserGestureInFrameLoadCallbacks = false; m_dumpResourceLoadCallbacks = false; m_dumpResourceResponseMIMETypes = false; m_dumpBackForwardList = false; @@ -1526,10 +1534,10 @@ void LayoutTestController::abortModal(const CppArgumentList& arguments, CppVaria void LayoutTestController::setMockSpeechInputResult(const CppArgumentList& arguments, CppVariant* result) { result->setNull(); - if (arguments.size() < 1 || !arguments[0].isString()) + if (arguments.size() < 2 || !arguments[0].isString() || !arguments[1].isString()) return; - m_speechInputControllerMock->setMockRecognitionResult(cppVariantToWebString(arguments[0])); + m_speechInputControllerMock->setMockRecognitionResult(cppVariantToWebString(arguments[0]), cppVariantToWebString(arguments[1])); } WebKit::WebSpeechInputController* LayoutTestController::speechInputController(WebKit::WebSpeechInputListener* listener) diff --git a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h index ae1a7a2..fc16827 100644 --- a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h +++ b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h @@ -88,6 +88,11 @@ public: // ignores any that may be present. void dumpFrameLoadCallbacks(const CppArgumentList&, CppVariant*); + // This function sets a flag that tells the test_shell to print a line of + // user gesture status text for some frame load callbacks. It takes no + // arguments, and ignores any that may be present. + void dumpUserGestureInFrameLoadCallbacks(const CppArgumentList&, CppVariant*); + // This function sets a flag that tells the test_shell to print out a text // representation of the back/forward list. It ignores all arguments. void dumpBackForwardList(const CppArgumentList&, CppVariant*); @@ -340,6 +345,8 @@ public: bool shouldDumpEditingCallbacks() { return m_dumpEditingCallbacks; } bool shouldDumpFrameLoadCallbacks() { return m_dumpFrameLoadCallbacks; } void setShouldDumpFrameLoadCallbacks(bool value) { m_dumpFrameLoadCallbacks = value; } + bool shouldDumpUserGestureInFrameLoadCallbacks() { return m_dumpUserGestureInFrameLoadCallbacks; } + void setShouldDumpUserGestureInFrameLoadCallbacks(bool value) { m_dumpUserGestureInFrameLoadCallbacks = value; } bool shouldDumpResourceLoadCallbacks() {return m_dumpResourceLoadCallbacks; } void setShouldDumpResourceResponseMIMETypes(bool value) { m_dumpResourceResponseMIMETypes = value; } bool shouldDumpResourceResponseMIMETypes() {return m_dumpResourceResponseMIMETypes; } @@ -460,6 +467,10 @@ private: // load callback. bool m_dumpFrameLoadCallbacks; + // If true, the test_shell will output a line of the user gesture status + // text for some frame load callbacks. + bool m_dumpUserGestureInFrameLoadCallbacks; + // If true, the test_shell will output a descriptive line for each resource // load callback. bool m_dumpResourceLoadCallbacks; diff --git a/WebKitTools/DumpRenderTree/chromium/TestNetscapePlugIn/ForwardingHeaders/WebKit/npapi.h b/WebKitTools/DumpRenderTree/chromium/TestNetscapePlugIn/ForwardingHeaders/WebKit/npapi.h index 49f72a6..9fa3fff 100644 --- a/WebKitTools/DumpRenderTree/chromium/TestNetscapePlugIn/ForwardingHeaders/WebKit/npapi.h +++ b/WebKitTools/DumpRenderTree/chromium/TestNetscapePlugIn/ForwardingHeaders/WebKit/npapi.h @@ -1 +1,9 @@ #include "bindings/npapi.h" + +// These are defined in WebCore/brdige/npapi.h and we need them on Linux/Win. +#ifndef FALSE +#define FALSE (0) +#endif +#ifndef TRUE +#define TRUE (1) +#endif diff --git a/WebKitTools/DumpRenderTree/chromium/TestNetscapePlugIn/ForwardingHeaders/WebKit/npfunctions.h b/WebKitTools/DumpRenderTree/chromium/TestNetscapePlugIn/ForwardingHeaders/WebKit/npfunctions.h index 61588ca..59ae666 100644 --- a/WebKitTools/DumpRenderTree/chromium/TestNetscapePlugIn/ForwardingHeaders/WebKit/npfunctions.h +++ b/WebKitTools/DumpRenderTree/chromium/TestNetscapePlugIn/ForwardingHeaders/WebKit/npfunctions.h @@ -1,3 +1,4 @@ +#include "npapi.h" #include "bindings/npfunctions.h" // Non-standard event types can be passed to HandleEvent. diff --git a/WebKitTools/DumpRenderTree/chromium/TestShell.cpp b/WebKitTools/DumpRenderTree/chromium/TestShell.cpp index 0b27c78..9bb0192 100644 --- a/WebKitTools/DumpRenderTree/chromium/TestShell.cpp +++ b/WebKitTools/DumpRenderTree/chromium/TestShell.cpp @@ -86,9 +86,12 @@ TestShell::TestShell(bool testShellMode) , m_allowExternalPages(false) , m_acceleratedCompositingEnabled(false) , m_accelerated2dCanvasEnabled(false) + , m_loadCount(1) + , m_dumpWhenFinished(true) { WebRuntimeFeatures::enableGeolocation(true); WebRuntimeFeatures::enableIndexedDatabase(true); + WebRuntimeFeatures::enableFileSystem(true); m_accessibilityController.set(new AccessibilityController(this)); m_layoutTestController.set(new LayoutTestController(this)); m_eventSender.set(new EventSender(this)); @@ -181,7 +184,8 @@ void TestShell::runFileTest(const TestParams& params) if (inspectorTestMode) showDevTools(); - m_printer->handleTestHeader(testUrl.c_str()); + if (m_dumpWhenFinished) + m_printer->handleTestHeader(testUrl.c_str()); loadURL(m_params.testUrl); m_testIsPreparing = false; @@ -270,7 +274,8 @@ void TestShell::testFinished() if (!m_testIsPending) return; m_testIsPending = false; - dump(); + if (m_dumpWhenFinished) + dump(); webkit_support::QuitMessageLoop(); } diff --git a/WebKitTools/DumpRenderTree/chromium/TestShell.h b/WebKitTools/DumpRenderTree/chromium/TestShell.h index a15d9ec..ca06812 100644 --- a/WebKitTools/DumpRenderTree/chromium/TestShell.h +++ b/WebKitTools/DumpRenderTree/chromium/TestShell.h @@ -67,7 +67,7 @@ struct TestParams { bool dumpPixels; bool printSeparators; WebKit::WebURL testUrl; - // Resultant image file name. Reqruired only if the test_shell mode. + // Resultant image file name. Required only if the test_shell mode. std::string pixelFileName; std::string pixelHash; @@ -109,6 +109,7 @@ public: void setFocus(WebKit::WebWidget*, bool enable); bool shouldDumpFrameLoadCallbacks() const { return (m_testIsPreparing || m_testIsPending) && layoutTestController()->shouldDumpFrameLoadCallbacks(); } + bool shouldDumpUserGestureInFrameLoadCallbacks() const { return (m_testIsPreparing || m_testIsPending) && layoutTestController()->shouldDumpUserGestureInFrameLoadCallbacks(); } bool shouldDumpResourceLoadCallbacks() const { return (m_testIsPreparing || m_testIsPending) && layoutTestController()->shouldDumpResourceLoadCallbacks(); } bool shouldDumpResourceResponseMIMETypes() const { return (m_testIsPreparing || m_testIsPending) && layoutTestController()->shouldDumpResourceResponseMIMETypes(); } void setIsLoading(bool flag) { m_isLoading = flag; } @@ -136,6 +137,20 @@ public: int layoutTestTimeoutForWatchDog() { return layoutTestTimeout() + 1000; } void setLayoutTestTimeout(int timeout) { m_timeout = timeout; } + // Number of times to load each URL. + int loadCount() { return m_loadCount; } + void setLoadCount(int loadCount) { m_loadCount = loadCount; } + + // The JavaScript flags are specified as a vector of strings. Each element of the vector is full flags string + // which can contain multiple flags (e.g. "--xxx --yyy"). With multiple load testing it is possible to specify + // separate sets of flags to each load. + std::string javaScriptFlagsForLoad(size_t load) { return (load >= 0 && load < m_javaScriptFlags.size()) ? m_javaScriptFlags[load] : ""; } + void setJavaScriptFlags(Vector<std::string> javaScriptFlags) { m_javaScriptFlags = javaScriptFlags; } + + // Set whether to dump when the loaded page has finished processing. This is used with multiple load + // testing where we only want to have the output from the last load. + void setDumpWhenFinished(bool dumpWhenFinished) { m_dumpWhenFinished = dumpWhenFinished; } + WebViewHost* createWebView(); WebViewHost* createNewWindow(const WebKit::WebURL&); void closeWindow(WebViewHost*); @@ -182,6 +197,10 @@ private: bool m_acceleratedCompositingEnabled; bool m_accelerated2dCanvasEnabled; WebPreferences m_prefs; + int m_loadCount; + Vector<std::string> m_javaScriptFlags; + bool m_dumpWhenFinished; + // List of all windows in this process. // The main window should be put into windowList[0]. diff --git a/WebKitTools/DumpRenderTree/chromium/TextInputController.cpp b/WebKitTools/DumpRenderTree/chromium/TextInputController.cpp index 7af4e9f..3603840 100644 --- a/WebKitTools/DumpRenderTree/chromium/TextInputController.cpp +++ b/WebKitTools/DumpRenderTree/chromium/TextInputController.cpp @@ -33,15 +33,16 @@ #include "TestShell.h" #include "WebBindings.h" +#include "WebCompositionUnderline.h" #include "WebFrame.h" #include "WebRange.h" #include "WebString.h" +#include "WebVector.h" #include "WebView.h" #include <wtf/StringExtras.h> #include <string> using namespace WebKit; -using namespace std; TestShell* TextInputController::testShell = 0; @@ -66,6 +67,7 @@ TextInputController::TextInputController(TestShell* shell) bindMethod("substringFromRange", &TextInputController::substringFromRange); bindMethod("unmarkText", &TextInputController::unmarkText); bindMethod("validAttributesForMarkedText", &TextInputController::validAttributesForMarkedText); + bindMethod("setComposition", &TextInputController::setComposition); } WebFrame* TextInputController::getMainFrame() @@ -167,9 +169,10 @@ void TextInputController::markedRange(const CppArgumentList&, CppVariant* result return; WebRange range = mainFrame->markedRange(); - char buffer[30]; - snprintf(buffer, 30, "%d,%d", range.startOffset(), range.endOffset()); - result->set(string(buffer)); + Vector<int> intArray(2); + intArray[0] = range.startOffset(); + intArray[1] = range.endOffset(); + result->set(WebBindings::makeIntArray(intArray)); } void TextInputController::selectedRange(const CppArgumentList&, CppVariant* result) @@ -181,9 +184,10 @@ void TextInputController::selectedRange(const CppArgumentList&, CppVariant* resu return; WebRange range = mainFrame->selectionRange(); - char buffer[30]; - snprintf(buffer, 30, "%d,%d", range.startOffset(), range.endOffset()); - result->set(string(buffer)); + Vector<int> intArray(2); + intArray[0] = range.startOffset(); + intArray[1] = range.endOffset(); + result->set(WebBindings::makeIntArray(intArray)); } void TextInputController::firstRectForCharacterRange(const CppArgumentList& arguments, CppVariant* result) @@ -232,3 +236,27 @@ void TextInputController::makeAttributedString(const CppArgumentList&, CppVarian // FIXME: Implement this. result->setNull(); } + +void TextInputController::setComposition(const CppArgumentList& arguments, CppVariant* result) +{ + result->setNull(); + + WebView* view = getMainFrame() ? getMainFrame()->view() : 0; + if (!view) + return; + + if (arguments.size() < 1) + return; + + // Sends a keydown event with key code = 0xE5 to emulate input method behavior. + WebKeyboardEvent keyDown; + keyDown.type = WebInputEvent::RawKeyDown; + keyDown.modifiers = 0; + keyDown.windowsKeyCode = 0xE5; // VKEY_PROCESSKEY + keyDown.setKeyIdentifierFromWindowsKeyCode(); + view->handleInputEvent(keyDown); + + WebVector<WebCompositionUnderline> underlines; + WebString text(WebString::fromUTF8(arguments[0].toString())); + view->setComposition(text, underlines, 0, text.length()); +} diff --git a/WebKitTools/DumpRenderTree/chromium/TextInputController.h b/WebKitTools/DumpRenderTree/chromium/TextInputController.h index 9896be5..3a3907f 100644 --- a/WebKitTools/DumpRenderTree/chromium/TextInputController.h +++ b/WebKitTools/DumpRenderTree/chromium/TextInputController.h @@ -61,6 +61,7 @@ public: void characterIndexForPoint(const CppArgumentList&, CppVariant*); void validAttributesForMarkedText(const CppArgumentList&, CppVariant*); void makeAttributedString(const CppArgumentList&, CppVariant*); + void setComposition(const CppArgumentList&, CppVariant*); private: // Returns the test shell's main WebFrame. diff --git a/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp b/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp index ab8dbf0..847e7dc 100644 --- a/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp +++ b/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp @@ -813,6 +813,8 @@ void WebViewHost::didCreateDataSource(WebFrame*, WebDataSource* ds) void WebViewHost::didStartProvisionalLoad(WebFrame* frame) { + if (m_shell->shouldDumpUserGestureInFrameLoadCallbacks()) + printFrameUserGestureStatus(frame, " - in didStartProvisionalLoadForFrame\n"); if (m_shell->shouldDumpFrameLoadCallbacks()) { printFrameDescription(frame); fputs(" - didStartProvisionalLoadForFrame\n", stdout); @@ -1051,6 +1053,11 @@ bool WebViewHost::allowScript(WebFrame*, bool enabledPerSettings) return enabledPerSettings; } +void WebViewHost::openFileSystem(WebFrame* frame, WebFileSystem::Type type, long long size, bool create, WebFileSystemCallbacks* callbacks) +{ + webkit_support::OpenFileSystem(frame, type, size, create, callbacks); +} + // Public functions ----------------------------------------------------------- WebViewHost::WebViewHost(TestShell* shell) @@ -1305,6 +1312,12 @@ void WebViewHost::printFrameDescription(WebFrame* webframe) printf("frame \"%s\"", name8.c_str()); } +void WebViewHost::printFrameUserGestureStatus(WebFrame* webframe, const char* msg) +{ + bool isUserGesture = webframe->isProcessingUserGesture(); + printf("Frame with user gesture \"%s\"%s", isUserGesture ? "true" : "false", msg); +} + void WebViewHost::printResourceDescription(unsigned identifier) { ResourceMap::iterator it = m_resourceIdentifierMap.find(identifier); diff --git a/WebKitTools/DumpRenderTree/chromium/WebViewHost.h b/WebKitTools/DumpRenderTree/chromium/WebViewHost.h index 429d3ab..1380ebd 100644 --- a/WebKitTools/DumpRenderTree/chromium/WebViewHost.h +++ b/WebKitTools/DumpRenderTree/chromium/WebViewHost.h @@ -192,6 +192,7 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient, virtual void didDisplayInsecureContent(WebKit::WebFrame*); virtual void didRunInsecureContent(WebKit::WebFrame*, const WebKit::WebSecurityOrigin&); virtual bool allowScript(WebKit::WebFrame*, bool enabledPerSettings); + virtual void openFileSystem(WebKit::WebFrame*, WebKit::WebFileSystem::Type, long long size, bool create, WebKit::WebFileSystemCallbacks*); private: LayoutTestController* layoutTestController() const; @@ -220,6 +221,9 @@ private: // Dumping a frame to the console. void printFrameDescription(WebKit::WebFrame*); + // Dumping the user gesture status to the console. + void printFrameUserGestureStatus(WebKit::WebFrame*, const char*); + bool hasWindow() const { return m_hasWindow; } void resetScrollRect(); void discardBackingStore(); diff --git a/WebKitTools/DumpRenderTree/config.h b/WebKitTools/DumpRenderTree/config.h index 33dee6d..55e2dc1 100644 --- a/WebKitTools/DumpRenderTree/config.h +++ b/WebKitTools/DumpRenderTree/config.h @@ -40,6 +40,18 @@ #define WEBKIT_EXPORTDATA #endif +#if PLATFORM(MAC) +#define WTF_PLATFORM_CF 1 + +#if !defined(MAC_OS_X_VERSION_10_5) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 +#define BUILDING_ON_TIGER 1 +#elif !defined(MAC_OS_X_VERSION_10_6) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 +#define BUILDING_ON_LEOPARD 1 +#elif !defined(MAC_OS_X_VERSION_10_7) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 +#define BUILDING_ON_SNOW_LEOPARD 1 +#endif +#endif // PLATFORM(MAC) + #if PLATFORM(WIN) #define WTF_PLATFORM_CF 1 #if defined(WIN_CAIRO) diff --git a/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp b/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp index d39ff1e..8493f1a 100644 --- a/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp +++ b/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp @@ -174,9 +174,12 @@ AccessibilityUIElement AccessibilityUIElement::titleUIElement() AccessibilityUIElement AccessibilityUIElement::parentElement() { - ASSERT(m_element); - AtkObject* parent = atk_object_get_parent(ATK_OBJECT(m_element)); + if (!m_element) + return 0; + ASSERT(ATK_IS_OBJECT(m_element)); + + AtkObject* parent = atk_object_get_parent(ATK_OBJECT(m_element)); return parent ? AccessibilityUIElement(parent) : 0; } diff --git a/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp index e115683..1c851d7 100644 --- a/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp +++ b/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp @@ -38,6 +38,7 @@ #include "GOwnPtr.h" #include "LayoutTestController.h" #include "PixelDumpSupport.h" +#include "WebCoreSupport/DumpRenderTreeSupportGtk.h" #include "WorkQueue.h" #include "WorkQueueItem.h" #include <JavaScriptCore/JavaScript.h> @@ -199,6 +200,16 @@ static void initializeFonts(const char* testURL = 0) "/usr/share/fonts/dejavu/DejaVuSans.ttf", }, { "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf", "/usr/share/fonts/dejavu/DejaVuSerif.ttf", }, + + // MathML tests require the STIX fonts. + { "/usr/share/fonts/opentype/stix/STIXGeneral.otf", + "/usr/share/fonts/stix/STIXGeneral.otf" }, + { "/usr/share/fonts/opentype/stix/STIXGeneralBolIta.otf", + "/usr/share/fonts/stix/STIXGeneralBolIta.otf" }, + { "/usr/share/fonts/opentype/stix/STIXGeneralBol.otf", + "/usr/share/fonts/stix/STIXGeneralBol.otf" }, + { "/usr/share/fonts/opentype/stix/STIXGeneralItalic.otf", + "/usr/share/fonts/stix/STIXGeneralItalic.otf" } }; // TODO: Some tests use Lucida. We should load these as well, once it becomes @@ -433,6 +444,8 @@ static void resetDefaultsToConsistentValues() #endif setlocale(LC_ALL, ""); + + DumpRenderTreeSupportGtk::setLinksIncludedInFocusChain(true); } static bool useLongRunningServerMode(int argc, char *argv[]) @@ -714,24 +727,8 @@ static char* getFrameNameSuitableForTestResult(WebKitWebView* view, WebKitWebFra return frameName; } -static void webViewLoadCommitted(WebKitWebView* view, WebKitWebFrame* frame, void*) -{ - if (!done && gLayoutTestController->dumpFrameLoadCallbacks()) { - char* frameName = getFrameNameSuitableForTestResult(view, frame); - printf("%s - didCommitLoadForFrame\n", frameName); - g_free(frameName); - } -} - - static void webViewLoadFinished(WebKitWebView* view, WebKitWebFrame* frame, void*) { - if (!done && gLayoutTestController->dumpFrameLoadCallbacks()) { - char* frameName = getFrameNameSuitableForTestResult(view, frame); - printf("%s - didFinishLoadForFrame\n", frameName); - g_free(frameName); - } - if (frame != topLoadingFrame) return; @@ -967,23 +964,43 @@ static WebKitWebView* webInspectorInspectWebView(WebKitWebInspector*, gpointer d return WEBKIT_WEB_VIEW(webView); } -static void webViewLoadStatusNotified(WebKitWebView* view, gpointer user_data) +static void webFrameLoadStatusNotified(WebKitWebFrame* frame, gpointer user_data) { - WebKitLoadStatus loadStatus = webkit_web_view_get_load_status(view); + WebKitLoadStatus loadStatus = webkit_web_frame_get_load_status(frame); if (gLayoutTestController->dumpFrameLoadCallbacks()) { - if (loadStatus == WEBKIT_LOAD_PROVISIONAL) { - char* frameName = getFrameNameSuitableForTestResult(view, mainFrame); - printf("%s - didStartProvisionalLoadForFrame\n", frameName); - g_free(frameName); + GOwnPtr<char> frameName(getFrameNameSuitableForTestResult(webkit_web_frame_get_web_view(frame), frame)); + + switch (loadStatus) { + case WEBKIT_LOAD_PROVISIONAL: + if (!done) + printf("%s - didStartProvisionalLoadForFrame\n", frameName.get()); + break; + case WEBKIT_LOAD_COMMITTED: + if (!done) + printf("%s - didCommitLoadForFrame\n", frameName.get()); + break; + case WEBKIT_LOAD_FINISHED: + if (frame != topLoadingFrame || !done) + printf("%s - didFinishLoadForFrame\n", frameName.get()); + break; + default: + break; } } } +static void frameCreatedCallback(WebKitWebView* webView, WebKitWebFrame* webFrame, gpointer user_data) +{ + g_signal_connect(webFrame, "notify::load-status", G_CALLBACK(webFrameLoadStatusNotified), NULL); +} + static WebKitWebView* createWebView() { WebKitWebView* view = WEBKIT_WEB_VIEW(webkit_web_view_new()); + DumpRenderTreeSupportGtk::setDumpRenderTreeModeEnabled(true); + // From bug 11756: Use a frame group name for all WebViews created by // DumpRenderTree to allow testing of cross-page frame lookup. webkit_web_view_set_group_name(view, "org.webkit.gtk.DumpRenderTree"); @@ -991,7 +1008,6 @@ static WebKitWebView* createWebView() g_object_connect(G_OBJECT(view), "signal::load-started", webViewLoadStarted, 0, "signal::load-finished", webViewLoadFinished, 0, - "signal::load-committed", webViewLoadCommitted, 0, "signal::window-object-cleared", webViewWindowObjectCleared, 0, "signal::console-message", webViewConsoleMessage, 0, "signal::script-alert", webViewScriptAlert, 0, @@ -1009,13 +1025,10 @@ static WebKitWebView* createWebView() "signal::drag-begin", dragBeginCallback, 0, "signal::drag-end", dragEndCallback, 0, "signal::drag-failed", dragFailedCallback, 0, + "signal::frame-created", frameCreatedCallback, 0, NULL); - g_signal_connect(view, - "notify::load-status", G_CALLBACK(webViewLoadStatusNotified), - NULL); - WebKitWebInspector* inspector = webkit_web_view_get_inspector(view); g_object_connect(G_OBJECT(inspector), "signal::inspect-web-view", webInspectorInspectWebView, 0, @@ -1028,6 +1041,10 @@ static WebKitWebView* createWebView() webkit_web_view_set_settings(view, settings); } + // frame-created is not issued for main frame. That's why we must do this here + WebKitWebFrame* frame = webkit_web_view_get_main_frame(view); + g_signal_connect(frame, "notify::load-status", G_CALLBACK(webFrameLoadStatusNotified), NULL); + return view; } diff --git a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp index 181ef9f..688b3f8 100644 --- a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp +++ b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp @@ -34,6 +34,7 @@ #include "LayoutTestController.h" #include "DumpRenderTree.h" +#include "WebCoreSupport/DumpRenderTreeSupportGtk.h" #include "WorkQueue.h" #include "WorkQueueItem.h" #include <JavaScriptCore/JSRetainPtr.h> @@ -500,7 +501,7 @@ void LayoutTestController::setGeolocationPermission(bool allow) setGeolocationPermissionCommon(allow); } -void LayoutTestController::setMockSpeechInputResult(JSStringRef result) +void LayoutTestController::setMockSpeechInputResult(JSStringRef result, JSStringRef language) { // FIXME: Implement for speech input layout tests. // See https://bugs.webkit.org/show_bug.cgi?id=39485. @@ -683,10 +684,13 @@ void LayoutTestController::overridePreference(JSStringRef key, JSStringRef value else if (g_str_equal(originalName.get(), "WebKitUsesPageCachePreferenceKey")) propertyName = "enable-page-cache"; else if (g_str_equal(originalName.get(), "WebKitPluginsEnabled")) - propertyName = "enable-plugins"; + propertyName = "enable-plugins"; else if (g_str_equal(originalName.get(), "WebKitHyperlinkAuditingEnabled")) - propertyName = "enable-hyperlink-auditing"; - else { + propertyName = "enable-hyperlink-auditing"; + else if (g_str_equal(originalName.get(), "WebKitTabToLinksPreferenceKey")) { + DumpRenderTreeSupportGtk::setLinksIncludedInFocusChain(!g_ascii_strcasecmp(valueAsString.get(), "true") || !g_ascii_strcasecmp(valueAsString.get(), "1")); + return; + } else { fprintf(stderr, "LayoutTestController::overridePreference tried to override " "unknown preference '%s'.\n", originalName.get()); return; diff --git a/WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm b/WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm index 2ca5755..e27ee0e 100644 --- a/WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm +++ b/WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm @@ -381,6 +381,26 @@ AccessibilityUIElement AccessibilityUIElement::disclosedRowAtIndex(unsigned inde return 0; } +AccessibilityUIElement AccessibilityUIElement::selectedChildAtIndex(unsigned index) const +{ + BEGIN_AX_OBJC_EXCEPTIONS + NSArray* array = [m_element accessibilityAttributeValue:NSAccessibilitySelectedChildrenAttribute]; + if (index < [array count]) + return [array objectAtIndex:index]; + END_AX_OBJC_EXCEPTIONS + + return 0; +} + +unsigned AccessibilityUIElement::selectedChildrenCount() const +{ + BEGIN_AX_OBJC_EXCEPTIONS + return [m_element accessibilityArrayAttributeCount:NSAccessibilitySelectedChildrenAttribute]; + END_AX_OBJC_EXCEPTIONS + + return 0; +} + AccessibilityUIElement AccessibilityUIElement::selectedRowAtIndex(unsigned index) { BEGIN_AX_OBJC_EXCEPTIONS @@ -1103,6 +1123,14 @@ void AccessibilityUIElement::press() END_AX_OBJC_EXCEPTIONS } +void AccessibilityUIElement::setSelectedChild(AccessibilityUIElement* element) const +{ + BEGIN_AX_OBJC_EXCEPTIONS + NSArray* array = [NSArray arrayWithObject:element->platformUIElement()]; + [m_element accessibilitySetValue:array forAttribute:NSAccessibilitySelectedChildrenAttribute]; + END_AX_OBJC_EXCEPTIONS +} + JSStringRef AccessibilityUIElement::accessibilityValue() const { // FIXME: implement diff --git a/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm b/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm index 68765f6..efdf54a 100644 --- a/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm +++ b/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm @@ -54,6 +54,7 @@ #import "WorkQueueItem.h" #import <Carbon/Carbon.h> #import <CoreFoundation/CoreFoundation.h> +#import <WebCore/FoundationExtras.h> #import <WebKit/DOMElement.h> #import <WebKit/DOMExtensions.h> #import <WebKit/DOMRange.h> @@ -920,11 +921,11 @@ void dump() resultMimeType = @"application/pdf"; } else if (gLayoutTestController->dumpDOMAsWebArchive()) { WebArchive *webArchive = [[mainFrame DOMDocument] webArchive]; - resultString = serializeWebArchiveToXML(webArchive); + resultString = HardAutorelease(createXMLStringFromWebArchiveData((CFDataRef)[webArchive data])); resultMimeType = @"application/x-webarchive"; } else if (gLayoutTestController->dumpSourceAsWebArchive()) { WebArchive *webArchive = [[mainFrame dataSource] webArchive]; - resultString = serializeWebArchiveToXML(webArchive); + resultString = HardAutorelease(createXMLStringFromWebArchiveData((CFDataRef)[webArchive data])); resultMimeType = @"application/x-webarchive"; } else { sizeWebViewForCurrentTest(); diff --git a/WebKitTools/DumpRenderTree/mac/DumpRenderTreeDraggingInfo.mm b/WebKitTools/DumpRenderTree/mac/DumpRenderTreeDraggingInfo.mm index 02280a1..8eded66 100644 --- a/WebKitTools/DumpRenderTree/mac/DumpRenderTreeDraggingInfo.mm +++ b/WebKitTools/DumpRenderTree/mac/DumpRenderTreeDraggingInfo.mm @@ -105,5 +105,42 @@ return nil; } +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) +- (NSDraggingFormation)draggingFormation +{ + return NSDraggingFormationDefault; +} + +- (void)setDraggingFormation:(NSDraggingFormation)formation +{ + // Ignored. +} + +- (BOOL)animatesToDestination +{ + return NO; +} + +- (void)setAnimatesToDestination:(BOOL)flag +{ + // Ignored. +} + +- (NSInteger)numberOfValidItemsForDrop +{ + return 1; +} + +- (void)setNumberOfValidItemsForDrop:(NSInteger)number +{ + // Ignored. +} + +- (void)enumerateDraggingItemsWithOptions:(NSEnumerationOptions)enumOpts forView:(NSView *)view classes:(NSArray *)classArray searchOptions:(NSDictionary *)searchOptions usingBlock:(void (^)(NSDraggingItem *draggingItem, NSInteger idx, BOOL *stop))block +{ + // Ignored. +} +#endif // !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) + @end diff --git a/WebKitTools/DumpRenderTree/mac/DumpRenderTreeMac.h b/WebKitTools/DumpRenderTree/mac/DumpRenderTreeMac.h index 5c93ee9..36c5eac 100644 --- a/WebKitTools/DumpRenderTree/mac/DumpRenderTreeMac.h +++ b/WebKitTools/DumpRenderTree/mac/DumpRenderTreeMac.h @@ -29,25 +29,23 @@ #ifndef DumpRenderTreeMac_h #define DumpRenderTreeMac_h -// FIXME: we should add a config.h file for DumpRenderTree. -#define WTF_PLATFORM_CF 1 - -#if !defined(MAC_OS_X_VERSION_10_5) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 -#define BUILDING_ON_TIGER 1 -#elif !defined(MAC_OS_X_VERSION_10_6) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 -#define BUILDING_ON_LEOPARD 1 -#elif !defined(MAC_OS_X_VERSION_10_7) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 -#define BUILDING_ON_SNOW_LEOPARD 1 -#endif +#include <CoreFoundation/CoreFoundation.h> +#ifdef __OBJC__ @class DumpRenderTreeDraggingInfo; @class NavigationController; @class PolicyDelegate; @class WebFrame; @class WebScriptWorld; @class WebView; - -typedef const struct __CFString* CFStringRef; +#else +class DumpRenderTreeDraggingInfo; +class NavigationController; +class PolicyDelegate; +class WebFrame; +class WebScriptWorld; +class WebView; +#endif extern CFMutableArrayRef openWindowsRef; extern CFMutableSetRef disallowedURLs; diff --git a/WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.mm b/WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.mm index 963eae7..a36982c 100644 --- a/WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.mm +++ b/WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.mm @@ -50,6 +50,7 @@ #import <WebKit/WebNSURLExtras.h> #import <WebKit/WebScriptWorld.h> #import <WebKit/WebSecurityOriginPrivate.h> +#import <WebKit/WebViewPrivate.h> #import <wtf/Assertions.h> @interface NSURL (DRTExtras) @@ -89,6 +90,12 @@ return @"frame (anonymous)"; } } + +- (NSString *)_drt_printFrameUserGestureStatus +{ + BOOL isUserGesture = [[self webView] _isProcessingUserGesture]; + return [NSString stringWithFormat:@"Frame with user gesture \"%@\"", isUserGesture ? @"true" : @"false"]; +} @end @implementation FrameLoadDelegate @@ -146,7 +153,12 @@ NSString *string = [NSString stringWithFormat:@"%@ - didStartProvisionalLoadForFrame", [frame _drt_descriptionSuitableForTestResult]]; printf ("%s\n", [string UTF8String]); } - + + if (!done && gLayoutTestController->dumpUserGestureInFrameLoadCallbacks()) { + NSString *string = [NSString stringWithFormat:@"%@ - in didStartProvisionalLoadForFrame", [frame _drt_printFrameUserGestureStatus]]; + printf ("%s\n", [string UTF8String]); + } + ASSERT([frame provisionalDataSource]); // Make sure we only set this once per test. If it gets cleared, and then set again, we might // end up doing two dumps for one test. @@ -166,7 +178,7 @@ NSString *string = [NSString stringWithFormat:@"%@ - didCommitLoadForFrame", [frame _drt_descriptionSuitableForTestResult]]; printf ("%s\n", [string UTF8String]); } - + ASSERT(![frame provisionalDataSource]); ASSERT([frame dataSource]); @@ -190,7 +202,7 @@ ASSERT_NOT_REACHED(); return; } - + ASSERT([frame provisionalDataSource]); [self webView:sender locationChangeDone:error forDataSource:[frame provisionalDataSource]]; } @@ -204,7 +216,7 @@ NSString *string = [NSString stringWithFormat:@"%@ - didFinishLoadForFrame", [frame _drt_descriptionSuitableForTestResult]]; printf ("%s\n", [string UTF8String]); } - + // FIXME: This call to displayIfNeeded can be removed when <rdar://problem/5092361> is fixed. // After that is fixed, we will reenable painting after WebCore is done loading the document, // and this call will no longer be needed. @@ -220,7 +232,7 @@ NSString *string = [NSString stringWithFormat:@"%@ - didFailLoadWithError", [frame _drt_descriptionSuitableForTestResult]]; printf ("%s\n", [string UTF8String]); } - + ASSERT(![frame provisionalDataSource]); ASSERT([frame dataSource]); @@ -233,7 +245,7 @@ NSString *string = [NSString stringWithFormat:@"?? - windowScriptObjectAvailable"]; printf ("%s\n", [string UTF8String]); } - + ASSERT_NOT_REACHED(); } @@ -314,7 +326,7 @@ NSString *string = [NSString stringWithFormat:@"%@ - didReceiveTitle: %@", [frame _drt_descriptionSuitableForTestResult], title]; printf ("%s\n", [string UTF8String]); } - + if (gLayoutTestController->dumpTitleChanges()) printf("TITLE CHANGED: %s\n", [title UTF8String]); } diff --git a/WebKitTools/DumpRenderTree/mac/InternalHeaders/WebKit/WebHTMLRepresentationInternal.h b/WebKitTools/DumpRenderTree/mac/InternalHeaders/WebKit/WebHTMLRepresentationInternal.h deleted file mode 100644 index b3d421d..0000000 --- a/WebKitTools/DumpRenderTree/mac/InternalHeaders/WebKit/WebHTMLRepresentationInternal.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../../../WebKit/mac/WebView/WebHTMLRepresentationInternal.h" diff --git a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm index c5d5a90..150b6f9 100644 --- a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm +++ b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm @@ -371,7 +371,7 @@ void LayoutTestController::setGeolocationPermission(bool allow) [[[mainFrame webView] UIDelegate] didSetMockGeolocationPermission]; } -void LayoutTestController::setMockSpeechInputResult(JSStringRef result) +void LayoutTestController::setMockSpeechInputResult(JSStringRef result, JSStringRef language) { // FIXME: Implement for speech input layout tests. // See https://bugs.webkit.org/show_bug.cgi?id=39485. diff --git a/WebKitTools/DumpRenderTree/mac/WebArchiveDumpSupport.mm b/WebKitTools/DumpRenderTree/mac/WebArchiveDumpSupport.mm deleted file mode 100644 index 7c52c6a..0000000 --- a/WebKitTools/DumpRenderTree/mac/WebArchiveDumpSupport.mm +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright (C) 2007, 2008, 2009, 2010 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 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. - */ - -#import "WebArchiveDumpSupport.h" - -#import <Foundation/Foundation.h> -#import <WebKit/WebArchive.h> -#import <WebKit/WebHTMLRepresentationInternal.h> - -static void convertMIMEType(NSMutableString *mimeType) -{ -#ifdef BUILDING_ON_LEOPARD - // Workaround for <rdar://problem/5539824> on Leopard - if ([mimeType isEqualToString:@"text/xml"]) - [mimeType setString:@"application/xml"]; -#endif - // Workaround for <rdar://problem/6234318> with Dashcode 2.0 - if ([mimeType isEqualToString:@"application/x-javascript"]) - [mimeType setString:@"text/javascript"]; -} - -static void convertWebResourceDataToString(NSMutableDictionary *resource) -{ - NSMutableString *mimeType = [resource objectForKey:@"WebResourceMIMEType"]; - convertMIMEType(mimeType); - - if ([mimeType hasPrefix:@"text/"] || [[WebHTMLRepresentation supportedNonImageMIMETypes] containsObject:mimeType]) { - NSString *textEncodingName = [resource objectForKey:@"WebResourceTextEncodingName"]; - NSStringEncoding stringEncoding; - if ([textEncodingName length] > 0) - stringEncoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)textEncodingName)); - else - stringEncoding = NSUTF8StringEncoding; - - NSData *data = [resource objectForKey:@"WebResourceData"]; - NSString *dataAsString = [[NSString alloc] initWithData:data encoding:stringEncoding]; - if (dataAsString) - [resource setObject:dataAsString forKey:@"WebResourceData"]; - [dataAsString release]; - } -} - -static void normalizeHTTPResponseHeaderFields(NSMutableDictionary *fields) -{ - // Normalize headers - if ([fields objectForKey:@"Date"]) - [fields setObject:@"Sun, 16 Nov 2008 17:00:00 GMT" forKey:@"Date"]; - if ([fields objectForKey:@"Last-Modified"]) - [fields setObject:@"Sun, 16 Nov 2008 16:55:00 GMT" forKey:@"Last-Modified"]; - if ([fields objectForKey:@"Etag"]) - [fields setObject:@"\"301925-21-45c7d72d3e780\"" forKey:@"Etag"]; - if ([fields objectForKey:@"Server"]) - [fields setObject:@"Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7l PHP/5.2.6" forKey:@"Server"]; - - // Remove headers - if ([fields objectForKey:@"Connection"]) - [fields removeObjectForKey:@"Connection"]; - if ([fields objectForKey:@"Keep-Alive"]) - [fields removeObjectForKey:@"Keep-Alive"]; -} - -static void normalizeWebResourceURL(NSMutableString *webResourceURL) -{ - static int fileUrlLength = [(NSString *)@"file://" length]; - NSRange layoutTestsWebArchivePathRange = [webResourceURL rangeOfString:@"/LayoutTests/" options:NSBackwardsSearch]; - if (layoutTestsWebArchivePathRange.location == NSNotFound) - return; - NSRange currentWorkingDirectoryRange = NSMakeRange(fileUrlLength, layoutTestsWebArchivePathRange.location - fileUrlLength); - [webResourceURL replaceCharactersInRange:currentWorkingDirectoryRange withString:@""]; -} - -static void convertWebResourceResponseToDictionary(NSMutableDictionary *propertyList) -{ - NSURLResponse *response = nil; - NSData *responseData = [propertyList objectForKey:@"WebResourceResponse"]; // WebResourceResponseKey in WebResource.m - if ([responseData isKindOfClass:[NSData class]]) { - // Decode NSURLResponse - NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:responseData]; - response = [unarchiver decodeObjectForKey:@"WebResourceResponse"]; // WebResourceResponseKey in WebResource.m - [unarchiver finishDecoding]; - [unarchiver release]; - } - - NSMutableDictionary *responseDictionary = [[NSMutableDictionary alloc] init]; - - NSMutableString *urlString = [[[response URL] description] mutableCopy]; - normalizeWebResourceURL(urlString); - [responseDictionary setObject:urlString forKey:@"URL"]; - [urlString release]; - - NSMutableString *mimeTypeString = [[response MIMEType] mutableCopy]; - convertMIMEType(mimeTypeString); - [responseDictionary setObject:mimeTypeString forKey:@"MIMEType"]; - [mimeTypeString release]; - - NSString *textEncodingName = [response textEncodingName]; - if (textEncodingName) - [responseDictionary setObject:textEncodingName forKey:@"textEncodingName"]; - [responseDictionary setObject:[NSNumber numberWithLongLong:[response expectedContentLength]] forKey:@"expectedContentLength"]; - - if ([response isKindOfClass:[NSHTTPURLResponse class]]) { - NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; - - NSMutableDictionary *allHeaderFields = [[httpResponse allHeaderFields] mutableCopy]; - normalizeHTTPResponseHeaderFields(allHeaderFields); - [responseDictionary setObject:allHeaderFields forKey:@"allHeaderFields"]; - [allHeaderFields release]; - - [responseDictionary setObject:[NSNumber numberWithInt:[httpResponse statusCode]] forKey:@"statusCode"]; - } - - [propertyList setObject:responseDictionary forKey:@"WebResourceResponse"]; - [responseDictionary release]; -} - -static NSInteger compareResourceURLs(id resource1, id resource2, void *context) -{ - NSString *url1 = [resource1 objectForKey:@"WebResourceURL"]; - NSString *url2 = [resource2 objectForKey:@"WebResourceURL"]; - - return [url1 compare:url2]; -} - -NSString *serializeWebArchiveToXML(WebArchive *webArchive) -{ - NSString *errorString; - NSMutableDictionary *propertyList = [NSPropertyListSerialization propertyListFromData:[webArchive data] - mutabilityOption:NSPropertyListMutableContainersAndLeaves - format:NULL - errorDescription:&errorString]; - if (!propertyList) - return errorString; - - NSMutableArray *resources = [NSMutableArray arrayWithCapacity:1]; - [resources addObject:propertyList]; - - while ([resources count]) { - NSMutableDictionary *resourcePropertyList = [resources objectAtIndex:0]; - [resources removeObjectAtIndex:0]; - - NSMutableDictionary *mainResource = [resourcePropertyList objectForKey:@"WebMainResource"]; - normalizeWebResourceURL([mainResource objectForKey:@"WebResourceURL"]); - convertWebResourceDataToString(mainResource); - - // Add subframeArchives to list for processing - NSMutableArray *subframeArchives = [resourcePropertyList objectForKey:@"WebSubframeArchives"]; // WebSubframeArchivesKey in WebArchive.m - if (subframeArchives) - [resources addObjectsFromArray:subframeArchives]; - - NSMutableArray *subresources = [resourcePropertyList objectForKey:@"WebSubresources"]; // WebSubresourcesKey in WebArchive.m - NSEnumerator *enumerator = [subresources objectEnumerator]; - NSMutableDictionary *subresourcePropertyList; - while ((subresourcePropertyList = [enumerator nextObject])) { - normalizeWebResourceURL([subresourcePropertyList objectForKey:@"WebResourceURL"]); - convertWebResourceResponseToDictionary(subresourcePropertyList); - convertWebResourceDataToString(subresourcePropertyList); - } - - // Sort the subresources so they're always in a predictable order for the dump - if (NSArray *sortedSubresources = [subresources sortedArrayUsingFunction:compareResourceURLs context:nil]) - [resourcePropertyList setObject:sortedSubresources forKey:@"WebSubresources"]; - } - - NSData *xmlData = [NSPropertyListSerialization dataFromPropertyList:propertyList - format:NSPropertyListXMLFormat_v1_0 - errorDescription:&errorString]; - if (!xmlData) - return errorString; - - NSMutableString *string = [[[NSMutableString alloc] initWithData:xmlData encoding:NSUTF8StringEncoding] autorelease]; - - // Replace "Apple Computer" with "Apple" in the DTD declaration. - NSRange range = [string rangeOfString:@"-//Apple Computer//"]; - if (range.location != NSNotFound) - [string replaceCharactersInRange:range withString:@"-//Apple//"]; - - return string; -} diff --git a/WebKitTools/DumpRenderTree/mac/WebArchiveDumpSupportMac.mm b/WebKitTools/DumpRenderTree/mac/WebArchiveDumpSupportMac.mm new file mode 100644 index 0000000..c273087 --- /dev/null +++ b/WebKitTools/DumpRenderTree/mac/WebArchiveDumpSupportMac.mm @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2010 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 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. + */ + +#import "WebArchiveDumpSupport.h" + +#import <CFNetwork/CFHTTPMessage.h> +#import <Foundation/Foundation.h> +#import <WebKit/WebHTMLRepresentation.h> +#import <wtf/RetainPtr.h> + +extern "C" { + +enum CFURLCacheStoragePolicy { + kCFURLCacheStorageAllowed = 0, + kCFURLCacheStorageAllowedInMemoryOnly = 1, + kCFURLCacheStorageNotAllowed = 2 +}; +typedef enum CFURLCacheStoragePolicy CFURLCacheStoragePolicy; + +extern const CFStringRef kCFHTTPVersion1_1; + +CFURLResponseRef CFURLResponseCreate(CFAllocatorRef alloc, CFURLRef URL, CFStringRef mimeType, SInt64 expectedContentLength, CFStringRef textEncodingName, CFURLCacheStoragePolicy recommendedPolicy); +CFURLResponseRef CFURLResponseCreateWithHTTPResponse(CFAllocatorRef alloc, CFURLRef URL, CFHTTPMessageRef httpResponse, CFURLCacheStoragePolicy recommendedPolicy); +void CFURLResponseSetExpectedContentLength(CFURLResponseRef response, SInt64 length); +void CFURLResponseSetMIMEType(CFURLResponseRef response, CFStringRef mimeType); + +} + +CFURLResponseRef createCFURLResponseFromResponseData(CFDataRef responseData) +{ + // Decode NSURLResponse + RetainPtr<NSKeyedUnarchiver> unarchiver(AdoptNS, [[NSKeyedUnarchiver alloc] initForReadingWithData:(NSData *)responseData]); + NSURLResponse *response = [unarchiver.get() decodeObjectForKey:@"WebResourceResponse"]; // WebResourceResponseKey in WebResource.m + [unarchiver.get() finishDecoding]; + + if (![response isKindOfClass:[NSHTTPURLResponse class]]) + return CFURLResponseCreate(kCFAllocatorDefault, (CFURLRef)[response URL], (CFStringRef)[response MIMEType], [response expectedContentLength], (CFStringRef)[response textEncodingName], kCFURLCacheStorageAllowed); + + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; + + // NSURLResponse is not toll-free bridged to CFURLResponse. + RetainPtr<CFHTTPMessageRef> httpMessage(AdoptCF, CFHTTPMessageCreateResponse(kCFAllocatorDefault, [httpResponse statusCode], 0, kCFHTTPVersion1_1)); + + NSDictionary *headerFields = [httpResponse allHeaderFields]; + for (NSString *headerField in [headerFields keyEnumerator]) + CFHTTPMessageSetHeaderFieldValue(httpMessage.get(), (CFStringRef)headerField, (CFStringRef)[headerFields objectForKey:headerField]); + + return CFURLResponseCreateWithHTTPResponse(kCFAllocatorDefault, (CFURLRef)[response URL], httpMessage.get(), kCFURLCacheStorageAllowed); +} + +CFArrayRef supportedNonImageMIMETypes() +{ + return (CFArrayRef)[WebHTMLRepresentation supportedNonImageMIMETypes]; +} diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp index d36a074..f99ec4f 100644 --- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp +++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp @@ -73,6 +73,7 @@ void LayoutTestController::reset() DumpRenderTreeSupportQt::dumpEditingCallbacks(false); DumpRenderTreeSupportQt::dumpFrameLoader(false); + DumpRenderTreeSupportQt::dumpUserGestureInFrameLoader(false); DumpRenderTreeSupportQt::dumpResourceLoadCallbacks(false); DumpRenderTreeSupportQt::dumpResourceResponseMIMETypes(false); DumpRenderTreeSupportQt::setDeferMainResourceDataLoad(true); @@ -246,6 +247,11 @@ void LayoutTestController::dumpFrameLoadCallbacks() DumpRenderTreeSupportQt::dumpFrameLoader(true); } +void LayoutTestController::dumpUserGestureInFrameLoadCallbacks() +{ + DumpRenderTreeSupportQt::dumpUserGestureInFrameLoader(true); +} + void LayoutTestController::dumpResourceLoadCallbacks() { DumpRenderTreeSupportQt::dumpResourceLoadCallbacks(true); @@ -759,7 +765,7 @@ void LayoutTestController::setMockGeolocationPosition(double latitude, double lo DumpRenderTreeSupportQt::setMockGeolocationPosition(latitude, longitude, accuracy); } -void LayoutTestController::setMockSpeechInputResult(const QString& result) +void LayoutTestController::setMockSpeechInputResult(const QString& result, const QString& language) { // FIXME: Implement for speech input layout tests. // See https://bugs.webkit.org/show_bug.cgi?id=39485. diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h index 3684946..11d72e4 100644 --- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h +++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h @@ -106,6 +106,7 @@ public slots: void handleErrorPages() { m_handleErrorPages = true; } void dumpEditingCallbacks(); void dumpFrameLoadCallbacks(); + void dumpUserGestureInFrameLoadCallbacks(); void dumpResourceLoadCallbacks(); void dumpResourceResponseMIMETypes(); void dumpHistoryCallbacks(); @@ -215,7 +216,7 @@ public slots: bool isGeolocationPermissionSet() const { return m_isGeolocationPermissionSet; } bool geolocationPermission() const { return m_geolocationPermission; } - void setMockSpeechInputResult(const QString& result); + void setMockSpeechInputResult(const QString& result, const QString& language); // Empty stub method to keep parity with object model exposed by global LayoutTestController. void abortModal() {} diff --git a/WebKitTools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro b/WebKitTools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro index 740ebb8..b958025 100644 --- a/WebKitTools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro +++ b/WebKitTools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro @@ -31,6 +31,7 @@ SOURCES = PluginObject.cpp \ Tests/DocumentOpenInDestroyStream.cpp \ Tests/NPRuntimeObjectFromDestroyedPlugin.cpp \ Tests/NPRuntimeRemoveProperty.cpp \ + Tests/NullNPPGetValuePointer.cpp \ Tests/PassDifferentNPPStruct.cpp \ Tests/PluginScriptableNPObjectInvokeDefault.cpp diff --git a/WebKitTools/DumpRenderTree/unix/TestNetscapePlugin/TestNetscapePlugin.cpp b/WebKitTools/DumpRenderTree/unix/TestNetscapePlugin/TestNetscapePlugin.cpp index 8c4e98d..14bb8ef 100644 --- a/WebKitTools/DumpRenderTree/unix/TestNetscapePlugin/TestNetscapePlugin.cpp +++ b/WebKitTools/DumpRenderTree/unix/TestNetscapePlugin/TestNetscapePlugin.cpp @@ -105,7 +105,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) { @@ -129,6 +129,8 @@ webkit_test_plugin_destroy_instance(NPP instance, NPSavedData** /*save*/) if (obj->onSetWindow) free(obj->onSetWindow); + obj->pluginTest->NPP_Destroy(save); + browser->releaseobject(&obj->header); } @@ -157,7 +159,7 @@ webkit_test_plugin_set_window(NPP instance, NPWindow *window) } - return NPERR_NO_ERROR; + return obj->pluginTest->NPP_SetWindow(instance, window); } static void executeScript(const PluginObject* obj, const char* script) @@ -386,6 +388,7 @@ NP_Initialize (NPNetscapeFuncs *aMozillaVTable, NPPluginFuncs *aPluginVTable) return NPERR_INVALID_FUNCTABLE_ERROR; browser = aMozillaVTable; + pluginFunctions = aPluginVTable; aPluginVTable->size = sizeof (NPPluginFuncs); aPluginVTable->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR; diff --git a/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp index 67e5d4b..5138562 100644 --- a/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp +++ b/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp @@ -1302,15 +1302,19 @@ int main(int argc, char* argv[]) standardPreferences->setJavaScriptEnabled(TRUE); standardPreferences->setDefaultFontSize(16); standardPreferences->setAcceleratedCompositingEnabled(true); + standardPreferences->setContinuousSpellCheckingEnabled(TRUE); if (printSupportedFeatures) { BOOL acceleratedCompositingAvailable; standardPreferences->acceleratedCompositingEnabled(&acceleratedCompositingAvailable); - BOOL threeDRenderingAvailable = + #if ENABLE(3D_RENDERING) - true; + // In theory, we could have a software-based 3D rendering implementation that we use when + // hardware-acceleration is not available. But we don't have any such software + // implementation, so 3D rendering is only available when hardware-acceleration is. + BOOL threeDRenderingAvailable = acceleratedCompositingAvailable; #else - false; + BOOL threeDRenderingAvailable = FALSE; #endif printf("SupportedFeatures:%s %s\n", acceleratedCompositingAvailable ? "AcceleratedCompositing" : "", threeDRenderingAvailable ? "3DRendering" : ""); diff --git a/WebKitTools/DumpRenderTree/win/DumpRenderTree.vcproj b/WebKitTools/DumpRenderTree/win/DumpRenderTree.vcproj index 1cba86a..2f4908f 100644 --- a/WebKitTools/DumpRenderTree/win/DumpRenderTree.vcproj +++ b/WebKitTools/DumpRenderTree/win/DumpRenderTree.vcproj @@ -18,7 +18,7 @@ <Configuration
Name="Debug|Win32"
ConfigurationType="1"
- InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug.vsprops"
+ InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\FeatureDefines.vsprops;$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug.vsprops"
CharacterSet="1"
>
<Tool
@@ -91,7 +91,7 @@ <Configuration
Name="Release|Win32"
ConfigurationType="1"
- InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\release.vsprops"
+ InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\FeatureDefines.vsprops;$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\release.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
@@ -165,7 +165,7 @@ <Configuration
Name="Debug_Internal|Win32"
ConfigurationType="1"
- InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug_internal.vsprops"
+ InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\FeatureDefines.vsprops;$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug_internal.vsprops"
CharacterSet="1"
>
<Tool
@@ -237,7 +237,7 @@ <Configuration
Name="Debug_Cairo|Win32"
ConfigurationType="1"
- InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug_wincairo.vsprops;$(WebKitLibrariesDir)\tools\vsprops\WinCairo.vsprops"
+ InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\FeatureDefinesCairo.vsprops;$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug_wincairo.vsprops;$(WebKitLibrariesDir)\tools\vsprops\WinCairo.vsprops"
CharacterSet="1"
>
<Tool
@@ -310,7 +310,7 @@ <Configuration
Name="Release_Cairo|Win32"
ConfigurationType="1"
- InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\release.vsprops;$(WebKitLibrariesDir)\tools\vsprops\WinCairo.vsprops"
+ InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\FeatureDefinesCairo.vsprops;$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\release.vsprops;$(WebKitLibrariesDir)\tools\vsprops\WinCairo.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
@@ -384,7 +384,7 @@ <Configuration
Name="Debug_All|Win32"
ConfigurationType="1"
- InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug_internal.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug_all.vsprops"
+ InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\FeatureDefines.vsprops;$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug_internal.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug_all.vsprops"
CharacterSet="1"
>
<Tool
diff --git a/WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h b/WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h index e3497c9..27edaa6 100644 --- a/WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h +++ b/WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h @@ -12,7 +12,7 @@ * 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. + * 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 diff --git a/WebKitTools/DumpRenderTree/win/EditingDelegate.cpp b/WebKitTools/DumpRenderTree/win/EditingDelegate.cpp index 32c02bd..71859cb 100644 --- a/WebKitTools/DumpRenderTree/win/EditingDelegate.cpp +++ b/WebKitTools/DumpRenderTree/win/EditingDelegate.cpp @@ -353,3 +353,72 @@ HRESULT STDMETHODCALLTYPE EditingDelegate::webViewDidChangeSelection( } return S_OK; } + +static int indexOfFirstWordCharacter(const TCHAR* text) +{ + const TCHAR* cursor = text; + while (*cursor && !isalpha(*cursor)) + ++cursor; + return *cursor ? (cursor - text) : -1; +}; + +static int wordLength(const TCHAR* text) +{ + const TCHAR* cursor = text; + while (*cursor && isalpha(*cursor)) + ++cursor; + return cursor - text; +}; + +HRESULT STDMETHODCALLTYPE EditingDelegate::checkSpellingOfString( + /* [in] */ IWebView* view, + /* [in] */ LPCTSTR text, + /* [in] */ int length, + /* [out] */ int* misspellingLocation, + /* [out] */ int* misspellingLength) +{ + static const TCHAR* misspelledWords[] = { + // These words are known misspelled words in webkit tests. + // If there are other misspelled words in webkit tests, please add them in + // this array. + TEXT("foo"), + TEXT("Foo"), + TEXT("baz"), + TEXT("fo"), + TEXT("LibertyF"), + TEXT("chello"), + TEXT("xxxtestxxx"), + TEXT("XXxxx"), + TEXT("Textx"), + TEXT("blockquoted"), + TEXT("asd"), + TEXT("Lorem"), + TEXT("Nunc"), + TEXT("Curabitur"), + TEXT("eu"), + TEXT("adlj"), + TEXT("adaasj"), + TEXT("sdklj"), + TEXT("jlkds"), + TEXT("jsaada"), + TEXT("jlda"), + TEXT("zz"), + TEXT("contentEditable"), + 0, + }; + + wstring textString(text, length); + int wordStart = indexOfFirstWordCharacter(textString.c_str()); + if (-1 == wordStart) + return S_OK; + wstring word = textString.substr(wordStart, wordLength(textString.c_str() + wordStart)); + for (size_t i = 0; misspelledWords[i]; ++i) { + if (word == misspelledWords[i]) { + *misspellingLocation = wordStart; + *misspellingLength = word.size(); + break; + } + } + + return S_OK; +} diff --git a/WebKitTools/DumpRenderTree/win/EditingDelegate.h b/WebKitTools/DumpRenderTree/win/EditingDelegate.h index 6dba675..7b7f418 100644 --- a/WebKitTools/DumpRenderTree/win/EditingDelegate.h +++ b/WebKitTools/DumpRenderTree/win/EditingDelegate.h @@ -127,7 +127,7 @@ public: /* [in] */ LPCTSTR text, /* [in] */ int length, /* [out] */ int *misspellingLocation, - /* [out] */ int *misspellingLength) { return E_NOTIMPL; } + /* [out] */ int *misspellingLength); virtual HRESULT STDMETHODCALLTYPE checkGrammarOfString( /* [in] */ IWebView *view, diff --git a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp index d2140d1..d7c41e0 100644 --- a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp +++ b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp @@ -405,7 +405,7 @@ void LayoutTestController::setGeolocationPermission(bool allow) setGeolocationPermissionCommon(allow); } -void LayoutTestController::setMockSpeechInputResult(JSStringRef result) +void LayoutTestController::setMockSpeechInputResult(JSStringRef result, JSStringRef language) { // FIXME: Implement for speech input layout tests. // See https://bugs.webkit.org/show_bug.cgi?id=39485. @@ -1391,8 +1391,13 @@ void LayoutTestController::abortModal() { } -bool LayoutTestController::hasSpellingMarker(int, int) +bool LayoutTestController::hasSpellingMarker(int from, int length) { - // FIXME: Implement this. - return false; + COMPtr<IWebFramePrivate> framePrivate(Query, frame); + if (!framePrivate) + return false; + BOOL ret = FALSE; + if (FAILED(framePrivate->hasSpellingMarker(from, length, &ret))) + return false; + return ret; } diff --git a/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp b/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp index eefc587..32614c1 100644 --- a/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp +++ b/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp @@ -320,7 +320,7 @@ void LayoutTestController::setGeolocationPermission(bool allow) setGeolocationPermissionCommon(allow); } -void LayoutTestController::setMockSpeechInputResult(JSStringRef result) +void LayoutTestController::setMockSpeechInputResult(JSStringRef result, JSStringRef language) { // FIXME: Implement for speech input layout tests. // See https://bugs.webkit.org/show_bug.cgi?id=39485. @@ -528,4 +528,3 @@ JSRetainPtr<JSStringRef> LayoutTestController::pageSizeAndMarginsInPixels(int pa // FIXME: Implement return 0; } - |