OSDN Git Service

Merge WebKit at r84325: Initial merge by git.
[android-x86/external-webkit.git] / Tools / DumpRenderTree / mac / DumpRenderTree.mm
index dca0d38..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.
@@ -414,6 +420,7 @@ static void resetDefaultsToConsistentValues()
 
     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];
@@ -448,6 +455,7 @@ static void resetDefaultsToConsistentValues()
     [preferences setOfflineWebApplicationCacheEnabled:YES];
     [preferences setDeveloperExtrasEnabled:NO];
     [preferences setLoadsImagesAutomatically:YES];
+    [preferences setLoadsSiteIconsIgnoringImageLoadingPreference:NO];
     [preferences setFrameFlatteningEnabled:NO];
     [preferences setSpatialNavigationEnabled:NO];
     [preferences setEditingBehavior:WebKitEditingMacBehavior];
@@ -461,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];
@@ -545,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.
@@ -562,6 +575,7 @@ static void releaseGlobalControllers()
     releaseAndZero(&resourceLoadDelegate);
     releaseAndZero(&uiDelegate);
     releaseAndZero(&policyDelegate);
+    releaseAndZero(&storageDelegate);
 }
 
 static void initializeGlobalsFromCommandLineOptions(int argc, const char *argv[])
@@ -721,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;
@@ -924,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);
@@ -947,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);
 
@@ -1013,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];