OSDN Git Service

Merge WebKit at r84325: Initial merge by git.
[android-x86/external-webkit.git] / Tools / DumpRenderTree / mac / DumpRenderTree.mm
index ed09cf6..441f6bb 100644 (file)
@@ -48,6 +48,7 @@
 #import "PixelDumpSupport.h"
 #import "PolicyDelegate.h"
 #import "ResourceLoadDelegate.h"
+#import "StorageTrackerDelegate.h"
 #import "UIDelegate.h"
 #import "WebArchiveDumpSupport.h"
 #import "WorkQueue.h"
@@ -77,6 +78,7 @@
 #import <WebKit/WebPreferencesPrivate.h>
 #import <WebKit/WebPreferenceKeysPrivate.h>
 #import <WebKit/WebResourceLoadDelegate.h>
+#import <WebKit/WebStorageManagerPrivate.h>
 #import <WebKit/WebTypesInternal.h>
 #import <WebKit/WebViewPrivate.h>
 #import <getopt.h>
@@ -134,6 +136,7 @@ static EditingDelegate *editingDelegate;
 static ResourceLoadDelegate *resourceLoadDelegate;
 static HistoryDelegate *historyDelegate;
 PolicyDelegate *policyDelegate;
+StorageTrackerDelegate *storageDelegate;
 
 static int dumpPixels;
 static int threaded;
@@ -303,6 +306,9 @@ WebView *createWebViewAndOffscreenWindow()
     [WebView registerURLSchemeAsLocal:@"feedsearch"];
     
     [webView setContinuousSpellCheckingEnabled:YES];
+    [webView setGrammarCheckingEnabled:YES];
+    [webView setInteractiveFormValidationEnabled:YES];
+    [webView setValidationMessageTimerMagnification:-1];
     
     // To make things like certain NSViews, dragging, and plug-ins work, put the WebView a window, but put it off-screen so you don't see it.
     // Put it at -10000, -10000 in "flipped coordinates", since WebCore and the DOM use flipped coordinates.
@@ -407,12 +413,14 @@ static void resetDefaultsToConsistentValues()
 
     [defaults setBool:NO forKey:@"AppleScrollAnimationEnabled"];
     [defaults setBool:NO forKey:@"NSOverlayScrollersEnabled"];
+    [defaults setObject:@"Always" forKey:@"AppleShowScrollBars"];
 
     if (initialValue)
         CFPreferencesSetValue(CFSTR("AppleScrollBarVariant"), initialValue.get(), kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
 
     NSString *path = libraryPathForDumpRenderTree();
     [defaults setObject:[path stringByAppendingPathComponent:@"Databases"] forKey:WebDatabaseDirectoryDefaultsKey];
+    [defaults setObject:[path stringByAppendingPathComponent:@"LocalStorage"] forKey:WebStorageDirectoryDefaultsKey];
     [defaults setObject:[path stringByAppendingPathComponent:@"LocalCache"] forKey:WebKitLocalCacheDefaultsKey];
 
     WebPreferences *preferences = [WebPreferences standardPreferences];
@@ -447,7 +455,9 @@ static void resetDefaultsToConsistentValues()
     [preferences setOfflineWebApplicationCacheEnabled:YES];
     [preferences setDeveloperExtrasEnabled:NO];
     [preferences setLoadsImagesAutomatically:YES];
+    [preferences setLoadsSiteIconsIgnoringImageLoadingPreference:NO];
     [preferences setFrameFlatteningEnabled:NO];
+    [preferences setSpatialNavigationEnabled:NO];
     [preferences setEditingBehavior:WebKitEditingMacBehavior];
     if (persistentUserStyleSheetLocation) {
         [preferences setUserStyleSheetLocation:[NSURL URLWithString:(NSString *)(persistentUserStyleSheetLocation.get())]];
@@ -459,6 +469,10 @@ static void resetDefaultsToConsistentValues()
     // So, turn it off for now, but we might want to turn it back on some day.
     [preferences setUsesPageCache:NO];
     [preferences setAcceleratedCompositingEnabled:YES];
+#if USE(CA) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+    [preferences setCanvasUsesAcceleratedDrawing:YES];
+    [preferences setAcceleratedDrawingEnabled:NO];
+#endif
     [preferences setWebGLEnabled:NO];
     [preferences setUsePreHTML5ParserQuirks:NO];
     [preferences setAsynchronousSpellCheckingEnabled:NO];
@@ -543,6 +557,7 @@ static void allocateGlobalControllers()
     resourceLoadDelegate = [[ResourceLoadDelegate alloc] init];
     policyDelegate = [[PolicyDelegate alloc] init];
     historyDelegate = [[HistoryDelegate alloc] init];
+    storageDelegate = [[StorageTrackerDelegate alloc] init];
 }
 
 // ObjC++ doens't seem to let me pass NSObject*& sadly.
@@ -560,6 +575,7 @@ static void releaseGlobalControllers()
     releaseAndZero(&resourceLoadDelegate);
     releaseAndZero(&uiDelegate);
     releaseAndZero(&policyDelegate);
+    releaseAndZero(&storageDelegate);
 }
 
 static void initializeGlobalsFromCommandLineOptions(int argc, const char *argv[])
