summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortkent@google.com <tkent@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-11 09:13:39 +0000
committertkent@google.com <tkent@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-11 09:13:39 +0000
commit587f4ff6420df90d4e6160aeb78918fcf55e3599 (patch)
treeeec256c6964c74ac7bcc448f37d20a31d6c1e397
parent5df870bf1e212e8ac4214e17d942a141fce2691a (diff)
downloadchromium_src-587f4ff6420df90d4e6160aeb78918fcf55e3599.zip
chromium_src-587f4ff6420df90d4e6160aeb78918fcf55e3599.tar.gz
chromium_src-587f4ff6420df90d4e6160aeb78918fcf55e3599.tar.bz2
Apply recent changes of test_shell to webkit_support.
- Enable some runtime WebKit flags - Use DumpRenderTreePasteboard - Use webkit_glue::WebFileSystemImpl - Use TestShellWebMimeRegistryImpl - Add webkit_support::CreateApplicationCacheHost() BUG=none TEST=none Review URL: http://codereview.chromium.org/2038010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46899 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/support/platform_support_mac.mm67
-rw-r--r--webkit/support/test_webkit_client.cc20
-rw-r--r--webkit/support/test_webkit_client.h9
-rw-r--r--webkit/support/webkit_support.cc5
-rw-r--r--webkit/support/webkit_support.gypi4
-rw-r--r--webkit/support/webkit_support.h9
-rw-r--r--webkit/tools/test_shell/test_shell.gypi4
7 files changed, 104 insertions, 14 deletions
diff --git a/webkit/support/platform_support_mac.mm b/webkit/support/platform_support_mac.mm
index 0cfb758..1eb61eb 100644
--- a/webkit/support/platform_support_mac.mm
+++ b/webkit/support/platform_support_mac.mm
@@ -6,6 +6,7 @@
#import <AppKit/AppKit.h>
#import <Foundation/Foundation.h>
+#import <objc/objc-runtime.h>
#include "base/data_pack.h"
#include "base/file_util.h"
@@ -15,6 +16,7 @@
#include "base/string16.h"
#include "grit/webkit_resources.h"
#include "third_party/WebKit/WebKit/mac/WebCoreSupport/WebSystemInterface.h"
+#import "webkit/tools/test_shell/mac/DumpRenderTreePasteboard.h"
static base::DataPack* g_resource_data_pack = NULL;
@@ -29,6 +31,68 @@ void BeforeInitialize() {
InitWebCoreSystemInterface();
}
+#if OBJC_API_VERSION == 2
+static void SwizzleAllMethods(Class imposter, Class original) {
+ unsigned int imposterMethodCount = 0;
+ Method* imposterMethods =
+ class_copyMethodList(imposter, &imposterMethodCount);
+
+ unsigned int originalMethodCount = 0;
+ Method* originalMethods =
+ class_copyMethodList(original, &originalMethodCount);
+
+ for (unsigned int i = 0; i < imposterMethodCount; i++) {
+ SEL imposterMethodName = method_getName(imposterMethods[i]);
+
+ // Attempt to add the method to the original class. If it fails, the method
+ // already exists and we should instead exchange the implementations.
+ if (class_addMethod(original,
+ imposterMethodName,
+ method_getImplementation(originalMethods[i]),
+ method_getTypeEncoding(originalMethods[i]))) {
+ continue;
+ }
+
+ unsigned int j = 0;
+ for (; j < originalMethodCount; j++) {
+ SEL originalMethodName = method_getName(originalMethods[j]);
+ if (sel_isEqual(imposterMethodName, originalMethodName)) {
+ break;
+ }
+ }
+
+ // If class_addMethod failed above then the method must exist on the
+ // original class.
+ DCHECK(j < originalMethodCount) << "method wasn't found?";
+ method_exchangeImplementations(imposterMethods[i], originalMethods[j]);
+ }
+
+ if (imposterMethods) {
+ free(imposterMethods);
+ }
+ if (originalMethods) {
+ free(originalMethods);
+ }
+}
+#endif
+
+static void SwizzleNSPasteboard() {
+ // We replace NSPaseboard w/ the shim (from WebKit) that avoids having
+ // sideeffects w/ whatever the user does at the same time.
+
+ Class imposterClass = objc_getClass("DumpRenderTreePasteboard");
+ Class originalClass = objc_getClass("NSPasteboard");
+#if OBJC_API_VERSION == 0
+ class_poseAs(imposterClass, originalClass);
+#else
+ // Swizzle instance methods...
+ SwizzleAllMethods(imposterClass, originalClass);
+ // and then class methods.
+ SwizzleAllMethods(object_getClass(imposterClass),
+ object_getClass(originalClass));
+#endif
+}
+
void AfterIniitalize() {
// Load a data pack.
g_resource_data_pack = new base::DataPack;
@@ -69,12 +133,15 @@ void AfterIniitalize() {
DLOG(FATAL) << "Fail to activate font: %s" << resource_path;
}
}
+
+ SwizzleNSPasteboard();
}
void BeforeShutdown() {
}
void AfterShutdown() {
+ [DumpRenderTreePasteboard releaseLocalPasteboards];
[autorelease_pool drain];
delete g_resource_data_pack;
}
diff --git a/webkit/support/test_webkit_client.cc b/webkit/support/test_webkit_client.cc
index a3191e1..749fa80 100644
--- a/webkit/support/test_webkit_client.cc
+++ b/webkit/support/test_webkit_client.cc
@@ -13,6 +13,7 @@
#include "media/base/media.h"
#include "third_party/WebKit/WebKit/chromium/public/WebData.h"
#include "third_party/WebKit/WebKit/chromium/public/WebDatabase.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebGraphicsContext3D.h"
#include "third_party/WebKit/WebKit/chromium/public/WebRuntimeFeatures.h"
#include "third_party/WebKit/WebKit/chromium/public/WebKit.h"
#include "third_party/WebKit/WebKit/chromium/public/WebScriptController.h"
@@ -67,7 +68,10 @@ TestWebKitClient::TestWebKitClient() {
WebKit::WebRuntimeFeatures::enableSockets(true);
WebKit::WebRuntimeFeatures::enableApplicationCache(true);
WebKit::WebRuntimeFeatures::enableDatabase(true);
+ WebKit::WebRuntimeFeatures::enableWebGL(true);
+ WebKit::WebRuntimeFeatures::enablePushState(true);
WebKit::WebRuntimeFeatures::enableNotifications(true);
+ WebKit::WebRuntimeFeatures::enableTouch(true);
// Load libraries for media and enable the media player.
bool enable_media = false;
@@ -100,6 +104,8 @@ TestWebKitClient::TestWebKitClient() {
WebKit::WebDatabase::setObserver(&database_system_);
+ file_system_.set_sandbox_enabled(false);
+
#if defined(OS_WIN)
// Ensure we pick up the default theme engine.
SetThemeEngine(NULL);
@@ -133,6 +139,10 @@ WebKit::WebClipboard* TestWebKitClient::clipboard() {
return &mock_clipboard_;
}
+WebKit::WebFileSystem* TestWebKitClient::fileSystem() {
+ return &file_system_;
+}
+
WebKit::WebSandboxSupport* TestWebKitClient::sandboxSupport() {
return NULL;
}
@@ -168,12 +178,6 @@ long long TestWebKitClient::databaseGetFileSize(
return SimpleDatabaseSystem::GetInstance()->GetFileSize(vfs_file_name);
}
-bool TestWebKitClient::getFileSize(const WebKit::WebString& path, long long& result) {
- return file_util::GetFileSize(
- webkit_glue::WebStringToFilePath(path),
- reinterpret_cast<int64*>(&result));
-}
-
unsigned long long TestWebKitClient::visitedLinkHash(const char* canonicalURL,
size_t length) {
return 0;
@@ -239,3 +243,7 @@ WebKit::WebThemeEngine* TestWebKitClient::themeEngine() {
WebKit::WebSharedWorkerRepository* TestWebKitClient::sharedWorkerRepository() {
return NULL;
}
+
+WebKit::WebGraphicsContext3D* TestWebKitClient::createGraphicsContext3D() {
+ return WebKit::WebGraphicsContext3D::createDefault();
+}
diff --git a/webkit/support/test_webkit_client.h b/webkit/support/test_webkit_client.h
index 8e4dacc..c0c8a6a 100644
--- a/webkit/support/test_webkit_client.h
+++ b/webkit/support/test_webkit_client.h
@@ -5,12 +5,13 @@
#ifndef WEBKIT_SUPPORT_TEST_WEBKIT_CLIENT_H_
#define WEBKIT_SUPPORT_TEST_WEBKIT_CLIENT_H_
-#include "webkit/glue/simple_webmimeregistry_impl.h"
+#include "webkit/glue/webfilesystem_impl.h"
#include "webkit/glue/webkitclient_impl.h"
#include "webkit/tools/test_shell/mock_webclipboard_impl.h"
#include "webkit/tools/test_shell/simple_appcache_system.h"
#include "webkit/tools/test_shell/simple_database_system.h"
#include "webkit/tools/test_shell/simple_webcookiejar_impl.h"
+#include "webkit/tools/test_shell/test_shell_webmimeregistry_impl.h"
// An implementation of WebKitClient for tests.
class TestWebKitClient : public webkit_glue::WebKitClientImpl {
@@ -20,6 +21,7 @@ class TestWebKitClient : public webkit_glue::WebKitClientImpl {
virtual WebKit::WebMimeRegistry* mimeRegistry();
WebKit::WebClipboard* clipboard();
+ virtual WebKit::WebFileSystem* fileSystem();
virtual WebKit::WebSandboxSupport* sandboxSupport();
virtual WebKit::WebCookieJar* cookieJar();
virtual bool sandboxEnabled();
@@ -32,7 +34,6 @@ class TestWebKitClient : public webkit_glue::WebKitClientImpl {
const WebKit::WebString& vfs_file_name);
virtual long long databaseGetFileSize(
const WebKit::WebString& vfs_file_name);
- virtual bool getFileSize(const WebKit::WebString& path, long long& result);
virtual unsigned long long visitedLinkHash(const char* canonicalURL,
size_t length);
virtual bool isLinkVisited(unsigned long long linkHash);
@@ -54,10 +55,12 @@ class TestWebKitClient : public webkit_glue::WebKitClientImpl {
#endif
virtual WebKit::WebSharedWorkerRepository* sharedWorkerRepository();
+ virtual WebKit::WebGraphicsContext3D* createGraphicsContext3D();
private:
- webkit_glue::SimpleWebMimeRegistryImpl mime_registry_;
+ TestShellWebMimeRegistryImpl mime_registry_;
MockWebClipboardImpl mock_clipboard_;
+ webkit_glue::WebFileSystemImpl file_system_;
ScopedTempDir appcache_dir_;
SimpleAppCacheSystem appcache_system_;
SimpleDatabaseSystem database_system_;
diff --git a/webkit/support/webkit_support.cc b/webkit/support/webkit_support.cc
index f42ffc4..2f3d4bf5 100644
--- a/webkit/support/webkit_support.cc
+++ b/webkit/support/webkit_support.cc
@@ -143,6 +143,11 @@ WebKit::WebMediaPlayer* CreateMediaPlayer(WebFrame* frame,
new webkit_glue::VideoRendererImpl::FactoryFactory(false));
}
+WebKit::WebApplicationCacheHost* CreateApplicationCacheHost(
+ WebFrame*, WebKit::WebApplicationCacheHostClient* client) {
+ return SimpleAppCacheSystem::CreateApplicationCacheHost(client);
+}
+
// Wrapper for debug_util
bool BeingDebugged() {
return DebugUtil::BeingDebugged();
diff --git a/webkit/support/webkit_support.gypi b/webkit/support/webkit_support.gypi
index ec34cda..6b8cb82 100644
--- a/webkit/support/webkit_support.gypi
+++ b/webkit/support/webkit_support.gypi
@@ -33,6 +33,8 @@
'webkit_support.h',
'webkit_support_glue.cc',
# TODO(tkent): Move the following files to here.
+ '<(DEPTH)/webkit/tools/test_shell/mac/DumpRenderTreePasteboard.h',
+ '<(DEPTH)/webkit/tools/test_shell/mac/DumpRenderTreePasteboard.m',
'<(DEPTH)/webkit/tools/test_shell/mock_webclipboard_impl.cc',
'<(DEPTH)/webkit/tools/test_shell/mock_webclipboard_impl.h',
'<(DEPTH)/webkit/tools/test_shell/simple_appcache_system.cc',
@@ -48,6 +50,8 @@
'<(DEPTH)/webkit/tools/test_shell/simple_webcookiejar_impl.h',
'<(DEPTH)/webkit/tools/test_shell/test_shell_request_context.cc',
'<(DEPTH)/webkit/tools/test_shell/test_shell_request_context.h',
+ '<(DEPTH)/webkit/tools/test_shell/test_shell_webmimeregistry_impl.cc',
+ '<(DEPTH)/webkit/tools/test_shell/test_shell_webmimeregistry_impl.h',
],
},
],
diff --git a/webkit/support/webkit_support.h b/webkit/support/webkit_support.h
index 485c931..16b0065 100644
--- a/webkit/support/webkit_support.h
+++ b/webkit/support/webkit_support.h
@@ -11,14 +11,16 @@
class Task;
namespace WebKit {
+class WebApplicationCacheHost;
+class WebApplicationCacheHostClient;
class WebFrame;
class WebKitClient;
class WebMediaPlayer;
class WebMediaPlayerClient;
class WebPlugin;
-struct WebPluginParams;
class WebString;
class WebURL;
+struct WebPluginParams;
}
// This package provides functions used by DumpRenderTree/chromium.
@@ -47,6 +49,11 @@ WebKit::WebPlugin* CreateWebPlugin(WebKit::WebFrame* frame,
WebKit::WebMediaPlayer* CreateMediaPlayer(WebKit::WebFrame* frame,
WebKit::WebMediaPlayerClient* client);
+// This is used by WebFrameClient::createApplicationCacheHost().
+WebKit::WebApplicationCacheHost* CreateApplicationCacheHost(
+ WebKit::WebFrame* frame, WebKit::WebApplicationCacheHostClient* client);
+
+
// Wrappers to minimize dependecy.
// -------- Debugging
diff --git a/webkit/tools/test_shell/test_shell.gypi b/webkit/tools/test_shell/test_shell.gypi
index 34c085e..c5a4d84 100644
--- a/webkit/tools/test_shell/test_shell.gypi
+++ b/webkit/tools/test_shell/test_shell.gypi
@@ -47,8 +47,6 @@
],
'msvs_guid': '77C32787-1B96-CB84-B905-7F170629F0AC',
'sources': [
- 'mac/DumpRenderTreePasteboard.h',
- 'mac/DumpRenderTreePasteboard.m',
'mac/test_shell_webview.h',
'mac/test_shell_webview.mm',
'mac/test_webview_delegate.mm',
@@ -95,8 +93,6 @@
'test_shell_switches.h',
'test_shell_win.cc',
'test_shell_webkit_init.h',
- 'test_shell_webmimeregistry_impl.cc',
- 'test_shell_webmimeregistry_impl.h',
'test_shell_webthemecontrol.h',
'test_shell_webthemecontrol.cc',
'test_shell_webthemeengine.h',