diff options
author | Ben Murdoch <benm@google.com> | 2009-08-11 17:01:47 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2009-08-11 18:21:02 +0100 |
commit | 0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5 (patch) | |
tree | 2943df35f62d885c89d01063cc528dd73b480fea /WebKitTools/DumpRenderTree/mac | |
parent | 7e7a70bfa49a1122b2597a1e6367d89eb4035eca (diff) | |
download | external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.zip external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.tar.gz external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.tar.bz2 |
Merge in WebKit r47029.
Diffstat (limited to 'WebKitTools/DumpRenderTree/mac')
35 files changed, 743 insertions, 132 deletions
diff --git a/WebKitTools/DumpRenderTree/mac/AccessibilityControllerMac.mm b/WebKitTools/DumpRenderTree/mac/AccessibilityControllerMac.mm index 482c4f3..a191495 100644 --- a/WebKitTools/DumpRenderTree/mac/AccessibilityControllerMac.mm +++ b/WebKitTools/DumpRenderTree/mac/AccessibilityControllerMac.mm @@ -23,6 +23,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#import "config.h" #import "DumpRenderTree.h" #import "AccessibilityController.h" diff --git a/WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm b/WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm index 2c4546d..b2cbb34 100644 --- a/WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm +++ b/WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm @@ -23,6 +23,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#import "config.h" #import "DumpRenderTree.h" #import "AccessibilityUIElement.h" @@ -35,6 +36,10 @@ #import <wtf/RetainPtr.h> #import <wtf/Vector.h> +#ifdef BUILDING_ON_TIGER +#define NSAccessibilityValueDescriptionAttribute @"AXValueDescription" +#endif + @interface NSObject (WebKitAccessibilityArrayCategory) - (NSArray *)accessibilityArrayAttributeValues:(NSString *)attribute index:(NSUInteger)index maxCount:(NSUInteger)maxCount; @end @@ -111,8 +116,8 @@ static NSString* descriptionOfValue(id valueObject, id focusedAccessibilityObjec // Strip pointer locations if ([description rangeOfString:@"0x"].length) { - NSString* role = [focusedAccessibilityObject accessibilityAttributeValue:@"AXRole"]; - NSString* title = [focusedAccessibilityObject accessibilityAttributeValue:@"AXTitle"]; + NSString* role = [focusedAccessibilityObject accessibilityAttributeValue:NSAccessibilityRoleAttribute]; + NSString* title = [focusedAccessibilityObject accessibilityAttributeValue:NSAccessibilityTitleAttribute]; if ([title length]) return [NSString stringWithFormat:@"<%@: '%@'>", role, title]; return [NSString stringWithFormat:@"<%@>", role]; @@ -203,6 +208,23 @@ void AccessibilityUIElement::getChildrenWithRange(Vector<AccessibilityUIElement> convertNSArrayToVector(children, elementVector); } +int AccessibilityUIElement::childrenCount() +{ + Vector<AccessibilityUIElement> children; + getChildren(children); + + return children.size(); +} + +AccessibilityUIElement AccessibilityUIElement::elementAtPoint(int x, int y) +{ + id element = [m_element accessibilityHitTest:NSMakePoint(x, y)]; + if (!element) + return nil; + + return AccessibilityUIElement(element); +} + AccessibilityUIElement AccessibilityUIElement::getChildAtIndex(unsigned index) { Vector<AccessibilityUIElement> children; @@ -285,37 +307,67 @@ JSStringRef AccessibilityUIElement::parameterizedAttributeNames() JSStringRef AccessibilityUIElement::role() { - NSString* role = descriptionOfValue([m_element accessibilityAttributeValue:@"AXRole"], m_element); + NSString* role = descriptionOfValue([m_element accessibilityAttributeValue:NSAccessibilityRoleAttribute], m_element); return concatenateAttributeAndValue(@"AXRole", role); } JSStringRef AccessibilityUIElement::title() { - NSString* title = descriptionOfValue([m_element accessibilityAttributeValue:@"AXTitle"], m_element); + NSString* title = descriptionOfValue([m_element accessibilityAttributeValue:NSAccessibilityTitleAttribute], m_element); return concatenateAttributeAndValue(@"AXTitle", title); } JSStringRef AccessibilityUIElement::description() { - id description = descriptionOfValue([m_element accessibilityAttributeValue:@"AXDescription"], m_element); + id description = descriptionOfValue([m_element accessibilityAttributeValue:NSAccessibilityDescriptionAttribute], m_element); return concatenateAttributeAndValue(@"AXDescription", description); } +JSStringRef AccessibilityUIElement::language() +{ + id description = descriptionOfValue([m_element accessibilityAttributeValue:@"AXLanguage"], m_element); + return concatenateAttributeAndValue(@"AXLanguage", description); +} + +double AccessibilityUIElement::x() +{ + NSValue* positionValue = [m_element accessibilityAttributeValue:NSAccessibilityPositionAttribute]; + return static_cast<double>([positionValue pointValue].x); +} + +double AccessibilityUIElement::y() +{ + NSValue* positionValue = [m_element accessibilityAttributeValue:NSAccessibilityPositionAttribute]; + return static_cast<double>([positionValue pointValue].y); +} + double AccessibilityUIElement::width() { - NSValue* sizeValue = [m_element accessibilityAttributeValue:@"AXSize"]; + NSValue* sizeValue = [m_element accessibilityAttributeValue:NSAccessibilitySizeAttribute]; return static_cast<double>([sizeValue sizeValue].width); } double AccessibilityUIElement::height() { - NSValue* sizeValue = [m_element accessibilityAttributeValue:@"AXSize"]; + NSValue* sizeValue = [m_element accessibilityAttributeValue:NSAccessibilitySizeAttribute]; return static_cast<double>([sizeValue sizeValue].height); } +double AccessibilityUIElement::clickPointX() +{ + NSValue* positionValue = [m_element accessibilityAttributeValue:@"AXClickPoint"]; + return static_cast<double>([positionValue pointValue].x); +} + +double AccessibilityUIElement::clickPointY() +{ + NSValue* positionValue = [m_element accessibilityAttributeValue:@"AXClickPoint"]; + return static_cast<double>([positionValue pointValue].x); +} + double AccessibilityUIElement::intValue() { - id value = [m_element accessibilityAttributeValue:@"AXValue"]; + id value = [m_element accessibilityAttributeValue:NSAccessibilityValueAttribute]; if ([value isKindOfClass:[NSNumber class]]) return [(NSNumber*)value doubleValue]; return 0.0f; @@ -323,7 +375,7 @@ double AccessibilityUIElement::intValue() double AccessibilityUIElement::minValue() { - id value = [m_element accessibilityAttributeValue:@"AXMinValue"]; + id value = [m_element accessibilityAttributeValue:NSAccessibilityMinValueAttribute]; if ([value isKindOfClass:[NSNumber class]]) return [(NSNumber*)value doubleValue]; return 0.0f; @@ -331,30 +383,54 @@ double AccessibilityUIElement::minValue() double AccessibilityUIElement::maxValue() { - id value = [m_element accessibilityAttributeValue:@"AXMaxValue"]; + id value = [m_element accessibilityAttributeValue:NSAccessibilityMaxValueAttribute]; if ([value isKindOfClass:[NSNumber class]]) return [(NSNumber*)value doubleValue]; return 0.0; } +JSStringRef AccessibilityUIElement::valueDescription() +{ + NSString* valueDescription = [m_element accessibilityAttributeValue:NSAccessibilityValueDescriptionAttribute]; + if ([valueDescription isKindOfClass:[NSString class]]) + return [valueDescription createJSStringRef]; + return 0; +} + int AccessibilityUIElement::insertionPointLineNumber() { - id value = [m_element accessibilityAttributeValue:@"AXInsertionPointLineNumber"]; + id value = [m_element accessibilityAttributeValue:NSAccessibilityInsertionPointLineNumberAttribute]; if ([value isKindOfClass:[NSNumber class]]) return [(NSNumber *)value intValue]; return -1; } -bool AccessibilityUIElement::supportsPressAction() +bool AccessibilityUIElement::isActionSupported(JSStringRef action) { NSArray* actions = [m_element accessibilityActionNames]; - return [actions containsObject:@"AXPress"]; + return [actions containsObject:[NSString stringWithJSStringRef:action]]; +} + +bool AccessibilityUIElement::isEnabled() +{ + id value = [m_element accessibilityAttributeValue:NSAccessibilityEnabledAttribute]; + if ([value isKindOfClass:[NSNumber class]]) + return [value boolValue]; + return false; +} + +bool AccessibilityUIElement::isRequired() const +{ + id value = [m_element accessibilityAttributeValue:@"AXRequired"]; + if ([value isKindOfClass:[NSNumber class]]) + return [value boolValue]; + return false; } // parameterized attributes int AccessibilityUIElement::lineForIndex(int index) { - id value = [m_element accessibilityAttributeValue:@"AXLineForIndex" forParameter:[NSNumber numberWithInt:index]]; + id value = [m_element accessibilityAttributeValue:NSAccessibilityLineForIndexParameterizedAttribute forParameter:[NSNumber numberWithInt:index]]; if ([value isKindOfClass:[NSNumber class]]) return [(NSNumber *)value intValue]; return -1; @@ -469,3 +545,13 @@ void AccessibilityUIElement::setSelectedTextRange(unsigned location, unsigned le NSValue *textRangeValue = [NSValue valueWithRange:textRange]; [m_element accessibilitySetValue:textRangeValue forAttribute:NSAccessibilitySelectedTextRangeAttribute]; } + +void AccessibilityUIElement::increment() +{ + [m_element accessibilityPerformAction:NSAccessibilityIncrementAction]; +} + +void AccessibilityUIElement::decrement() +{ + [m_element accessibilityPerformAction:NSAccessibilityDecrementAction]; +} diff --git a/WebKitTools/DumpRenderTree/mac/AppleScriptController.m b/WebKitTools/DumpRenderTree/mac/AppleScriptController.m index 86d2881..2eab827 100644 --- a/WebKitTools/DumpRenderTree/mac/AppleScriptController.m +++ b/WebKitTools/DumpRenderTree/mac/AppleScriptController.m @@ -27,6 +27,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#import "config.h" #import "AppleScriptController.h" #import <WebKit/WebView.h> diff --git a/WebKitTools/DumpRenderTree/mac/CheckedMalloc.cpp b/WebKitTools/DumpRenderTree/mac/CheckedMalloc.cpp index 467f1bb..85d0613 100644 --- a/WebKitTools/DumpRenderTree/mac/CheckedMalloc.cpp +++ b/WebKitTools/DumpRenderTree/mac/CheckedMalloc.cpp @@ -27,7 +27,8 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + +#import "config.h" #import "CheckedMalloc.h" #import <malloc/malloc.h> diff --git a/WebKitTools/DumpRenderTree/mac/Configurations/Base.xcconfig b/WebKitTools/DumpRenderTree/mac/Configurations/Base.xcconfig index fce81d3..79d1e14 100644 --- a/WebKitTools/DumpRenderTree/mac/Configurations/Base.xcconfig +++ b/WebKitTools/DumpRenderTree/mac/Configurations/Base.xcconfig @@ -1,10 +1,33 @@ +// Copyright (C) 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + HEADER_SEARCH_PATHS = ForwardingHeaders mac/InternalHeaders; FRAMEWORK_SEARCH_PATHS = $(FRAMEWORK_SEARCH_PATHS_$(MAC_OS_X_VERSION_MAJOR)); FRAMEWORK_SEARCH_PATHS_ = $(SYSTEM_LIBRARY_DIR)/Frameworks/Quartz.framework/Frameworks $(SYSTEM_LIBRARY_DIR)/Frameworks/ApplicationServices.framework/Frameworks FRAMEWORK_SEARCH_PATHS_1040 = $(SYSTEM_LIBRARY_DIR)/Frameworks/Quartz.framework/Frameworks $(SYSTEM_LIBRARY_DIR)/Frameworks/ApplicationServices.framework/Frameworks FRAMEWORK_SEARCH_PATHS_1050 = $(SYSTEM_LIBRARY_DIR)/Frameworks/Quartz.framework/Frameworks $(SYSTEM_LIBRARY_DIR)/Frameworks/ApplicationServices.framework/Frameworks $(SYSTEM_LIBRARY_DIR)/Frameworks/CoreServices.framework/Frameworks FRAMEWORK_SEARCH_PATHS_1060 = $(SYSTEM_LIBRARY_DIR)/Frameworks/Quartz.framework/Frameworks $(SYSTEM_LIBRARY_DIR)/Frameworks/ApplicationServices.framework/Frameworks $(SYSTEM_LIBRARY_DIR)/Frameworks/CoreServices.framework/Frameworks -GCC_PREPROCESSOR_DEFINITIONS = ENABLE_DASHBOARD_SUPPORT; +GCC_PREPROCESSOR_DEFINITIONS = ENABLE_DASHBOARD_SUPPORT WEBKIT_VERSION_MIN_REQUIRED=WEBKIT_VERSION_LATEST; DEBUG_INFORMATION_FORMAT = dwarf PREBINDING = NO GCC_C_LANGUAGE_STANDARD = gnu99 diff --git a/WebKitTools/DumpRenderTree/mac/Configurations/DebugRelease.xcconfig b/WebKitTools/DumpRenderTree/mac/Configurations/DebugRelease.xcconfig index eab511f..05af1e5 100644 --- a/WebKitTools/DumpRenderTree/mac/Configurations/DebugRelease.xcconfig +++ b/WebKitTools/DumpRenderTree/mac/Configurations/DebugRelease.xcconfig @@ -1,3 +1,26 @@ +// Copyright (C) 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + #include "Base.xcconfig" ARCHS = $(ARCHS_$(MAC_OS_X_VERSION_MAJOR)); diff --git a/WebKitTools/DumpRenderTree/mac/Configurations/DumpRenderTree.xcconfig b/WebKitTools/DumpRenderTree/mac/Configurations/DumpRenderTree.xcconfig index b977225..35a0720 100644 --- a/WebKitTools/DumpRenderTree/mac/Configurations/DumpRenderTree.xcconfig +++ b/WebKitTools/DumpRenderTree/mac/Configurations/DumpRenderTree.xcconfig @@ -1,3 +1,26 @@ +// Copyright (C) 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + OTHER_LDFLAGS = -sectcreate __DATA Ahem qt/fonts/AHEM____.TTF -sectcreate __DATA WeightWatcher100 fonts/WebKitWeightWatcher100.ttf -sectcreate __DATA WeightWatcher200 fonts/WebKitWeightWatcher200.ttf -sectcreate __DATA WeightWatcher300 fonts/WebKitWeightWatcher300.ttf -sectcreate __DATA WeightWatcher400 fonts/WebKitWeightWatcher400.ttf -sectcreate __DATA WeightWatcher500 fonts/WebKitWeightWatcher500.ttf -sectcreate __DATA WeightWatcher600 fonts/WebKitWeightWatcher600.ttf -sectcreate __DATA WeightWatcher700 fonts/WebKitWeightWatcher700.ttf -sectcreate __DATA WeightWatcher800 fonts/WebKitWeightWatcher800.ttf -sectcreate __DATA WeightWatcher900 fonts/WebKitWeightWatcher900.ttf PRODUCT_NAME = DumpRenderTree GCC_ENABLE_OBJC_EXCEPTIONS = YES diff --git a/WebKitTools/DumpRenderTree/mac/Configurations/ImageDiff.xcconfig b/WebKitTools/DumpRenderTree/mac/Configurations/ImageDiff.xcconfig index fcd64c5..35968af 100644 --- a/WebKitTools/DumpRenderTree/mac/Configurations/ImageDiff.xcconfig +++ b/WebKitTools/DumpRenderTree/mac/Configurations/ImageDiff.xcconfig @@ -1 +1,24 @@ +// Copyright (C) 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + PRODUCT_NAME = ImageDiff diff --git a/WebKitTools/DumpRenderTree/mac/Configurations/TestNetscapePlugIn.xcconfig b/WebKitTools/DumpRenderTree/mac/Configurations/TestNetscapePlugIn.xcconfig index ea17629..22ea4c2 100644 --- a/WebKitTools/DumpRenderTree/mac/Configurations/TestNetscapePlugIn.xcconfig +++ b/WebKitTools/DumpRenderTree/mac/Configurations/TestNetscapePlugIn.xcconfig @@ -1,3 +1,26 @@ +// Copyright (C) 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + PRODUCT_NAME = TestNetscapePlugIn WRAPPER_EXTENSION = plugin INFOPLIST_FILE = TestNetscapePlugIn.subproj/Info.plist diff --git a/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm b/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm index 485dece..d49248b 100644 --- a/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm +++ b/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm @@ -26,11 +26,13 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + +#import "config.h" #import "DumpRenderTree.h" #import "AccessibilityController.h" #import "CheckedMalloc.h" +#import "DumpRenderTreeDraggingInfo.h" #import "DumpRenderTreePasteboard.h" #import "DumpRenderTreeWindow.h" #import "EditingDelegate.h" @@ -49,7 +51,7 @@ #import "WorkQueueItem.h" #import <Carbon/Carbon.h> #import <CoreFoundation/CoreFoundation.h> -#import <WebKit/DOMElementPrivate.h> +#import <WebKit/DOMElement.h> #import <WebKit/DOMExtensions.h> #import <WebKit/DOMRange.h> #import <WebKit/WebBackForwardList.h> @@ -64,9 +66,11 @@ #import <WebKit/WebHistory.h> #import <WebKit/WebHistoryItemPrivate.h> #import <WebKit/WebInspector.h> +#import <WebKit/WebKitNSStringExtras.h> #import <WebKit/WebPluginDatabase.h> #import <WebKit/WebPreferences.h> #import <WebKit/WebPreferencesPrivate.h> +#import <WebKit/WebPreferenceKeysPrivate.h> #import <WebKit/WebResourceLoadDelegate.h> #import <WebKit/WebTypesInternal.h> #import <WebKit/WebViewPrivate.h> @@ -254,7 +258,7 @@ static void activateFonts() NSURL *resourcesDirectory = [NSURL URLWithString:@"DumpRenderTree.resources" relativeToURL:[[NSBundle mainBundle] executableURL]]; for (unsigned i = 0; fontFileNames[i]; ++i) { NSURL *fontURL = [resourcesDirectory URLByAppendingPathComponent:[NSString stringWithUTF8String:fontFileNames[i]]]; - [fontURLs addObject:fontURL]; + [fontURLs addObject:[fontURL absoluteURL]]; } CFArrayRef errors = 0; @@ -287,6 +291,11 @@ WebView *createWebViewAndOffscreenWindow() // Put it at -10000, -10000 in "flipped coordinates", since WebCore and the DOM use flipped coordinates. NSRect windowRect = NSOffsetRect(rect, -10000, [[[NSScreen screens] objectAtIndex:0] frame].size.height - rect.size.height + 10000); DumpRenderTreeWindow *window = [[DumpRenderTreeWindow alloc] initWithContentRect:windowRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]; + +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) + [window setColorSpace:[[NSScreen mainScreen] colorSpace]]; +#endif + [[window contentView] addSubview:webView]; [window orderBack:nil]; [window setAutodisplay:NO]; @@ -340,6 +349,11 @@ void testStringByEvaluatingJavaScriptFromString() [pool release]; } +static NSString *libraryPathForDumpRenderTree() +{ + return [@"~/Library/Application Support/DumpRenderTree" stringByExpandingTildeInPath]; +} + static void setDefaultsToConsistentValuesForTesting() { // Give some clear to undocumented defaults values @@ -353,6 +367,7 @@ static void setDefaultsToConsistentValuesForTesting() [defaults setObject:@"0.709800 0.835300 1.000000" forKey:@"AppleHighlightColor"]; [defaults setObject:@"0.500000 0.500000 0.500000" forKey:@"AppleOtherHighlightColor"]; [defaults setObject:[NSArray arrayWithObject:@"en"] forKey:@"AppleLanguages"]; + [defaults setBool:YES forKey:WebKitEnableFullDocumentTeardownPreferenceKey]; // Scrollbars are drawn either using AppKit (which uses NSUserDefaults) or using HIToolbox (which uses CFPreferences / kCFPreferencesAnyApplication / kCFPreferencesCurrentUser / kCFPreferencesAnyHost) [defaults setObject:@"DoubleMax" forKey:@"AppleScrollBarVariant"]; @@ -366,9 +381,16 @@ static void setDefaultsToConsistentValuesForTesting() if (initialValue) CFPreferencesSetValue(CFSTR("AppleScrollBarVariant"), initialValue.get(), kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - NSString *libraryPath = [@"~/Library/Application Support/DumpRenderTree" stringByExpandingTildeInPath]; - [defaults setObject:[libraryPath stringByAppendingPathComponent:@"Databases"] forKey:WebDatabaseDirectoryDefaultsKey]; - + NSString *path = libraryPathForDumpRenderTree(); + [defaults setObject:[path stringByAppendingPathComponent:@"Databases"] forKey:WebDatabaseDirectoryDefaultsKey]; + [defaults setObject:[path stringByAppendingPathComponent:@"LocalCache"] forKey:WebKitLocalCacheDefaultsKey]; + NSURLCache *sharedCache = + [[NSURLCache alloc] initWithMemoryCapacity:1024 * 1024 + diskCapacity:0 + diskPath:[path stringByAppendingPathComponent:@"URLCache"]]; + [NSURLCache setSharedURLCache:sharedCache]; + [sharedCache release]; + WebPreferences *preferences = [WebPreferences standardPreferences]; [preferences setStandardFontFamily:@"Times"]; @@ -385,8 +407,9 @@ static void setDefaultsToConsistentValuesForTesting() [preferences setEditableLinkBehavior:WebKitEditableLinkOnlyLiveWithShiftKey]; [preferences setTabsToLinks:NO]; [preferences setDOMPasteAllowed:YES]; - [preferences setFullDocumentTeardownEnabled:YES]; [preferences setShouldPrintBackgrounds:YES]; + [preferences setCacheModel:WebCacheModelDocumentBrowser]; + [preferences setXSSAuditorEnabled:NO]; // The back/forward cache is causing problems due to layouts during transition from one page to another. // So, turn it off for now, but we might want to turn it back on some day. @@ -599,7 +622,14 @@ static void dumpHistoryItem(WebHistoryItem *item, int indent, BOOL current) } for (int i = start; i < indent; i++) putchar(' '); - printf("%s", [[item URLString] UTF8String]); + + NSString *urlString = [item URLString]; + if ([[NSURL URLWithString:urlString] isFileURL]) { + NSRange range = [urlString rangeOfString:@"/LayoutTests/"]; + urlString = [@"(file test):" stringByAppendingString:[urlString substringFromIndex:(range.length + range.location)]]; + } + + printf("%s", [urlString UTF8String]); NSString *target = [item target]; if (target && [target length] > 0) printf(" (in frame \"%s\")", [target UTF8String]); @@ -669,7 +699,7 @@ static NSData *dumpFrameAsPDF(WebFrame *frame) // likewise +[NSView dataWithPDFInsideRect:] also prints to a single continuous page // The goal of this function is to test "real" printing across multiple pages. // FIXME: It's possible there might be printing SPI to let us print a multi-page PDF to an NSData object - NSString *path = @"/tmp/test.pdf"; + NSString *path = [libraryPathForDumpRenderTree() stringByAppendingPathComponent:@"test.pdf"]; NSMutableDictionary *printInfoDict = [NSMutableDictionary dictionaryWithDictionary:[[NSPrintInfo sharedPrintInfo] dictionary]]; [printInfoDict setObject:NSPrintSaveJob forKey:NSPrintJobDisposition]; @@ -1016,6 +1046,8 @@ static void resetWebViewToConsistentStateBeforeTesting() [webView resetPageZoom:nil]; [webView setTabKeyCyclesThroughElements:YES]; [webView setPolicyDelegate:nil]; + [policyDelegate setPermissive:NO]; + [policyDelegate setControllerToNotifyDone:0]; [webView _setDashboardBehavior:WebDashboardBehaviorUseBackwardCompatibilityMode to:NO]; [webView _clearMainFrameName]; [[webView undoManager] removeAllActions]; @@ -1025,8 +1057,9 @@ static void resetWebViewToConsistentStateBeforeTesting() [preferences setAuthorAndUserStylesEnabled:YES]; [preferences setJavaScriptCanOpenWindowsAutomatically:YES]; [preferences setOfflineWebApplicationCacheEnabled:YES]; - [preferences setFullDocumentTeardownEnabled:YES]; [preferences setDeveloperExtrasEnabled:NO]; + [preferences setXSSAuditorEnabled:NO]; + [preferences setLoadsImagesAutomatically:YES]; if (persistentUserStyleSheetLocation) { [preferences setUserStyleSheetLocation:[NSURL URLWithString:(NSString *)(persistentUserStyleSheetLocation.get())]]; @@ -1076,6 +1109,8 @@ static void runTest(const string& testPathOrURL) gLayoutTestController = new LayoutTestController(testURL, expectedPixelHash); topLoadingFrame = nil; + ASSERT(!draggingInfo); // the previous test should have called eventSender.mouseUp to drop! + releaseAndZero(&draggingInfo); done = NO; gLayoutTestController->setIconDatabaseEnabled(false); @@ -1131,7 +1166,9 @@ static void runTest(const string& testPathOrURL) [window close]; } } - + + resetWebViewToConsistentStateBeforeTesting(); + [mainFrame loadHTMLString:@"<html></html>" baseURL:[NSURL URLWithString:@"about:blank"]]; [mainFrame stopLoading]; diff --git a/WebKitTools/DumpRenderTree/mac/DumpRenderTreeDraggingInfo.mm b/WebKitTools/DumpRenderTree/mac/DumpRenderTreeDraggingInfo.mm index 41aa639..02280a1 100644 --- a/WebKitTools/DumpRenderTree/mac/DumpRenderTreeDraggingInfo.mm +++ b/WebKitTools/DumpRenderTree/mac/DumpRenderTreeDraggingInfo.mm @@ -26,6 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#import "config.h" #import "DumpRenderTreeDraggingInfo.h" #import "DumpRenderTree.h" diff --git a/WebKitTools/DumpRenderTree/mac/DumpRenderTreePasteboard.m b/WebKitTools/DumpRenderTree/mac/DumpRenderTreePasteboard.m index a797b5c..75be9de 100644 --- a/WebKitTools/DumpRenderTree/mac/DumpRenderTreePasteboard.m +++ b/WebKitTools/DumpRenderTree/mac/DumpRenderTreePasteboard.m @@ -28,6 +28,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#import "config.h" #import "DumpRenderTreeMac.h" #import "DumpRenderTreePasteboard.h" diff --git a/WebKitTools/DumpRenderTree/mac/DumpRenderTreeWindow.h b/WebKitTools/DumpRenderTree/mac/DumpRenderTreeWindow.h index d2fb60d..b6bdcb8 100644 --- a/WebKitTools/DumpRenderTree/mac/DumpRenderTreeWindow.h +++ b/WebKitTools/DumpRenderTree/mac/DumpRenderTreeWindow.h @@ -33,6 +33,10 @@ @class WebView; @interface DumpRenderTreeWindow : NSWindow +{ + BOOL observingWebView; +} + // I'm not sure why we can't just use [NSApp windows] + (NSArray *)openWindows; diff --git a/WebKitTools/DumpRenderTree/mac/DumpRenderTreeWindow.mm b/WebKitTools/DumpRenderTree/mac/DumpRenderTreeWindow.mm index 3b1fc1f..aa5b117 100644 --- a/WebKitTools/DumpRenderTree/mac/DumpRenderTreeWindow.mm +++ b/WebKitTools/DumpRenderTree/mac/DumpRenderTreeWindow.mm @@ -28,6 +28,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#import "config.h" #import "DumpRenderTreeWindow.h" #import "DumpRenderTree.h" @@ -70,9 +71,9 @@ static CFArrayCallBacks NonRetainingArrayCallbacks = { CFRange arrayRange = CFRangeMake(0, CFArrayGetCount(openWindowsRef)); CFIndex i = CFArrayGetFirstIndexOfValue(openWindowsRef, arrayRange, self); - assert(i != -1); - CFArrayRemoveValueAtIndex(openWindowsRef, i); - + if (i != kCFNotFound) + CFArrayRemoveValueAtIndex(openWindowsRef, i); + [super close]; } @@ -100,12 +101,17 @@ static CFArrayCallBacks NonRetainingArrayCallbacks = { - (void)startObservingWebView { + [self stopObservingWebView]; [[self webView] addObserver:self forKeyPath:@"_isUsingAcceleratedCompositing" options:0 context:0]; + observingWebView = YES; } - (void)stopObservingWebView { + if (!observingWebView) + return; [[self webView] removeObserver:self forKeyPath:@"_isUsingAcceleratedCompositing"]; + observingWebView = NO; } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context diff --git a/WebKitTools/DumpRenderTree/mac/EditingDelegate.mm b/WebKitTools/DumpRenderTree/mac/EditingDelegate.mm index cf4026b..02e931c 100644 --- a/WebKitTools/DumpRenderTree/mac/EditingDelegate.mm +++ b/WebKitTools/DumpRenderTree/mac/EditingDelegate.mm @@ -26,6 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#import "config.h" #import "EditingDelegate.h" #import "DumpRenderTree.h" diff --git a/WebKitTools/DumpRenderTree/mac/EventSendingController.mm b/WebKitTools/DumpRenderTree/mac/EventSendingController.mm index 5883026..8c7c1c4 100644 --- a/WebKitTools/DumpRenderTree/mac/EventSendingController.mm +++ b/WebKitTools/DumpRenderTree/mac/EventSendingController.mm @@ -29,10 +29,12 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#import "config.h" #import "EventSendingController.h" #import "DumpRenderTree.h" #import "DumpRenderTreeDraggingInfo.h" +#import "DumpRenderTreeFileDraggingSource.h" #import <Carbon/Carbon.h> // for GetCurrentEventTime() #import <WebKit/DOMPrivate.h> @@ -118,16 +120,17 @@ BOOL replayingSavedEvents; + (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector { - if (aSelector == @selector(mouseDown:) - || aSelector == @selector(mouseUp:) + if (aSelector == @selector(beginDragWithFiles:) + || aSelector == @selector(clearKillRing) || aSelector == @selector(contextClick) - || aSelector == @selector(scheduleAsynchronousClick) - || aSelector == @selector(mouseMoveToX:Y:) - || aSelector == @selector(leapForward:) - || aSelector == @selector(keyDown:withModifiers:) || aSelector == @selector(enableDOMUIEventLogging:) || aSelector == @selector(fireKeyboardEventsToElement:) - || aSelector == @selector(clearKillRing) + || aSelector == @selector(keyDown:withModifiers:) + || aSelector == @selector(leapForward:) + || aSelector == @selector(mouseDown:) + || aSelector == @selector(mouseMoveToX:Y:) + || aSelector == @selector(mouseUp:) + || aSelector == @selector(scheduleAsynchronousClick) || aSelector == @selector(textZoomIn) || aSelector == @selector(textZoomOut) || aSelector == @selector(zoomPageIn) @@ -145,20 +148,22 @@ BOOL replayingSavedEvents; + (NSString *)webScriptNameForSelector:(SEL)aSelector { + if (aSelector == @selector(beginDragWithFiles:)) + return @"beginDragWithFiles"; + if (aSelector == @selector(enableDOMUIEventLogging:)) + return @"enableDOMUIEventLogging"; + if (aSelector == @selector(fireKeyboardEventsToElement:)) + return @"fireKeyboardEventsToElement"; + if (aSelector == @selector(keyDown:withModifiers:)) + return @"keyDown"; + if (aSelector == @selector(leapForward:)) + return @"leapForward"; if (aSelector == @selector(mouseDown:)) return @"mouseDown"; if (aSelector == @selector(mouseUp:)) return @"mouseUp"; if (aSelector == @selector(mouseMoveToX:Y:)) return @"mouseMoveTo"; - if (aSelector == @selector(leapForward:)) - return @"leapForward"; - if (aSelector == @selector(keyDown:withModifiers:)) - return @"keyDown"; - if (aSelector == @selector(enableDOMUIEventLogging:)) - return @"enableDOMUIEventLogging"; - if (aSelector == @selector(fireKeyboardEventsToElement:)) - return @"fireKeyboardEventsToElement"; if (aSelector == @selector(setDragMode:)) return @"setDragMode"; return nil; @@ -238,6 +243,37 @@ static NSEventType eventTypeForMouseButtonAndAction(int button, MouseAction acti return static_cast<NSEventType>(0); } +- (void)beginDragWithFiles:(WebScriptObject*)jsFilePaths +{ + assert(!draggingInfo); + assert([jsFilePaths isKindOfClass:[WebScriptObject class]]); + + NSPasteboard *pboard = [NSPasteboard pasteboardWithUniqueName]; + [pboard declareTypes:[NSArray arrayWithObject:NSFilenamesPboardType] owner:nil]; + + NSURL *currentTestURL = [NSURL URLWithString:[[mainFrame webView] mainFrameURL]]; + + NSMutableArray *filePaths = [NSMutableArray array]; + for (unsigned i = 0; [[jsFilePaths webScriptValueAtIndex:i] isKindOfClass:[NSString class]]; i++) { + NSString *filePath = (NSString *)[jsFilePaths webScriptValueAtIndex:i]; + // Have NSURL encode the name so that we handle '?' in file names correctly. + NSURL *fileURL = [NSURL fileURLWithPath:filePath]; + NSURL *absoluteFileURL = [NSURL URLWithString:[fileURL relativeString] relativeToURL:currentTestURL]; + [filePaths addObject:[absoluteFileURL path]]; + } + + [pboard setPropertyList:filePaths forType:NSFilenamesPboardType]; + assert([pboard propertyListForType:NSFilenamesPboardType]); // setPropertyList will silently fail on error, assert that it didn't fail + + // Provide a source, otherwise [DumpRenderTreeDraggingInfo draggingSourceOperationMask] defaults to NSDragOperationNone + DumpRenderTreeFileDraggingSource *source = [[[DumpRenderTreeFileDraggingSource alloc] init] autorelease]; + draggingInfo = [[DumpRenderTreeDraggingInfo alloc] initWithImage:nil offset:NSZeroSize pasteboard:pboard source:source]; + [[mainFrame webView] draggingEntered:draggingInfo]; + + dragMode = NO; // dragMode saves events and then replays them later. We don't need/want that. + leftMouseButtonDown = YES; // Make the rest of eventSender think a drag is in progress +} + - (void)updateClickCountForButton:(int)buttonNumber { if (([self currentEventTime] - lastClick >= 1) || @@ -339,7 +375,9 @@ static NSEventType eventTypeForMouseButtonAndAction(int button, MouseAction acti [webView performDragOperation:draggingInfo]; else [webView draggingExited:draggingInfo]; - [[draggingInfo draggingSource] draggedImage:[draggingInfo draggedImage] endedAt:lastMousePosition operation:dragOperation]; + // Per NSDragging.h: draggingSources may not implement draggedImage:endedAt:operation: + if ([[draggingInfo draggingSource] respondsToSelector:@selector(draggedImage:endedAt:operation:)]) + [[draggingInfo draggingSource] draggedImage:[draggingInfo draggedImage] endedAt:lastMousePosition operation:dragOperation]; [draggingInfo release]; draggingInfo = nil; } @@ -355,7 +393,6 @@ static NSEventType eventTypeForMouseButtonAndAction(int button, MouseAction acti [invocation setArgument:&y atIndex:3]; [EventSendingController saveEvent:invocation]; - return; } @@ -376,7 +413,9 @@ static NSEventType eventTypeForMouseButtonAndAction(int button, MouseAction acti if (leftMouseButtonDown) { [subView mouseDragged:event]; if (draggingInfo) { - [[draggingInfo draggingSource] draggedImage:[draggingInfo draggedImage] movedTo:lastMousePosition]; + // Per NSDragging.h: draggingSources may not implement draggedImage:movedTo: + if ([[draggingInfo draggingSource] respondsToSelector:@selector(draggedImage:movedTo:)]) + [[draggingInfo draggingSource] draggedImage:[draggingInfo draggedImage] movedTo:lastMousePosition]; [[mainFrame webView] draggingUpdated:draggingInfo]; } } else @@ -476,7 +515,7 @@ static NSEventType eventTypeForMouseButtonAndAction(int button, MouseAction acti charactersIgnoringModifiers = [character lowercaseString]; } - if ([modifiers isKindOfClass:[WebScriptObject class]]) + if ([modifiers isKindOfClass:[WebScriptObject class]]) { for (unsigned i = 0; [[modifiers webScriptValueAtIndex:i] isKindOfClass:[NSString class]]; i++) { NSString *modifier = (NSString *)[modifiers webScriptValueAtIndex:i]; if ([modifier isEqual:@"ctrlKey"]) @@ -488,6 +527,7 @@ static NSEventType eventTypeForMouseButtonAndAction(int button, MouseAction acti else if ([modifier isEqual:@"metaKey"]) modifierFlags |= NSCommandKeyMask; } + } [[[mainFrame frameView] documentView] layout]; @@ -617,9 +657,8 @@ static NSEventType eventTypeForMouseButtonAndAction(int button, MouseAction acti // to work well enough that we can test that way instead. - (void)fireKeyboardEventsToElement:(WebScriptObject *)element { - if (![element isKindOfClass:[DOMHTMLElement class]]) { + if (![element isKindOfClass:[DOMHTMLElement class]]) return; - } DOMHTMLElement *target = (DOMHTMLElement*)element; DOMDocument *document = [target ownerDocument]; diff --git a/WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.mm b/WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.mm index f079cb5..4bf02ed 100644 --- a/WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.mm +++ b/WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.mm @@ -26,6 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#import "config.h" #import "DumpRenderTree.h" #import "FrameLoadDelegate.h" @@ -38,6 +39,7 @@ #import "ObjCController.h" #import "ObjCPlugin.h" #import "ObjCPluginFunction.h" +#import "PlainTextController.h" #import "TextInputController.h" #import "WorkQueue.h" #import "WorkQueueItem.h" @@ -105,22 +107,19 @@ - (void)dealloc { delete gcController; + delete accessibilityController; [super dealloc]; } // Exec messages in the work queue until they're all done, or one of them starts a new load - (void)processWork:(id)dummy { - // quit doing work once a load is in progress - while (WorkQueue::shared()->count() > 0 && !topLoadingFrame) { - WorkQueueItem* item = WorkQueue::shared()->dequeue(); - ASSERT(item); - item->invoke(); - delete item; - } + // if another load started, then wait for it to complete. + if (topLoadingFrame) + return; - // if we didn't start a new load, then we finished all the commands, so we're ready to dump state - if (!topLoadingFrame && !gLayoutTestController->waitToDump()) + // if we finish all the commands, we're ready to dump state + if (WorkQueue::shared()->processWork() && !gLayoutTestController->waitToDump()) dump(); } @@ -171,8 +170,6 @@ gLayoutTestController->setWindowIsKey(true); NSView *documentView = [[mainFrame frameView] documentView]; [[[mainFrame webView] window] makeFirstResponder:documentView]; - if ([documentView isKindOfClass:[WebHTMLView class]]) - [(WebHTMLView *)documentView _updateFocusedAndActiveState]; } - (void)webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame @@ -182,7 +179,7 @@ printf ("%s\n", [string UTF8String]); } - if ([error domain] == NSURLErrorDomain && [error code] == NSURLErrorServerCertificateHasUnknownRoot) { + if ([error domain] == NSURLErrorDomain && ([error code] == NSURLErrorServerCertificateHasUnknownRoot || [error code] == NSURLErrorServerCertificateUntrusted)) { NSURL *failedURL = [[error userInfo] objectForKey:@"NSErrorFailingURLKey"]; [NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[failedURL _web_hostString]]; [frame loadRequest:[[[[frame provisionalDataSource] request] mutableCopy] autorelease]]; @@ -256,24 +253,21 @@ ASSERT(!exception); // Make Old-Style controllers + + AppleScriptController *asc = [[AppleScriptController alloc] initWithWebView:sender]; + [obj setValue:asc forKey:@"appleScriptController"]; + [asc release]; + EventSendingController *esc = [[EventSendingController alloc] init]; [obj setValue:esc forKey:@"eventSender"]; [esc release]; - TextInputController *tic = [[TextInputController alloc] initWithWebView:sender]; - [obj setValue:tic forKey:@"textInputController"]; - [tic release]; + [obj setValue:gNavigationController forKey:@"navigationController"]; - AppleScriptController *asc = [[AppleScriptController alloc] initWithWebView:sender]; - [obj setValue:asc forKey:@"appleScriptController"]; - [asc release]; - ObjCController *occ = [[ObjCController alloc] init]; [obj setValue:occ forKey:@"objCController"]; [occ release]; - [obj setValue:gNavigationController forKey:@"navigationController"]; - ObjCPlugin *plugin = [[ObjCPlugin alloc] init]; [obj setValue:plugin forKey:@"objCPlugin"]; [plugin release]; @@ -281,6 +275,12 @@ ObjCPluginFunction *pluginFunction = [[ObjCPluginFunction alloc] init]; [obj setValue:pluginFunction forKey:@"objCPluginFunction"]; [pluginFunction release]; + + [obj setValue:[PlainTextController sharedPlainTextController] forKey:@"plainText"]; + + TextInputController *tic = [[TextInputController alloc] initWithWebView:sender]; + [obj setValue:tic forKey:@"textInputController"]; + [tic release]; } - (void)webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame diff --git a/WebKitTools/DumpRenderTree/mac/GCControllerMac.mm b/WebKitTools/DumpRenderTree/mac/GCControllerMac.mm index 4b845ba..de8a61e 100644 --- a/WebKitTools/DumpRenderTree/mac/GCControllerMac.mm +++ b/WebKitTools/DumpRenderTree/mac/GCControllerMac.mm @@ -27,7 +27,9 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#import "config.h" #import "GCController.h" + #import <WebKit/WebCoreStatistics.h> diff --git a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm index 3aa1f2c..591bb81 100644 --- a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm +++ b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm @@ -26,6 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#import "config.h" #import "DumpRenderTree.h" #import "LayoutTestController.h" @@ -174,16 +175,6 @@ JSStringRef LayoutTestController::pathToLocalResource(JSContextRef context, JSSt return JSStringRetain(url); // Do nothing on mac. } -void LayoutTestController::queueBackNavigation(int howFarBack) -{ - WorkQueue::shared()->queue(new BackItem(howFarBack)); -} - -void LayoutTestController::queueForwardNavigation(int howFarForward) -{ - WorkQueue::shared()->queue(new ForwardItem(howFarForward)); -} - void LayoutTestController::queueLoad(JSStringRef url, JSStringRef target) { RetainPtr<CFStringRef> urlCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, url)); @@ -196,16 +187,6 @@ void LayoutTestController::queueLoad(JSStringRef url, JSStringRef target) WorkQueue::shared()->queue(new LoadItem(absoluteURL.get(), target)); } -void LayoutTestController::queueReload() -{ - WorkQueue::shared()->queue(new ReloadItem); -} - -void LayoutTestController::queueScript(JSStringRef script) -{ - WorkQueue::shared()->queue(new ScriptItem(script)); -} - void LayoutTestController::setAcceptsEditing(bool newAcceptsEditing) { [(EditingDelegate *)[[mainFrame webView] editingDelegate] setAcceptsEditing:newAcceptsEditing]; @@ -263,9 +244,6 @@ void LayoutTestController::setMainFrameIsFirstResponder(bool flag) NSResponder *firstResponder = flag ? documentView : nil; [[[mainFrame webView] window] makeFirstResponder:firstResponder]; - - if ([documentView isKindOfClass:[WebHTMLView class]]) - [(WebHTMLView *)documentView _updateFocusedAndActiveState]; } void LayoutTestController::setPrivateBrowsingEnabled(bool privateBrowsingEnabled) @@ -273,6 +251,11 @@ void LayoutTestController::setPrivateBrowsingEnabled(bool privateBrowsingEnabled [[[mainFrame webView] preferences] setPrivateBrowsingEnabled:privateBrowsingEnabled]; } +void LayoutTestController::setXSSAuditorEnabled(bool enabled) +{ + [[[mainFrame webView] preferences] setXSSAuditorEnabled:enabled]; +} + void LayoutTestController::setPopupBlockingEnabled(bool popupBlockingEnabled) { [[[mainFrame webView] preferences] setJavaScriptCanOpenWindowsAutomatically:!popupBlockingEnabled]; @@ -300,6 +283,16 @@ void LayoutTestController::setUserStyleSheetLocation(JSStringRef path) [[WebPreferences standardPreferences] setUserStyleSheetLocation:url]; } +void LayoutTestController::disableImageLoading() +{ + [[WebPreferences standardPreferences] setLoadsImagesAutomatically:NO]; +} + +void LayoutTestController::dispatchPendingLoadRequests() +{ + [[mainFrame webView] _dispatchPendingLoadRequests]; +} + void LayoutTestController::setPersistentUserStyleSheetLocation(JSStringRef jsURL) { RetainPtr<CFStringRef> urlString(AdoptCF, JSStringCopyCFString(0, jsURL)); @@ -314,9 +307,7 @@ void LayoutTestController::clearPersistentUserStyleSheet() void LayoutTestController::setWindowIsKey(bool windowIsKey) { m_windowIsKey = windowIsKey; - NSView *documentView = [[mainFrame frameView] documentView]; - if ([documentView isKindOfClass:[WebHTMLView class]]) - [(WebHTMLView *)documentView _updateFocusedAndActiveState]; + [[mainFrame webView] _updateActiveState]; } void LayoutTestController::setSmartInsertDeleteEnabled(bool flag) @@ -378,6 +369,11 @@ void LayoutTestController::execCommand(JSStringRef name, JSStringRef value) [[mainFrame webView] _executeCoreCommandByName:nameNS value:valueNS]; } +void LayoutTestController::setCacheModel(int cacheModel) +{ + [[WebPreferences standardPreferences] setCacheModel:cacheModel]; +} + bool LayoutTestController::isCommandEnabled(JSStringRef name) { RetainPtr<CFStringRef> nameCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, name)); @@ -426,3 +422,10 @@ unsigned LayoutTestController::numberOfActiveAnimations() const { return [mainFrame _numberOfActiveAnimations]; } + +void LayoutTestController::waitForPolicyDelegate() +{ + setWaitToDump(true); + [policyDelegate setControllerToNotifyDone:this]; + [[mainFrame webView] setPolicyDelegate:policyDelegate]; +} diff --git a/WebKitTools/DumpRenderTree/mac/NavigationController.m b/WebKitTools/DumpRenderTree/mac/NavigationController.m index 44aed8a..8c01d50 100644 --- a/WebKitTools/DumpRenderTree/mac/NavigationController.m +++ b/WebKitTools/DumpRenderTree/mac/NavigationController.m @@ -26,9 +26,12 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#import "config.h" +#import "NavigationController.h" + #import <WebKit/WebFrame.h> #import <WebKit/WebScriptObject.h> -#import "NavigationController.h" + @implementation NavigationController + (BOOL)isSelectorExcludedFromWebScript:(SEL)selector diff --git a/WebKitTools/DumpRenderTree/mac/ObjCController.m b/WebKitTools/DumpRenderTree/mac/ObjCController.m index ec1ed38..e0d663e 100644 --- a/WebKitTools/DumpRenderTree/mac/ObjCController.m +++ b/WebKitTools/DumpRenderTree/mac/ObjCController.m @@ -26,6 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#import "config.h" #import "ObjCController.h" #import <JavaScriptCore/JavaScriptCore.h> diff --git a/WebKitTools/DumpRenderTree/mac/ObjCPlugin.m b/WebKitTools/DumpRenderTree/mac/ObjCPlugin.m index 3ec3e74..023eae1 100644 --- a/WebKitTools/DumpRenderTree/mac/ObjCPlugin.m +++ b/WebKitTools/DumpRenderTree/mac/ObjCPlugin.m @@ -24,10 +24,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#import "config.h" #import "ObjCPlugin.h" -#import <objc/objc-runtime.h> -#import <WebKit/WebKit.h> +#import <WebKit/WebKit.h> +#import <objc/objc-runtime.h> // === NSObject category to expose almost everything to JavaScript === diff --git a/WebKitTools/DumpRenderTree/mac/ObjCPluginFunction.m b/WebKitTools/DumpRenderTree/mac/ObjCPluginFunction.m index 5cd16f8..5bf3617 100644 --- a/WebKitTools/DumpRenderTree/mac/ObjCPluginFunction.m +++ b/WebKitTools/DumpRenderTree/mac/ObjCPluginFunction.m @@ -23,7 +23,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - +#import "config.h" #import "ObjCPluginFunction.h" diff --git a/WebKitTools/DumpRenderTree/mac/PerlSupport/DumpRenderTreeSupport.c b/WebKitTools/DumpRenderTree/mac/PerlSupport/DumpRenderTreeSupport.c new file mode 100644 index 0000000..35f051c --- /dev/null +++ b/WebKitTools/DumpRenderTree/mac/PerlSupport/DumpRenderTreeSupport.c @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/sysctl.h> + +int processIsCrashing(int pid) +{ + int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid }; + struct kinfo_proc info; + size_t bufferSize = sizeof(info); + if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), &info, &bufferSize, 0, 0)) { + perror("sysctl"); + return 0; + } + + struct extern_proc proc = info.kp_proc; + + // The process is crashing if it is waiting to exit, is not a zombie, and has a non-zero exit code. + return proc.p_stat != SZOMB && (proc.p_flag & P_WEXIT) && proc.p_xstat; +} diff --git a/WebKitTools/DumpRenderTree/mac/PerlSupport/DumpRenderTreeSupportTiger.pm b/WebKitTools/DumpRenderTree/mac/PerlSupport/DumpRenderTreeSupportTiger.pm new file mode 100644 index 0000000..f0697fc --- /dev/null +++ b/WebKitTools/DumpRenderTree/mac/PerlSupport/DumpRenderTreeSupportTiger.pm @@ -0,0 +1,52 @@ +# Copyright (C) 2009 Apple Inc. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +use strict; +use warnings; + +package DumpRenderTreeSupport; + +BEGIN { + use Exporter (); + our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); + $VERSION = 1.00; + @ISA = qw(Exporter); + @EXPORT = qw(&processIsCrashing); + %EXPORT_TAGS = ( ); + @EXPORT_OK = (); +} + +our @EXPORT_OK; + +sub processIsCrashing +{ + my $pid = shift; + my $tryingToExit = 0; + open PS, "ps -o state -p $pid |"; + <PS>; # skip header + $tryingToExit = 1 if <PS> =~ /E/; + close PS; + return $tryingToExit; +} + +1; diff --git a/WebKitTools/DumpRenderTree/mac/PerlSupport/Makefile b/WebKitTools/DumpRenderTree/mac/PerlSupport/Makefile new file mode 100644 index 0000000..6c97877 --- /dev/null +++ b/WebKitTools/DumpRenderTree/mac/PerlSupport/Makefile @@ -0,0 +1,63 @@ +# Copyright (C) 2009 Apple Inc. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +CONFIGURATION_BUILD_DIR ?= . +OUTPUT_DIR=$(CONFIGURATION_BUILD_DIR) + +WRAPPER=$(OUTPUT_DIR)/DerivedSources/DumpRenderTree/DumpRenderTreeSupport_wrap.c +PERL_MODULE=$(OUTPUT_DIR)/DumpRenderTreeSupport.pm +DYLIB=$(OUTPUT_DIR)/DumpRenderTreeSupport.dylib +DUMPRENDERTREE=$(OUTPUT_DIR)/DumpRenderTree + +OSX_VERSION=$(shell sw_vers -productVersion | cut -d. -f 2) + +ifneq "$(OSX_VERSION)" "4" + +PERL=/usr/bin/perl +SWIG=/usr/bin/swig + +all: $(DYLIB) $(PERL_MODULE) + +$(WRAPPER) $(PERL_MODULE): DumpRenderTreeSupport.c $(DUMPRENDERTREE) + mkdir -p $$(dirname $(WRAPPER)) + $(SWIG) -o $(WRAPPER) -outdir $(OUTPUT_DIR) -perl -module DumpRenderTreeSupport $< + +$(DYLIB): DumpRenderTreeSupport.c $(WRAPPER) + gcc -g -dynamiclib -o $(DYLIB) `$(PERL) -MExtUtils::Embed -eperl_inc` `$(PERL) -MExtUtils::Embed -eldopts` $^ + + +else + + +all: $(PERL_MODULE) + +$(PERL_MODULE): DumpRenderTreeSupportTiger.pm + cp $^ $(PERL_MODULE) + + +endif + +clean: + rm -f $(WRAPPER) $(PERL_MODULE) $(DYLIB) + +installhdrs installsrc install: diff --git a/WebKitTools/DumpRenderTree/mac/PixelDumpSupportMac.mm b/WebKitTools/DumpRenderTree/mac/PixelDumpSupportMac.mm index d17c111..0059b69 100644 --- a/WebKitTools/DumpRenderTree/mac/PixelDumpSupportMac.mm +++ b/WebKitTools/DumpRenderTree/mac/PixelDumpSupportMac.mm @@ -28,16 +28,13 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "DumpRenderTree.h" +#include "config.h" #include "PixelDumpSupport.h" #include "PixelDumpSupportCG.h" +#include "DumpRenderTree.h" #include "LayoutTestController.h" #include <CoreGraphics/CGBitmapContext.h> -#ifndef BUILDING_ON_LEOPARD -#include <OpenGL/OpenGL.h> -#include <OpenGL/CGLMacro.h> -#endif #include <wtf/Assertions.h> #include <wtf/RefPtr.h> @@ -46,6 +43,11 @@ #import <WebKit/WebKit.h> #import <WebKit/WebViewPrivate.h> +#if defined(BUILDING_ON_TIGER) +#include <OpenGL/OpenGL.h> +#include <OpenGL/CGLMacro.h> +#endif + // To ensure pixel tests consistency, we need to always render in the same colorspace. // Unfortunately, because of AppKit / WebKit constraints, we can't render directly in the colorspace of our choice. // This implies we have to temporarily change the profile of the main display to the colorspace we want to render into. @@ -153,11 +155,18 @@ PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool inc [view displayRectIgnoringOpacity:line inContext:nsContext]; } } else { + if (onscreen) { -#ifdef BUILDING_ON_LEOPARD +#if !defined(BUILDING_ON_TIGER) + // displayIfNeeded does not update the CA layers if the layer-hosting view was not marked as needing display, so + // we're at the mercy of CA's display-link callback to update layers in time. So we need to force a display of the view + // to get AppKit to update the CA layers synchronously. + // FIXME: this will break repaint testing if we have compositing in repaint tests + // (displayWebView() painted gray over the webview, but we'll be making everything repaint again). + [view display]; + // Ask the window server to provide us a composited version of the *real* window content including surfaces (i.e. OpenGL content) // Note that the returned image might differ very slightly from the window backing because of dithering artifacts in the window server compositor - CGImageRef image = CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, [[view window] windowNumber], kCGWindowImageBoundsIgnoreFraming | kCGWindowImageShouldBeOpaque); CGContextDrawImage(context, CGRectMake(0, 0, CGImageGetWidth(image), CGImageGetHeight(image)), image); CGImageRelease(image); @@ -216,10 +225,11 @@ PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool inc [window setLevel:oldLevel]; #endif } else { + // Make sure the view has been painted. + [view displayIfNeeded]; + // Grab directly the contents of the window backing buffer (this ignores any surfaces on the window) // FIXME: This path is suboptimal: data is read from window backing store, converted to RGB8 then drawn again into an RGBA8 bitmap - - [view displayIfNeeded]; [view lockFocus]; NSBitmapImageRep *imageRep = [[[NSBitmapImageRep alloc] initWithFocusedViewRect:[view frame]] autorelease]; [view unlockFocus]; diff --git a/WebKitTools/DumpRenderTree/mac/PlainTextController.h b/WebKitTools/DumpRenderTree/mac/PlainTextController.h new file mode 100644 index 0000000..1488f2f --- /dev/null +++ b/WebKitTools/DumpRenderTree/mac/PlainTextController.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +@interface PlainTextController : NSObject ++ (PlainTextController *)sharedPlainTextController; +@end diff --git a/WebKitTools/DumpRenderTree/mac/PlainTextController.mm b/WebKitTools/DumpRenderTree/mac/PlainTextController.mm new file mode 100644 index 0000000..eb89bce --- /dev/null +++ b/WebKitTools/DumpRenderTree/mac/PlainTextController.mm @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "config.h" +#import "PlainTextController.h" + +#import <WebKit/WebKit.h> + +@implementation PlainTextController + ++ (PlainTextController *)sharedPlainTextController +{ + static PlainTextController *controller = [[PlainTextController alloc] init]; + return controller; +} + ++ (BOOL)isSelectorExcludedFromWebScript:(SEL)selector +{ + if (selector == @selector(plainTextForRange:)) + return NO; + return YES; +} + ++ (NSString *)webScriptNameForSelector:(SEL)selector +{ + if (selector == @selector(plainTextForRange:)) + return @"plainText"; + return nil; +} + +- (NSString *)plainTextForRange:(DOMRange *)range +{ + if (![range isKindOfClass:[DOMRange class]]) + return nil; + return [range text]; +} + +@end diff --git a/WebKitTools/DumpRenderTree/mac/PolicyDelegate.h b/WebKitTools/DumpRenderTree/mac/PolicyDelegate.h index 4cdf7c0..3b95455 100644 --- a/WebKitTools/DumpRenderTree/mac/PolicyDelegate.h +++ b/WebKitTools/DumpRenderTree/mac/PolicyDelegate.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -28,11 +28,14 @@ #import <Cocoa/Cocoa.h> +class LayoutTestController; @interface PolicyDelegate : NSObject { BOOL permissiveDelegate; + LayoutTestController* controllerToNotifyDone; } - (void)setPermissive:(BOOL)permissive; +- (void)setControllerToNotifyDone:(LayoutTestController*)controller; @end diff --git a/WebKitTools/DumpRenderTree/mac/PolicyDelegate.mm b/WebKitTools/DumpRenderTree/mac/PolicyDelegate.mm index a0855d3..6935ea7 100644 --- a/WebKitTools/DumpRenderTree/mac/PolicyDelegate.mm +++ b/WebKitTools/DumpRenderTree/mac/PolicyDelegate.mm @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,13 +26,25 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#import "config.h" #import "PolicyDelegate.h" #import "DumpRenderTree.h" -#import "DumpRenderTreeDraggingInfo.h" +#import "LayoutTestController.h" +#import <WebKit/DOMElement.h> #import <WebKit/WebPolicyDelegate.h> +#import <WebKit/WebView.h> + +@interface NSURL (DRTExtras) +- (NSString *)_drt_descriptionSuitableForTestResult; +@end + +@interface DOMNode (dumpPath) +- (NSString *)dumpPath; +@end @implementation PolicyDelegate + - (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame @@ -63,13 +75,29 @@ default: typeDescription = "illegal value"; } - - printf("Policy delegate: attempt to load %s with navigation type '%s'\n", [[[request URL] absoluteString] UTF8String], typeDescription); - + + NSString *message = [NSString stringWithFormat:@"Policy delegate: attempt to load %@ with navigation type '%s'", [[request URL] _drt_descriptionSuitableForTestResult], typeDescription]; + + if (DOMElement *originatingNode = [[actionInformation objectForKey:WebActionElementKey] objectForKey:WebElementDOMNodeKey]) + message = [message stringByAppendingFormat:@" originating from %@", [originatingNode dumpPath]]; + + printf("%s\n", [message UTF8String]); + if (permissiveDelegate) [listener use]; else [listener ignore]; + + if (controllerToNotifyDone) { + controllerToNotifyDone->notifyDone(); + controllerToNotifyDone = 0; + } +} + +- (void)webView:(WebView *)webView unableToImplementPolicyWithError:(NSError *)error frame:(WebFrame *)frame +{ + NSString *message = [NSString stringWithFormat:@"Policy delegate: unable to implement policy with error domain '%@', error code %d, in frame '%@'", [error domain], [error code], [frame name]]; + printf("%s\n", [message UTF8String]); } - (void)setPermissive:(BOOL)permissive @@ -77,5 +105,9 @@ permissiveDelegate = permissive; } +- (void)setControllerToNotifyDone:(LayoutTestController*)controller +{ + controllerToNotifyDone = controller; +} @end diff --git a/WebKitTools/DumpRenderTree/mac/ResourceLoadDelegate.mm b/WebKitTools/DumpRenderTree/mac/ResourceLoadDelegate.mm index 2b7a8f3..0089f7f 100644 --- a/WebKitTools/DumpRenderTree/mac/ResourceLoadDelegate.mm +++ b/WebKitTools/DumpRenderTree/mac/ResourceLoadDelegate.mm @@ -26,6 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#import "config.h" #import "ResourceLoadDelegate.h" #import "DumpRenderTree.h" @@ -88,7 +89,10 @@ - (NSString *)_drt_descriptionSuitableForTestResult { - return [NSString stringWithFormat:@"<NSURLResponse %@>", [[self URL] _drt_descriptionSuitableForTestResult]]; + int statusCode = 0; + if ([self isKindOfClass:[NSHTTPURLResponse class]]) + statusCode = [(NSHTTPURLResponse *)self statusCode]; + return [NSString stringWithFormat:@"<NSURLResponse %@, http status code %i>", [[self URL] _drt_descriptionSuitableForTestResult], statusCode]; } @end @@ -97,7 +101,10 @@ - (NSString *)_drt_descriptionSuitableForTestResult { - return [NSString stringWithFormat:@"<NSURLRequest URL %@, main document URL %@>", [[self URL] _drt_descriptionSuitableForTestResult], [[self mainDocumentURL] _drt_descriptionSuitableForTestResult]]; + NSString *httpMethod = [self HTTPMethod]; + if (!httpMethod) + httpMethod = @"(none)"; + return [NSString stringWithFormat:@"<NSURLRequest URL %@, main document URL %@, http method %@>", [[self URL] _drt_descriptionSuitableForTestResult], [[self mainDocumentURL] _drt_descriptionSuitableForTestResult], httpMethod]; } @end @@ -122,6 +129,11 @@ printf("%s\n", [string UTF8String]); } + if (!done && gLayoutTestController->willSendRequestReturnsNullOnRedirect() && redirectResponse) { + printf("Returning null for this redirect\n"); + return nil; + } + NSURL *url = [newRequest URL]; NSString *host = [url host]; if (host @@ -153,6 +165,8 @@ NSString *string = [NSString stringWithFormat:@"%@ - didReceiveResponse %@", identifier, [response _drt_descriptionSuitableForTestResult]]; printf("%s\n", [string UTF8String]); } + if (!done && gLayoutTestController->dumpResourceResponseMIMETypes()) + printf("%s has MIME type %s\n", [[[[response URL] relativePath] lastPathComponent] UTF8String], [[response MIMEType] UTF8String]); } -(void)webView: (WebView *)wv resource:identifier didReceiveContentLength: (NSInteger)length fromDataSource:(WebDataSource *)dataSource @@ -184,7 +198,7 @@ -(NSCachedURLResponse *) webView: (WebView *)wv resource:(id)identifier willCacheResponse:(NSCachedURLResponse *)response fromDataSource:(WebDataSource *)dataSource { - if (!done && gLayoutTestController->dumpResourceLoadCallbacks()) { + if (!done && gLayoutTestController->dumpWillCacheResponse()) { NSString *string = [NSString stringWithFormat:@"%@ - willCacheResponse: called", identifier]; printf("%s\n", [string UTF8String]); } diff --git a/WebKitTools/DumpRenderTree/mac/TextInputController.m b/WebKitTools/DumpRenderTree/mac/TextInputController.m index a635070..3ea9c22 100644 --- a/WebKitTools/DumpRenderTree/mac/TextInputController.m +++ b/WebKitTools/DumpRenderTree/mac/TextInputController.m @@ -26,9 +26,10 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#import "DumpRenderTreeMac.h" +#import "config.h" #import "TextInputController.h" +#import "DumpRenderTreeMac.h" #import <AppKit/NSInputManager.h> #import <WebKit/WebDocument.h> #import <WebKit/WebFrame.h> diff --git a/WebKitTools/DumpRenderTree/mac/UIDelegate.mm b/WebKitTools/DumpRenderTree/mac/UIDelegate.mm index 550892f..807ea08 100644 --- a/WebKitTools/DumpRenderTree/mac/UIDelegate.mm +++ b/WebKitTools/DumpRenderTree/mac/UIDelegate.mm @@ -26,16 +26,17 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#import "DumpRenderTree.h" +#import "config.h" #import "UIDelegate.h" +#import "DumpRenderTree.h" #import "DumpRenderTreeDraggingInfo.h" #import "EventSendingController.h" #import "LayoutTestController.h" #import <WebKit/WebFramePrivate.h> #import <WebKit/WebHTMLViewPrivate.h> -#import <WebKit/WebView.h> #import <WebKit/WebSecurityOriginPrivate.h> +#import <WebKit/WebView.h> #import <wtf/Assertions.h> DumpRenderTreeDraggingInfo *draggingInfo = nil; @@ -95,11 +96,8 @@ DumpRenderTreeDraggingInfo *draggingInfo = nil; - (void)webView:(WebView *)sender dragImage:(NSImage *)anImage at:(NSPoint)viewLocation offset:(NSSize)initialOffset event:(NSEvent *)event pasteboard:(NSPasteboard *)pboard source:(id)sourceObj slideBack:(BOOL)slideFlag forView:(NSView *)view { assert(!draggingInfo); - if (gLayoutTestController->addFileToPasteboardOnDrag()) { - [pboard declareTypes:[NSArray arrayWithObject:NSFilenamesPboardType] owner:nil]; - [pboard setPropertyList:[NSArray arrayWithObject:@"DRTFakeFile"] forType:NSFilenamesPboardType]; - } draggingInfo = [[DumpRenderTreeDraggingInfo alloc] initWithImage:anImage offset:initialOffset pasteboard:pboard source:sourceObj]; + [sender draggingUpdated:draggingInfo]; [EventSendingController replaySavedEvents]; } diff --git a/WebKitTools/DumpRenderTree/mac/WorkQueueItemMac.mm b/WebKitTools/DumpRenderTree/mac/WorkQueueItemMac.mm index 3a7b0e2..4e39a5a 100644 --- a/WebKitTools/DumpRenderTree/mac/WorkQueueItemMac.mm +++ b/WebKitTools/DumpRenderTree/mac/WorkQueueItemMac.mm @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,6 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#import "config.h" #import "DumpRenderTree.h" #import "WorkQueueItem.h" @@ -37,7 +38,7 @@ #import <WebKit/WebView.h> #import <wtf/RetainPtr.h> -void LoadItem::invoke() const +bool LoadItem::invoke() const { RetainPtr<CFStringRef> urlCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, m_url.get())); NSString *urlNS = (NSString *)urlCF.get(); @@ -50,21 +51,24 @@ void LoadItem::invoke() const else targetFrame = mainFrame; [targetFrame loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlNS]]]; + return true; } -void ReloadItem::invoke() const +bool ReloadItem::invoke() const { [[mainFrame webView] reload:nil]; + return true; } -void ScriptItem::invoke() const +bool ScriptItem::invoke() const { RetainPtr<CFStringRef> scriptCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, m_script.get())); NSString *scriptNS = (NSString *)scriptCF.get(); [[mainFrame webView] stringByEvaluatingJavaScriptFromString:scriptNS]; + return true; } -void BackForwardItem::invoke() const +bool BackForwardItem::invoke() const { if (m_howFar == 1) [[mainFrame webView] goForward]; @@ -74,4 +78,5 @@ void BackForwardItem::invoke() const WebBackForwardList *bfList = [[mainFrame webView] backForwardList]; [[mainFrame webView] goToBackForwardItem:[bfList itemAtIndex:m_howFar]]; } + return true; } |