@@ -719,6 +735,14 @@ static NSInteger compareHistoryItems(id item1, id item2, void *context)
     return [[item1 target] caseInsensitiveCompare:[item2 target]];
 }
 
+static NSData *dumpAudio()
+{
+    const char *encodedAudioData = gLayoutTestController->encodedAudioData().c_str();
+    
+    NSData *data = [NSData dataWithBytes:encodedAudioData length:gLayoutTestController->encodedAudioData().length()];
+    return data;
+}
+
 static void dumpHistoryItem(WebHistoryItem *item, int indent, BOOL current)
 {
     int start = 0;
@@ -753,7 +777,10 @@ static void dumpHistoryItem(WebHistoryItem *item, int indent, BOOL current)
 
 static void dumpFrameScrollPosition(WebFrame *f)
 {
-    NSPoint scrollPosition = [[[[f frameView] documentView] superview] bounds].origin;
+    WebScriptObject* scriptObject = [f windowObject];
+    NSPoint scrollPosition = NSMakePoint(
+        [[scriptObject valueForKey:@"pageXOffset"] floatValue],
+        [[scriptObject valueForKey:@"pageYOffset"] floatValue]);
     if (ABS(scrollPosition.x) > 0.00000001 || ABS(scrollPosition.y) > 0.00000001) {
         if ([f parentFrame] != nil)
             printf("frame '%s' ", [[f name] UTF8String]);
@@ -919,7 +946,10 @@ void dump()
             gLayoutTestController->setDumpAsText(true);
             gLayoutTestController->setGeneratePixelResults(false);
         }
-        if (gLayoutTestController->dumpAsText()) {
+        if (gLayoutTestController->dumpAsAudio()) {
+            resultData = dumpAudio();
+            resultMimeType = @"audio/wav";
+        } else if (gLayoutTestController->dumpAsText()) {
             resultString = dumpFramesAsText(mainFrame);
         } else if (gLayoutTestController->dumpAsPDF()) {
             resultData = dumpFrameAsPDF(mainFrame);
@@ -942,6 +972,9 @@ void dump()
 
         printf("Content-Type: %s\n", [resultMimeType UTF8String]);
 
+        if (gLayoutTestController->dumpAsAudio())
+            printf("Content-Transfer-Encoding: base64\n");            
+        
         if (resultData) {
             fwrite([resultData bytes], 1, [resultData length], stdout);
 
@@ -991,6 +1024,11 @@ static bool shouldOpenWebInspector(const char* pathOrURL)
     return strstr(pathOrURL, "inspector/");
 }
 
+static bool shouldDumpAsText(const char* pathOrURL)
+{
+    return strstr(pathOrURL, "dumpAsText/");
+}
+
 static bool shouldEnableDeveloperExtras(const char* pathOrURL)
 {
     return true;
@@ -1003,6 +1041,7 @@ static void resetWebViewToConsistentStateBeforeTesting()
     [(EditingDelegate *)[webView editingDelegate] setAcceptsEditing:YES];
     [webView makeTextStandardSize:nil];
     [webView resetPageZoom:nil];
+    [webView _scaleWebView:1.0 atOrigin:NSZeroPoint];
     [webView setTabKeyCyclesThroughElements:YES];
     [webView setPolicyDelegate:nil];
     [policyDelegate setPermissive:NO];
@@ -1013,6 +1052,7 @@ static void resetWebViewToConsistentStateBeforeTesting()
     [[webView undoManager] removeAllActions];
     [WebView _removeAllUserContentFromGroup:[webView groupName]];
     [[webView window] setAutodisplay:NO];
+    [webView _setMinimumTimerInterval:[WebView _defaultMinimumTimerInterval]];
 
     resetDefaultsToConsistentValues();
 
@@ -1026,6 +1066,8 @@ static void resetWebViewToConsistentStateBeforeTesting()
     
     // Clear the contents of the general pasteboard
     [[NSPasteboard generalPasteboard] declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
+
+    [mainFrame _clearOpener];
 }
 
 static void runTest(const string& testPathOrURL)
@@ -1084,6 +1126,10 @@ static void runTest(const string& testPathOrURL)
         gLayoutTestController->setDeveloperExtrasEnabled(true);
         if (shouldOpenWebInspector(pathOrURL.c_str()))
             gLayoutTestController->showWebInspector();
+        if (shouldDumpAsText(pathOrURL.c_str())) {
+            gLayoutTestController->setDumpAsText(true);
+            gLayoutTestController->setGeneratePixelResults(false);
+        }
     }
 
     if ([WebHistory optionalSharedHistory])