1/* 2 * Copyright (C) 2010 Igalia S.L. 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20#include "autotoolsconfig.h" 21#include <errno.h> 22#include <glib.h> 23#include <glib/gstdio.h> 24#include <gtk/gtk.h> 25#include <webkit/webkit.h> 26 27/* This function is not public, so we need an extern declaration */ 28extern void webkit_web_settings_add_extra_plugin_directory(WebKitWebView* view, const gchar* directory); 29 30static void test_webkit_web_plugin_database_get_plugins() 31{ 32 WebKitWebView* view = WEBKIT_WEB_VIEW(webkit_web_view_new()); 33 WebKitWebPluginDatabase* database; 34 GSList* pluginList, *p; 35 gboolean found = FALSE; 36 gboolean enabled = FALSE; 37 38 webkit_web_settings_add_extra_plugin_directory(view, TEST_PLUGIN_DIR); 39 g_object_ref_sink(G_OBJECT(view)); 40 41 database = webkit_get_web_plugin_database(); 42 pluginList = webkit_web_plugin_database_get_plugins(database); 43 for (p = pluginList; p; p = p->next) { 44 WebKitWebPlugin* plugin = (WebKitWebPlugin*)p->data; 45 if (!g_strcmp0(webkit_web_plugin_get_name(plugin), "WebKit Test PlugIn") && 46 !g_strcmp0(webkit_web_plugin_get_description(plugin), "Simple Netscape® plug-in that handles test content for WebKit")) { 47 found = TRUE; 48 enabled = webkit_web_plugin_get_enabled(plugin); 49 webkit_web_plugin_set_enabled(plugin, FALSE); 50 } 51 } 52 webkit_web_plugin_database_plugins_list_free(pluginList); 53 g_assert(found); 54 g_assert(enabled); 55 56 webkit_web_plugin_database_refresh(database); 57 pluginList = webkit_web_plugin_database_get_plugins(database); 58 59 for (p = pluginList; p; p = p->next) { 60 WebKitWebPlugin* plugin = (WebKitWebPlugin*)p->data; 61 if (!g_strcmp0(webkit_web_plugin_get_name(plugin), "WebKit Test PlugIn") && 62 !g_strcmp0(webkit_web_plugin_get_description(plugin), "Simple Netscape® plug-in that handles test content for WebKit")) 63 enabled = webkit_web_plugin_get_enabled(plugin); 64 } 65 webkit_web_plugin_database_plugins_list_free(pluginList); 66 g_assert(!enabled); 67 68 g_object_unref(view); 69} 70 71int main(int argc, char** argv) 72{ 73 gtk_test_init(&argc, &argv, NULL); 74 75 g_test_bug_base("https://bugs.webkit.org/"); 76 g_test_add_func("/webkit/webplugindatabase/getplugins", test_webkit_web_plugin_database_get_plugins); 77 return g_test_run (); 78} 79