summaryrefslogtreecommitdiffstats
path: root/WebKitTools/DumpRenderTree/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'WebKitTools/DumpRenderTree/gtk')
-rw-r--r--WebKitTools/DumpRenderTree/gtk/AccessibilityControllerGtk.cpp6
-rw-r--r--WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp102
-rw-r--r--WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp65
-rw-r--r--WebKitTools/DumpRenderTree/gtk/EventSender.cpp34
-rw-r--r--WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp35
-rw-r--r--WebKitTools/DumpRenderTree/gtk/TestNetscapePlugin/ForwardingHeaders/WebKit/npapi.h1
-rw-r--r--WebKitTools/DumpRenderTree/gtk/TestNetscapePlugin/ForwardingHeaders/WebKit/npfunctions.h1
-rw-r--r--WebKitTools/DumpRenderTree/gtk/TestNetscapePlugin/ForwardingHeaders/WebKit/npruntime.h1
-rw-r--r--WebKitTools/DumpRenderTree/gtk/TestNetscapePlugin/TestNetscapePlugin.cpp316
9 files changed, 215 insertions, 346 deletions
diff --git a/WebKitTools/DumpRenderTree/gtk/AccessibilityControllerGtk.cpp b/WebKitTools/DumpRenderTree/gtk/AccessibilityControllerGtk.cpp
index 593f2eb..df06cea 100644
--- a/WebKitTools/DumpRenderTree/gtk/AccessibilityControllerGtk.cpp
+++ b/WebKitTools/DumpRenderTree/gtk/AccessibilityControllerGtk.cpp
@@ -58,7 +58,11 @@ AccessibilityUIElement AccessibilityController::focusedElement()
AccessibilityUIElement AccessibilityController::rootElement()
{
WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
- AtkObject* axObject = gtk_widget_get_accessible(GTK_WIDGET(view));
+
+ // The presumed, desired rootElement is the parent of the web view.
+ GtkWidget* webViewParent = gtk_widget_get_parent(GTK_WIDGET(view));
+ AtkObject* axObject = gtk_widget_get_accessible(webViewParent);
+
return AccessibilityUIElement(axObject);
}
diff --git a/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp b/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp
index 9aa31a8..13d313d 100644
--- a/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp
+++ b/WebKitTools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp
@@ -161,6 +161,11 @@ JSStringRef AccessibilityUIElement::subrole()
return 0;
}
+JSStringRef AccessibilityUIElement::roleDescription()
+{
+ return 0;
+}
+
JSStringRef AccessibilityUIElement::title()
{
const gchar* name = atk_object_get_name(ATK_OBJECT(m_element));
@@ -181,6 +186,12 @@ JSStringRef AccessibilityUIElement::description()
return JSStringCreateWithUTF8CString(description);
}
+JSStringRef AccessibilityUIElement::stringValue()
+{
+ // FIXME: implement
+ return JSStringCreateWithCharacters(0, 0);
+}
+
JSStringRef AccessibilityUIElement::language()
{
// FIXME: implement
@@ -233,6 +244,10 @@ double AccessibilityUIElement::clickPointY()
return 0.f;
}
+JSStringRef AccessibilityUIElement::orientation() const
+{
+ return 0;
+}
double AccessibilityUIElement::intValue()
{
@@ -316,6 +331,34 @@ bool AccessibilityUIElement::isRequired() const
return false;
}
+bool AccessibilityUIElement::isSelected() const
+{
+ // FIXME: implement
+ return false;
+}
+
+int AccessibilityUIElement::hierarchicalLevel() const
+{
+ // FIXME: implement
+ return 0;
+}
+
+bool AccessibilityUIElement::ariaIsGrabbed() const
+{
+ return false;
+}
+
+JSStringRef AccessibilityUIElement::ariaDropEffects() const
+{
+ return 0;
+}
+
+bool AccessibilityUIElement::isExpanded() const
+{
+ // FIXME: implement
+ return false;
+}
+
JSStringRef AccessibilityUIElement::attributesOfColumnHeaders()
{
// FIXME: implement
@@ -417,6 +460,11 @@ bool AccessibilityUIElement::isAttributeSettable(JSStringRef attribute)
return false;
}
+bool AccessibilityUIElement::isAttributeSupported(JSStringRef attribute)
+{
+ return false;
+}
+
void AccessibilityUIElement::increment()
{
// FIXME: implement
@@ -426,3 +474,57 @@ void AccessibilityUIElement::decrement()
{
// FIXME: implement
}
+
+void AccessibilityUIElement::showMenu()
+{
+ // FIXME: implement
+}
+
+AccessibilityUIElement AccessibilityUIElement::disclosedRowAtIndex(unsigned index)
+{
+ return 0;
+}
+
+AccessibilityUIElement AccessibilityUIElement::ariaOwnsElementAtIndex(unsigned index)
+{
+ return 0;
+}
+
+AccessibilityUIElement AccessibilityUIElement::ariaFlowToElementAtIndex(unsigned index)
+{
+ return 0;
+}
+
+AccessibilityUIElement AccessibilityUIElement::selectedRowAtIndex(unsigned index)
+{
+ return 0;
+}
+
+AccessibilityUIElement AccessibilityUIElement::disclosedByRow()
+{
+ return 0;
+}
+
+JSStringRef AccessibilityUIElement::accessibilityValue() const
+{
+ // FIXME: implement
+ return JSStringCreateWithCharacters(0, 0);
+}
+
+JSStringRef AccessibilityUIElement::documentEncoding()
+{
+ AtkRole role = atk_object_get_role(ATK_OBJECT(m_element));
+ if (role != ATK_ROLE_DOCUMENT_FRAME)
+ return JSStringCreateWithCharacters(0, 0);
+
+ return JSStringCreateWithUTF8CString(atk_document_get_attribute_value(ATK_DOCUMENT(m_element), "Encoding"));
+}
+
+JSStringRef AccessibilityUIElement::documentURI()
+{
+ AtkRole role = atk_object_get_role(ATK_OBJECT(m_element));
+ if (role != ATK_ROLE_DOCUMENT_FRAME)
+ return JSStringCreateWithCharacters(0, 0);
+
+ return JSStringCreateWithUTF8CString(atk_document_get_attribute_value(ATK_DOCUMENT(m_element), "URI"));
+}
diff --git a/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp
index 4ed6e36..fd1e3c6 100644
--- a/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp
+++ b/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp
@@ -82,6 +82,7 @@ static GCController* gcController = 0;
static WebKitWebView* webView;
static GtkWidget* window;
static GtkWidget* container;
+static GtkWidget* webInspectorWindow;
WebKitWebFrame* mainFrame = 0;
WebKitWebFrame* topLoadingFrame = 0;
guint waitToDumpWatchdog = 0;
@@ -113,6 +114,11 @@ static bool shouldLogFrameLoadDelegates(const char* pathOrURL)
return strstr(pathOrURL, "loading/");
}
+static bool shouldOpenWebInspector(const char* pathOrURL)
+{
+ return strstr(pathOrURL, "inspector/");
+}
+
void dumpFrameScrollPosition(WebKitWebFrame* frame)
{
@@ -120,7 +126,7 @@ void dumpFrameScrollPosition(WebKitWebFrame* frame)
void displayWebView()
{
-
+ gtk_widget_queue_draw(GTK_WIDGET(webView));
}
static void appendString(gchar*& target, gchar* string)
@@ -319,7 +325,6 @@ static void resetDefaultsToConsistentValues()
"enable-offline-web-application-cache", TRUE,
"enable-universal-access-from-file-uris", TRUE,
"enable-scripts", TRUE,
- "enable-web-sockets", TRUE,
"enable-dom-paste", TRUE,
"default-font-family", "Times",
"monospace-font-family", "Courier",
@@ -400,12 +405,8 @@ void dump()
// FIXME: call displayWebView here when we support --paint
- puts("#EOF"); // terminate the (possibly empty) pixels block
-
- fflush(stdout);
- fflush(stderr);
-
done = true;
+ gtk_main_quit();
}
static void setDefaultsToConsistentStateValuesForTesting()
@@ -427,6 +428,14 @@ static void setDefaultsToConsistentStateValuesForTesting()
g_free(databaseDirectory);
}
+static void sendPixelResultsEOF()
+{
+ puts("#EOF");
+
+ fflush(stdout);
+ fflush(stderr);
+}
+
static void runTest(const string& testPathOrURL)
{
ASSERT(!testPathOrURL.empty());
@@ -455,6 +464,9 @@ static void runTest(const string& testPathOrURL)
if (shouldLogFrameLoadDelegates(pathOrURL.c_str()))
gLayoutTestController->setDumpFrameLoadCallbacks(true);
+ if (shouldOpenWebInspector(pathOrURL.c_str()))
+ gLayoutTestController->showWebInspector();
+
WorkQueue::shared()->clear();
WorkQueue::shared()->setFrozen(false);
@@ -484,9 +496,10 @@ static void runTest(const string& testPathOrURL)
g_free(url);
url = NULL;
- while (!done)
- g_main_context_iteration(NULL, TRUE);
+ gtk_main();
+ if (shouldOpenWebInspector(pathOrURL.c_str()))
+ gLayoutTestController->closeWebInspector();
// Also check if we still have opened webViews and free them.
if (gLayoutTestController->closeRemainingWindowsWhenComplete() || webViewList) {
@@ -503,6 +516,9 @@ static void runTest(const string& testPathOrURL)
gLayoutTestController->deref();
gLayoutTestController = 0;
+
+ // terminate the (possibly empty) pixels block after all the state reset
+ sendPixelResultsEOF();
}
void webViewLoadStarted(WebKitWebView* view, WebKitWebFrame* frame, void*)
@@ -565,7 +581,7 @@ static void webViewLoadFinished(WebKitWebView* view, WebKitWebFrame* frame, void
if (WorkQueue::shared()->count())
g_timeout_add(0, processWork, 0);
- else
+ else
dump();
}
@@ -708,9 +724,29 @@ static void databaseQuotaExceeded(WebKitWebView* view, WebKitWebFrame* frame, We
static WebKitWebView* webViewCreate(WebKitWebView*, WebKitWebFrame*);
+static gboolean webInspectorShowWindow(WebKitWebInspector*, gpointer data)
+{
+ gtk_window_set_default_size(GTK_WINDOW(webInspectorWindow), 800, 600);
+ gtk_widget_show_all(webInspectorWindow);
+ return TRUE;
+}
+
+static gboolean webInspectorCloseWindow(WebKitWebInspector*, gpointer data)
+{
+ gtk_widget_destroy(webInspectorWindow);
+ webInspectorWindow = 0;
+ return TRUE;
+}
+
static WebKitWebView* webInspectorInspectWebView(WebKitWebInspector*, gpointer data)
{
- return WEBKIT_WEB_VIEW(webkit_web_view_new());
+ webInspectorWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+
+ GtkWidget* webView = webkit_web_view_new();
+ gtk_container_add(GTK_CONTAINER(webInspectorWindow),
+ webView);
+
+ return WEBKIT_WEB_VIEW(webView);
}
static WebKitWebView* createWebView()
@@ -738,7 +774,11 @@ static WebKitWebView* createWebView()
NULL);
WebKitWebInspector* inspector = webkit_web_view_get_inspector(view);
- g_signal_connect(inspector, "inspect-web-view", G_CALLBACK(webInspectorInspectWebView), 0);
+ g_object_connect(G_OBJECT(inspector),
+ "signal::inspect-web-view", webInspectorInspectWebView, 0,
+ "signal::show-window", webInspectorShowWindow, 0,
+ "signal::close-window", webInspectorCloseWindow, 0,
+ NULL);
return view;
}
@@ -793,6 +833,7 @@ int main(int argc, char* argv[])
gtk_container_add(GTK_CONTAINER(container), GTK_WIDGET(webView));
gtk_widget_realize(GTK_WIDGET(webView));
gtk_widget_show_all(container);
+ gtk_widget_grab_focus(GTK_WIDGET(webView));
mainFrame = webkit_web_view_get_main_frame(webView);
setDefaultsToConsistentStateValuesForTesting();
diff --git a/WebKitTools/DumpRenderTree/gtk/EventSender.cpp b/WebKitTools/DumpRenderTree/gtk/EventSender.cpp
index f42928c..6268b5b 100644
--- a/WebKitTools/DumpRenderTree/gtk/EventSender.cpp
+++ b/WebKitTools/DumpRenderTree/gtk/EventSender.cpp
@@ -200,6 +200,23 @@ static JSValueRef mouseDownCallback(JSContextRef context, JSObjectRef function,
return JSValueMakeUndefined(context);
}
+static guint getStateFlags()
+{
+ guint state = 0;
+
+ if (down) {
+ if (currentEventButton == 1)
+ state = GDK_BUTTON1_MASK;
+ else if (currentEventButton == 2)
+ state = GDK_BUTTON2_MASK;
+ else if (currentEventButton == 3)
+ state = GDK_BUTTON3_MASK;
+ } else
+ state = 0;
+
+ return state;
+}
+
static JSValueRef mouseUpCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
@@ -207,8 +224,6 @@ static JSValueRef mouseUpCallback(JSContextRef context, JSObjectRef function, JS
if (!view)
return JSValueMakeUndefined(context);
- down = false;
-
GdkEvent event;
memset(&event, 0, sizeof(event));
event.type = GDK_BUTTON_RELEASE;
@@ -226,6 +241,9 @@ static JSValueRef mouseUpCallback(JSContextRef context, JSObjectRef function, JS
event.button.window = GTK_WIDGET(view)->window;
event.button.time = GDK_CURRENT_TIME;
event.button.device = gdk_device_get_core_pointer();
+ event.button.state = getStateFlags();
+
+ down = false;
int x_root, y_root;
#if GTK_CHECK_VERSION(2,17,3)
@@ -286,16 +304,8 @@ static JSValueRef mouseMoveToCallback(JSContextRef context, JSObjectRef function
event.motion.x_root = x_root;
event.motion.y_root = y_root;
-
- if (down) {
- if (currentEventButton == 1)
- event.motion.state = GDK_BUTTON1_MASK;
- else if (currentEventButton == 2)
- event.motion.state = GDK_BUTTON2_MASK;
- else if (currentEventButton == 3)
- event.motion.state = GDK_BUTTON3_MASK;
- } else
- event.motion.state = 0;
+
+ event.motion.state = getStateFlags();
if (dragMode && down && !replayingSavedEvents) {
msgQueue[endOfQueue].event = event;
diff --git a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
index 631fc31..6e94c1c 100644
--- a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
+++ b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
@@ -49,6 +49,7 @@
extern "C" {
bool webkit_web_frame_pause_animation(WebKitWebFrame* frame, const gchar* name, double time, const gchar* element);
bool webkit_web_frame_pause_transition(WebKitWebFrame* frame, const gchar* name, double time, const gchar* element);
+bool webkit_web_frame_pause_svg_animation(WebKitWebFrame* frame, const gchar* name, double time, const gchar* element);
unsigned int webkit_web_frame_number_of_active_animations(WebKitWebFrame* frame);
void webkit_application_cache_set_maximum_size(unsigned long long size);
unsigned int webkit_worker_thread_count(void);
@@ -224,7 +225,18 @@ void LayoutTestController::setMainFrameIsFirstResponder(bool flag)
void LayoutTestController::setTabKeyCyclesThroughElements(bool cycles)
{
- // FIXME: implement
+ WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
+ WebKitWebSettings* settings = webkit_web_view_get_settings(webView);
+ g_object_set(G_OBJECT(settings), "tab-key-cycles-through-elements", cycles, NULL);
+}
+
+void LayoutTestController::setTimelineProfilingEnabled(bool flag)
+{
+ WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
+ ASSERT(view);
+
+ WebKitWebInspector* inspector = webkit_web_view_get_inspector(view);
+ g_object_set(G_OBJECT(inspector), "timeline-profiling-enabled", flag, NULL);
}
void LayoutTestController::setUseDashboardCompatibilityMode(bool flag)
@@ -305,6 +317,15 @@ void LayoutTestController::setXSSAuditorEnabled(bool flag)
g_object_set(G_OBJECT(settings), "enable-xss-auditor", flag, NULL);
}
+void LayoutTestController::setAllowUniversalAccessFromFileURLs(bool flag)
+{
+ WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
+ ASSERT(view);
+
+ WebKitWebSettings* settings = webkit_web_view_get_settings(view);
+ g_object_set(G_OBJECT(settings), "enable-universal-access-from-file-uris", flag, NULL);
+}
+
void LayoutTestController::setAuthorAndUserStylesEnabled(bool flag)
{
// FIXME: implement
@@ -428,6 +449,16 @@ bool LayoutTestController::pauseTransitionAtTimeOnElementWithId(JSStringRef prop
return returnValue;
}
+bool LayoutTestController::sampleSVGAnimationForElementAtTime(JSStringRef animationId, double time, JSStringRef elementId)
+{
+ gchar* name = JSStringCopyUTF8CString(animationId);
+ gchar* element = JSStringCopyUTF8CString(elementId);
+ bool returnValue = webkit_web_frame_pause_svg_animation(mainFrame, name, time, element);
+ g_free(name);
+ g_free(element);
+ return returnValue;
+}
+
unsigned LayoutTestController::numberOfActiveAnimations() const
{
return webkit_web_frame_number_of_active_animations(mainFrame);
@@ -493,7 +524,7 @@ void LayoutTestController::showWebInspector()
WebKitWebInspector* inspector = webkit_web_view_get_inspector(webView);
g_object_set(webSettings, "enable-developer-extras", TRUE, NULL);
- webkit_web_inspector_inspect_coordinates(inspector, 0, 0);
+ webkit_web_inspector_show(inspector);
}
void LayoutTestController::closeWebInspector()
diff --git a/WebKitTools/DumpRenderTree/gtk/TestNetscapePlugin/ForwardingHeaders/WebKit/npapi.h b/WebKitTools/DumpRenderTree/gtk/TestNetscapePlugin/ForwardingHeaders/WebKit/npapi.h
deleted file mode 100644
index 08706f7..0000000
--- a/WebKitTools/DumpRenderTree/gtk/TestNetscapePlugin/ForwardingHeaders/WebKit/npapi.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <bridge/npapi.h>
diff --git a/WebKitTools/DumpRenderTree/gtk/TestNetscapePlugin/ForwardingHeaders/WebKit/npfunctions.h b/WebKitTools/DumpRenderTree/gtk/TestNetscapePlugin/ForwardingHeaders/WebKit/npfunctions.h
deleted file mode 100644
index 54a603d..0000000
--- a/WebKitTools/DumpRenderTree/gtk/TestNetscapePlugin/ForwardingHeaders/WebKit/npfunctions.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <plugins/npfunctions.h>
diff --git a/WebKitTools/DumpRenderTree/gtk/TestNetscapePlugin/ForwardingHeaders/WebKit/npruntime.h b/WebKitTools/DumpRenderTree/gtk/TestNetscapePlugin/ForwardingHeaders/WebKit/npruntime.h
deleted file mode 100644
index 00bbc18..0000000
--- a/WebKitTools/DumpRenderTree/gtk/TestNetscapePlugin/ForwardingHeaders/WebKit/npruntime.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <bridge/npruntime.h>
diff --git a/WebKitTools/DumpRenderTree/gtk/TestNetscapePlugin/TestNetscapePlugin.cpp b/WebKitTools/DumpRenderTree/gtk/TestNetscapePlugin/TestNetscapePlugin.cpp
deleted file mode 100644
index 6c62a7c..0000000
--- a/WebKitTools/DumpRenderTree/gtk/TestNetscapePlugin/TestNetscapePlugin.cpp
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Zan Dobersek <zandobersek@gmail.com>
- * Copyright (C) 2009 Holger Hans Peter Freyther
- *
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 INC. OR
- * 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 "config.h"
-#include "PluginObject.h"
-
-#include "npapi.h"
-#include "npruntime.h"
-#include "npfunctions.h"
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <X11/Xlib.h>
-
-extern "C" {
- NPError NP_Initialize (NPNetscapeFuncs *aMozillaVTable, NPPluginFuncs *aPluginVTable);
- NPError NP_Shutdown(void);
- NPError NP_GetValue(void *future, NPPVariable variable, void *value);
- char* NP_GetMIMEDescription(void);
-}
-
-static NPError
-webkit_test_plugin_new_instance(NPMIMEType /*mimetype*/,
- NPP instance,
- uint16_t /*mode*/,
- int16_t argc,
- char *argn[],
- char *argv[],
- NPSavedData* /*savedData*/)
-{
- if (browser->version >= 14) {
- PluginObject* obj = (PluginObject*)browser->createobject(instance, getPluginClass());
-
- for (int i = 0; i < argc; i++) {
- if (strcasecmp(argn[i], "onstreamload") == 0 && !obj->onStreamLoad)
- obj->onStreamLoad = strdup(argv[i]);
- else if (strcasecmp(argn[i], "onStreamDestroy") == 0 && !obj->onStreamDestroy)
- obj->onStreamDestroy = strdup(argv[i]);
- else if (strcasecmp(argn[i], "onURLNotify") == 0 && !obj->onURLNotify)
- obj->onURLNotify = strdup(argv[i]);
- else if (strcasecmp(argn[i], "src") == 0 &&
- strcasecmp(argv[i], "data:application/x-webkit-test-netscape,returnerrorfromnewstream") == 0)
- obj->returnErrorFromNewStream = TRUE;
- else if (strcasecmp(argn[i], "logfirstsetwindow") == 0)
- obj->logSetWindow = TRUE;
- else if (strcasecmp(argn[i], "testnpruntime") == 0)
- testNPRuntime(instance);
- else if (strcasecmp(argn[i], "logSrc") == 0) {
- for (int i = 0; i < argc; i++)
- if (strcasecmp(argn[i], "src") == 0)
- pluginLog(instance, "src: %s", argv[i]);
- }
- }
-
- instance->pdata = obj;
- }
-
- return NPERR_NO_ERROR;
-}
-
-static NPError
-webkit_test_plugin_destroy_instance(NPP instance, NPSavedData** /*save*/)
-{
- PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
- if (obj) {
- if (obj->onStreamLoad)
- free(obj->onStreamLoad);
-
- if (obj->onStreamDestroy)
- free(obj->onStreamDestroy);
-
- if (obj->onURLNotify)
- free(obj->onURLNotify);
-
- if (obj->logDestroy)
- pluginLog(instance, "NPP_Destroy");
-
- browser->releaseobject(&obj->header);
- }
-
- return NPERR_NO_ERROR;
-}
-
-static NPError
-webkit_test_plugin_set_window(NPP instance, NPWindow *window)
-{
- PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
-
- if (obj) {
- if (obj->logSetWindow) {
- pluginLog(instance, "NPP_SetWindow: %d %d", (int)window->width, (int)window->height);
- obj->logSetWindow = false;
- }
- }
-
- return NPERR_NO_ERROR;
-}
-
-static void executeScript(const PluginObject* obj, const char* script)
-{
- NPObject *windowScriptObject;
- browser->getvalue(obj->npp, NPNVWindowNPObject, &windowScriptObject);
-
- NPString npScript;
- npScript.UTF8Characters = script;
- npScript.UTF8Length = strlen(script);
-
- NPVariant browserResult;
- browser->evaluate(obj->npp, windowScriptObject, &npScript, &browserResult);
- browser->releasevariantvalue(&browserResult);
-}
-
-static NPError
-webkit_test_plugin_new_stream(NPP instance,
- NPMIMEType /*type*/,
- NPStream *stream,
- NPBool /*seekable*/,
- uint16* stype)
-{
- PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
- obj->stream = stream;
- *stype = NP_ASFILEONLY;
-
- if (obj->returnErrorFromNewStream)
- return NPERR_GENERIC_ERROR;
-
- if (browser->version >= NPVERS_HAS_RESPONSE_HEADERS)
- notifyStream(obj, stream->url, stream->headers);
-
- if (obj->onStreamLoad)
- executeScript(obj, obj->onStreamLoad);
-
- return NPERR_NO_ERROR;
-}
-
-static NPError
-webkit_test_plugin_destroy_stream(NPP instance, NPStream* /*stream*/, NPError /*reason*/)
-{
- PluginObject* obj = (PluginObject*)instance->pdata;
-
- if (obj->onStreamDestroy)
- executeScript(obj, obj->onStreamDestroy);
-
- return NPERR_NO_ERROR;
-}
-
-static void
-webkit_test_plugin_stream_as_file(NPP /*instance*/, NPStream* /*stream*/, const char* /*fname*/)
-{
-}
-
-static int32
-webkit_test_plugin_write_ready(NPP /*instance*/, NPStream* /*stream*/)
-{
- return 0;
-}
-
-static int32
-webkit_test_plugin_write(NPP /*instance*/,
- NPStream* /*stream*/,
- int32_t /*offset*/,
- int32_t /*len*/,
- void* /*buffer*/)
-{
- return 0;
-}
-
-static void
-webkit_test_plugin_print(NPP /*instance*/, NPPrint* /*platformPrint*/)
-{
-}
-
-static int16_t
-webkit_test_plugin_handle_event(NPP instance, void* event)
-{
- PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
- if (!obj->eventLogging)
- return 0;
-
- XEvent* evt = static_cast<XEvent*>(event);
- pluginLog(instance, "event %d", evt->type);
-
- return 0;
-}
-
-static void
-webkit_test_plugin_url_notify(NPP instance, const char* url, NPReason reason, void* notifyData)
-{
- PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
-
- if (obj->onURLNotify)
- executeScript(obj, obj->onURLNotify);
-
- handleCallback(obj, url, reason, notifyData);
-}
-
-static NPError
-webkit_test_plugin_get_value(NPP instance, NPPVariable variable, void *value)
-{
- NPError err = NPERR_NO_ERROR;
-
- switch (variable) {
- case NPPVpluginNameString:
- *((char **)value) = const_cast<char*>("WebKit Test PlugIn");
- break;
- case NPPVpluginDescriptionString:
- *((char **)value) = const_cast<char*>("Simple Netscape plug-in that handles test content for WebKit");
- break;
- case NPPVpluginNeedsXEmbed:
- *((NPBool *)value) = TRUE;
- break;
- case NPPVpluginScriptableIID:
- case NPPVpluginScriptableInstance:
- case NPPVpluginScriptableNPObject:
- err = NPERR_GENERIC_ERROR;
- break;
- default:
- fprintf(stderr, "Unhandled variable\n");
- err = NPERR_GENERIC_ERROR;
- break;
- }
-
- if (variable == NPPVpluginScriptableNPObject) {
- void **v = (void **)value;
- PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
- browser->retainobject((NPObject *)obj);
- *v = obj;
- err = NPERR_NO_ERROR;
- }
-
- return err;
-}
-
-static NPError
-webkit_test_plugin_set_value(NPP /*instance*/, NPNVariable /*variable*/, void* /*value*/)
-{
- return NPERR_NO_ERROR;
-}
-
-char *
-NP_GetMIMEDescription(void)
-{
- return const_cast<char*>("application/x-webkit-test-netscape:testnetscape:test netscape content");
-}
-
-NPError
-NP_Initialize (NPNetscapeFuncs *aMozillaVTable, NPPluginFuncs *aPluginVTable)
-{
- if (aMozillaVTable == NULL || aPluginVTable == NULL)
- return NPERR_INVALID_FUNCTABLE_ERROR;
-
- if ((aMozillaVTable->version >> 8) > NP_VERSION_MAJOR)
- return NPERR_INCOMPATIBLE_VERSION_ERROR;
-
- if (aPluginVTable->size < sizeof (NPPluginFuncs))
- return NPERR_INVALID_FUNCTABLE_ERROR;
-
- browser = aMozillaVTable;
-
- aPluginVTable->size = sizeof (NPPluginFuncs);
- aPluginVTable->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
- aPluginVTable->newp = webkit_test_plugin_new_instance;
- aPluginVTable->destroy = webkit_test_plugin_destroy_instance;
- aPluginVTable->setwindow = webkit_test_plugin_set_window;
- aPluginVTable->newstream = webkit_test_plugin_new_stream;
- aPluginVTable->destroystream = webkit_test_plugin_destroy_stream;
- aPluginVTable->asfile = webkit_test_plugin_stream_as_file;
- aPluginVTable->writeready = webkit_test_plugin_write_ready;
- aPluginVTable->write = webkit_test_plugin_write;
- aPluginVTable->print = webkit_test_plugin_print;
- aPluginVTable->event = webkit_test_plugin_handle_event;
- aPluginVTable->urlnotify = webkit_test_plugin_url_notify;
- aPluginVTable->javaClass = NULL;
- aPluginVTable->getvalue = webkit_test_plugin_get_value;
- aPluginVTable->setvalue = webkit_test_plugin_set_value;
-
- return NPERR_NO_ERROR;
-}
-
-NPError
-NP_Shutdown(void)
-{
- return NPERR_NO_ERROR;
-}
-
-NPError
-NP_GetValue(void* /*future*/, NPPVariable variable, void *value)
-{
- return webkit_test_plugin_get_value(NULL, variable, value);
-}