diff options
author | Steve Block <steveblock@google.com> | 2010-05-26 10:11:43 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-05-27 11:14:42 +0100 |
commit | e78cbe89e6f337f2f1fe40315be88f742b547151 (patch) | |
tree | d778000b84a04f24bbad50c7fa66244365e960e9 /WebKitTools/DumpRenderTree | |
parent | 7b582e96e4e909ed7dba1e07153d20fbddaec3f7 (diff) | |
download | external_webkit-e78cbe89e6f337f2f1fe40315be88f742b547151.zip external_webkit-e78cbe89e6f337f2f1fe40315be88f742b547151.tar.gz external_webkit-e78cbe89e6f337f2f1fe40315be88f742b547151.tar.bz2 |
Merge WebKit at r60074: Initial merge by git
Change-Id: I18a2dc5439e36c928351ea829d8fb4e39b062fc7
Diffstat (limited to 'WebKitTools/DumpRenderTree')
24 files changed, 235 insertions, 35 deletions
diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/LayoutTestController.cpp index f564afa..b96a9c9 100644 --- a/WebKitTools/DumpRenderTree/LayoutTestController.cpp +++ b/WebKitTools/DumpRenderTree/LayoutTestController.cpp @@ -31,6 +31,7 @@ #include "WorkQueue.h" #include "WorkQueueItem.h" +#include <cstring> #include <JavaScriptCore/JSContextRef.h> #include <JavaScriptCore/JSObjectRef.h> #include <JavaScriptCore/JSRetainPtr.h> @@ -1453,6 +1454,33 @@ static JSValueRef authenticateSessionCallback(JSContextRef context, JSObjectRef, return JSValueMakeUndefined(context); } +static JSValueRef setEditingBehaviorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + // The editing behavior string. + if (argumentCount < 1) + return JSValueMakeUndefined(context); + + JSRetainPtr<JSStringRef> editingBehavior(Adopt, JSValueToStringCopy(context, arguments[0], exception)); + ASSERT(!*exception); + + size_t maxLength = JSStringGetMaximumUTF8CStringSize(editingBehavior.get()); + char* behaviorBuffer = new char[maxLength + 1]; + JSStringGetUTF8CString(editingBehavior.get(), behaviorBuffer, maxLength); + + if (strcmp(behaviorBuffer, "mac") && strcmp(behaviorBuffer, "win")) { + JSRetainPtr<JSStringRef> invalidArgument(JSStringCreateWithUTF8CString("Passed invalid editing behavior. Must be 'mac' or 'win'.")); + *exception = JSValueMakeString(context, invalidArgument.get()); + return JSValueMakeUndefined(context); + } + + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + controller->setEditingBehavior(behaviorBuffer); + + delete [] behaviorBuffer; + + return JSValueMakeUndefined(context); +} + // Static Values static JSValueRef getGlobalFlagCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) @@ -1602,6 +1630,7 @@ JSStaticFunction* LayoutTestController::staticFunctions() { "setCustomPolicyDelegate", setCustomPolicyDelegateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setDatabaseQuota", setDatabaseQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setDomainRelaxationForbiddenForURLScheme", setDomainRelaxationForbiddenForURLSchemeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "setEditingBehavior", setEditingBehaviorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setFrameFlatteningEnabled", setFrameFlatteningEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setGeolocationPermission", setGeolocationPermissionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setHandlesAuthenticationChallenges", setHandlesAuthenticationChallengesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.h b/WebKitTools/DumpRenderTree/LayoutTestController.h index c6da2ff..8ff38d1 100644 --- a/WebKitTools/DumpRenderTree/LayoutTestController.h +++ b/WebKitTools/DumpRenderTree/LayoutTestController.h @@ -99,6 +99,7 @@ public: void setFrameFlatteningEnabled(bool enable); void setSpatialNavigationEnabled(bool enable); void setScrollbarPolicy(JSStringRef orientation, JSStringRef policy); + void setEditingBehavior(const char* editingBehavior); void waitForPolicyDelegate(); size_t webHistoryItemCount(); diff --git a/WebKitTools/DumpRenderTree/chromium/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/chromium/DumpRenderTree.cpp index a964518..8f292ed 100644 --- a/WebKitTools/DumpRenderTree/chromium/DumpRenderTree.cpp +++ b/WebKitTools/DumpRenderTree/chromium/DumpRenderTree.cpp @@ -36,6 +36,8 @@ using namespace std; +void platformInit(); + static const char optionComplexText[] = "--complex-text"; static const char optionDumpAllPixels[] = "--dump-all-pixels"; static const char optionNotree[] = "--notree"; @@ -59,6 +61,7 @@ static void runTest(TestShell& shell, TestParams& params, const string& testName int main(int argc, char* argv[]) { webkit_support::SetUpTestEnvironment(); + platformInit(); TestParams params; Vector<string> tests; diff --git a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp index 4413ff2..b4e3764 100644 --- a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp +++ b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp @@ -39,6 +39,7 @@ #include "public/WebConsoleMessage.h" #include "public/WebDocument.h" #include "public/WebFrame.h" +#include "public/WebGeolocationServiceMock.h" #include "public/WebInputElement.h" #include "public/WebKit.h" #include "public/WebNotificationPresenter.h" @@ -159,6 +160,11 @@ LayoutTestController::LayoutTestController(TestShell* shell) bindMethod("setTimelineProfilingEnabled", &LayoutTestController::setTimelineProfilingEnabled); bindMethod("evaluateInWebInspector", &LayoutTestController::evaluateInWebInspector); bindMethod("forceRedSelectionColors", &LayoutTestController::forceRedSelectionColors); + bindMethod("setEditingBehavior", &LayoutTestController::setEditingBehavior); + + bindMethod("setGeolocationPermission", &LayoutTestController::setGeolocationPermission); + bindMethod("setMockGeolocationPosition", &LayoutTestController::setMockGeolocationPosition); + bindMethod("setMockGeolocationError", &LayoutTestController::setMockGeolocationError); // The fallback method is called when an unknown method is invoked. bindFallbackMethod(&LayoutTestController::fallbackMethod); @@ -477,6 +483,7 @@ void LayoutTestController::reset() m_stopProvisionalFrameLoads = false; m_globalFlag.set(false); m_webHistoryItemCount.set(0); + m_userStyleSheetLocation = WebURL(); webkit_support::SetAcceptAllCookies(false); WebSecurityPolicy::resetOriginAccessWhitelists(); @@ -852,7 +859,7 @@ void LayoutTestController::grantDesktopNotificationPermission(const CppArgumentL result->set(false); return; } - m_shell->notificationPresenter()->grantPermission(WebString::fromUTF8(arguments[0].toString())); + m_shell->notificationPresenter()->grantPermission(cppVariantToWebString(arguments[0])); result->set(true); } @@ -955,7 +962,7 @@ void LayoutTestController::setXSSAuditorEnabled(const CppArgumentList& arguments void LayoutTestController::evaluateScriptInIsolatedWorld(const CppArgumentList& arguments, CppVariant* result) { if (arguments.size() >= 2 && arguments[0].isNumber() && arguments[1].isString()) { - WebScriptSource source(WebString::fromUTF8(arguments[1].toString())); + WebScriptSource source(cppVariantToWebString(arguments[1])); // This relies on the iframe focusing itself when it loads. This is a bit // sketchy, but it seems to be what other tests do. m_shell->webView()->focusedFrame()->executeScriptInIsolatedWorld(arguments[0].toInt32(), &source, 1, 1); @@ -1110,8 +1117,8 @@ void LayoutTestController::addOriginAccessWhitelistEntry(const CppArgumentList& WebSecurityPolicy::addOriginAccessWhitelistEntry( url, - WebString::fromUTF8(arguments[1].toString()), - WebString::fromUTF8(arguments[2].toString()), + cppVariantToWebString(arguments[1]), + cppVariantToWebString(arguments[2]), arguments[3].toBoolean()); } @@ -1129,8 +1136,8 @@ void LayoutTestController::removeOriginAccessWhitelistEntry(const CppArgumentLis WebSecurityPolicy::removeOriginAccessWhitelistEntry( url, - WebString::fromUTF8(arguments[1].toString()), - WebString::fromUTF8(arguments[2].toString()), + cppVariantToWebString(arguments[1]), + cppVariantToWebString(arguments[2]), arguments[3].toBoolean()); } @@ -1261,7 +1268,7 @@ void LayoutTestController::addUserScript(const CppArgumentList& arguments, CppVa result->setNull(); if (arguments.size() < 2 || !arguments[0].isString() || !arguments[1].isBool()) return; - m_shell->webView()->addUserScript(WebString::fromUTF8(arguments[0].toString()), arguments[1].toBoolean()); + m_shell->webView()->addUserScript(cppVariantToWebString(arguments[0]), arguments[1].toBoolean()); } void LayoutTestController::addUserStyleSheet(const CppArgumentList& arguments, CppVariant* result) @@ -1269,5 +1276,41 @@ void LayoutTestController::addUserStyleSheet(const CppArgumentList& arguments, C result->setNull(); if (arguments.size() < 1 || !arguments[0].isString()) return; - m_shell->webView()->addUserStyleSheet(WebString::fromUTF8(arguments[0].toString())); + m_shell->webView()->addUserStyleSheet(cppVariantToWebString(arguments[0])); +} + +void LayoutTestController::setEditingBehavior(const CppArgumentList& arguments, CppVariant* results) +{ + WebSettings* settings = m_shell->webView()->settings(); + string key = arguments[0].toString(); + if (key == "mac") + settings->setEditingBehavior(WebSettings::EditingBehaviorMac); + else if (key == "win") + settings->setEditingBehavior(WebSettings::EditingBehaviorWin); + else + logErrorToConsole("Passed invalid editing behavior. Should be 'mac' or 'win'."); +} + +void LayoutTestController::setGeolocationPermission(const CppArgumentList& arguments, CppVariant* result) +{ + result->setNull(); + if (arguments.size() < 1 || !arguments[0].isBool()) + return; + WebGeolocationServiceMock::setMockGeolocationPermission(arguments[0].toBoolean()); +} + +void LayoutTestController::setMockGeolocationPosition(const CppArgumentList& arguments, CppVariant* result) +{ + result->setNull(); + if (arguments.size() < 3 || !arguments[0].isNumber() || !arguments[1].isNumber() || !arguments[2].isNumber()) + return; + WebGeolocationServiceMock::setMockGeolocationPosition(arguments[0].toDouble(), arguments[1].toDouble(), arguments[2].toDouble()); +} + +void LayoutTestController::setMockGeolocationError(const CppArgumentList& arguments, CppVariant* result) +{ + result->setNull(); + if (arguments.size() < 2 || !arguments[0].isInt32() || !arguments[1].isString()) + return; + WebGeolocationServiceMock::setMockGeolocationError(arguments[0].toInt32(), cppVariantToWebString(arguments[1])); } diff --git a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h index e7a48e2..0e66087 100644 --- a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h +++ b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h @@ -209,6 +209,8 @@ public: // Grants permission for desktop notifications to an origin void grantDesktopNotificationPermission(const CppArgumentList&, CppVariant*); + void setEditingBehavior(const CppArgumentList&, CppVariant*); + // The following are only stubs. TODO(pamg): Implement any of these that // are needed to pass the layout tests. void dumpAsWebArchive(const CppArgumentList&, CppVariant*); @@ -279,6 +281,11 @@ public: void addUserScript(const CppArgumentList&, CppVariant*); void addUserStyleSheet(const CppArgumentList&, CppVariant*); + // Geolocation related functions. + void setGeolocationPermission(const CppArgumentList&, CppVariant*); + void setMockGeolocationPosition(const CppArgumentList&, CppVariant*); + void setMockGeolocationError(const CppArgumentList&, CppVariant*); + public: // The following methods are not exposed to JavaScript. void setWorkQueueFrozen(bool frozen) { m_workQueue.setFrozen(frozen); } @@ -331,7 +338,7 @@ private: // queueScript. class WorkQueue { public: - WorkQueue(LayoutTestController* controller) : m_controller(controller) {} + WorkQueue(LayoutTestController* controller) : m_frozen(false), m_controller(controller) {} virtual ~WorkQueue(); void processWorkSoon(); @@ -441,10 +448,6 @@ private: // If true, don't dump output until notifyDone is called. bool m_waitUntilDone; - // To prevent infinite loops, only the first page of a test can add to a - // work queue (since we may well come back to that same page). - bool m_workQueueFrozen; - WorkQueue m_workQueue; CppVariant m_globalFlag; diff --git a/WebKitTools/DumpRenderTree/chromium/NotificationPresenter.cpp b/WebKitTools/DumpRenderTree/chromium/NotificationPresenter.cpp index 86903be..501b513 100644 --- a/WebKitTools/DumpRenderTree/chromium/NotificationPresenter.cpp +++ b/WebKitTools/DumpRenderTree/chromium/NotificationPresenter.cpp @@ -52,23 +52,11 @@ void NotificationPresenter::grantPermission(const WebString& origin) // The output from all these methods matches what DumpRenderTree produces. bool NotificationPresenter::show(const WebNotification& notification) { - if (!notification.replaceId().isEmpty()) { - String replaceId(notification.replaceId().data(), notification.replaceId().length()); - if (m_replacements.find(replaceId) != m_replacements.end()) - printf("REPLACING NOTIFICATION %s\n", - m_replacements.find(replaceId)->second.utf8().data()); - - WebString identifier = notification.isHTML() ? - notification.url().spec().utf16() : notification.title(); - m_replacements.set(replaceId, String(identifier.data(), identifier.length())); - } - if (notification.isHTML()) { printf("DESKTOP NOTIFICATION: contents at %s\n", notification.url().spec().data()); } else { - printf("DESKTOP NOTIFICATION:%s icon %s, title %s, text %s\n", - notification.dir() == "rtl" ? "(RTL)" : "", + printf("DESKTOP NOTIFICATION: icon %s, title %s, text %s\n", notification.iconURL().isEmpty() ? "" : notification.iconURL().spec().data(), notification.title().isEmpty() ? "" : diff --git a/WebKitTools/DumpRenderTree/chromium/TestShell.cpp b/WebKitTools/DumpRenderTree/chromium/TestShell.cpp index 24a895a..29bd596 100644 --- a/WebKitTools/DumpRenderTree/chromium/TestShell.cpp +++ b/WebKitTools/DumpRenderTree/chromium/TestShell.cpp @@ -80,6 +80,7 @@ TestShell::TestShell() , m_testIsPreparing(false) , m_focusedWidget(0) { + WebRuntimeFeatures::enableGeolocation(true); m_accessibilityController.set(new AccessibilityController(this)); m_layoutTestController.set(new LayoutTestController(this)); m_eventSender.set(new EventSender(this)); @@ -211,6 +212,7 @@ void TestShell::resizeWindowForTest(WebViewHost* window, const WebURL& url) void TestShell::resetTestController() { + resetWebSettings(*webView()); m_accessibilityController->reset(); m_layoutTestController->reset(); m_eventSender->reset(); @@ -565,7 +567,11 @@ void TestShell::bindJSObjectsToWindow(WebFrame* frame) int TestShell::layoutTestTimeout() { - return 10 * 1000; + // 30 second is the same as the value in Mac DRT. + // If we use a value smaller than the timeout value of + // (new-)run-webkit-tests, (new-)run-webkit-tests misunderstands that a + // timed-out DRT process was crashed. + return 30 * 1000; } WebViewHost* TestShell::createWebView() diff --git a/WebKitTools/DumpRenderTree/chromium/TestShell.h b/WebKitTools/DumpRenderTree/chromium/TestShell.h index 283cbd4..6dd0198 100644 --- a/WebKitTools/DumpRenderTree/chromium/TestShell.h +++ b/WebKitTools/DumpRenderTree/chromium/TestShell.h @@ -153,3 +153,5 @@ private: HANDLE m_finishedEvent; #endif }; + +void platformInit(); diff --git a/WebKitTools/DumpRenderTree/chromium/TestShellGtk.cpp b/WebKitTools/DumpRenderTree/chromium/TestShellGtk.cpp index d71881a..e31ca0a 100644 --- a/WebKitTools/DumpRenderTree/chromium/TestShellGtk.cpp +++ b/WebKitTools/DumpRenderTree/chromium/TestShellGtk.cpp @@ -62,3 +62,7 @@ void TestShell::waitTestFinished() alarm(0); signal(SIGALRM, SIG_DFL); } + +void platformInit() +{ +} diff --git a/WebKitTools/DumpRenderTree/chromium/TestShellMac.mm b/WebKitTools/DumpRenderTree/chromium/TestShellMac.mm index ec8dbac..218b6d0 100644 --- a/WebKitTools/DumpRenderTree/chromium/TestShellMac.mm +++ b/WebKitTools/DumpRenderTree/chromium/TestShellMac.mm @@ -123,3 +123,7 @@ void TestShell::waitTestFinished() [thread cancel]; [thread release]; } + +void platformInit() +{ +} diff --git a/WebKitTools/DumpRenderTree/chromium/TestShellWin.cpp b/WebKitTools/DumpRenderTree/chromium/TestShellWin.cpp index 2d806a2..e0e0af1 100644 --- a/WebKitTools/DumpRenderTree/chromium/TestShellWin.cpp +++ b/WebKitTools/DumpRenderTree/chromium/TestShellWin.cpp @@ -32,7 +32,11 @@ #include "TestShell.h" #include "webkit/support/webkit_support.h" +#include <fcntl.h> +#include <io.h> #include <process.h> +#include <shlwapi.h> +#include <sys/stat.h> // Default timeout in ms for file page loads when in layout test mode. const int kDefaultFileTestTimeoutMillisecs = 10 * 1000; @@ -98,3 +102,47 @@ void TestShell::waitTestFinished() // Wait to join the watchdog thread. (up to 1s, then quit) WaitForSingleObject(threadHandle, 1000); } + +void platformInit() +{ + // Set stdout/stderr binary mode. + _setmode(_fileno(stdout), _O_BINARY); + _setmode(_fileno(stderr), _O_BINARY); + + // Load Ahem font. + // AHEM____.TTF is copied to the directory of DumpRenderTree.exe by WebKit.gyp. + WCHAR path[_MAX_PATH]; + if (!::GetModuleFileName(0, path, _MAX_PATH)) { + fprintf(stderr, "Can't get the module path.\n"); + exit(1); + } + ::PathRemoveFileSpec(path); + wcscat_s(path, _MAX_PATH, L"/AHEM____.TTF"); + struct _stat ahemStat; + if (_wstat(path, &ahemStat) == -1) { + fprintf(stderr, "Can't access: '%S'\n", path); + exit(1); + } + + FILE* fp = _wfopen(path, L"rb"); + if (!fp) { + _wperror(path); + exit(1); + } + size_t size = ahemStat.st_size; + char* fontBuffer = new char[size]; + if (fread(fontBuffer, 1, size, fp) != size) { + fprintf(stderr, "Can't read the font: '%S'\n", path); + fclose(fp); + exit(1); + } + fclose(fp); + DWORD numFonts = 1; + HANDLE fontHandle = ::AddFontMemResourceEx(fontBuffer, size, 0, &numFonts); + delete[] fontBuffer; // OS owns a copy of the buffer. + if (!fontHandle) { + fprintf(stderr, "Failed to register Ahem font: '%S'\n", path); + exit(1); + } + // We don't need to release the font explicitly. +} diff --git a/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp b/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp index 4761b1a..eb44c2a 100644 --- a/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp +++ b/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp @@ -42,6 +42,7 @@ #include "public/WebDataSource.h" #include "public/WebDragData.h" #include "public/WebFrame.h" +#include "public/WebGeolocationServiceMock.h" #include "public/WebHistoryItem.h" #include "public/WebNode.h" #include "public/WebRange.h" @@ -527,6 +528,13 @@ WebNotificationPresenter* WebViewHost::notificationPresenter() return m_shell->notificationPresenter(); } +WebKit::WebGeolocationService* WebViewHost::geolocationService() +{ + if (!m_geolocationServiceMock.get()) + m_geolocationServiceMock.set(new WebGeolocationServiceMock); + return m_geolocationServiceMock.get(); +} + // WebWidgetClient ----------------------------------------------------------- void WebViewHost::didInvalidateRect(const WebRect& rect) @@ -1321,7 +1329,6 @@ PlatformCanvas* WebViewHost::canvas() return m_canvas.get(); WebSize widgetSize = webWidget()->size(); resetScrollRect(); - m_paintRect = WebRect(0, 0, widgetSize.width, widgetSize.height); m_canvas.set(new PlatformCanvas(widgetSize.width, widgetSize.height, true)); return m_canvas.get(); } diff --git a/WebKitTools/DumpRenderTree/chromium/WebViewHost.h b/WebKitTools/DumpRenderTree/chromium/WebViewHost.h index 5227b28..8fb9d04 100644 --- a/WebKitTools/DumpRenderTree/chromium/WebViewHost.h +++ b/WebKitTools/DumpRenderTree/chromium/WebViewHost.h @@ -45,6 +45,7 @@ class LayoutTestController; class TestShell; namespace WebKit { class WebFrame; +class WebGeolocationServiceMock; class WebURL; struct WebRect; struct WebURLError; @@ -125,6 +126,7 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient, virtual int historyForwardListCount(); virtual void focusAccessibilityObject(const WebKit::WebAccessibilityObject&); virtual WebKit::WebNotificationPresenter* notificationPresenter(); + virtual WebKit::WebGeolocationService* geolocationService(); // WebKit::WebWidgetClient virtual void didInvalidateRect(const WebKit::WebRect&); @@ -278,6 +280,9 @@ private: WebKit::WebRect m_paintRect; bool m_isPainting; + // Geolocation + OwnPtr<WebKit::WebGeolocationServiceMock> m_geolocationServiceMock; + OwnPtr<TestNavigationController*> m_navigationController; }; diff --git a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp index 4ffab88..e8b8627 100644 --- a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp +++ b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp @@ -39,6 +39,7 @@ #include <JavaScriptCore/JSRetainPtr.h> #include <JavaScriptCore/JSStringRef.h> +#include <cstring> #include <iostream> #include <sstream> #include <stdio.h> @@ -693,3 +694,14 @@ JSRetainPtr<JSStringRef> LayoutTestController::markerTextForListItem(JSContextRe void LayoutTestController::authenticateSession(JSStringRef, JSStringRef, JSStringRef) { } + +void LayoutTestController::setEditingBehavior(const char* editingBehavior) +{ + WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame); + WebKitWebSettings* settings = webkit_web_view_get_settings(webView); + + if (!strcmp(editingBehavior, "win")) + g_object_set(G_OBJECT(settings), "editing-behavior", WEBKIT_EDITING_BEHAVIOR_WINDOWS, NULL); + if (!strcmp(editingBehavior, "mac")) + g_object_set(G_OBJECT(settings), "editing-behavior", WEBKIT_EDITING_BEHAVIOR_MAC, NULL); +} diff --git a/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm b/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm index 6572a8e..8fd5298 100644 --- a/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm +++ b/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm @@ -135,6 +135,7 @@ static int dumpPixels; static int threaded; static int dumpTree = YES; static int forceComplexText; +static int useHTML5Parser; static BOOL printSeparators; static RetainPtr<CFStringRef> persistentUserStyleSheetLocation; @@ -440,6 +441,7 @@ static void resetDefaultsToConsistentValues() [preferences setDeveloperExtrasEnabled:NO]; [preferences setLoadsImagesAutomatically:YES]; [preferences setFrameFlatteningEnabled:NO]; + [preferences setEditingBehavior:WebKitEditingMacBehavior]; if (persistentUserStyleSheetLocation) { [preferences setUserStyleSheetLocation:[NSURL URLWithString:(NSString *)(persistentUserStyleSheetLocation.get())]]; [preferences setUserStyleSheetEnabled:YES]; @@ -451,6 +453,7 @@ static void resetDefaultsToConsistentValues() [preferences setUsesPageCache:NO]; [preferences setAcceleratedCompositingEnabled:YES]; [preferences setWebGLEnabled:NO]; + [preferences setHTML5ParserEnabled:useHTML5Parser]; [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain]; @@ -557,6 +560,7 @@ static void initializeGlobalsFromCommandLineOptions(int argc, const char *argv[] {"tree", no_argument, &dumpTree, YES}, {"threaded", no_argument, &threaded, YES}, {"complex-text", no_argument, &forceComplexText, YES}, + {"html5-parser", no_argument, &useHTML5Parser, YES}, {NULL, 0, NULL, 0} }; diff --git a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm index 44aea81..898235b 100644 --- a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm +++ b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm @@ -66,10 +66,6 @@ #import <wtf/HashMap.h> #import <wtf/RetainPtr.h> -#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) -#include <Foundation/NSPrivateDecls.h> -#endif - @interface CommandValidationTarget : NSObject <NSValidatedUserInterfaceItem> { SEL _action; @@ -762,7 +758,7 @@ void LayoutTestController::setWebViewEditable(bool editable) #ifndef BUILDING_ON_TIGER static NSString *SynchronousLoaderRunLoopMode = @"DumpRenderTreeSynchronousLoaderRunLoopMode"; -#if defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD) || !defined(__COCOA_FORMAL_PROTOCOLS_2__) +#if defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD) @protocol NSURLConnectionDelegate <NSObject> @end #endif @@ -849,3 +845,13 @@ void LayoutTestController::authenticateSession(JSStringRef url, JSStringRef user [SynchronousLoader makeRequest:request withUsername:(NSString *)usernameCF.get() password:(NSString *)passwordCF.get()]; #endif } + +void LayoutTestController::setEditingBehavior(const char* editingBehavior) +{ + NSString* editingBehaviorNS = [[NSString alloc] initWithUTF8String:editingBehavior]; + if ([editingBehaviorNS isEqualToString:@"mac"]) + [[WebPreferences standardPreferences] setEditingBehavior:WebKitEditingMacBehavior]; + if ([editingBehaviorNS isEqualToString:@"win"]) + [[WebPreferences standardPreferences] setEditingBehavior:WebKitEditingWinBehavior]; + [editingBehaviorNS release]; +} diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp index f9caca6..f119dd0 100644 --- a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp +++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp @@ -156,7 +156,7 @@ WebPage::WebPage(QObject* parent, DumpRenderTree* drt) connect(this, SIGNAL(geometryChangeRequested(const QRect &)), this, SLOT(setViewGeometry(const QRect & ))); - setNetworkAccessManager(new NetworkAccessManager(this)); + setNetworkAccessManager(m_drt->networkAccessManager()); setPluginFactory(new TestPlugin(this)); } @@ -346,6 +346,7 @@ DumpRenderTree::DumpRenderTree() QWebSettings::enablePersistentStorage(m_persistentStoragePath); + m_networkAccessManager = new NetworkAccessManager(this); // create our primary testing page/view. m_mainView = new QWebView(0); m_mainView->resize(QSize(LayoutTestController::maxViewWidth, LayoutTestController::maxViewHeight)); diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.h b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.h index e6449b7..ad41e3a 100644 --- a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.h +++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.h @@ -61,6 +61,7 @@ class GCController; namespace WebCore { class WebPage; +class NetworkAccessManager; class DumpRenderTree : public QObject { Q_OBJECT @@ -87,6 +88,7 @@ public: EventSender *eventSender() const { return m_eventSender; } TextInputController *textInputController() const { return m_textInputController; } QString persistentStoragePath() const { return m_persistentStoragePath; } + NetworkAccessManager *networkAccessManager() const { return m_networkAccessManager; } QWebPage *createWindow(); int windowCount() const; @@ -95,7 +97,6 @@ public: WebPage *webPage() const { return m_page; } - #if defined(Q_WS_X11) static void initializeFonts(); #endif @@ -136,6 +137,7 @@ private: EventSender *m_eventSender; TextInputController *m_textInputController; GCController* m_gcController; + NetworkAccessManager* m_networkAccessManager; QFile *m_stdin; diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp index 1fadd61..9616835 100644 --- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp +++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp @@ -638,5 +638,10 @@ void LayoutTestController::setIconDatabaseEnabled(bool enable) QWebSettings::setIconDatabasePath(QString()); } +void LayoutTestController::setEditingBehavior(const QString& editingBehavior) +{ + // FIXME: Implement. +} + const unsigned LayoutTestController::maxViewWidth = 800; const unsigned LayoutTestController::maxViewHeight = 600; diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h index 1359a6f..5fb40b6 100644 --- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h +++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h @@ -193,6 +193,8 @@ public slots: // Simulate a request an embedding application could make, populating per-session credential storage. void authenticateSession(const QString& url, const QString& username, const QString& password); + void setEditingBehavior(const QString& editingBehavior); + private slots: void processWork(); diff --git a/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp index dfa4de0..b22f342 100644 --- a/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp +++ b/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp @@ -787,6 +787,7 @@ static void resetDefaultsToConsistentValues(IWebPreferences* preferences) preferences->setTabsToLinks(FALSE); preferences->setShouldPrintBackgrounds(TRUE); preferences->setLoadsImagesAutomatically(TRUE); + preferences->setEditingBehavior(WebKitEditingWinBehavior); if (persistentUserStyleSheetLocation) { Vector<wchar_t> urlCharacters(CFStringGetLength(persistentUserStyleSheetLocation.get())); diff --git a/WebKitTools/DumpRenderTree/win/FrameLoadDelegate.cpp b/WebKitTools/DumpRenderTree/win/FrameLoadDelegate.cpp index 9b9e3c1..a84e0f3 100644 --- a/WebKitTools/DumpRenderTree/win/FrameLoadDelegate.cpp +++ b/WebKitTools/DumpRenderTree/win/FrameLoadDelegate.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005, 2006, 2007, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -146,6 +147,7 @@ HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didFailProvisionalLoadWithError( if (!done && gLayoutTestController->dumpFrameLoadCallbacks()) printf("%s - didFailProvisionalLoadWithError\n", descriptionSuitableForTestResult(frame).c_str()); + locationChangeDone(error, frame); return S_OK; } diff --git a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp index 112b355..c70b517 100644 --- a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp +++ b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp @@ -1267,3 +1267,20 @@ void LayoutTestController::setWebViewEditable(bool) void LayoutTestController::authenticateSession(JSStringRef, JSStringRef, JSStringRef) { } + +void LayoutTestController::setEditingBehavior(const char* editingBehavior) +{ + COMPtr<IWebView> webView; + if (FAILED(frame->webView(&webView))) + return; + + COMPtr<IWebPreferences> preferences; + if (FAILED(webView->preferences(&preferences))) + return; + + string behaviorString(editingBehavior); + if (behaviorString == "mac") + preferences->setEditingBehavior(WebKitEditingMacBehavior); + if (behaviorString == "win") + preferences->setEditingBehavior(WebKitEditingWinBehavior); +} diff --git a/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp b/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp index bc157be..d34e40a 100644 --- a/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp +++ b/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp @@ -446,3 +446,8 @@ JSValueRef LayoutTestController::computedStyleIncludingVisitedInfo(JSContextRef, void LayoutTestController::authenticateSession(JSStringRef, JSStringRef, JSStringRef) { } + +void LayoutTestController::setEditingBehavior(JSStringRef editingBehavior) +{ + // FIXME: Implement +} |