summaryrefslogtreecommitdiffstats
path: root/WebKitTools/DumpRenderTree
diff options
context:
space:
mode:
Diffstat (limited to 'WebKitTools/DumpRenderTree')
-rw-r--r--WebKitTools/DumpRenderTree/DumpRenderTree.h3
-rw-r--r--WebKitTools/DumpRenderTree/LayoutTestController.cpp101
-rw-r--r--WebKitTools/DumpRenderTree/LayoutTestController.h14
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.cpp5
-rw-r--r--WebKitTools/DumpRenderTree/chromium/DumpRenderTree.cpp8
-rw-r--r--WebKitTools/DumpRenderTree/chromium/EventSender.cpp2
-rw-r--r--WebKitTools/DumpRenderTree/chromium/TestEventPrinter.cpp2
-rw-r--r--WebKitTools/DumpRenderTree/chromium/TestShell.cpp6
-rw-r--r--WebKitTools/DumpRenderTree/chromium/TestShell.h18
-rw-r--r--[-rwxr-xr-x]WebKitTools/DumpRenderTree/chromium/WebThemeControlDRT.h0
-rw-r--r--[-rwxr-xr-x]WebKitTools/DumpRenderTree/chromium/WebThemeEngineDRT.h0
-rw-r--r--WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp14
-rw-r--r--WebKitTools/DumpRenderTree/chromium/WebViewHost.h3
-rw-r--r--WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp64
-rw-r--r--WebKitTools/DumpRenderTree/gtk/EventSender.cpp43
-rw-r--r--WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp24
-rw-r--r--WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm14
-rw-r--r--WebKitTools/DumpRenderTree/mac/DumpRenderTreePasteboard.m2
-rw-r--r--WebKitTools/DumpRenderTree/mac/DumpRenderTreeWindow.mm2
-rw-r--r--WebKitTools/DumpRenderTree/mac/EventSendingController.mm2
-rw-r--r--WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm34
-rw-r--r--WebKitTools/DumpRenderTree/mac/UIDelegate.mm14
-rw-r--r--WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp43
-rw-r--r--WebKitTools/DumpRenderTree/qt/EventSenderQt.h1
-rw-r--r--WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp15
-rw-r--r--WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h7
-rw-r--r--WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp25
-rw-r--r--WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h1
-rw-r--r--WebKitTools/DumpRenderTree/win/EventSender.cpp2
-rw-r--r--WebKitTools/DumpRenderTree/win/ImageDiff.vcproj8
-rw-r--r--WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp24
-rw-r--r--WebKitTools/DumpRenderTree/win/TestNetscapePlugin/main.cpp2
-rwxr-xr-xWebKitTools/DumpRenderTree/win/UIDelegate.cpp2
-rw-r--r--WebKitTools/DumpRenderTree/wx/DumpRenderTreeWx.cpp10
-rw-r--r--WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp23
35 files changed, 409 insertions, 129 deletions
diff --git a/WebKitTools/DumpRenderTree/DumpRenderTree.h b/WebKitTools/DumpRenderTree/DumpRenderTree.h
index 8366e89..7a862f7 100644
--- a/WebKitTools/DumpRenderTree/DumpRenderTree.h
+++ b/WebKitTools/DumpRenderTree/DumpRenderTree.h
@@ -45,6 +45,7 @@
#endif
#include <string>
+#include <wtf/RefPtr.h>
#if !OS(OPENBSD)
std::wstring urlSuitableForTestResult(const std::wstring& url);
@@ -55,7 +56,7 @@ class LayoutTestController;
extern volatile bool done;
// FIXME: This is a bad abstraction. We should insted pass this to other controller objects which need access to it.
-extern LayoutTestController* gLayoutTestController;
+extern RefPtr<LayoutTestController> gLayoutTestController;
void dump();
void displayWebView();
diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/LayoutTestController.cpp
index b96a9c9..02c77a4 100644
--- a/WebKitTools/DumpRenderTree/LayoutTestController.cpp
+++ b/WebKitTools/DumpRenderTree/LayoutTestController.cpp
@@ -83,6 +83,11 @@ LayoutTestController::LayoutTestController(const std::string& testPathOrURL, con
{
}
+PassRefPtr<LayoutTestController> LayoutTestController::create(const std::string& testPathOrURL, const std::string& expectedPixelHash)
+{
+ return adoptRef(new LayoutTestController(testPathOrURL, expectedPixelHash));
+}
+
// Static Functions
static JSValueRef dumpAsPDFCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
@@ -521,6 +526,41 @@ static bool parsePageParameters(JSContextRef context, int argumentCount, const J
return true;
}
+// Caller needs to delete[] propertyName.
+static bool parsePagePropertyParameters(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, char*& propertyName, int& pageNumber)
+{
+ pageNumber = 0;
+ switch (argumentCount) {
+ case 2:
+ pageNumber = static_cast<float>(JSValueToNumber(context, arguments[1], exception));
+ if (*exception)
+ return false;
+ // Fall through.
+ case 1: {
+ JSRetainPtr<JSStringRef> propertyNameString(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+ if (*exception)
+ return false;
+
+ size_t maxLength = JSStringGetMaximumUTF8CStringSize(propertyNameString.get());
+ propertyName = new char[maxLength + 1];
+ JSStringGetUTF8CString(propertyNameString.get(), propertyName, maxLength + 1);
+ return true;
+ }
+ case 0:
+ default:
+ return false;
+ }
+}
+
+static bool parsePageNumber(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, int& pageNumber)
+{
+ pageNumber = 0;
+ if (argumentCount != 1)
+ return false;
+ pageNumber = static_cast<int>(JSValueToNumber(context, arguments[0], exception));
+ return !*exception;
+}
+
static JSValueRef pageNumberForElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
float pageWidthInPixels = 0;
@@ -548,6 +588,50 @@ static JSValueRef numberOfPagesCallback(JSContextRef context, JSObjectRef functi
return JSValueMakeNumber(context, controller->numberOfPages(pageWidthInPixels, pageHeightInPixels));
}
+static JSValueRef pagePropertyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+ char* propertyName = 0;
+ int pageNumber = 0;
+ if (!parsePagePropertyParameters(context, argumentCount, arguments, exception, propertyName, pageNumber))
+ return JSValueMakeUndefined(context);
+
+ LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+ JSValueRef value = JSValueMakeString(context, controller->pageProperty(propertyName, pageNumber).get());
+
+ delete[] propertyName;
+ return value;
+}
+
+static JSValueRef isPageBoxVisibleCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+ int pageNumber = 0;
+ if (!parsePageNumber(context, argumentCount, arguments, exception, pageNumber))
+ return JSValueMakeUndefined(context);
+
+ LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+ return JSValueMakeBoolean(context, controller->isPageBoxVisible(pageNumber));
+}
+
+static JSValueRef pageAreaRectInPixelsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+ int pageNumber = 0;
+ if (!parsePageNumber(context, argumentCount, arguments, exception, pageNumber))
+ return JSValueMakeUndefined(context);
+
+ LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+ return JSValueMakeString(context, controller->pageAreaRectInPixels(pageNumber).get());
+}
+
+static JSValueRef preferredPageSizeInPixelsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+ int pageNumber = 0;
+ if (!parsePageNumber(context, argumentCount, arguments, exception, pageNumber))
+ return JSValueMakeUndefined(context);
+
+ LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+ return JSValueMakeString(context, controller->preferredPageSizeInPixels(pageNumber).get());
+}
+
static JSValueRef queueBackNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
// Has mac & windows implementation
@@ -1428,6 +1512,16 @@ static JSValueRef setWebViewEditableCallback(JSContextRef context, JSObjectRef f
return JSValueMakeUndefined(context);
}
+
+#if PLATFORM(MAC)
+static JSValueRef abortModalCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+ LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+ controller->abortModal();
+ return JSValueMakeUndefined(context);
+}
+#endif
+
static JSValueRef markerTextForListItemCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
@@ -1554,6 +1648,9 @@ JSStaticValue* LayoutTestController::staticValues()
JSStaticFunction* LayoutTestController::staticFunctions()
{
static JSStaticFunction staticFunctions[] = {
+#if PLATFORM(MAC)
+ { "abortModal", abortModalCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+#endif
{ "addDisallowedURL", addDisallowedURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "addUserScript", addUserScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "addUserStyleSheet", addUserStyleSheetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
@@ -1593,6 +1690,7 @@ JSStaticFunction* LayoutTestController::staticFunctions()
{ "counterValueForElementById", counterValueForElementByIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "grantDesktopNotificationPermission", grantDesktopNotificationPermissionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "isCommandEnabled", isCommandEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+ { "isPageBoxVisible", isPageBoxVisibleCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "keepWebHistory", keepWebHistoryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "layerTreeAsText", layerTreeAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "numberOfPages", numberOfPagesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
@@ -1601,9 +1699,12 @@ JSStaticFunction* LayoutTestController::staticFunctions()
{ "numberOfActiveAnimations", numberOfActiveAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "overridePreference", overridePreferenceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "pageNumberForElementById", pageNumberForElementByIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+ { "pageAreaRectInPixels", pageAreaRectInPixelsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+ { "pageProperty", pagePropertyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "pathToLocalResource", pathToLocalResourceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "pauseAnimationAtTimeOnElementWithId", pauseAnimationAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "pauseTransitionAtTimeOnElementWithId", pauseTransitionAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+ { "preferredPageSizeInPixels", preferredPageSizeInPixelsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "sampleSVGAnimationForElementAtTime", sampleSVGAnimationForElementAtTimeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "printToPDF", dumpAsPDFCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "queueBackNavigation", queueBackNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.h b/WebKitTools/DumpRenderTree/LayoutTestController.h
index 8ff38d1..6af2c57 100644
--- a/WebKitTools/DumpRenderTree/LayoutTestController.h
+++ b/WebKitTools/DumpRenderTree/LayoutTestController.h
@@ -34,11 +34,12 @@
#include <set>
#include <string>
#include <vector>
+#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
class LayoutTestController : public RefCounted<LayoutTestController> {
public:
- LayoutTestController(const std::string& testPathOrURL, const std::string& expectedPixelHash);
+ static PassRefPtr<LayoutTestController> create(const std::string& testPathOrURL, const std::string& expectedPixelHash);
~LayoutTestController();
void makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception);
@@ -62,6 +63,10 @@ public:
int numberOfPages(float pageWidthInPixels, float pageHeightInPixels);
void overridePreference(JSStringRef key, JSStringRef value);
int pageNumberForElementById(JSStringRef id, float pageWidthInPixels, float pageHeightInPixels);
+ JSRetainPtr<JSStringRef> pageProperty(const char* propertyName, int pageNumber) const;
+ bool isPageBoxVisible(int pageNumber) const;
+ JSRetainPtr<JSStringRef> pageAreaRectInPixels(int pageNumber) const;
+ JSRetainPtr<JSStringRef> preferredPageSizeInPixels(int pageNumber) const;
JSStringRef pathToLocalResource(JSContextRef, JSStringRef url);
void queueBackNavigation(int howFarBackward);
void queueForwardNavigation(int howFarForward);
@@ -255,6 +260,11 @@ public:
void setWebViewEditable(bool);
+
+#if PLATFORM(MAC)
+ void abortModal();
+#endif
+
// The following API test functions should probably be moved to platform-specific
// unit tests outside of DRT once they exist.
void apiTestNewWindowDataLoadBaseURL(JSStringRef utf8Data, JSStringRef baseURL);
@@ -271,6 +281,8 @@ public:
static const unsigned maxViewHeight;
private:
+ LayoutTestController(const std::string& testPathOrURL, const std::string& expectedPixelHash);
+
bool m_dumpAsPDF;
bool m_dumpAsText;
bool m_dumpBackForwardList;
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.cpp
index 60103a5..477ca17 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.cpp
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.cpp
@@ -260,7 +260,10 @@ static bool pluginGetProperty(NPObject* obj, NPIdentifier name, NPVariant* resul
{
PluginObject* plugin = reinterpret_cast<PluginObject*>(obj);
if (name == pluginPropertyIdentifiers[ID_PROPERTY_PROPERTY]) {
- STRINGZ_TO_NPVARIANT("property", *result);
+ static const char* originalString = "property";
+ char* buf = static_cast<char*>(browser->memalloc(strlen(originalString) + 1));
+ strcpy(buf, originalString);
+ STRINGZ_TO_NPVARIANT(buf, *result);
return true;
} else if (name == pluginPropertyIdentifiers[ID_PROPERTY_EVENT_LOGGING]) {
BOOLEAN_TO_NPVARIANT(plugin->eventLogging, *result);
diff --git a/WebKitTools/DumpRenderTree/chromium/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/chromium/DumpRenderTree.cpp
index b0cff82..7194279 100644
--- a/WebKitTools/DumpRenderTree/chromium/DumpRenderTree.cpp
+++ b/WebKitTools/DumpRenderTree/chromium/DumpRenderTree.cpp
@@ -47,6 +47,7 @@ static const char optionTree[] = "--tree";
static const char optionPixelTestsWithName[] = "--pixel-tests=";
static const char optionTestShell[] = "--test-shell";
+static const char optionAllowExternalPages[] = "--allow-external-pages";
static void runTest(TestShell& shell, TestParams& params, const string& testName, bool testShellMode)
{
@@ -74,6 +75,7 @@ static void runTest(TestShell& shell, TestParams& params, const string& testName
}
}
params.testUrl = webkit_support::CreateURLForPathOrURL(pathOrURL);
+ webkit_support::SetCurrentDirectoryForFileURL(params.testUrl);
shell.resetTestController();
shell.runFileTest(params);
shell.setLayoutTestTimeout(oldTimeoutMsec);
@@ -88,6 +90,7 @@ int main(int argc, char* argv[])
Vector<string> tests;
bool serverMode = false;
bool testShellMode = false;
+ bool allowExternalPages = false;
for (int i = 1; i < argc; ++i) {
string argument(argv[i]);
if (argument == "-")
@@ -102,7 +105,9 @@ int main(int argc, char* argv[])
} else if (argument == optionTestShell) {
testShellMode = true;
serverMode = true;
- } else if (argument.size() && argument[0] == '-')
+ } else if (argument == optionAllowExternalPages)
+ allowExternalPages = true;
+ else if (argument.size() && argument[0] == '-')
fprintf(stderr, "Unknown option: %s\n", argv[i]);
else
tests.append(argument);
@@ -114,6 +119,7 @@ int main(int argc, char* argv[])
{ // Explicit scope for the TestShell instance.
TestShell shell(testShellMode);
+ shell.setAllowExternalPages(allowExternalPages);
if (serverMode && !tests.size()) {
params.printSeparators = true;
char testString[2048]; // 2048 is the same as the sizes of other platforms.
diff --git a/WebKitTools/DumpRenderTree/chromium/EventSender.cpp b/WebKitTools/DumpRenderTree/chromium/EventSender.cpp
index 7695095..fd7ba2d 100644
--- a/WebKitTools/DumpRenderTree/chromium/EventSender.cpp
+++ b/WebKitTools/DumpRenderTree/chromium/EventSender.cpp
@@ -542,7 +542,7 @@ void EventSender::keyDown(const CppArgumentList& arguments, CppVariant* result)
else if ("upArrow" == codeStr)
code = base::VKEY_UP;
else if ("delete" == codeStr)
- code = base::VKEY_BACK;
+ code = base::VKEY_DELETE;
else if ("pageUp" == codeStr)
code = base::VKEY_PRIOR;
else if ("pageDown" == codeStr)
diff --git a/WebKitTools/DumpRenderTree/chromium/TestEventPrinter.cpp b/WebKitTools/DumpRenderTree/chromium/TestEventPrinter.cpp
index 929656d..d9e79a0 100644
--- a/WebKitTools/DumpRenderTree/chromium/TestEventPrinter.cpp
+++ b/WebKitTools/DumpRenderTree/chromium/TestEventPrinter.cpp
@@ -142,7 +142,7 @@ void TestShellPrinter::handleImage(const char* actualHash, const char*, const un
if (imageData && imageSize) {
ASSERT(fileName);
FILE* fp = fopen(fileName, "wb");
- if (fp) {
+ if (!fp) {
perror(fileName);
exit(EXIT_FAILURE);
}
diff --git a/WebKitTools/DumpRenderTree/chromium/TestShell.cpp b/WebKitTools/DumpRenderTree/chromium/TestShell.cpp
index 761f8d1..610248a 100644
--- a/WebKitTools/DumpRenderTree/chromium/TestShell.cpp
+++ b/WebKitTools/DumpRenderTree/chromium/TestShell.cpp
@@ -80,6 +80,7 @@ TestShell::TestShell(bool testShellMode)
, m_testIsPreparing(false)
, m_focusedWidget(0)
, m_testShellMode(testShellMode)
+ , m_allowExternalPages(false)
{
WebRuntimeFeatures::enableGeolocation(true);
m_accessibilityController.set(new AccessibilityController(this));
@@ -200,6 +201,11 @@ void TestShell::runFileTest(const TestParams& params)
bool inspectorTestMode = testUrl.find("/inspector/") != string::npos
|| testUrl.find("\\inspector\\") != string::npos;
m_webView->settings()->setDeveloperExtrasEnabled(inspectorTestMode);
+
+ if (testUrl.find("loading/") != string::npos
+ || testUrl.find("loading\\") != string::npos)
+ m_layoutTestController->setShouldDumpFrameLoadCallbacks(true);
+
m_printer->handleTestHeader(testUrl.c_str());
loadURL(m_params.testUrl);
diff --git a/WebKitTools/DumpRenderTree/chromium/TestShell.h b/WebKitTools/DumpRenderTree/chromium/TestShell.h
index 2b99b3d..2397246 100644
--- a/WebKitTools/DumpRenderTree/chromium/TestShell.h
+++ b/WebKitTools/DumpRenderTree/chromium/TestShell.h
@@ -107,6 +107,9 @@ public:
// the test results.
void testTimedOut();
+ bool allowExternalPages() const { return m_allowExternalPages; }
+ void setAllowExternalPages(bool allowExternalPages) { m_allowExternalPages = allowExternalPages; }
+
#if defined(OS_WIN)
// Access to the finished event. Used by the static WatchDog thread.
HANDLE finishedEvent() { return m_finishedEvent; }
@@ -140,15 +143,16 @@ private:
WebKit::WebWidget* m_focusedWidget;
bool m_testShellMode;
WebViewHost* m_webViewHost;
- OwnPtr<AccessibilityController*> m_accessibilityController;
- OwnPtr<EventSender*> m_eventSender;
- OwnPtr<LayoutTestController*> m_layoutTestController;
- OwnPtr<PlainTextController*> m_plainTextController;
- OwnPtr<TextInputController*> m_textInputController;
- OwnPtr<NotificationPresenter*> m_notificationPresenter;
- OwnPtr<TestEventPrinter*> m_printer;
+ OwnPtr<AccessibilityController> m_accessibilityController;
+ OwnPtr<EventSender> m_eventSender;
+ OwnPtr<LayoutTestController> m_layoutTestController;
+ OwnPtr<PlainTextController> m_plainTextController;
+ OwnPtr<TextInputController> m_textInputController;
+ OwnPtr<NotificationPresenter> m_notificationPresenter;
+ OwnPtr<TestEventPrinter> m_printer;
TestParams m_params;
int m_timeout; // timeout value in millisecond
+ bool m_allowExternalPages;
// List of all windows in this process.
// The main window should be put into windowList[0].
diff --git a/WebKitTools/DumpRenderTree/chromium/WebThemeControlDRT.h b/WebKitTools/DumpRenderTree/chromium/WebThemeControlDRT.h
index 1f73610..1f73610 100755..100644
--- a/WebKitTools/DumpRenderTree/chromium/WebThemeControlDRT.h
+++ b/WebKitTools/DumpRenderTree/chromium/WebThemeControlDRT.h
diff --git a/WebKitTools/DumpRenderTree/chromium/WebThemeEngineDRT.h b/WebKitTools/DumpRenderTree/chromium/WebThemeEngineDRT.h
index 89805b1..89805b1 100755..100644
--- a/WebKitTools/DumpRenderTree/chromium/WebThemeEngineDRT.h
+++ b/WebKitTools/DumpRenderTree/chromium/WebThemeEngineDRT.h
diff --git a/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp b/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp
index d3aadc8..ef821ce 100644
--- a/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp
+++ b/WebKitTools/DumpRenderTree/chromium/WebViewHost.cpp
@@ -253,12 +253,7 @@ static string textAffinityDescription(WebTextAffinity affinity)
// WebViewClient -------------------------------------------------------------
-WebView* WebViewHost::createView(WebFrame* creator)
-{
- return createView(creator, WebWindowFeatures());
-}
-
-WebView* WebViewHost::createView(WebFrame*, const WebWindowFeatures&)
+WebView* WebViewHost::createView(WebFrame*, const WebWindowFeatures&, const WebString&)
{
if (!layoutTestController()->canOpenWindows())
return 0;
@@ -923,7 +918,8 @@ void WebViewHost::willSendRequest(WebFrame*, unsigned identifier, WebURLRequest&
if (!host.empty() && (url.SchemeIs("http") || url.SchemeIs("https"))
&& host != "127.0.0.1"
&& host != "255.255.255.255"
- && host != "localhost") {
+ && host != "localhost"
+ && !m_shell->allowExternalPages()) {
printf("Blocked access to external URL %s\n", requestURL.c_str());
// To block the request, we set its URL to an empty one.
@@ -1036,7 +1032,7 @@ void WebViewHost::reset()
this->~WebViewHost();
new (this) WebViewHost(shell);
setWebWidget(widget);
- webView()->mainFrame()->clearName();
+ webView()->mainFrame()->setName(WebString());
}
void WebViewHost::setSelectTrailingWhitespaceEnabled(bool enabled)
@@ -1284,7 +1280,7 @@ void WebViewHost::paintRect(const WebRect& rect)
ASSERT(canvas());
m_isPainting = true;
#if PLATFORM(CG)
- webWidget()->paint(m_canvas->getTopPlatformDevice().GetBitmapContext(), rect);
+ webWidget()->paint(canvas()->getTopPlatformDevice().GetBitmapContext(), rect);
#else
webWidget()->paint(canvas(), rect);
#endif
diff --git a/WebKitTools/DumpRenderTree/chromium/WebViewHost.h b/WebKitTools/DumpRenderTree/chromium/WebViewHost.h
index 8fb9d04..1e51be7 100644
--- a/WebKitTools/DumpRenderTree/chromium/WebViewHost.h
+++ b/WebKitTools/DumpRenderTree/chromium/WebViewHost.h
@@ -90,8 +90,7 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient,
virtual bool navigate(const TestNavigationEntry&, bool reload);
// WebKit::WebViewClient
- virtual WebKit::WebView* createView(WebKit::WebFrame*);
- virtual WebKit::WebView* createView(WebKit::WebFrame*, const WebKit::WebWindowFeatures&);
+ virtual WebKit::WebView* createView(WebKit::WebFrame*, const WebKit::WebWindowFeatures&, const WebKit::WebString&);
virtual WebKit::WebWidget* createPopupMenu(WebKit::WebPopupType);
virtual WebKit::WebWidget* createPopupMenu(const WebKit::WebPopupMenuInfo&);
virtual WebKit::WebStorageNamespace* createSessionStorageNamespace(unsigned quota);
diff --git a/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp
index 14577f1..d79addf 100644
--- a/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp
+++ b/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp
@@ -2,6 +2,7 @@
* Copyright (C) 2007 Eric Seidel <eric@webkit.org>
* Copyright (C) 2008 Alp Toker <alp@nuanti.com>
* Copyright (C) 2009 Jan Alonzo <jmalonzo@gmail.com>
+ * Copyright (C) 2010 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -77,7 +78,7 @@ static int dumpPixels;
static int dumpTree = 1;
AccessibilityController* axController = 0;
-LayoutTestController* gLayoutTestController = 0;
+RefPtr<LayoutTestController> gLayoutTestController;
static GCController* gcController = 0;
static WebKitWebView* webView;
static GtkWidget* window;
@@ -96,30 +97,19 @@ static WebKitWebHistoryItem* prevTestBFItem = NULL;
const unsigned historyItemIndent = 8;
-static gchar* autocorrectURL(const gchar* url)
+static bool shouldLogFrameLoadDelegates(const string& pathOrURL)
{
- if (strncmp("http://", url, 7) != 0 && strncmp("https://", url, 8) != 0) {
- GString* string = g_string_new("file://");
- g_string_append(string, url);
- return g_string_free(string, FALSE);
- }
-
- return g_strdup(url);
-}
-
-static bool shouldLogFrameLoadDelegates(const char* pathOrURL)
-{
- return strstr(pathOrURL, "loading/");
+ return pathOrURL.find("loading/") != string::npos;
}
-static bool shouldOpenWebInspector(const char* pathOrURL)
+static bool shouldOpenWebInspector(const string& pathOrURL)
{
- return strstr(pathOrURL, "inspector/");
+ return pathOrURL.find("inspector/") != string::npos;
}
-static bool shouldEnableDeveloperExtras(const char* pathOrURL)
+static bool shouldEnableDeveloperExtras(const string& pathOrURL)
{
- return shouldOpenWebInspector(pathOrURL) || strstr(pathOrURL, "inspector-enabled/");
+ return shouldOpenWebInspector(pathOrURL) || pathOrURL.find("inspector-enabled/") != string::npos;
}
void dumpFrameScrollPosition(WebKitWebFrame* frame)
@@ -474,39 +464,45 @@ static void runTest(const string& testPathOrURL)
ASSERT(!testPathOrURL.empty());
// Look for "'" as a separator between the path or URL, and the pixel dump hash that follows.
- string pathOrURL(testPathOrURL);
+ string testURL(testPathOrURL);
string expectedPixelHash;
-
- size_t separatorPos = pathOrURL.find("'");
+ size_t separatorPos = testURL.find("'");
if (separatorPos != string::npos) {
- pathOrURL = string(testPathOrURL, 0, separatorPos);
+ testURL = string(testPathOrURL, 0, separatorPos);
expectedPixelHash = string(testPathOrURL, separatorPos + 1);
}
- gchar* url = autocorrectURL(pathOrURL.c_str());
- const string testURL(url);
+ // Convert the path into a full file URL if it does not look
+ // like an HTTP/S URL (doesn't start with http:// or https://).
+ if (testURL.find("http://") && testURL.find("https://")) {
+ GFile* testFile = g_file_new_for_path(testURL.c_str());
+ gchar* testURLCString = g_file_get_uri(testFile);
+ testURL = testURLCString;
+ g_free(testURLCString);
+ g_object_unref(testFile);
+ }
resetDefaultsToConsistentValues();
- gLayoutTestController = new LayoutTestController(testURL, expectedPixelHash);
+ gLayoutTestController = LayoutTestController::create(testURL, expectedPixelHash);
topLoadingFrame = 0;
done = false;
gLayoutTestController->setIconDatabaseEnabled(false);
- if (shouldLogFrameLoadDelegates(pathOrURL.c_str()))
+ if (shouldLogFrameLoadDelegates(testURL))
gLayoutTestController->setDumpFrameLoadCallbacks(true);
- if (shouldEnableDeveloperExtras(pathOrURL.c_str())) {
+ if (shouldEnableDeveloperExtras(testURL)) {
gLayoutTestController->setDeveloperExtrasEnabled(true);
- if (shouldOpenWebInspector(pathOrURL.c_str()))
+ if (shouldOpenWebInspector(testURL))
gLayoutTestController->showWebInspector();
}
WorkQueue::shared()->clear();
WorkQueue::shared()->setFrozen(false);
- bool isSVGW3CTest = (gLayoutTestController->testPathOrURL().find("svg/W3C-SVG-1.1") != string::npos);
+ bool isSVGW3CTest = (testURL.find("svg/W3C-SVG-1.1") != string::npos);
GtkAllocation size;
size.x = size.y = 0;
size.width = isSVGW3CTest ? 480 : LayoutTestController::maxViewWidth;
@@ -527,15 +523,12 @@ static void runTest(const string& testPathOrURL)
// Focus the web view before loading the test to avoid focusing problems
gtk_widget_grab_focus(GTK_WIDGET(webView));
- webkit_web_view_open(webView, url);
-
- g_free(url);
- url = NULL;
+ webkit_web_view_open(webView, testURL.c_str());
gtk_main();
// If developer extras enabled Web Inspector may have been open by the test.
- if (shouldEnableDeveloperExtras(pathOrURL.c_str())) {
+ if (shouldEnableDeveloperExtras(testURL)) {
gLayoutTestController->closeWebInspector();
gLayoutTestController->setDeveloperExtrasEnabled(false);
}
@@ -553,8 +546,7 @@ static void runTest(const string& testPathOrURL)
// A blank load seems to be necessary to reset state after certain tests.
webkit_web_view_open(webView, "about:blank");
- gLayoutTestController->deref();
- gLayoutTestController = 0;
+ gLayoutTestController.clear();
// terminate the (possibly empty) pixels block after all the state reset
sendPixelResultsEOF();
diff --git a/WebKitTools/DumpRenderTree/gtk/EventSender.cpp b/WebKitTools/DumpRenderTree/gtk/EventSender.cpp
index 0ef4a42..7836ff0 100644
--- a/WebKitTools/DumpRenderTree/gtk/EventSender.cpp
+++ b/WebKitTools/DumpRenderTree/gtk/EventSender.cpp
@@ -87,6 +87,15 @@ static void sendOrQueueEvent(GdkEvent, bool = true);
static void dispatchEvent(GdkEvent event);
static guint getStateFlags();
+#if !GTK_CHECK_VERSION(2, 17, 3)
+static void gdk_window_get_root_coords(GdkWindow* window, gint x, gint y, gint* rootX, gint* rootY)
+{
+ gdk_window_get_root_origin(window, rootX, rootY);
+ *rootX = *rootX + x;
+ *rootY = *rootY + y;
+}
+#endif
+
static JSValueRef getDragModeCallback(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
{
return JSValueMakeBoolean(context, dragMode);
@@ -109,21 +118,6 @@ static JSValueRef leapForwardCallback(JSContextRef context, JSObjectRef function
return JSValueMakeUndefined(context);
}
-#if !GTK_CHECK_VERSION(2,17,3)
-static void getRootCoords(GtkWidget* view, int* rootX, int* rootY)
-{
- GtkWidget* window = gtk_widget_get_toplevel(GTK_WIDGET(view));
- int tmpX, tmpY;
-
- gtk_widget_translate_coordinates(view, window, lastMousePositionX, lastMousePositionY, &tmpX, &tmpY);
-
- gdk_window_get_origin(window->window, rootX, rootY);
-
- *rootX += tmpX;
- *rootY += tmpY;
-}
-#endif
-
bool prepareMouseButtonEvent(GdkEvent* event, int eventSenderButtonNumber)
{
WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
@@ -148,19 +142,10 @@ bool prepareMouseButtonEvent(GdkEvent* event, int eventSenderButtonNumber)
event->button.window = GTK_WIDGET(view)->window;
event->button.device = gdk_device_get_core_pointer();
event->button.state = getStateFlags();
-
- // Mouse up & down events dispatched via g_signal_emit_by_name must offset
- // their time value, so that WebKit can detect where sequences of mouse
- // clicks begin and end. This should not interfere with GDK or GTK+ event
- // processing, because the event is only seen by the widget.
- event->button.time = GDK_CURRENT_TIME + timeOffset;
+ event->button.time = GDK_CURRENT_TIME;
int xRoot, yRoot;
-#if GTK_CHECK_VERSION(2, 17, 3)
gdk_window_get_root_coords(GTK_WIDGET(view)->window, lastMousePositionX, lastMousePositionY, &xRoot, &yRoot);
-#else
- getRootCoords(GTK_WIDGET(view), &xRoot, &yRoot);
-#endif
event->button.x_root = xRoot;
event->button.y_root = yRoot;
@@ -286,11 +271,7 @@ static JSValueRef mouseMoveToCallback(JSContextRef context, JSObjectRef function
event.motion.state = getStateFlags();
int xRoot, yRoot;
-#if GTK_CHECK_VERSION(2,17,3)
gdk_window_get_root_coords(GTK_WIDGET(view)->window, lastMousePositionX, lastMousePositionY, &xRoot, &yRoot);
-#else
- getRootCoords(GTK_WIDGET(view), &xRoot, &yRoot);
-#endif
event.motion.x_root = xRoot;
event.motion.y_root = yRoot;
@@ -350,7 +331,7 @@ static void sendOrQueueEvent(GdkEvent event, bool shouldReplaySavedEvents)
{
// Mouse move events are queued if the previous event was queued or if a
// delay was set up by leapForward().
- if (buttonCurrentlyDown || endOfQueue != startOfQueue || msgQueue[endOfQueue].delay) {
+ if ((dragMode && buttonCurrentlyDown) || endOfQueue != startOfQueue || msgQueue[endOfQueue].delay) {
msgQueue[endOfQueue++].event = event;
if (shouldReplaySavedEvents)
@@ -467,7 +448,7 @@ static JSValueRef keyDownCallback(JSContextRef context, JSObjectRef function, JS
else if (JSStringIsEqualToUTF8CString(character, "end"))
gdkKeySym = GDK_End;
else if (JSStringIsEqualToUTF8CString(character, "delete"))
- gdkKeySym = GDK_BackSpace;
+ gdkKeySym = GDK_Delete;
else if (JSStringIsEqualToUTF8CString(character, "F1"))
gdkKeySym = GDK_F1;
else if (JSStringIsEqualToUTF8CString(character, "F2"))
diff --git a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
index e8b8627..6f8e637 100644
--- a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
+++ b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
@@ -171,6 +171,30 @@ int LayoutTestController::numberOfPages(float pageWidth, float pageHeight)
return webkit_web_frame_number_of_pages(mainFrame, pageWidth, pageHeight);
}
+JSRetainPtr<JSStringRef> LayoutTestController::pageProperty(const char* propertyName, int pageNumber) const
+{
+ // FIXME: implement
+ return JSRetainPtr<JSStringRef>();
+}
+
+bool LayoutTestController::isPageBoxVisible(int pageNumber) const
+{
+ // FIXME: implement
+ return false;
+}
+
+JSRetainPtr<JSStringRef> LayoutTestController::pageAreaRectInPixels(int pageNumber) const
+{
+ // FIXME: implement
+ return JSRetainPtr<JSStringRef>();
+}
+
+JSRetainPtr<JSStringRef> LayoutTestController::preferredPageSizeInPixels(int pageNumber) const
+{
+ // FIXME: implement
+ return JSRetainPtr<JSStringRef>();
+}
+
size_t LayoutTestController::webHistoryItemCount()
{
// FIXME: implement
diff --git a/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm b/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm
index 9e4b203..51ea004 100644
--- a/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm
+++ b/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm
@@ -111,7 +111,7 @@ static void runTest(const string& testPathOrURL);
volatile bool done;
NavigationController* gNavigationController = 0;
-LayoutTestController* gLayoutTestController = 0;
+RefPtr<LayoutTestController> gLayoutTestController;
WebFrame *mainFrame = 0;
// This is the topmost frame that is loading, during a given load, or nil when no load is
@@ -136,7 +136,7 @@ static int dumpPixels;
static int threaded;
static int dumpTree = YES;
static int forceComplexText;
-static int useHTML5Parser;
+static int useHTML5Parser = YES;
static BOOL printSeparators;
static RetainPtr<CFStringRef> persistentUserStyleSheetLocation;
@@ -562,7 +562,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},
+ {"legacy-parser", no_argument, &useHTML5Parser, NO},
{NULL, 0, NULL, 0}
};
@@ -1185,6 +1185,9 @@ static void resetWebViewToConsistentStateBeforeTesting()
[WebView _resetOriginAccessWhitelists];
[[MockGeolocationProvider shared] stopTimer];
+
+ // Clear the contents of the general pasteboard
+ [[NSPasteboard generalPasteboard] declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
}
static void runTest(const string& testPathOrURL)
@@ -1221,7 +1224,7 @@ static void runTest(const string& testPathOrURL)
resetWebViewToConsistentStateBeforeTesting();
- gLayoutTestController = new LayoutTestController(testURL, expectedPixelHash);
+ gLayoutTestController = LayoutTestController::create(testURL, expectedPixelHash);
topLoadingFrame = nil;
ASSERT(!draggingInfo); // the previous test should have called eventSender.mouseUp to drop!
releaseAndZero(&draggingInfo);
@@ -1311,8 +1314,7 @@ static void runTest(const string& testPathOrURL)
ASSERT(CFArrayGetCount(openWindowsRef) == 1);
ASSERT(CFArrayGetValueAtIndex(openWindowsRef, 0) == [[mainFrame webView] window]);
- gLayoutTestController->deref();
- gLayoutTestController = 0;
+ gLayoutTestController.clear();
if (ignoreWebCoreNodeLeaks)
[WebCoreStatistics stopIgnoringWebCoreNodeLeaks];
diff --git a/WebKitTools/DumpRenderTree/mac/DumpRenderTreePasteboard.m b/WebKitTools/DumpRenderTree/mac/DumpRenderTreePasteboard.m
index 75be9de..b1b3b86 100644
--- a/WebKitTools/DumpRenderTree/mac/DumpRenderTreePasteboard.m
+++ b/WebKitTools/DumpRenderTree/mac/DumpRenderTreePasteboard.m
@@ -177,7 +177,7 @@ static NSMutableDictionary *localPasteboards;
return [dataByType objectForKey:dataType];
}
-- (BOOL)setPropertyList:(id)propertyList forType:(NSString *)dataType;
+- (BOOL)setPropertyList:(id)propertyList forType:(NSString *)dataType
{
CFDataRef data = NULL;
if (propertyList)
diff --git a/WebKitTools/DumpRenderTree/mac/DumpRenderTreeWindow.mm b/WebKitTools/DumpRenderTree/mac/DumpRenderTreeWindow.mm
index 8845ef0..e0cdc6b 100644
--- a/WebKitTools/DumpRenderTree/mac/DumpRenderTreeWindow.mm
+++ b/WebKitTools/DumpRenderTree/mac/DumpRenderTreeWindow.mm
@@ -82,7 +82,7 @@ static CFArrayCallBacks NonRetainingArrayCallbacks = {
return gLayoutTestController ? gLayoutTestController->windowIsKey() : YES;
}
-- (void)keyDown:(id)sender
+- (void)keyDown:(NSEvent *)event
{
// Do nothing, avoiding the beep we'd otherwise get from NSResponder,
// once we get to the end of the responder chain.
diff --git a/WebKitTools/DumpRenderTree/mac/EventSendingController.mm b/WebKitTools/DumpRenderTree/mac/EventSendingController.mm
index 73831ff..9d2fc75 100644
--- a/WebKitTools/DumpRenderTree/mac/EventSendingController.mm
+++ b/WebKitTools/DumpRenderTree/mac/EventSendingController.mm
@@ -598,7 +598,7 @@ static int buildModifierFlags(const WebScriptObject* modifiers)
eventCharacter = [NSString stringWithCharacters:&ch length:1];
keyCode = 0x77;
} else if ([character isEqualToString:@"delete"]) {
- const unichar ch = 0x7f;
+ const unichar ch = NSDeleteFunctionKey;
eventCharacter = [NSString stringWithCharacters:&ch length:1];
keyCode = 0x75;
}
diff --git a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
index eb01090..d0599e0 100644
--- a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
+++ b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
@@ -212,6 +212,29 @@ int LayoutTestController::pageNumberForElementById(JSStringRef id, float pageWid
return [mainFrame pageNumberForElement:element:pageWidthInPixels:pageHeightInPixels];
}
+JSRetainPtr<JSStringRef> LayoutTestController::pageProperty(const char* propertyName, int pageNumber) const
+{
+ JSRetainPtr<JSStringRef> propertyValue(Adopt, JSStringCreateWithCFString((CFStringRef)[mainFrame pageProperty:propertyName:pageNumber]));
+ return propertyValue;
+}
+
+bool LayoutTestController::isPageBoxVisible(int pageNumber) const
+{
+ return [mainFrame isPageBoxVisible:pageNumber];
+}
+
+JSRetainPtr<JSStringRef> LayoutTestController::pageAreaRectInPixels(int pageNumber) const
+{
+ JSRetainPtr<JSStringRef> propertyValue(Adopt, JSStringCreateWithCFString((CFStringRef)[mainFrame pageAreaRectInPixels:pageNumber]));
+ return propertyValue;
+}
+
+JSRetainPtr<JSStringRef> LayoutTestController::preferredPageSizeInPixels(int pageNumber) const
+{
+ JSRetainPtr<JSStringRef> propertyValue(Adopt, JSStringCreateWithCFString((CFStringRef)[mainFrame preferredPageSizeInPixels:pageNumber]));
+ return propertyValue;
+}
+
int LayoutTestController::numberOfPages(float pageWidthInPixels, float pageHeightInPixels)
{
return [mainFrame numberOfPages:pageWidthInPixels:pageHeightInPixels];
@@ -487,9 +510,9 @@ int LayoutTestController::windowCount()
return CFArrayGetCount(openWindowsRef);
}
-bool LayoutTestController::elementDoesAutoCompleteForElementWithId(JSStringRef id)
+bool LayoutTestController::elementDoesAutoCompleteForElementWithId(JSStringRef jsString)
{
- RetainPtr<CFStringRef> idCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, id));
+ RetainPtr<CFStringRef> idCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, jsString));
NSString *idNS = (NSString *)idCF.get();
DOMElement *element = [[mainFrame DOMDocument] getElementById:idNS];
@@ -520,7 +543,7 @@ void LayoutTestController::setCacheModel(int cacheModel)
bool LayoutTestController::isCommandEnabled(JSStringRef name)
{
RetainPtr<CFStringRef> nameCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, name));
- NSString *nameNS = reinterpret_cast<const NSString *>(nameCF.get());
+ NSString *nameNS = (NSString *)nameCF.get();
// Accept command strings with capital letters for first letter without trailing colon.
if (![nameNS hasSuffix:@":"] && [nameNS length]) {
@@ -860,3 +883,8 @@ void LayoutTestController::setEditingBehavior(const char* editingBehavior)
[[WebPreferences standardPreferences] setEditingBehavior:WebKitEditingWinBehavior];
[editingBehaviorNS release];
}
+
+void LayoutTestController::abortModal()
+{
+ [NSApp abortModal];
+}
diff --git a/WebKitTools/DumpRenderTree/mac/UIDelegate.mm b/WebKitTools/DumpRenderTree/mac/UIDelegate.mm
index e6754c1..83bf0c6 100644
--- a/WebKitTools/DumpRenderTree/mac/UIDelegate.mm
+++ b/WebKitTools/DumpRenderTree/mac/UIDelegate.mm
@@ -67,6 +67,20 @@ DumpRenderTreeDraggingInfo *draggingInfo = nil;
printf ("CONSOLE MESSAGE: line %d: %s\n", [lineNumber intValue], [message UTF8String]);
}
+- (void)modalWindowWillClose:(NSNotification *)notification
+{
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowWillCloseNotification object:nil];
+ [NSApp abortModal];
+}
+
+- (void)webViewRunModal:(WebView *)sender
+{
+ gLayoutTestController->setWindowIsKey(false);
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(modalWindowWillClose:) name:NSWindowWillCloseNotification object:nil];
+ [NSApp runModalForWindow:[sender window]];
+ gLayoutTestController->setWindowIsKey(true);
+}
+
- (void)webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame
{
if (!done)
diff --git a/WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp b/WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp
index 7ec505f..5f340e9 100644
--- a/WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp
+++ b/WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp
@@ -191,11 +191,23 @@ void EventSender::continuousMouseScrollBy(int x, int y)
// continuousMouseScrollBy() mimics devices that send fine-grained scroll events where the 'delta' specified is not the usual
// multiple of 120. See http://doc.qt.nokia.com/4.6/qwheelevent.html#delta for a good explanation of this.
if (x) {
- QWheelEvent* event = new QWheelEvent(m_mousePos, m_mousePos, x, m_mouseButtons, Qt::NoModifier, Qt::Horizontal);
+ QEvent* event;
+ if (isGraphicsBased()) {
+ event = createGraphicsSceneWheelEvent(QEvent::GraphicsSceneWheel,
+ m_mousePos, m_mousePos, x, Qt::NoModifier, Qt::Horizontal);
+ } else
+ event = new QWheelEvent(m_mousePos, m_mousePos, x, m_mouseButtons, Qt::NoModifier, Qt::Horizontal);
+
sendOrQueueEvent(event);
}
if (y) {
- QWheelEvent* event = new QWheelEvent(m_mousePos, m_mousePos, y, m_mouseButtons, Qt::NoModifier, Qt::Vertical);
+ QEvent* event;
+ if (isGraphicsBased()) {
+ event = createGraphicsSceneWheelEvent(QEvent::GraphicsSceneWheel,
+ m_mousePos, m_mousePos, y, Qt::NoModifier, Qt::Vertical);
+ } else
+ event = new QWheelEvent(m_mousePos, m_mousePos, y, m_mouseButtons, Qt::NoModifier, Qt::Vertical);
+
sendOrQueueEvent(event);
}
}
@@ -339,8 +351,18 @@ void EventSender::contextClick()
sendEvent(m_page, &event);
QMouseEvent event2(QEvent::MouseButtonRelease, m_mousePos, Qt::RightButton, Qt::RightButton, Qt::NoModifier);
sendEvent(m_page, &event2);
- QContextMenuEvent event3(QContextMenuEvent::Mouse, m_mousePos);
- sendEvent(m_page->view(), &event3);
+
+ if (isGraphicsBased()) {
+ QGraphicsSceneContextMenuEvent ctxEvent(QEvent::GraphicsSceneContextMenu);
+ ctxEvent.setReason(QGraphicsSceneContextMenuEvent::Mouse);
+ ctxEvent.setPos(m_mousePos);
+ WebCore::WebViewGraphicsBased* view = qobject_cast<WebCore::WebViewGraphicsBased*>(m_page->view());
+ if (view)
+ sendEvent(view->graphicsView(), &ctxEvent);
+ } else {
+ QContextMenuEvent ctxEvent(QContextMenuEvent::Mouse, m_mousePos);
+ sendEvent(m_page->view(), &ctxEvent);
+ }
}
void EventSender::scheduleAsynchronousClick()
@@ -601,6 +623,19 @@ QGraphicsSceneMouseEvent* EventSender::createGraphicsSceneMouseEvent(QEvent::Typ
return event;
}
+QGraphicsSceneWheelEvent* EventSender::createGraphicsSceneWheelEvent(QEvent::Type type, const QPoint& pos, const QPoint& screenPos, int delta, Qt::KeyboardModifiers modifiers, Qt::Orientation orientation)
+{
+ QGraphicsSceneWheelEvent* event;
+ event = new QGraphicsSceneWheelEvent(type);
+ event->setPos(pos);
+ event->setScreenPos(screenPos);
+ event->setDelta(delta);
+ event->setModifiers(modifiers);
+ event->setOrientation(orientation);
+
+ return event;
+}
+
void EventSender::sendEvent(QObject* receiver, QEvent* event)
{
if (WebCore::WebViewGraphicsBased* view = qobject_cast<WebCore::WebViewGraphicsBased*>(receiver))
diff --git a/WebKitTools/DumpRenderTree/qt/EventSenderQt.h b/WebKitTools/DumpRenderTree/qt/EventSenderQt.h
index 51c8325..c2ff746 100644
--- a/WebKitTools/DumpRenderTree/qt/EventSenderQt.h
+++ b/WebKitTools/DumpRenderTree/qt/EventSenderQt.h
@@ -88,6 +88,7 @@ protected:
private:
bool isGraphicsBased() const { return qobject_cast<WebCore::WebViewGraphicsBased*>(m_page->view()); }
QGraphicsSceneMouseEvent* createGraphicsSceneMouseEvent(QEvent::Type, const QPoint& pos, const QPoint& screenPos, Qt::MouseButton, Qt::MouseButtons, Qt::KeyboardModifiers);
+ QGraphicsSceneWheelEvent* createGraphicsSceneWheelEvent(QEvent::Type, const QPoint& pos, const QPoint& screenPos, int delta, Qt::KeyboardModifiers, Qt::Orientation);
void sendEvent(QObject* receiver, QEvent* event);
private:
diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp
index 8450376..3cced7d 100644
--- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp
+++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp
@@ -35,6 +35,7 @@
#include "WorkQueueItemQt.h"
#include <QDir>
#include <QLocale>
+#include <qwebscriptworld.h>
#include <qwebsettings.h>
LayoutTestController::LayoutTestController(WebCore::DumpRenderTree* drt)
@@ -662,5 +663,19 @@ void LayoutTestController::setMockGeolocationPosition(double latitude, double lo
DumpRenderTreeSupportQt::setMockGeolocationPosition(latitude, longitude, accuracy);
}
+void LayoutTestController::evaluateScriptInIsolatedWorld(int worldID, const QString& script)
+{
+ QWebScriptWorld* scriptWorld;
+ if (!worldID) {
+ scriptWorld = new QWebScriptWorld();
+ } else if (!m_worldMap.contains(worldID)) {
+ scriptWorld = new QWebScriptWorld();
+ m_worldMap.insert(worldID, scriptWorld);
+ } else
+ scriptWorld = m_worldMap.value(worldID);
+
+ m_drt->webPage()->mainFrame()->evaluateScriptInIsolatedWorld(scriptWorld, script);
+}
+
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 a041ad0..b56f1c9 100644
--- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h
+++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h
@@ -183,6 +183,10 @@ public slots:
// For now, this is a no-op. This may change depending on outcome of
// https://bugs.webkit.org/show_bug.cgi?id=33333
void setCallCloseOnWebViews() {}
+ // This is a no-op - it allows us to pass
+ // plugins/get-url-that-the-resource-load-delegate-will-disallow.html
+ // which is a Mac-specific test.
+ void addDisallowedURL(const QString&) {}
void setMockGeolocationError(int code, const QString& message);
void setMockGeolocationPosition(double latitude, double longitude, double accuracy);
@@ -204,6 +208,8 @@ public slots:
void setEditingBehavior(const QString& editingBehavior);
+ void evaluateScriptInIsolatedWorld(int worldID, const QString& script);
+
private slots:
void processWork();
@@ -224,6 +230,7 @@ private:
bool m_isGeolocationPermissionSet;
bool m_geolocationPermission;
+ QMap<int, QWebScriptWorld*> m_worldMap;
QUrl m_userStyleSheetLocation;
QBasicTimer m_timeoutTimer;
QWebFrame* m_topLoadingFrame;
diff --git a/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp
index 1ed54d5..451ff86 100644
--- a/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp
+++ b/WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp
@@ -104,7 +104,7 @@ COMPtr<HistoryDelegate> sharedHistoryDelegate;
IWebFrame* frame;
HWND webViewWindow;
-LayoutTestController* gLayoutTestController = 0;
+RefPtr<LayoutTestController> gLayoutTestController;
UINT_PTR waitToDumpWatchdog = 0;
@@ -140,17 +140,27 @@ wstring urlSuitableForTestResult(const wstring& url)
return PathFindFileNameW(url.c_str());
}
-string toUTF8(BSTR bstr)
+static string toUTF8(const wchar_t* wideString, size_t length)
{
- int result = WideCharToMultiByte(CP_UTF8, 0, bstr, SysStringLen(bstr) + 1, 0, 0, 0, 0);
+ int result = WideCharToMultiByte(CP_UTF8, 0, wideString, length + 1, 0, 0, 0, 0);
Vector<char> utf8Vector(result);
- result = WideCharToMultiByte(CP_UTF8, 0, bstr, SysStringLen(bstr) + 1, utf8Vector.data(), result, 0, 0);
+ result = WideCharToMultiByte(CP_UTF8, 0, wideString, length + 1, utf8Vector.data(), result, 0, 0);
if (!result)
return string();
return string(utf8Vector.data(), utf8Vector.size() - 1);
}
+string toUTF8(BSTR bstr)
+{
+ return toUTF8(bstr, SysStringLen(bstr));
+}
+
+string toUTF8(const wstring& wideString)
+{
+ return toUTF8(wideString.c_str(), wideString.length());
+}
+
static LRESULT CALLBACK DumpRenderTreeWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
@@ -687,7 +697,7 @@ void dump()
COMPtr<IWebFramePrivate> framePrivate;
if (FAILED(frame->QueryInterface(&framePrivate)))
goto fail;
- framePrivate->renderTreeAsExternalRepresentation(&resultString);
+ framePrivate->renderTreeAsExternalRepresentation(gLayoutTestController->isPrinting(), &resultString);
}
if (!resultString)
@@ -903,7 +913,7 @@ static void runTest(const string& testPathOrURL)
CFRelease(url);
- ::gLayoutTestController = new LayoutTestController(pathOrURL, expectedPixelHash);
+ ::gLayoutTestController = LayoutTestController::create(pathOrURL, expectedPixelHash);
done = false;
topLoadingFrame = 0;
@@ -994,8 +1004,7 @@ static void runTest(const string& testPathOrURL)
exit:
SysFreeString(urlBStr);
- ::gLayoutTestController->deref();
- ::gLayoutTestController = 0;
+ ::gLayoutTestController.clear();
return;
}
diff --git a/WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h b/WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h
index eb5d312..cc4337b 100644
--- a/WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h
+++ b/WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h
@@ -50,6 +50,7 @@ extern HWND webViewWindow;
std::wstring urlSuitableForTestResult(const std::wstring& url);
std::string toUTF8(BSTR);
+std::string toUTF8(const std::wstring&);
IWebView* createWebViewAndOffscreenWindow(HWND* webViewWindow = 0);
Vector<HWND>& openWindows();
typedef HashMap<HWND, COMPtr<IWebView> > WindowToWebViewMap;
diff --git a/WebKitTools/DumpRenderTree/win/EventSender.cpp b/WebKitTools/DumpRenderTree/win/EventSender.cpp
index 2a36d8d..c9749e7 100644
--- a/WebKitTools/DumpRenderTree/win/EventSender.cpp
+++ b/WebKitTools/DumpRenderTree/win/EventSender.cpp
@@ -468,7 +468,7 @@ static JSValueRef keyDownCallback(JSContextRef context, JSObjectRef function, JS
else if (JSStringIsEqualToUTF8CString(character, "end"))
virtualKeyCode = VK_END;
else if (JSStringIsEqualToUTF8CString(character, "delete"))
- virtualKeyCode = VK_BACK;
+ virtualKeyCode = VK_DELETE;
else {
charCode = JSStringGetCharactersPtr(character)[0];
virtualKeyCode = LOBYTE(VkKeyScan(charCode));
diff --git a/WebKitTools/DumpRenderTree/win/ImageDiff.vcproj b/WebKitTools/DumpRenderTree/win/ImageDiff.vcproj
index 73d541b..361069a 100644
--- a/WebKitTools/DumpRenderTree/win/ImageDiff.vcproj
+++ b/WebKitTools/DumpRenderTree/win/ImageDiff.vcproj
@@ -51,7 +51,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="CoreGraphics$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib"
+ AdditionalDependencies="JavaScriptCore$(WebKitDLLConfigSuffix).lib CoreGraphics$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib"
AdditionalLibraryDirectories=""
SubSystem="1"
/>
@@ -119,7 +119,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="CoreGraphics$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib"
+ AdditionalDependencies="JavaScriptCore$(WebKitDLLConfigSuffix).lib CoreGraphics$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib"
AdditionalLibraryDirectories=""
SubSystem="1"
/>
@@ -186,7 +186,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="CoreGraphics$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib"
+ AdditionalDependencies="JavaScriptCore$(WebKitDLLConfigSuffix).lib CoreGraphics$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib"
AdditionalLibraryDirectories=""
SubSystem="1"
/>
@@ -253,7 +253,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="CoreGraphics$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib"
+ AdditionalDependencies="JavaScriptCore$(WebKitDLLConfigSuffix).lib CoreGraphics$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib"
AdditionalLibraryDirectories=""
SubSystem="1"
/>
diff --git a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
index c70b517..e0d5731 100644
--- a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
+++ b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
@@ -1237,11 +1237,35 @@ int LayoutTestController::numberOfPages(float pageWidthInPixels, float pageHeigh
return pageNumber;
}
+JSRetainPtr<JSStringRef> LayoutTestController::pageProperty(const char* propertyName, int pageNumber) const
+{
+ // FIXME: Implement this.
+ return JSRetainPtr<JSStringRef>();
+}
+
void LayoutTestController::apiTestNewWindowDataLoadBaseURL(JSStringRef utf8Data, JSStringRef baseURL)
{
}
+bool LayoutTestController::isPageBoxVisible(int pageNumber) const
+{
+ // FIXME: implement
+ return false;
+}
+
+JSRetainPtr<JSStringRef> LayoutTestController::pageAreaRectInPixels(int pageNumber) const
+{
+ // FIXME: implement
+ return JSRetainPtr<JSStringRef>();
+}
+
+JSRetainPtr<JSStringRef> LayoutTestController::preferredPageSizeInPixels(int pageNumber) const
+{
+ // FIXME: implement
+ return JSRetainPtr<JSStringRef>();
+}
+
void LayoutTestController::apiTestGoToCurrentBackForwardItem()
{
COMPtr<IWebView> webView;
diff --git a/WebKitTools/DumpRenderTree/win/TestNetscapePlugin/main.cpp b/WebKitTools/DumpRenderTree/win/TestNetscapePlugin/main.cpp
index 321d9cf..24c6304 100644
--- a/WebKitTools/DumpRenderTree/win/TestNetscapePlugin/main.cpp
+++ b/WebKitTools/DumpRenderTree/win/TestNetscapePlugin/main.cpp
@@ -142,7 +142,7 @@ NPError NPP_Destroy(NPP instance, NPSavedData **save)
}
if (obj->logDestroy)
- pluginLog(instance, "NPP_Destroy\n");
+ pluginLog(instance, "NPP_Destroy");
if (obj->onSetWindow)
free(obj->onSetWindow);
diff --git a/WebKitTools/DumpRenderTree/win/UIDelegate.cpp b/WebKitTools/DumpRenderTree/win/UIDelegate.cpp
index 6637068..519b9e1 100755
--- a/WebKitTools/DumpRenderTree/win/UIDelegate.cpp
+++ b/WebKitTools/DumpRenderTree/win/UIDelegate.cpp
@@ -485,7 +485,7 @@ HRESULT STDMETHODCALLTYPE UIDelegate::webViewAddMessageToConsole(
newMessage = newMessage.substr(0, fileProtocol) + urlSuitableForTestResult(newMessage.substr(fileProtocol));
}
- printf("CONSOLE MESSAGE: line %d: %S\n", lineNumber, newMessage.c_str());
+ printf("CONSOLE MESSAGE: line %d: %s\n", lineNumber, toUTF8(newMessage).c_str());
return S_OK;
}
diff --git a/WebKitTools/DumpRenderTree/wx/DumpRenderTreeWx.cpp b/WebKitTools/DumpRenderTree/wx/DumpRenderTreeWx.cpp
index f905786..c56f129 100644
--- a/WebKitTools/DumpRenderTree/wx/DumpRenderTreeWx.cpp
+++ b/WebKitTools/DumpRenderTree/wx/DumpRenderTreeWx.cpp
@@ -58,7 +58,7 @@ using namespace std;
FILE* logOutput;
-LayoutTestController* gLayoutTestController = 0;
+RefPtr<LayoutTestController> gLayoutTestController;
static wxWebView* webView;
static wxTimer* idleTimer;
@@ -215,8 +215,7 @@ void dump()
fflush(stdout);
fflush(stderr);
- gLayoutTestController->deref();
- gLayoutTestController = 0;
+ gLayoutTestController.clear();
}
static void runTest(const wxString testPathOrURL)
@@ -238,7 +237,7 @@ static void runTest(const wxString testPathOrURL)
if (http == string::npos)
pathOrURL.insert(0, "file://");
- gLayoutTestController = new LayoutTestController(pathOrURL, expectedPixelHash);
+ gLayoutTestController = LayoutTestController::create(pathOrURL, expectedPixelHash);
if (!gLayoutTestController) {
wxTheApp->ExitMainLoop();
}
@@ -337,9 +336,6 @@ bool MyApp::OnInit()
delete logger;
fclose(logOutput);
- delete gLayoutTestController;
- gLayoutTestController = 0;
-
// returning false shuts the app down
return false;
}
diff --git a/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp b/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp
index 265802d..90ddea8 100644
--- a/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp
+++ b/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp
@@ -451,3 +451,26 @@ void LayoutTestController::setEditingBehavior(const char* editingBehavior)
{
// FIXME: Implement
}
+
+JSRetainPtr<JSStringRef> LayoutTestController::pageProperty(const char* propertyName, int pageNumber) const
+{
+
+}
+
+bool LayoutTestController::isPageBoxVisible(int pageNumber) const
+{
+ // FIXME: Implement
+ return true;
+}
+
+JSRetainPtr<JSStringRef> LayoutTestController::pageAreaRectInPixels(int pageNumber) const
+{
+ // FIXME: Implement
+ return 0;
+}
+
+JSRetainPtr<JSStringRef> LayoutTestController::preferredPageSizeInPixels(int pageNumber) const
+{
+ // FIXME: Implement
+ return 0;
+}