Commit b4d68057 authored by alp@webkit.org's avatar alp@webkit.org

2007-12-04 Xan Lopez <xan@gnome.org>

        Reviewed by Alp Toker.

        http://bugs.webkit.org/show_bug.cgi?id=15561
        GTK port needs DumpRenderTree implementation

        Start work on the GTK+ DRT.

        This does not work yet, and there are a few lingering style issues
        (nothing major) but this patch has been stuck in the bug tracker for
        too long already.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@28384 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f81c15cf
2007-12-04 Xan Lopez <xan@gnome.org>
Reviewed by Alp Toker.
http://bugs.webkit.org/show_bug.cgi?id=15561
GTK port needs DumpRenderTree implementation
Start work on the GTK+ DRT.
* WebKit.pro:
2007-11-30 Alp Toker <alp@atoker.com>
Reviewed by Adam Roben.
......
......@@ -14,4 +14,5 @@ qt-port {
}
gtk-port:SUBDIRS += \
WebKitTools/GtkLauncher
WebKitTools/GtkLauncher \
WebKitTools/DumpRenderTree/gtk/DumpRenderTree.pro
2007-12-04 Xan Lopez <xan@gnome.org>
Reviewed by Alp Toker.
http://bugs.webkit.org/show_bug.cgi?id=15561
GTK port needs DumpRenderTree implementation
Start work on the GTK+ DRT.
Add a couple of proposed new API entry points. They are currently for
internal use only by DRT and not in the public headers.
* WebView/webkitprivate.h:
* WebView/webkitwebframe.cpp:
2007-12-03 Dan Bernstein <mitz@apple.com>
Reviewed by Dave Hyatt.
......
......@@ -35,6 +35,7 @@
* They are using WebCore which musn't be exposed to the outer world.
*/
#include "webkitdefines.h"
#include "webkitsettings.h"
#include "webkitwebview.h"
#include "webkitwebframe.h"
......@@ -91,6 +92,16 @@ extern "C" {
};
WebKitWebFrame* webkit_web_frame_init_with_web_view(WebKitWebView*, WebCore::HTMLFrameOwnerElement*);
// TODO: Move these to webkitwebframe.h once these functions are fully
// implemented and their API has been discussed.
WEBKIT_API GSList*
webkit_web_frame_get_children (WebKitWebFrame* frame);
WEBKIT_API gchar*
webkit_web_frame_get_inner_text (WebKitWebFrame* frame);
}
#endif
......@@ -385,4 +385,48 @@ JSGlobalContextRef webkit_web_frame_get_global_context(WebKitWebFrame* frame)
return toGlobalRef(coreFrame->scriptProxy()->globalObject()->globalExec());
}
/**
* webkit_web_frame_get_children:
* @frame: a #WebKitWebFrame
*
* Return value: child frames of @frame
*/
GSList* webkit_web_frame_get_children(WebKitWebFrame* frame)
{
g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL);
GSList* children = NULL;
Frame* coreFrame = core(frame);
for (Frame* child = coreFrame->tree()->firstChild(); child; child = child->tree()->nextSibling()) {
FrameLoader* loader = child->loader();
WebKit::FrameLoaderClient* client = static_cast<WebKit::FrameLoaderClient*>(loader->client());
if (client)
children = g_slist_append(children, client->webFrame());
}
return children;
}
/**
* webkit_web_frame_get_inner_text:
* @frame: a #WebKitWebFrame
*
* Return value: inner text of @frame
*/
gchar* webkit_web_frame_get_inner_text(WebKitWebFrame* frame)
{
g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL);
Frame* coreFrame = core(frame);
FrameView* view = coreFrame->view();
if (view->layoutPending())
view->layout();
Element* documentElement = coreFrame->document()->documentElement();
String string = documentElement->innerText();
return g_strdup(string.utf8().data());
}
}
2007-12-04 Xan Lopez <xan@gnome.org>
Reviewed by Alp Toker.
http://bugs.webkit.org/show_bug.cgi?id=15561
GTK port needs DumpRenderTree implementation
Start work on the GTK+ DRT.
This does not work yet, and there are a few lingering style issues
(nothing major) but this patch has been stuck in the bug tracker for
too long already.
* DumpRenderTree/DumpRenderTree.h:
* DumpRenderTree/gtk: Added.
* DumpRenderTree/gtk/DumpRenderTree.cpp: Added.
(autocorrectURL):
(shouldLogFrameLoadDelegates):
(dumpFrameScrollPosition):
(displayWebView):
(appendString):
(dumpFramesAsText):
(dumpRenderTreeAsText):
(dump):
(runTest):
(main):
* DumpRenderTree/gtk/DumpRenderTree.pro: Added.
* DumpRenderTree/gtk/DumpRenderTreeGtk.h: Added.
* DumpRenderTree/gtk/GCControllerGtk.cpp: Added.
(GCController::collect):
(GCController::collectOnAlternateThread):
(GCController::getJSObjectCount):
* DumpRenderTree/gtk/LayoutTestControllerGtk.cpp: Added.
(LayoutTestController::~LayoutTestController):
(LayoutTestController::addDisallowedURL):
(LayoutTestController::clearBackForwardList):
(LayoutTestController::copyDecodedHostName):
(LayoutTestController::copyEncodedHostName):
(LayoutTestController::display):
(LayoutTestController::keepWebHistory):
(LayoutTestController::notifyDone):
(LayoutTestController::queueBackNavigation):
(LayoutTestController::queueForwardNavigation):
(LayoutTestController::queueLoad):
(LayoutTestController::queueReload):
(LayoutTestController::queueScript):
(LayoutTestController::setAcceptsEditing):
(LayoutTestController::setCustomPolicyDelegate):
(LayoutTestController::setMainFrameIsFirstResponder):
(LayoutTestController::setTabKeyCyclesThroughElements):
(LayoutTestController::setUseDashboardCompatibilityMode):
(LayoutTestController::setUserStyleSheetEnabled):
(LayoutTestController::setUserStyleSheetLocation):
(LayoutTestController::setWindowIsKey):
(LayoutTestController::setWaitToDump):
(LayoutTestController::windowCount):
(LayoutTestController::setPrivateBrowsingEnabled):
(LayoutTestController::setAuthorAndUserStylesEnabled):
* DumpRenderTree/gtk/WorkQueueItemGtk.cpp: Added.
(JSStringCopyUTF8CString):
(LoadItem::invoke):
(ReloadItem::invoke):
(ScriptItem::invoke):
(BackForwardItem::invoke):
2007-12-03 Sam Weinig <sam@webkit.org>
Move JavaScriptCore thread testing code to pthread specific directory
......
......@@ -33,18 +33,21 @@
#if PLATFORM(MAC)
#include "DumpRenderTreeMac.h"
#else if PLATFORM(WIN)
#elif PLATFORM(WIN)
#include "DumpRenderTreeWin.h"
#elif PLATFORM(GTK)
#include "DumpRenderTreeGtk.h"
#endif
#if PLATFORM(CF)
#include <CoreFoundation/CoreFoundation.h>
extern CFRunLoopTimerRef waitToDumpWatchdog;
#endif
class LayoutTestController;
extern volatile bool done;
extern CFRunLoopTimerRef waitToDumpWatchdog;
// FIXME: This is a bad abstraction. We should insted pass this to other controller objects which need access to it.
extern LayoutTestController* layoutTestController;
......
/*
* Copyright (C) 2007 Eric Seidel <eric@webkit.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT falseT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN false EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT falseT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "webkitwebframe.h"
#include "webkitwebview.h"
#include <gtk/gtk.h>
#include <string.h>
#include <JavaScriptCore/JSBase.h>
#include <JavaScriptCore/JSContextRef.h>
#include <JavaScriptCore/JSStringRef.h>
#include <JavaScriptCore/JSObjectRef.h>
#include <JavaScriptCore/JSValueRef.h>
#include "LayoutTestController.h"
#include "WorkQueue.h"
#include "WorkQueueItem.h"
#include <getopt.h>
#include <stdlib.h>
extern "C" {
// This API is not yet public.
extern GSList* webkit_web_frame_get_children(WebKitWebFrame* frame);
extern gchar* webkit_web_frame_get_inner_text(WebKitWebFrame* frame);
}
volatile bool done;
static bool printSeparators;
static int testRepaintDefault;
static int repaintSweepHorizontallyDefault;
static int dumpPixels;
static int dumpTree;
static gchar* currentTest;
LayoutTestController* layoutTestController = 0;
static WebKitWebView* view;
WebKitWebFrame* mainFrame = 0;
const unsigned maxViewHeight = 600;
const unsigned maxViewWidth = 800;
static gchar* autocorrectURL(const gchar* url)
{
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/");
}
void dumpFrameScrollPosition(WebKitWebFrame* frame)
{
}
void displayWebView()
{
}
static void appendString(gchar*& target, gchar* string)
{
gchar* oldString = target;
target = g_strconcat(target, string, NULL);
g_free(oldString);
}
static gchar* dumpFramesAsText(WebKitWebFrame* frame)
{
gchar* result = 0;
// Add header for all but the main frame.
bool isMainFrame = (webkit_web_view_get_main_frame(view) == frame);
if (isMainFrame) {
const gchar* frameName = webkit_web_frame_get_name(frame);
gchar* innerText = webkit_web_frame_get_inner_text(frame);
result = g_strdup_printf("\n--------\nFrame: '%s'\n--------\n%s", frameName, innerText);
g_free(innerText);
}
if (layoutTestController->dumpChildFramesAsText()) {
GSList* children = webkit_web_frame_get_children(frame);
for (;children; children = g_slist_next(children))
appendString(result, dumpFramesAsText((WebKitWebFrame*)children->data));
}
return result;
}
static gchar* dumpRenderTreeAsText(WebKitWebFrame* frame)
{
// FIXME: this will require new WebKitGtk SPI
return strdup("foo");
}
void dump()
{
if (dumpTree) {
char* result = 0;
bool dumpAsText = layoutTestController->dumpAsText();
// FIXME: Also dump text resuls as text.
layoutTestController->setDumpAsText(dumpAsText);
if (layoutTestController->dumpAsText())
result = dumpFramesAsText(mainFrame);
else {
bool isSVGW3CTest = (g_strrstr(currentTest, "svg/W3C-SVG-1.1"));
if (isSVGW3CTest)
gtk_widget_set_size_request(GTK_WIDGET(view), 480, 360);
else
gtk_widget_set_size_request(GTK_WIDGET(view), maxViewWidth, maxViewHeight);
result = dumpRenderTreeAsText(mainFrame);
}
if (!result) {
const char* errorMessage;
if (layoutTestController->dumpAsText())
errorMessage = "[documentElement innerText]";
else if (layoutTestController->dumpDOMAsWebArchive())
errorMessage = "[[mainFrame DOMDocument] webArchive]";
else if (layoutTestController->dumpSourceAsWebArchive())
errorMessage = "[[mainFrame dataSource] webArchive]";
else
errorMessage = "[mainFrame renderTreeAsExternalRepresentation]";
printf("ERROR: nil result from %s", errorMessage);
} else {
printf("%s", result);
g_free(result);
if (!layoutTestController->dumpAsText() && !layoutTestController->dumpDOMAsWebArchive() && !layoutTestController->dumpSourceAsWebArchive())
dumpFrameScrollPosition(mainFrame);
}
if (layoutTestController->dumpBackForwardList()) {
// FIXME: not implemented
}
if (printSeparators)
puts("#EOF");
}
if (dumpPixels) {
if (!layoutTestController->dumpAsText() && !layoutTestController->dumpDOMAsWebArchive() && !layoutTestController->dumpSourceAsWebArchive()) {
// FIXME: Add support for dumping pixels
}
}
fflush(stdout);
// FIXME: call displayWebView here when we support --paint
done = true;
}
static void runTest(const char* pathOrURL)
{
gchar* url = autocorrectURL(pathOrURL);
layoutTestController = new LayoutTestController(testRepaintDefault, repaintSweepHorizontallyDefault);
done = false;
if (shouldLogFrameLoadDelegates(pathOrURL))
layoutTestController->setDumpFrameLoadCallbacks(true);
if (currentTest)
g_free(currentTest);
currentTest = url;
WorkQueue::shared()->clear();
WorkQueue::shared()->setFrozen(false);
webkit_web_view_open(view, url);
while (!done)
g_main_context_iteration(NULL, true);
WorkQueue::shared()->clear();
delete layoutTestController;
layoutTestController = 0;
}
int main(int argc, char* argv[])
{
struct option options[] = {
{"horizontal-sweep", no_argument, &repaintSweepHorizontallyDefault, true},
{"notree", no_argument, &dumpTree, false},
{"pixel-tests", no_argument, &dumpPixels, true},
{"repaint", no_argument, &testRepaintDefault, true},
{"tree", no_argument, &dumpTree, true},
{NULL, 0, NULL, 0}
};
int option;
while ((option = getopt_long(argc, (char* const*)argv, "", options, NULL)) != -1)
switch (option) {
case '?': // unknown or ambiguous option
case ':': // missing argument
exit(1);
break;
}
view = WEBKIT_WEB_VIEW(webkit_web_view_new());
mainFrame = webkit_web_view_get_main_frame(view);
if (argc == optind+1 && strcmp(argv[optind], "-") == 0) {
char filenameBuffer[2048];
printSeparators = true;
while (fgets(filenameBuffer, sizeof(filenameBuffer), stdin)) {
char* newLineCharacter = strchr(filenameBuffer, '\n');
if (newLineCharacter)
*newLineCharacter = '\0';
if (strlen(filenameBuffer) == 0)
continue;
runTest(filenameBuffer);
}
} else {
printSeparators = (optind < argc-1 || (dumpPixels && dumpTree));
for (int i = optind; i != argc; ++i)
runTest(argv[i]);
}
return 0;
}
TEMPLATE = app
SOURCES += DumpRenderTree.cpp \
../LayoutTestController.cpp \
../GCController.cpp \
../WorkQueue.cpp \
GCControllerGtk.cpp \
LayoutTestControllerGtk.cpp \
WorkQueueItemGtk.cpp
CONFIG -= app_bundle
BASE_DIR = $$PWD/../../..
include(../../../WebKit.pri)
INCLUDEPATH += \
$$BASE_DIR/WebKitTools/DumpRenderTree
QMAKE_RPATHDIR += $$OUTPUT_DIR/lib
/*
* Copyright (C) 2007 Eric Seidel <eric@webkit.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef DumpRenderTreeGtk_h
#define DumpRenderTreeGtk_h
#include "webkitdefines.h"
extern WebKitWebFrame* mainFrame;
#endif // DumpRenderTreeGtk_h
/*
* Copyright (C) 2007 Eric Seidel <eric@webkit.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "GCController.h"
void GCController::collect() const
{
}
void GCController::collectOnAlternateThread(bool waitUntilDone) const
{
}
size_t GCController::getJSObjectCount() const
{
return 0;
}
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
* Copyright (C) 2007 Eric Seidel <eric@webkit.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "LayoutTestController.h"
#include "DumpRenderTree.h"
#include "WorkQueue.h"
#include "WorkQueueItem.h"
#include <JavaScriptCore/JSRetainPtr.h>
#include <JavaScriptCore/JSStringRef.h>
LayoutTestController::~LayoutTestController()
{
// FIXME: implement
}
void LayoutTestController::addDisallowedURL(JSStringRef url)
{
// FIXME: implement
}
void LayoutTestController::clearBackForwardList()
{
// FIXME: implement
}
JSStringRef LayoutTestController::copyDecodedHostName(JSStringRef name)
{
// FIXME: implement
return 0;
}
JSStringRef LayoutTestController::copyEncodedHostName(JSStringRef name)