summaryrefslogtreecommitdiffstats
path: root/WebKitTools/DumpRenderTree/chromium
diff options
context:
space:
mode:
Diffstat (limited to 'WebKitTools/DumpRenderTree/chromium')
-rw-r--r--WebKitTools/DumpRenderTree/chromium/DumpRenderTree.cpp3
-rw-r--r--WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp59
-rw-r--r--WebKitTools/DumpRenderTree/chromium/LayoutTestController.h13
-rw-r--r--WebKitTools/DumpRenderTree/chromium/NotificationPresenter.cpp14
-rw-r--r--WebKitTools/DumpRenderTree/chromium/TestShell.cpp8
-rw-r--r--WebKitTools/DumpRenderTree/chromium/TestShell.h2
-rw-r--r--WebKitTools/DumpRenderTree/chromium/TestShellGtk.cpp4
-rw-r--r--WebKitTools/DumpRenderTree/chromium/TestShellMac.mm4
-rw-r--r--WebKitTools/DumpRenderTree/chromium/TestShellWin.cpp48
-rw-r--r--WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp9
-rw-r--r--WebKitTools/DumpRenderTree/chromium/WebViewHost.h5
11 files changed, 141 insertions, 28 deletions
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;
};