2009-06-30 Xan Lopez <xlopez@igalia.com>
authorxan@webkit.org <xan@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Jul 2009 06:42:07 +0000 (06:42 +0000)
committerxan@webkit.org <xan@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Jul 2009 06:42:07 +0000 (06:42 +0000)
        Reviewed by Jan Alonzo.

        https://bugs.webkit.org/show_bug.cgi?id=26877
        [GTK] DRT fixes to pass new plugin test

        Use the common pluginLog function instead of a local copy.

        * DumpRenderTree/gtk/TestNetscapePlugin/TestNetscapePlugin.cpp:
        (webkit_test_plugin_new_instance):
        (webkit_test_plugin_destroy_instance):
        (webkit_test_plugin_set_window):
        (webkit_test_plugin_handle_event):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@45430 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/gtk/TestNetscapePlugin/TestNetscapePlugin.cpp

index 3d73cc0f25a27e9f67c3be705f731884a5b4703c..80d4fb5c7dd2b0cb8a44ddc6403f37cd7fa9b83a 100644 (file)
@@ -1,3 +1,18 @@
+2009-06-30  Xan Lopez  <xlopez@igalia.com>
+
+        Reviewed by Jan Alonzo.
+
+        https://bugs.webkit.org/show_bug.cgi?id=26877
+        [GTK] DRT fixes to pass new plugin test
+
+        Use the common pluginLog function instead of a local copy.
+
+        * DumpRenderTree/gtk/TestNetscapePlugin/TestNetscapePlugin.cpp:
+        (webkit_test_plugin_new_instance):
+        (webkit_test_plugin_destroy_instance):
+        (webkit_test_plugin_set_window):
+        (webkit_test_plugin_handle_event):
+
 2009-06-30  Xan Lopez  <xlopez@igalia.com>
 
         Reviewed by Jan Alonzo.
index 55552a011c9fa90619e6279fb285c7b24bd9fb60..760025a6de5c991f0de8dc481465d6e5ddac1c11 100644 (file)
 #include <stdlib.h>
 #include <X11/Xlib.h>
 
-static void log(NPP instance, const char* format, ...)
-{
-    va_list args;
-    va_start(args, format);
-    char message[2048] = "PLUGIN: ";
-    vsprintf(message + strlen(message), format, args);
-    va_end(args);
-
-    NPObject* windowObject = 0;
-    NPError error = browser->getvalue(instance, NPNVWindowNPObject, &windowObject);
-    if (error != NPERR_NO_ERROR) {
-        fprintf(stderr, "Failed to retrieve window object while logging: %s\n", message);
-        return;
-    }
-
-    NPVariant consoleVariant;
-    if (!browser->getproperty(instance, windowObject, browser->getstringidentifier("console"), &consoleVariant)) {
-        fprintf(stderr, "Failed to retrieve console object while logging: %s\n", message);
-        browser->releaseobject(windowObject);
-        return;
-    }
-
-    NPObject* consoleObject = NPVARIANT_TO_OBJECT(consoleVariant);
-
-    NPVariant messageVariant;
-    STRINGZ_TO_NPVARIANT(message, messageVariant);
-
-    NPVariant result;
-    if (!browser->invoke(instance, consoleObject, browser->getstringidentifier("log"), &messageVariant, 1, &result)) {
-        fprintf(stderr, "Failed to invoke console.log while logging: %s\n", message);
-        browser->releaseobject(consoleObject);
-        browser->releaseobject(windowObject);
-        return;
-    }
-
-    browser->releasevariantvalue(&result);
-    browser->releaseobject(consoleObject);
-    browser->releaseobject(windowObject);
-}
-
 extern "C" {
     NPError NP_Initialize (NPNetscapeFuncs *aMozillaVTable, NPPluginFuncs *aPluginVTable);
     NPError NP_Shutdown(void);
@@ -114,7 +74,7 @@ webkit_test_plugin_new_instance(NPMIMEType mimetype,
             else if (strcasecmp(argn[i], "logSrc") == 0) {
                 for (int i = 0; i < argc; i++)
                     if (strcasecmp(argn[i], "src") == 0)
-                        log(instance, "src: %s", argv[i]);
+                        pluginLog(instance, "src: %s", argv[i]);
             }
         }
 
@@ -139,7 +99,7 @@ webkit_test_plugin_destroy_instance(NPP instance, NPSavedData **save)
             free(obj->onURLNotify);
 
         if (obj->logDestroy)
-            log(instance, "NPP_Destroy");
+            pluginLog(instance, "NPP_Destroy");
 
         browser->releaseobject(&obj->header);
     }
@@ -154,7 +114,7 @@ webkit_test_plugin_set_window(NPP instance, NPWindow *window)
 
     if (obj) {
         if (obj->logSetWindow) {
-            log(instance, "NPP_SetWindow: %d %d", (int)window->width, (int)window->height);
+            pluginLog(instance, "NPP_SetWindow: %d %d", (int)window->width, (int)window->height);
             obj->logSetWindow = false;
         }
     }
@@ -244,7 +204,7 @@ webkit_test_plugin_handle_event(NPP instance, void* event)
         return 0;
 
     XEvent* evt = static_cast<XEvent*>(event);
-    log(instance, "event %d", evt->type);
+    pluginLog(instance, "event %d", evt->type);
 
     return 0;
 }