summaryrefslogtreecommitdiffstats
path: root/WebKitTools/DumpRenderTree/mac
diff options
context:
space:
mode:
Diffstat (limited to 'WebKitTools/DumpRenderTree/mac')
-rw-r--r--WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm156
-rw-r--r--WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm35
-rw-r--r--WebKitTools/DumpRenderTree/mac/DumpRenderTreeMac.h3
-rw-r--r--WebKitTools/DumpRenderTree/mac/DumpRenderTreeWindow.h4
-rw-r--r--WebKitTools/DumpRenderTree/mac/DumpRenderTreeWindow.mm34
-rw-r--r--WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.mm47
-rw-r--r--WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm65
-rw-r--r--WebKitTools/DumpRenderTree/mac/UIDelegate.mm12
8 files changed, 298 insertions, 58 deletions
diff --git a/WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm b/WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm
index 375dbad..948f379 100644
--- a/WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm
+++ b/WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm
@@ -40,6 +40,18 @@
#define NSAccessibilityValueDescriptionAttribute @"AXValueDescription"
#endif
+#ifndef NSAccessibilityOwnsAttribute
+#define NSAccessibilityOwnsAttribute @"AXOwns"
+#endif
+
+#ifndef NSAccessibilityGrabbedAttribute
+#define NSAccessibilityGrabbedAttribute @"AXGrabbed"
+#endif
+
+#ifndef NSAccessibilityDropEffectsAttribute
+#define NSAccessibilityDropEffectsAttribute @"AXDropEffects"
+#endif
+
@interface NSObject (WebKitAccessibilityArrayCategory)
- (NSArray *)accessibilityArrayAttributeValues:(NSString *)attribute index:(NSUInteger)index maxCount:(NSUInteger)maxCount;
@end
@@ -232,7 +244,43 @@ AccessibilityUIElement AccessibilityUIElement::getChildAtIndex(unsigned index)
if (children.size() == 1)
return children[0];
- return nil;
+ return 0;
+}
+
+AccessibilityUIElement AccessibilityUIElement::ariaOwnsElementAtIndex(unsigned index)
+{
+ NSArray* objects = [m_element accessibilityAttributeValue:NSAccessibilityOwnsAttribute];
+ if (index < [objects count])
+ return [objects objectAtIndex:index];
+
+ return 0;
+}
+
+AccessibilityUIElement AccessibilityUIElement::ariaFlowToElementAtIndex(unsigned index)
+{
+ NSArray* objects = [m_element accessibilityAttributeValue:NSAccessibilityLinkedUIElementsAttribute];
+ if (index < [objects count])
+ return [objects objectAtIndex:index];
+
+ return 0;
+}
+
+AccessibilityUIElement AccessibilityUIElement::disclosedRowAtIndex(unsigned index)
+{
+ NSArray* rows = [m_element accessibilityAttributeValue:NSAccessibilityDisclosedRowsAttribute];
+ if (index < [rows count])
+ return [rows objectAtIndex:index];
+
+ return 0;
+}
+
+AccessibilityUIElement AccessibilityUIElement::selectedRowAtIndex(unsigned index)
+{
+ NSArray* rows = [m_element accessibilityAttributeValue:NSAccessibilitySelectedRowsAttribute];
+ if (index < [rows count])
+ return [rows objectAtIndex:index];
+
+ return 0;
}
AccessibilityUIElement AccessibilityUIElement::titleUIElement()
@@ -241,7 +289,7 @@ AccessibilityUIElement AccessibilityUIElement::titleUIElement()
if (accessibilityObject)
return AccessibilityUIElement(accessibilityObject);
- return nil;
+ return 0;
}
AccessibilityUIElement AccessibilityUIElement::parentElement()
@@ -250,7 +298,16 @@ AccessibilityUIElement AccessibilityUIElement::parentElement()
if (accessibilityObject)
return AccessibilityUIElement(accessibilityObject);
- return nil;
+ return 0;
+}
+
+AccessibilityUIElement AccessibilityUIElement::disclosedByRow()
+{
+ id accessibilityObject = [m_element accessibilityAttributeValue:NSAccessibilityDisclosedByRowAttribute];
+ if (accessibilityObject)
+ return AccessibilityUIElement(accessibilityObject);
+
+ return 0;
}
JSStringRef AccessibilityUIElement::attributesOfLinkedUIElements()
@@ -293,6 +350,11 @@ bool AccessibilityUIElement::isAttributeSettable(JSStringRef attribute)
return [m_element accessibilityIsAttributeSettable:[NSString stringWithJSStringRef:attribute]];
}
+bool AccessibilityUIElement::isAttributeSupported(JSStringRef attribute)
+{
+ return [[m_element accessibilityAttributeNames] containsObject:[NSString stringWithJSStringRef:attribute]];
+}
+
JSStringRef AccessibilityUIElement::parameterizedAttributeNames()
{
NSArray* supportedParameterizedAttributes = [m_element accessibilityParameterizedAttributeNames];
@@ -317,6 +379,12 @@ JSStringRef AccessibilityUIElement::subrole()
return concatenateAttributeAndValue(@"AXSubrole", role);
}
+JSStringRef AccessibilityUIElement::roleDescription()
+{
+ NSString* role = descriptionOfValue([m_element accessibilityAttributeValue:NSAccessibilityRoleDescriptionAttribute], m_element);
+ return concatenateAttributeAndValue(@"AXRoleDescription", role);
+}
+
JSStringRef AccessibilityUIElement::title()
{
NSString* title = descriptionOfValue([m_element accessibilityAttributeValue:NSAccessibilityTitleAttribute], m_element);
@@ -329,6 +397,18 @@ JSStringRef AccessibilityUIElement::description()
return concatenateAttributeAndValue(@"AXDescription", description);
}
+JSStringRef AccessibilityUIElement::orientation() const
+{
+ id description = descriptionOfValue([m_element accessibilityAttributeValue:NSAccessibilityOrientationAttribute], m_element);
+ return concatenateAttributeAndValue(@"AXOrientation", description);
+}
+
+JSStringRef AccessibilityUIElement::stringValue()
+{
+ id description = descriptionOfValue([m_element accessibilityAttributeValue:NSAccessibilityValueAttribute], m_element);
+ return concatenateAttributeAndValue(@"AXValue", description);
+}
+
JSStringRef AccessibilityUIElement::language()
{
id description = descriptionOfValue([m_element accessibilityAttributeValue:@"AXLanguage"], m_element);
@@ -433,6 +513,55 @@ bool AccessibilityUIElement::isRequired() const
return false;
}
+bool AccessibilityUIElement::isSelected() const
+{
+ id value = [m_element accessibilityAttributeValue:NSAccessibilitySelectedAttribute];
+ if ([value isKindOfClass:[NSNumber class]])
+ return [value boolValue];
+ return false;
+}
+
+bool AccessibilityUIElement::isExpanded() const
+{
+ id value = [m_element accessibilityAttributeValue:NSAccessibilityExpandedAttribute];
+ if ([value isKindOfClass:[NSNumber class]])
+ return [value boolValue];
+ return false;
+}
+
+int AccessibilityUIElement::hierarchicalLevel() const
+{
+ id value = [m_element accessibilityAttributeValue:NSAccessibilityDisclosureLevelAttribute];
+ if ([value isKindOfClass:[NSNumber class]])
+ return [value intValue];
+ return 0;
+}
+
+bool AccessibilityUIElement::ariaIsGrabbed() const
+{
+ id value = [m_element accessibilityAttributeValue:NSAccessibilityGrabbedAttribute];
+ if ([value isKindOfClass:[NSNumber class]])
+ return [value boolValue];
+ return false;
+}
+
+JSStringRef AccessibilityUIElement::ariaDropEffects() const
+{
+ id value = [m_element accessibilityAttributeValue:NSAccessibilityDropEffectsAttribute];
+ if (![value isKindOfClass:[NSArray class]])
+ return 0;
+
+ NSMutableString* dropEffects = [NSMutableString string];
+ NSInteger length = [value count];
+ for (NSInteger k = 0; k < length; ++k) {
+ [dropEffects appendString:[value objectAtIndex:k]];
+ if (k < length - 1)
+ [dropEffects appendString:@","];
+ }
+
+ return [dropEffects createJSStringRef];
+}
+
// parameterized attributes
int AccessibilityUIElement::lineForIndex(int index)
{
@@ -571,3 +700,24 @@ void AccessibilityUIElement::decrement()
{
[m_element accessibilityPerformAction:NSAccessibilityDecrementAction];
}
+
+void AccessibilityUIElement::showMenu()
+{
+ [m_element accessibilityPerformAction:NSAccessibilityShowMenuAction];
+}
+
+JSStringRef AccessibilityUIElement::accessibilityValue() const
+{
+ // FIXME: implement
+ return JSStringCreateWithCharacters(0, 0);
+}
+
+JSStringRef AccessibilityUIElement::documentEncoding()
+{
+ return JSStringCreateWithCharacters(0, 0);
+}
+
+JSStringRef AccessibilityUIElement::documentURI()
+{
+ return JSStringCreateWithCharacters(0, 0);
+}
diff --git a/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm b/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm
index 98f4f9c..4ffeac3 100644
--- a/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm
+++ b/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm
@@ -87,6 +87,10 @@ using namespace std;
@interface DumpRenderTreeEvent : NSEvent
@end
+@interface NSURLRequest (PrivateThingsWeShouldntReallyUse)
++(void)setAllowsAnyHTTPSCertificate:(BOOL)allow forHost:(NSString *)host;
+@end
+
static void runTest(const string& testPathOrURL);
// Deciding when it's OK to dump out the state is a bit tricky. All these must be true:
@@ -302,7 +306,7 @@ WebView *createWebViewAndOffscreenWindow()
[window orderBack:nil];
[window setAutodisplay:NO];
- [window startObservingWebView];
+ [window startListeningForAcceleratedCompositingChanges];
// For reasons that are not entirely clear, the following pair of calls makes WebView handle its
// dynamic scrollbars properly. Without it, every frame will always have scrollbars.
@@ -596,9 +600,17 @@ void dumpRenderTree(int argc, const char *argv[])
mainFrame = [webView mainFrame];
[[NSURLCache sharedURLCache] removeAllCachedResponses];
-
[WebCache empty];
-
+
+ // <http://webkit.org/b/31200> In order to prevent extra frame load delegate logging being generated if the first test to use SSL
+ // is set to log frame load delegate calls we ignore SSL certificate errors on localhost and 127.0.0.1.
+#if BUILDING_ON_TIGER
+ // Initialize internal NSURLRequest data for setAllowsAnyHTTPSCertificate:forHost: to work properly.
+ [[[[NSURLRequest alloc] init] autorelease] HTTPMethod];
+#endif
+ [NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:@"localhost"];
+ [NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:@"127.0.0.1"];
+
// <rdar://problem/5222911>
testStringByEvaluatingJavaScriptFromString();
@@ -1090,6 +1102,11 @@ static bool shouldLogHistoryDelegates(const char* pathOrURL)
return strstr(pathOrURL, "globalhistory/");
}
+static bool shouldOpenWebInspector(const char* pathOrURL)
+{
+ return strstr(pathOrURL, "inspector/");
+}
+
static void resetWebViewToConsistentStateBeforeTesting()
{
WebView *webView = [mainFrame webView];
@@ -1105,6 +1122,7 @@ static void resetWebViewToConsistentStateBeforeTesting()
[webView _clearMainFrameName];
[[webView undoManager] removeAllActions];
[WebView _removeAllUserContentFromGroup:[webView groupName]];
+ [[webView window] setAutodisplay:NO];
resetDefaultsToConsistentValues();
@@ -1166,7 +1184,10 @@ static void runTest(const string& testPathOrURL)
[[mainFrame webView] setHistoryDelegate:historyDelegate];
else
[[mainFrame webView] setHistoryDelegate:nil];
-
+
+ if (shouldOpenWebInspector(pathOrURL.c_str()))
+ gLayoutTestController->showWebInspector();
+
if ([WebHistory optionalSharedHistory])
[WebHistory setOptionalSharedHistory:nil];
lastMousePosition = NSZeroPoint;
@@ -1190,6 +1211,7 @@ static void runTest(const string& testPathOrURL)
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantPast]];
[pool release];
}
+
pool = [[NSAutoreleasePool alloc] init];
[EventSendingController clearSavedEvents];
[[mainFrame webView] setSelectedDOMRange:nil affinity:NSSelectionAffinityDownstream];
@@ -1214,11 +1236,14 @@ static void runTest(const string& testPathOrURL)
}
}
+ if (shouldOpenWebInspector(pathOrURL.c_str()))
+ gLayoutTestController->closeWebInspector();
+
resetWebViewToConsistentStateBeforeTesting();
[mainFrame loadHTMLString:@"<html></html>" baseURL:[NSURL URLWithString:@"about:blank"]];
[mainFrame stopLoading];
-
+
[pool release];
// We should only have our main window left open when we're done
diff --git a/WebKitTools/DumpRenderTree/mac/DumpRenderTreeMac.h b/WebKitTools/DumpRenderTree/mac/DumpRenderTreeMac.h
index 72d5db1..fe1ac00 100644
--- a/WebKitTools/DumpRenderTree/mac/DumpRenderTreeMac.h
+++ b/WebKitTools/DumpRenderTree/mac/DumpRenderTreeMac.h
@@ -42,6 +42,7 @@
@class NavigationController;
@class PolicyDelegate;
@class WebFrame;
+@class WebScriptWorld;
@class WebView;
typedef const struct __CFString* CFStringRef;
@@ -62,4 +63,6 @@ extern CFRunLoopTimerRef waitToDumpWatchdog;
WebView* createWebViewAndOffscreenWindow();
void setPersistentUserStyleSheetLocation(CFStringRef);
+unsigned worldIDForWorld(WebScriptWorld *);
+
#endif // DumpRenderTreeMac_h
diff --git a/WebKitTools/DumpRenderTree/mac/DumpRenderTreeWindow.h b/WebKitTools/DumpRenderTree/mac/DumpRenderTreeWindow.h
index b6bdcb8..a229d20 100644
--- a/WebKitTools/DumpRenderTree/mac/DumpRenderTreeWindow.h
+++ b/WebKitTools/DumpRenderTree/mac/DumpRenderTreeWindow.h
@@ -34,7 +34,6 @@
@interface DumpRenderTreeWindow : NSWindow
{
- BOOL observingWebView;
}
// I'm not sure why we can't just use [NSApp windows]
@@ -42,7 +41,6 @@
- (WebView *)webView;
-- (void)startObservingWebView;
-- (void)stopObservingWebView;
+- (void)startListeningForAcceleratedCompositingChanges;
@end
diff --git a/WebKitTools/DumpRenderTree/mac/DumpRenderTreeWindow.mm b/WebKitTools/DumpRenderTree/mac/DumpRenderTreeWindow.mm
index aa5b117..8845ef0 100644
--- a/WebKitTools/DumpRenderTree/mac/DumpRenderTreeWindow.mm
+++ b/WebKitTools/DumpRenderTree/mac/DumpRenderTreeWindow.mm
@@ -67,7 +67,7 @@ static CFArrayCallBacks NonRetainingArrayCallbacks = {
- (void)close
{
- [self stopObservingWebView];
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
CFRange arrayRange = CFRangeMake(0, CFArrayGetCount(openWindowsRef));
CFIndex i = CFArrayGetFirstIndexOfValue(openWindowsRef, arrayRange, self);
@@ -99,32 +99,20 @@ static CFArrayCallBacks NonRetainingArrayCallbacks = {
return nil;
}
-- (void)startObservingWebView
+- (void)startListeningForAcceleratedCompositingChanges
{
- [self stopObservingWebView];
- [[self webView] addObserver:self forKeyPath:@"_isUsingAcceleratedCompositing" options:0 context:0];
- observingWebView = YES;
+ [[self webView] _setPostsAcceleratedCompositingNotifications:YES];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(webViewStartedAcceleratedCompositing:)
+ name:_WebViewDidStartAcceleratedCompositingNotification object:nil];
}
-- (void)stopObservingWebView
+- (void)webViewStartedAcceleratedCompositing:(NSNotification *)notification
{
- if (!observingWebView)
- return;
- [[self webView] removeObserver:self forKeyPath:@"_isUsingAcceleratedCompositing"];
- observingWebView = NO;
-}
-
-- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
-{
- if ([keyPath isEqualToString:@"_isUsingAcceleratedCompositing"]) {
- // When using accelerated compositing, the window needs to be autodisplay for AppKit/CA to
- // start accelerated animations correctly.
- BOOL isAccelerated = [[self webView] _isUsingAcceleratedCompositing];
- [self setAutodisplay:isAccelerated];
- return;
- }
-
- [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
+ // If the WebView has gone into compositing mode, turn on window autodisplay. This is necessary for CA
+ // to update layers and start animations.
+ // We only ever turn autodisplay on here, because we turn it off before every test.
+ if ([[self webView] _isUsingAcceleratedCompositing])
+ [self setAutodisplay:YES];
}
@end
diff --git a/WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.mm b/WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.mm
index 2838d2e..963eae7 100644
--- a/WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.mm
+++ b/WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.mm
@@ -48,13 +48,10 @@
#import <WebKit/WebHTMLViewPrivate.h>
#import <WebKit/WebKit.h>
#import <WebKit/WebNSURLExtras.h>
+#import <WebKit/WebScriptWorld.h>
#import <WebKit/WebSecurityOriginPrivate.h>
#import <wtf/Assertions.h>
-@interface NSURLRequest (PrivateThingsWeShouldntReallyUse)
-+(void)setAllowsAnyHTTPSCertificate:(BOOL)allow forHost:(NSString *)host;
-@end
-
@interface NSURL (DRTExtras)
- (NSString *)_drt_descriptionSuitableForTestResult;
@end
@@ -182,13 +179,15 @@
{
if (!done && gLayoutTestController->dumpFrameLoadCallbacks()) {
NSString *string = [NSString stringWithFormat:@"%@ - didFailProvisionalLoadWithError", [frame _drt_descriptionSuitableForTestResult]];
- printf ("%s\n", [string UTF8String]);
+ printf("%s\n", [string UTF8String]);
}
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]];
+ // <http://webkit.org/b/31200> In order to prevent extra frame load delegate logging being generated if the first test to use SSL
+ // is set to log frame load delegate calls we ignore SSL certificate errors on localhost and 127.0.0.1 from within dumpRenderTree.
+ // Those are the only hosts that we use SSL with at present. If we hit this code path then we've found another host that we need
+ // to apply the workaround to.
+ ASSERT_NOT_REACHED();
return;
}
@@ -238,11 +237,8 @@
ASSERT_NOT_REACHED();
}
-- (void)webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)obj forFrame:(WebFrame *)frame
+- (void)didClearWindowObjectInStandardWorldForFrame:(WebFrame *)frame
{
- ASSERT(obj == [frame windowObject]);
- ASSERT([obj JSObject] == JSContextGetGlobalObject([frame globalContext]));
-
// Make New-Style LayoutTestController
JSContextRef context = [frame globalContext];
JSObjectRef globalObject = JSContextGetGlobalObject(context);
@@ -260,7 +256,9 @@
// Make Old-Style controllers
- AppleScriptController *asc = [[AppleScriptController alloc] initWithWebView:sender];
+ WebView *webView = [frame webView];
+ WebScriptObject *obj = [frame windowObject];
+ AppleScriptController *asc = [[AppleScriptController alloc] initWithWebView:webView];
[obj setValue:asc forKey:@"appleScriptController"];
[asc release];
@@ -284,11 +282,32 @@
[obj setValue:[PlainTextController sharedPlainTextController] forKey:@"plainText"];
- TextInputController *tic = [[TextInputController alloc] initWithWebView:sender];
+ TextInputController *tic = [[TextInputController alloc] initWithWebView:webView];
[obj setValue:tic forKey:@"textInputController"];
[tic release];
}
+- (void)didClearWindowObjectForFrame:(WebFrame *)frame inIsolatedWorld:(WebScriptWorld *)world
+{
+ JSGlobalContextRef ctx = [frame _globalContextForScriptWorld:world];
+ if (!ctx)
+ return;
+
+ JSObjectRef globalObject = JSContextGetGlobalObject(ctx);
+ if (!globalObject)
+ return;
+
+ JSObjectSetProperty(ctx, globalObject, JSRetainPtr<JSStringRef>(Adopt, JSStringCreateWithUTF8CString("__worldID")).get(), JSValueMakeNumber(ctx, worldIDForWorld(world)), kJSPropertyAttributeReadOnly, 0);
+}
+
+- (void)webView:(WebView *)sender didClearWindowObjectForFrame:(WebFrame *)frame inScriptWorld:(WebScriptWorld *)world
+{
+ if (world == [WebScriptWorld standardWorld])
+ [self didClearWindowObjectInStandardWorldForFrame:frame];
+ else
+ [self didClearWindowObjectForFrame:frame inIsolatedWorld:world];
+}
+
- (void)webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame
{
if (!done && gLayoutTestController->dumpFrameLoadCallbacks()) {
diff --git a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
index 4d6a609..69fe19f 100644
--- a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
+++ b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
@@ -43,25 +43,27 @@
#import <WebKit/WebApplicationCache.h>
#import <WebKit/WebBackForwardList.h>
#import <WebKit/WebCoreStatistics.h>
-#import <WebKit/WebDatabaseManagerPrivate.h>
#import <WebKit/WebDataSource.h>
+#import <WebKit/WebDatabaseManagerPrivate.h>
#import <WebKit/WebFrame.h>
#import <WebKit/WebFrameViewPrivate.h>
-#import <WebKit/WebIconDatabasePrivate.h>
+#import <WebKit/WebGeolocationMockPrivate.h>
#import <WebKit/WebHTMLRepresentation.h>
#import <WebKit/WebHTMLViewPrivate.h>
#import <WebKit/WebHistory.h>
#import <WebKit/WebHistoryPrivate.h>
+#import <WebKit/WebIconDatabasePrivate.h>
#import <WebKit/WebInspectorPrivate.h>
-#import <WebKit/WebGeolocationMockPrivate.h>
#import <WebKit/WebNSURLExtras.h>
#import <WebKit/WebPreferences.h>
#import <WebKit/WebPreferencesPrivate.h>
+#import <WebKit/WebScriptWorld.h>
#import <WebKit/WebSecurityOriginPrivate.h>
#import <WebKit/WebTypesInternal.h>
#import <WebKit/WebView.h>
#import <WebKit/WebViewPrivate.h>
#import <WebKit/WebWorkersPrivate.h>
+#import <wtf/HashMap.h>
#import <wtf/RetainPtr.h>
@interface CommandValidationTarget : NSObject <NSValidatedUserInterfaceItem>
@@ -299,6 +301,11 @@ void LayoutTestController::setXSSAuditorEnabled(bool enabled)
[[[mainFrame webView] preferences] setXSSAuditorEnabled:enabled];
}
+void LayoutTestController::setAllowUniversalAccessFromFileURLs(bool enabled)
+{
+ [[[mainFrame webView] preferences] setAllowUniversalAccessFromFileURLs:enabled];
+}
+
void LayoutTestController::setPopupBlockingEnabled(bool popupBlockingEnabled)
{
[[[mainFrame webView] preferences] setJavaScriptCanOpenWindowsAutomatically:!popupBlockingEnabled];
@@ -309,6 +316,11 @@ void LayoutTestController::setTabKeyCyclesThroughElements(bool cycles)
[[mainFrame webView] setTabKeyCyclesThroughElements:cycles];
}
+void LayoutTestController::setTimelineProfilingEnabled(bool enabled)
+{
+ [[[mainFrame webView] inspector] setTimelineProfilingEnabled:enabled];
+}
+
void LayoutTestController::setUseDashboardCompatibilityMode(bool flag)
{
[[mainFrame webView] _setDashboardBehavior:WebDashboardBehaviorUseBackwardCompatibilityMode to:flag];
@@ -474,6 +486,16 @@ bool LayoutTestController::pauseTransitionAtTimeOnElementWithId(JSStringRef prop
return [mainFrame _pauseTransitionOfProperty:nameNS onNode:[[mainFrame DOMDocument] getElementById:idNS] atTime:time];
}
+bool LayoutTestController::sampleSVGAnimationForElementAtTime(JSStringRef animationId, double time, JSStringRef elementId)
+{
+ RetainPtr<CFStringRef> animationIDCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, animationId));
+ NSString *animationIDNS = (NSString *)animationIDCF.get();
+ RetainPtr<CFStringRef> elementIDCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, elementId));
+ NSString *elementIDNS = (NSString *)elementIDCF.get();
+
+ return [mainFrame _pauseSVGAnimation:elementIDNS onSMILNode:[[mainFrame DOMDocument] getElementById:animationIDNS] atTime:time];
+}
+
unsigned LayoutTestController::numberOfActiveAnimations() const
{
return [mainFrame _numberOfActiveAnimations];
@@ -501,14 +523,14 @@ void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart)
{
RetainPtr<CFStringRef> sourceCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, source));
NSString *sourceNS = (NSString *)sourceCF.get();
- [WebView _addUserScriptToGroup:@"org.webkit.DumpRenderTree" worldID:1 source:sourceNS url:nil whitelist:nil blacklist:nil injectionTime:(runAtStart ? WebInjectAtDocumentStart : WebInjectAtDocumentEnd)];
+ [WebView _addUserScriptToGroup:@"org.webkit.DumpRenderTree" world:[WebScriptWorld world] source:sourceNS url:nil whitelist:nil blacklist:nil injectionTime:(runAtStart ? WebInjectAtDocumentStart : WebInjectAtDocumentEnd)];
}
void LayoutTestController::addUserStyleSheet(JSStringRef source)
{
RetainPtr<CFStringRef> sourceCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, source));
NSString *sourceNS = (NSString *)sourceCF.get();
- [WebView _addUserStyleSheetToGroup:@"org.webkit.DumpRenderTree" worldID:1 source:sourceNS url:nil whitelist:nil blacklist:nil];
+ [WebView _addUserStyleSheetToGroup:@"org.webkit.DumpRenderTree" world:[WebScriptWorld world] source:sourceNS url:nil whitelist:nil blacklist:nil];
}
void LayoutTestController::showWebInspector()
@@ -530,9 +552,40 @@ void LayoutTestController::evaluateInWebInspector(long callId, JSStringRef scrip
[[[mainFrame webView] inspector] evaluateInFrontend:nil callId:callId script:scriptNS];
}
+typedef HashMap<unsigned, RetainPtr<WebScriptWorld> > WorldMap;
+static WorldMap& worldMap()
+{
+ static WorldMap& map = *new WorldMap;
+ return map;
+}
+
+unsigned worldIDForWorld(WebScriptWorld *world)
+{
+ WorldMap::const_iterator end = worldMap().end();
+ for (WorldMap::const_iterator it = worldMap().begin(); it != end; ++it) {
+ if (it->second == world)
+ return it->first;
+ }
+
+ return 0;
+}
+
void LayoutTestController::evaluateScriptInIsolatedWorld(unsigned worldID, JSObjectRef globalObject, JSStringRef script)
{
RetainPtr<CFStringRef> scriptCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, script));
NSString *scriptNS = (NSString *)scriptCF.get();
- [mainFrame _stringByEvaluatingJavaScriptInIsolatedWorld:worldID WithGlobalObject:globalObject FromString:scriptNS];
+
+ // A worldID of 0 always corresponds to a new world. Any other worldID corresponds to a world
+ // that is created once and cached forever.
+ WebScriptWorld *world;
+ if (!worldID)
+ world = [WebScriptWorld world];
+ else {
+ RetainPtr<WebScriptWorld>& worldSlot = worldMap().add(worldID, 0).first->second;
+ if (!worldSlot)
+ worldSlot.adoptNS([[WebScriptWorld alloc] init]);
+ world = worldSlot.get();
+ }
+
+ [mainFrame _stringByEvaluatingJavaScriptFromString:scriptNS withGlobalObject:globalObject inScriptWorld:world];
}
diff --git a/WebKitTools/DumpRenderTree/mac/UIDelegate.mm b/WebKitTools/DumpRenderTree/mac/UIDelegate.mm
index 393899e..81c03d2 100644
--- a/WebKitTools/DumpRenderTree/mac/UIDelegate.mm
+++ b/WebKitTools/DumpRenderTree/mac/UIDelegate.mm
@@ -34,9 +34,9 @@
#import "EventSendingController.h"
#import "LayoutTestController.h"
#import <WebKit/WebFramePrivate.h>
-#import <WebKit/WebGeolocationPrivate.h>
#import <WebKit/WebHTMLViewPrivate.h>
#import <WebKit/WebSecurityOriginPrivate.h>
+#import <WebKit/WebUIDelegatePrivate.h>
#import <WebKit/WebView.h>
#import <wtf/Assertions.h>
@@ -151,10 +151,14 @@ DumpRenderTreeDraggingInfo *draggingInfo = nil;
printf("UI DELEGATE STATUS CALLBACK: setStatusText:%s\n", [text UTF8String]);
}
-- (void)webView:(WebView *)sender frame:(WebFrame *)frame requestGeolocationPermission:(WebGeolocation *)geolocation securityOrigin:(WebSecurityOrigin *)origin
+- (void)webView:(WebView *)webView decidePolicyForGeolocationRequestFromOrigin:(WebSecurityOrigin *)origin frame:(WebFrame *)frame listener:(id<WebGeolocationPolicyListener>)listener
{
- if (gLayoutTestController->isGeolocationPermissionSet())
- [geolocation setIsAllowed:gLayoutTestController->geolocationPermission()];
+ if (gLayoutTestController->isGeolocationPermissionSet()) {
+ if (gLayoutTestController->geolocationPermission())
+ [listener allow];
+ else
+ [listener deny];
+ }
}
- (BOOL)webView:(WebView *)sender shouldHaltPlugin:(DOMNode *)pluginNode