Title: [176256] trunk
Revision
176256
Author
[email protected]
Date
2014-11-18 06:19:15 -0800 (Tue, 18 Nov 2014)

Log Message

[GTK] Add API to create a WebKitWebContext
https://bugs.webkit.org/show_bug.cgi?id=138826

Reviewed by Gustavo Noronha Silva.

Source/WebKit2:

We have always used a default web context without providing API to
create others. The main reason was that nobody requested it and we
haven't needed it either. The main problem of the default web
context is that you can't configure anything during
construction. This hasn't been a problem so far because all the
web context configuration we expose in the API can be configured
after construction. But now we need to expose API to allow the
user to configure the local storage directory, which is a
construct only configuration. The default web context was also a
problem for our unit tests, because sharing the same context made
it difficult to ensure tests cases are independent to each other.

* UIProcess/API/gtk/WebKitGeolocationProvider.cpp:
(WebKitGeolocationProvider::~WebKitGeolocationProvider): Reset the
provider to avoid crashes when web context is destroyed and a new
one is created.
* UIProcess/API/gtk/WebKitWebContext.cpp:
(webkitWebContextConstructed): Add constructed implementation to
create the WebContext and initialize it.
(webkitWebContextDispose): Detach web context clients to avoid
crashes when a client callback is called on a disposed WebKitWebContext.
(webkit_web_context_class_init): Initialize gettext, add
constructed implementation and add the pointer to the vmethods
when creating signals.
(createDefaultWebContext): Simply create a WebKitWebContext.
(webkit_web_context_new): New public method to create a WebKitWebContext.
(injectedBundleFilename): Deleted.
* UIProcess/API/gtk/WebKitWebContext.h: Add virtual methods for
signals, so that users can inherit from WebKitWebContext and
override the virtual methods.
* UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add new symbol.

Tools:

Use a different WebKitWebContext for every test to ensure test
cases are independent to each other. Tests using DBus to
communicate with the injected bundle extension now use a unique
name for the well known DBus name.

* TestWebKitAPI/Tests/WebKit2Gtk/TestAuthentication.cpp:
(beforeAll): Remove comment about the order of the tests and
move the success test before the failed one now that tests don't
depend on each others.
* TestWebKitAPI/Tests/WebKit2Gtk/TestContextMenu.cpp:
(beforeAll): Remove call to set the web extensions directory,
since this is now done for all test in the Test constructor.
* TestWebKitAPI/Tests/WebKit2Gtk/TestCookieManager.cpp:
(beforeAll): Do not create a temporary directory, a temporary data
directory is now created for all tests.
(afterAll):
* TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNode.cpp:
(testWebKitDOMNodeHierarchyNavigation): Pass the web extension ID
to the web process test runner.
(testWebKitDOMNodeInsertion): Ditto.
(testWebKitDOMNodeTagNames): Ditto.
(beforeAll): Remove call to set the web extensions directory.
* TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNodeFilter.cpp:
(runTest): Pass the web extension ID to the web process test runner.
(beforeAll): Remove call to set the web extensions directory.
* TestWebKitAPI/Tests/WebKit2Gtk/TestDOMXPathNSResolver.cpp:
(runTest): Pass the web extension ID to the web process test runner.
(beforeAll): Remove call to set the web extensions directory.
* TestWebKitAPI/Tests/WebKit2Gtk/TestDownloads.cpp:
(createFileAtDestination): Use Test::dataDirectory() as base dir
for temporary files.
(beforeAll): Do not create a temporary directory.
(afterAll):
* TestWebKitAPI/Tests/WebKit2Gtk/TestFrame.cpp:
(webkitFrameTestRun): Pass the web extension ID to the web process
test runner.
(beforeAll): Remove call to set the web extensions directory.
* TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp:
(beforeAll): Remove call to set the web extensions directory.
* TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp:
(testProcessPerWebView): Use local member instead of global variable.
(testMultiprocessWebViewCreateReadyClose): Ditto.
(beforeAll): Do not connect to initialize-web-extensions, Test now
connects to the signal for all tests and calls a virtual method
that test can override.
(afterAll):
(initializeWebExtensions): Deleted.
* TestWebKitAPI/Tests/WebKit2Gtk/TestPrinting.cpp:
(testPrintOperationPrint): Use Test::dataDirectory() as base dir
for temporary files.
(beforeAll): Do not create a temporary directory.
(afterAll):
* TestWebKitAPI/Tests/WebKit2Gtk/TestResources.cpp:
(beforeAll): Remove call to set the web extensions directory.
* TestWebKitAPI/Tests/WebKit2Gtk/TestSSL.cpp:
(beforeAll): Remove comment about the tests order.
* TestWebKitAPI/Tests/WebKit2Gtk/TestWebExtensions.cpp:
(testWebExtensionGetTitle): Build the DBus service name using the
web extension ID.
(testDocumentLoadedSignal): Ditto.
(testWebKitWebViewProcessCrashed): Ditto.
(testWebExtensionIsolatedWorld): Ditto.
(beforeAll): Remove initialization-user-data test, since now all
tests are passing user data to the web extension.
(testWebExtensionInitializationUserData): Deleted.
(initializeWebExtensions): Deleted.
* TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitFaviconDatabase.cpp:
(testSetDirectory): Use the web context member inherited from Test.
(testClearDatabase): Ditto.
(testGetFaviconURI): Ditto.
(beforeAll): Do not create a temporary directory.
(afterAll):
(webkitFaviconDatabaseFinalizedCallback): Deleted.
* TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitUserContentManager.cpp:
(UserContentManagerTest::UserContentManagerTest):
(beforeAll): Remove call to set the web extensions directory.
* TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp:
(testWebContextDefault): Check also that a newly create web
context is not the default web context.
(testWebContextSpellChecker): Use the web context member inherited
from Test.
(testWebContextLanguages): Ditto.
* TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp:
(methodCallCallback): Remove GetInitializationUserData method.
(webkit_web_extension_initialize_with_user_data): Always create
the DBus name using the user data provided.
(makeBusName): Deleted.
* TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.cpp:
(webkit_web_extension_initialize_with_user_data): Create the DBus
name using the user data provided.
(webkit_web_extension_initialize): Deleted.
* TestWebKitAPI/gtk/WebKit2Gtk/TestMain.cpp:
(Test::dataDirectory): Return the temporary data directory.
(removeNonEmptyDirectory): Also remove directories recursively.
(main): Remove the disk cache directory initialization, since this
is now done in the Test constructor.
* TestWebKitAPI/gtk/WebKit2Gtk/TestMain.h:
(Test::initializeWebExtensionsCallback): Call the virtual method
initializeWebExtensions()
(Test::Test): Create a new WebKitWebContext and initialize it.
(Test::~Test): Disconnect initialize-web-extensions signal.
(Test::initializeWebExtensions): Set the web extensions directory
and user data.
* TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.cpp:
(WebProcessTestRunner::~WebProcessTestRunner): Use nullptr.
(WebProcessTestRunner::runTest): Build the DBus proxy using a
unique name created with the Test web extension ID.
(WebProcessTestRunner::proxy): Deleted.
* TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.h:
* TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp:
(WebViewTest::WebViewTest): Create the web view with the Test web
context.
* TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h: Add optional user
content manager parameter to the constructor.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (176255 => 176256)


--- trunk/Source/WebKit2/ChangeLog	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Source/WebKit2/ChangeLog	2014-11-18 14:19:15 UTC (rev 176256)
@@ -1,3 +1,42 @@
+2014-11-18  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] Add API to create a WebKitWebContext
+        https://bugs.webkit.org/show_bug.cgi?id=138826
+
+        Reviewed by Gustavo Noronha Silva.
+
+        We have always used a default web context without providing API to
+        create others. The main reason was that nobody requested it and we
+        haven't needed it either. The main problem of the default web
+        context is that you can't configure anything during
+        construction. This hasn't been a problem so far because all the
+        web context configuration we expose in the API can be configured
+        after construction. But now we need to expose API to allow the
+        user to configure the local storage directory, which is a
+        construct only configuration. The default web context was also a
+        problem for our unit tests, because sharing the same context made
+        it difficult to ensure tests cases are independent to each other.
+
+        * UIProcess/API/gtk/WebKitGeolocationProvider.cpp:
+        (WebKitGeolocationProvider::~WebKitGeolocationProvider): Reset the
+        provider to avoid crashes when web context is destroyed and a new
+        one is created.
+        * UIProcess/API/gtk/WebKitWebContext.cpp:
+        (webkitWebContextConstructed): Add constructed implementation to
+        create the WebContext and initialize it.
+        (webkitWebContextDispose): Detach web context clients to avoid
+        crashes when a client callback is called on a disposed WebKitWebContext.
+        (webkit_web_context_class_init): Initialize gettext, add
+        constructed implementation and add the pointer to the vmethods
+        when creating signals.
+        (createDefaultWebContext): Simply create a WebKitWebContext.
+        (webkit_web_context_new): New public method to create a WebKitWebContext.
+        (injectedBundleFilename): Deleted.
+        * UIProcess/API/gtk/WebKitWebContext.h: Add virtual methods for
+        signals, so that users can inherit from WebKitWebContext and
+        override the virtual methods.
+        * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add new symbol.
+
 2014-11-18  Carlos Alberto Lopez Perez  <[email protected]>
 
         [SOUP] [GnuTLS] Don't use a SSL3.0 record version in client hello.

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationProvider.cpp (176255 => 176256)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationProvider.cpp	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationProvider.cpp	2014-11-18 14:19:15 UTC (rev 176256)
@@ -51,6 +51,7 @@
 WebKitGeolocationProvider::~WebKitGeolocationProvider()
 {
     m_provider.stopUpdating();
+    WKGeolocationManagerSetProvider(toAPI(m_geolocationManager.get()), nullptr);
 }
 
 PassRefPtr<WebKitGeolocationProvider> WebKitGeolocationProvider::create(WebGeolocationManagerProxy* geolocationManager)

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp (176255 => 176256)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp	2014-11-18 14:19:15 UTC (rev 176256)
@@ -20,6 +20,7 @@
 #include "config.h"
 #include "WebKitWebContext.h"
 
+#include "APIDownloadClient.h"
 #include "APIString.h"
 #include "WebBatteryManagerProxy.h"
 #include "WebCertificateInfo.h"
@@ -144,6 +145,7 @@
 
 struct _WebKitWebContextPrivate {
     RefPtr<WebContext> context;
+    bool clientsDetached;
 
     GRefPtr<WebKitCookieManager> cookieManager;
     GRefPtr<WebKitFaviconDatabase> faviconDatabase;
@@ -199,10 +201,73 @@
     }
 }
 
+static const char* injectedBundleDirectory()
+{
+    const char* bundleDirectory = g_getenv("WEBKIT_INJECTED_BUNDLE_PATH");
+    if (bundleDirectory && g_file_test(bundleDirectory, G_FILE_TEST_IS_DIR))
+        return bundleDirectory;
+
+    static const char* injectedBundlePath = LIBDIR G_DIR_SEPARATOR_S "webkit2gtk-" WEBKITGTK_API_VERSION_STRING
+        G_DIR_SEPARATOR_S "injected-bundle" G_DIR_SEPARATOR_S;
+    return injectedBundlePath;
+}
+
+static void webkitWebContextConstructed(GObject* object)
+{
+    G_OBJECT_CLASS(webkit_web_context_parent_class)->constructed(object);
+
+    GUniquePtr<char> bundleFilename(g_build_filename(injectedBundleDirectory(), "libwebkit2gtkinjectedbundle.so", nullptr));
+    WebContextConfiguration webContextConfiguration;
+    webContextConfiguration.injectedBundlePath = WebCore::filenameToString(bundleFilename.get());
+    WebContext::applyPlatformSpecificConfigurationDefaults(webContextConfiguration);
+
+    WebKitWebContext* webContext = WEBKIT_WEB_CONTEXT(object);
+    WebKitWebContextPrivate* priv = webContext->priv;
+    priv->context = WebContext::create(WTF::move(webContextConfiguration));
+
+    priv->requestManager = priv->context->supplement<WebSoupCustomProtocolRequestManager>();
+    priv->context->setCacheModel(CacheModelPrimaryWebBrowser);
+
+    priv->tlsErrorsPolicy = WEBKIT_TLS_ERRORS_POLICY_FAIL;
+    priv->context->setIgnoreTLSErrors(false);
+
+    attachInjectedBundleClientToContext(webContext);
+    attachDownloadClientToContext(webContext);
+    attachRequestManagerClientToContext(webContext);
+
+#if ENABLE(GEOLOCATION)
+    priv->geolocationProvider = WebKitGeolocationProvider::create(priv->context->supplement<WebGeolocationManagerProxy>());
+#endif
+#if ENABLE(BATTERY_STATUS)
+    priv->batteryProvider = WebKitBatteryProvider::create(priv->context->supplement<WebBatteryManagerProxy>());
+#endif
+#if ENABLE(SPELLCHECK)
+    priv->textChecker = WebKitTextChecker::create();
+#endif
+}
+
+static void webkitWebContextDispose(GObject* object)
+{
+    WebKitWebContextPrivate* priv = WEBKIT_WEB_CONTEXT(object)->priv;
+    if (!priv->clientsDetached) {
+        priv->clientsDetached = true;
+        priv->context->initializeInjectedBundleClient(nullptr);
+        priv->context->setDownloadClient(nullptr);
+    }
+
+    G_OBJECT_CLASS(webkit_web_context_parent_class)->dispose(object);
+}
+
 static void webkit_web_context_class_init(WebKitWebContextClass* webContextClass)
 {
     GObjectClass* gObjectClass = G_OBJECT_CLASS(webContextClass);
 
+    bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
+    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+
+    gObjectClass->constructed = webkitWebContextConstructed;
+    gObjectClass->dispose = webkitWebContextDispose;
+
     /**
      * WebKitWebContext::download-started:
      * @context: the #WebKitWebContext
@@ -212,12 +277,13 @@
      */
     signals[DOWNLOAD_STARTED] =
         g_signal_new("download-started",
-                     G_TYPE_FROM_CLASS(gObjectClass),
-                     G_SIGNAL_RUN_LAST,
-                     0, 0, 0,
-                     g_cclosure_marshal_VOID__OBJECT,
-                     G_TYPE_NONE, 1,
-                     WEBKIT_TYPE_DOWNLOAD);
+            G_TYPE_FROM_CLASS(gObjectClass),
+            G_SIGNAL_RUN_LAST,
+            G_STRUCT_OFFSET(WebKitWebContextClass, download_started),
+            nullptr, nullptr,
+            g_cclosure_marshal_VOID__OBJECT,
+            G_TYPE_NONE, 1,
+            WEBKIT_TYPE_DOWNLOAD);
 
     /**
      * WebKitWebContext::initialize-web-extensions:
@@ -234,60 +300,15 @@
         g_signal_new("initialize-web-extensions",
             G_TYPE_FROM_CLASS(gObjectClass),
             G_SIGNAL_RUN_LAST,
-            0, nullptr, nullptr,
+            G_STRUCT_OFFSET(WebKitWebContextClass, initialize_web_extensions),
+            nullptr, nullptr,
             g_cclosure_marshal_VOID__VOID,
             G_TYPE_NONE, 0);
 }
 
-static CString injectedBundleDirectory()
-{
-    const char* bundleDirectory = g_getenv("WEBKIT_INJECTED_BUNDLE_PATH");
-    if (bundleDirectory && g_file_test(bundleDirectory, G_FILE_TEST_IS_DIR))
-        return bundleDirectory;
-
-    static const char* injectedBundlePath = LIBDIR G_DIR_SEPARATOR_S "webkit2gtk-" WEBKITGTK_API_VERSION_STRING
-        G_DIR_SEPARATOR_S "injected-bundle" G_DIR_SEPARATOR_S;
-    return injectedBundlePath;
-}
-
-static CString injectedBundleFilename()
-{
-    GUniquePtr<char> bundleFilename(g_build_filename(injectedBundleDirectory().data(), "libwebkit2gtkinjectedbundle.so", NULL));
-    return bundleFilename.get();
-}
-
 static gpointer createDefaultWebContext(gpointer)
 {
-    bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
-    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
-
-    static GRefPtr<WebKitWebContext> webContext = adoptGRef(WEBKIT_WEB_CONTEXT(g_object_new(WEBKIT_TYPE_WEB_CONTEXT, NULL)));
-    WebKitWebContextPrivate* priv = webContext->priv;
-
-    WebContextConfiguration webContextConfiguration;
-    webContextConfiguration.injectedBundlePath = WebCore::filenameToString(injectedBundleFilename().data());
-    WebContext::applyPlatformSpecificConfigurationDefaults(webContextConfiguration);
-    priv->context = WebContext::create(WTF::move(webContextConfiguration));
-
-    priv->requestManager = webContext->priv->context->supplement<WebSoupCustomProtocolRequestManager>();
-    priv->context->setCacheModel(CacheModelPrimaryWebBrowser);
-
-    priv->tlsErrorsPolicy = WEBKIT_TLS_ERRORS_POLICY_FAIL;
-    priv->context->setIgnoreTLSErrors(false);
-
-    attachInjectedBundleClientToContext(webContext.get());
-    attachDownloadClientToContext(webContext.get());
-    attachRequestManagerClientToContext(webContext.get());
-
-#if ENABLE(GEOLOCATION)
-    priv->geolocationProvider = WebKitGeolocationProvider::create(priv->context->supplement<WebGeolocationManagerProxy>());
-#endif
-#if ENABLE(BATTERY_STATUS)
-    priv->batteryProvider = WebKitBatteryProvider::create(priv->context->supplement<WebBatteryManagerProxy>());
-#endif
-#if ENABLE(SPELLCHECK)
-    priv->textChecker = WebKitTextChecker::create();
-#endif
+    static GRefPtr<WebKitWebContext> webContext = adoptGRef(WEBKIT_WEB_CONTEXT(g_object_new(WEBKIT_TYPE_WEB_CONTEXT, nullptr)));
     return webContext.get();
 }
 
@@ -305,6 +326,20 @@
 }
 
 /**
+ * webkit_web_context_new:
+ *
+ * Create a new #WebKitWebContext
+ *
+ * Returns: (transfer full): a newly created #WebKitWebContext
+ *
+ * Since: 2.8
+ */
+WebKitWebContext* webkit_web_context_new(void)
+{
+    return WEBKIT_WEB_CONTEXT(g_object_new(WEBKIT_TYPE_WEB_CONTEXT, nullptr));
+}
+
+/**
  * webkit_web_context_set_cache_model:
  * @context: the #WebKitWebContext
  * @cache_model: a #WebKitCacheModel

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h (176255 => 176256)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h	2014-11-18 14:19:15 UTC (rev 176256)
@@ -127,14 +127,16 @@
 struct _WebKitWebContextClass {
     GObjectClass parent;
 
+    void (* download_started)          (WebKitWebContext *context,
+                                        WebKitDownload   *download);
+    void (* initialize_web_extensions) (WebKitWebContext *context);
+
     void (*_webkit_reserved0) (void);
     void (*_webkit_reserved1) (void);
     void (*_webkit_reserved2) (void);
     void (*_webkit_reserved3) (void);
     void (*_webkit_reserved4) (void);
     void (*_webkit_reserved5) (void);
-    void (*_webkit_reserved6) (void);
-    void (*_webkit_reserved7) (void);
 };
 
 WEBKIT_API GType
@@ -143,6 +145,9 @@
 WEBKIT_API WebKitWebContext *
 webkit_web_context_get_default                      (void);
 
+WEBKIT_API WebKitWebContext *
+webkit_web_context_new                              (void);
+
 WEBKIT_API void
 webkit_web_context_set_cache_model                  (WebKitWebContext              *context,
                                                      WebKitCacheModel               cache_model);

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt (176255 => 176256)


--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt	2014-11-18 14:19:15 UTC (rev 176256)
@@ -28,6 +28,7 @@
 WebKitProcessModel
 WebKitTLSErrorsPolicy
 webkit_web_context_get_default
+webkit_web_context_new
 webkit_web_context_get_cache_model
 webkit_web_context_set_cache_model
 webkit_web_context_clear_cache

Modified: trunk/Tools/ChangeLog (176255 => 176256)


--- trunk/Tools/ChangeLog	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Tools/ChangeLog	2014-11-18 14:19:15 UTC (rev 176256)
@@ -1,3 +1,125 @@
+2014-11-18  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] Add API to create a WebKitWebContext
+        https://bugs.webkit.org/show_bug.cgi?id=138826
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Use a different WebKitWebContext for every test to ensure test
+        cases are independent to each other. Tests using DBus to
+        communicate with the injected bundle extension now use a unique
+        name for the well known DBus name.
+
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestAuthentication.cpp:
+        (beforeAll): Remove comment about the order of the tests and
+        move the success test before the failed one now that tests don't
+        depend on each others.
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestContextMenu.cpp:
+        (beforeAll): Remove call to set the web extensions directory,
+        since this is now done for all test in the Test constructor.
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestCookieManager.cpp:
+        (beforeAll): Do not create a temporary directory, a temporary data
+        directory is now created for all tests.
+        (afterAll):
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNode.cpp:
+        (testWebKitDOMNodeHierarchyNavigation): Pass the web extension ID
+        to the web process test runner.
+        (testWebKitDOMNodeInsertion): Ditto.
+        (testWebKitDOMNodeTagNames): Ditto.
+        (beforeAll): Remove call to set the web extensions directory.
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNodeFilter.cpp:
+        (runTest): Pass the web extension ID to the web process test runner.
+        (beforeAll): Remove call to set the web extensions directory.
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestDOMXPathNSResolver.cpp:
+        (runTest): Pass the web extension ID to the web process test runner.
+        (beforeAll): Remove call to set the web extensions directory.
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestDownloads.cpp:
+        (createFileAtDestination): Use Test::dataDirectory() as base dir
+        for temporary files.
+        (beforeAll): Do not create a temporary directory.
+        (afterAll):
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestFrame.cpp:
+        (webkitFrameTestRun): Pass the web extension ID to the web process
+        test runner.
+        (beforeAll): Remove call to set the web extensions directory.
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp:
+        (beforeAll): Remove call to set the web extensions directory.
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp:
+        (testProcessPerWebView): Use local member instead of global variable.
+        (testMultiprocessWebViewCreateReadyClose): Ditto.
+        (beforeAll): Do not connect to initialize-web-extensions, Test now
+        connects to the signal for all tests and calls a virtual method
+        that test can override.
+        (afterAll):
+        (initializeWebExtensions): Deleted.
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestPrinting.cpp:
+        (testPrintOperationPrint): Use Test::dataDirectory() as base dir
+        for temporary files.
+        (beforeAll): Do not create a temporary directory.
+        (afterAll):
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestResources.cpp:
+        (beforeAll): Remove call to set the web extensions directory.
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestSSL.cpp:
+        (beforeAll): Remove comment about the tests order.
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestWebExtensions.cpp:
+        (testWebExtensionGetTitle): Build the DBus service name using the
+        web extension ID.
+        (testDocumentLoadedSignal): Ditto.
+        (testWebKitWebViewProcessCrashed): Ditto.
+        (testWebExtensionIsolatedWorld): Ditto.
+        (beforeAll): Remove initialization-user-data test, since now all
+        tests are passing user data to the web extension.
+        (testWebExtensionInitializationUserData): Deleted.
+        (initializeWebExtensions): Deleted.
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitFaviconDatabase.cpp:
+        (testSetDirectory): Use the web context member inherited from Test.
+        (testClearDatabase): Ditto.
+        (testGetFaviconURI): Ditto.
+        (beforeAll): Do not create a temporary directory.
+        (afterAll):
+        (webkitFaviconDatabaseFinalizedCallback): Deleted.
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitUserContentManager.cpp:
+        (UserContentManagerTest::UserContentManagerTest):
+        (beforeAll): Remove call to set the web extensions directory.
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp:
+        (testWebContextDefault): Check also that a newly create web
+        context is not the default web context.
+        (testWebContextSpellChecker): Use the web context member inherited
+        from Test.
+        (testWebContextLanguages): Ditto.
+        * TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp:
+        (methodCallCallback): Remove GetInitializationUserData method.
+        (webkit_web_extension_initialize_with_user_data): Always create
+        the DBus name using the user data provided.
+        (makeBusName): Deleted.
+        * TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.cpp:
+        (webkit_web_extension_initialize_with_user_data): Create the DBus
+        name using the user data provided.
+        (webkit_web_extension_initialize): Deleted.
+        * TestWebKitAPI/gtk/WebKit2Gtk/TestMain.cpp:
+        (Test::dataDirectory): Return the temporary data directory.
+        (removeNonEmptyDirectory): Also remove directories recursively.
+        (main): Remove the disk cache directory initialization, since this
+        is now done in the Test constructor.
+        * TestWebKitAPI/gtk/WebKit2Gtk/TestMain.h:
+        (Test::initializeWebExtensionsCallback): Call the virtual method
+        initializeWebExtensions()
+        (Test::Test): Create a new WebKitWebContext and initialize it.
+        (Test::~Test): Disconnect initialize-web-extensions signal.
+        (Test::initializeWebExtensions): Set the web extensions directory
+        and user data.
+        * TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.cpp:
+        (WebProcessTestRunner::~WebProcessTestRunner): Use nullptr.
+        (WebProcessTestRunner::runTest): Build the DBus proxy using a
+        unique name created with the Test web extension ID.
+        (WebProcessTestRunner::proxy): Deleted.
+        * TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.h:
+        * TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp:
+        (WebViewTest::WebViewTest): Create the web view with the Test web
+        context.
+        * TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h: Add optional user
+        content manager parameter to the constructor.
+
 2014-11-18  ChangSeok Oh  <[email protected]>
 
         [GTK] Mesa build fails over llvm-3.5

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestAuthentication.cpp (176255 => 176256)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestAuthentication.cpp	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestAuthentication.cpp	2014-11-18 14:19:15 UTC (rev 176256)
@@ -272,12 +272,10 @@
     AuthenticationTest::add("WebKitWebView", "authentication-request", testWebViewAuthenticationRequest);
     AuthenticationTest::add("WebKitWebView", "authentication-cancel", testWebViewAuthenticationCancel);
     AuthenticationTest::add("WebKitWebView", "authentication-load-cancelled", testWebViewAuthenticationLoadCancelled);
+    AuthenticationTest::add("WebKitWebView", "authentication-success", testWebViewAuthenticationSuccess);
     AuthenticationTest::add("WebKitWebView", "authentication-failure", testWebViewAuthenticationFailure);
     AuthenticationTest::add("WebKitWebView", "authentication-no-credential", testWebViewAuthenticationNoCredential);
     AuthenticationTest::add("WebKitWebView", "authentication-storage", testWebViewAuthenticationStorage);
-    // Testing authentication success must be done last because libsoup will never fire
-    // the authenticate signal again once authentication is successful.
-    AuthenticationTest::add("WebKitWebView", "authentication-success", testWebViewAuthenticationSuccess);
 }
 
 void afterAll()

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestContextMenu.cpp (176255 => 176256)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestContextMenu.cpp	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestContextMenu.cpp	2014-11-18 14:19:15 UTC (rev 176256)
@@ -1040,7 +1040,6 @@
 
 void beforeAll()
 {
-    webkit_web_context_set_web_extensions_directory(webkit_web_context_get_default(), WEBKIT_TEST_WEB_EXTENSIONS_DIR);
     ContextMenuDefaultTest::add("WebKitWebView", "default-menu", testContextMenuDefaultMenu);
     ContextMenuCustomTest::add("WebKitWebView", "populate-menu", testContextMenuPopulateMenu);
     ContextMenuCustomFullTest::add("WebKitWebView", "custom-menu", testContextMenuCustomMenu);

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestCookieManager.cpp (176255 => 176256)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestCookieManager.cpp	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestCookieManager.cpp	2014-11-18 14:19:15 UTC (rev 176256)
@@ -24,7 +24,6 @@
 #include <glib/gstdio.h>
 
 static WebKitTestServer* kServer;
-static char* kTempDirectory;
 
 static const char* kFirstPartyDomain = "127.0.0.1";
 static const char* kThirdPartyDomain = "localhost";
@@ -72,12 +71,12 @@
         switch (storage) {
         case WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT:
             if (!m_cookiesTextFile)
-                m_cookiesTextFile.reset(g_build_filename(kTempDirectory, "cookies.txt", NULL));
+                m_cookiesTextFile.reset(g_build_filename(Test::dataDirectory(), "cookies.txt", nullptr));
             filename = m_cookiesTextFile.get();
             break;
         case WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE:
             if (!m_cookiesSQLiteFile)
-                m_cookiesSQLiteFile.reset(g_build_filename(kTempDirectory, "cookies.db", NULL));
+                m_cookiesSQLiteFile.reset(g_build_filename(Test::dataDirectory(), "cookies.db", nullptr));
             filename = m_cookiesSQLiteFile.get();
             break;
         default:
@@ -315,9 +314,6 @@
     kServer = new WebKitTestServer();
     kServer->run(serverCallback);
 
-    kTempDirectory = g_dir_make_tmp("WebKit2Tests-XXXXXX", 0);
-    g_assert(kTempDirectory);
-
     CookieManagerTest::add("WebKitCookieManager", "accept-policy", testCookieManagerAcceptPolicy);
     CookieManagerTest::add("WebKitCookieManager", "delete-cookies", testCookieManagerDeleteCookies);
     CookieManagerTest::add("WebKitCookieManager", "cookies-changed", testCookieManagerCookiesChanged);
@@ -327,5 +323,4 @@
 void afterAll()
 {
     delete kServer;
-    g_rmdir(kTempDirectory);
 }

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNode.cpp (176255 => 176256)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNode.cpp	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNode.cpp	2014-11-18 14:19:15 UTC (rev 176256)
@@ -35,7 +35,7 @@
     GVariantBuilder builder;
     g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
     g_variant_builder_add(&builder, "{sv}", "pageID", g_variant_new_uint64(webkit_web_view_get_page_id(test->m_webView)));
-    g_assert(testRunner->runTest("WebKitDOMNode", "hierarchy-navigation", g_variant_builder_end(&builder)));
+    g_assert(testRunner->runTest("WebKitDOMNode", "hierarchy-navigation", Test::s_webExtensionID, g_variant_builder_end(&builder)));
 }
 
 static void testWebKitDOMNodeInsertion(WebViewTest* test, gconstpointer)
@@ -47,7 +47,7 @@
     GVariantBuilder builder;
     g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
     g_variant_builder_add(&builder, "{sv}", "pageID", g_variant_new_uint64(webkit_web_view_get_page_id(test->m_webView)));
-    g_assert(testRunner->runTest("WebKitDOMNode", "insertion", g_variant_builder_end(&builder)));
+    g_assert(testRunner->runTest("WebKitDOMNode", "insertion", Test::s_webExtensionID, g_variant_builder_end(&builder)));
 }
 
 static void testWebKitDOMNodeTagNames(WebViewTest* test, gconstpointer)
@@ -68,13 +68,12 @@
     GVariantBuilder builder;
     g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
     g_variant_builder_add(&builder, "{sv}", "pageID", g_variant_new_uint64(webkit_web_view_get_page_id(test->m_webView)));
-    g_assert(testRunner->runTest("WebKitDOMNode", "tag-names", g_variant_builder_end(&builder)));
+    g_assert(testRunner->runTest("WebKitDOMNode", "tag-names", Test::s_webExtensionID, g_variant_builder_end(&builder)));
 }
 
 void beforeAll()
 {
     testRunner = new WebProcessTestRunner();
-    webkit_web_context_set_web_extensions_directory(webkit_web_context_get_default(), WEBKIT_TEST_WEB_EXTENSIONS_DIR);
 
     WebViewTest::add("WebKitDOMNode", "hierarchy-navigation", testWebKitDOMNodeHierarchyNavigation);
     WebViewTest::add("WebKitDOMNode", "insertion", testWebKitDOMNodeInsertion);

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNodeFilter.cpp (176255 => 176256)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNodeFilter.cpp	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNodeFilter.cpp	2014-11-18 14:19:15 UTC (rev 176256)
@@ -37,7 +37,7 @@
     GVariantBuilder builder;
     g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
     g_variant_builder_add(&builder, "{sv}", "pageID", g_variant_new_uint64(webkit_web_view_get_page_id(test->m_webView)));
-    g_assert(testRunner->runTest("WebKitDOMNodeFilter", name, g_variant_builder_end(&builder)));
+    g_assert(testRunner->runTest("WebKitDOMNodeFilter", name, Test::s_webExtensionID, g_variant_builder_end(&builder)));
 }
 
 static void testWebKitDOMNodeFilterTreeWalker(WebViewTest* test, gconstpointer)
@@ -53,7 +53,6 @@
 void beforeAll()
 {
     testRunner = new WebProcessTestRunner();
-    webkit_web_context_set_web_extensions_directory(webkit_web_context_get_default(), WEBKIT_TEST_WEB_EXTENSIONS_DIR);
 
     WebViewTest::add("WebKitDOMNodeFilter", "tree-walker", testWebKitDOMNodeFilterTreeWalker);
     WebViewTest::add("WebKitDOMNodeFilter", "node-iterator", testWebKitDOMNodeFilterNodeIterator);

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMXPathNSResolver.cpp (176255 => 176256)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMXPathNSResolver.cpp	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMXPathNSResolver.cpp	2014-11-18 14:19:15 UTC (rev 176256)
@@ -31,7 +31,7 @@
     GVariantBuilder builder;
     g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
     g_variant_builder_add(&builder, "{sv}", "pageID", g_variant_new_uint64(webkit_web_view_get_page_id(test->m_webView)));
-    g_assert(testRunner->runTest("WebKitDOMXPathNSResolver", name, g_variant_builder_end(&builder)));
+    g_assert(testRunner->runTest("WebKitDOMXPathNSResolver", name, Test::s_webExtensionID, g_variant_builder_end(&builder)));
 }
 
 static void testWebKitDOMXPathNSResolverNative(WebViewTest* test, gconstpointer)
@@ -55,7 +55,6 @@
 void beforeAll()
 {
     testRunner = new WebProcessTestRunner();
-    webkit_web_context_set_web_extensions_directory(webkit_web_context_get_default(), WEBKIT_TEST_WEB_EXTENSIONS_DIR);
 
     WebViewTest::add("WebKitDOMXPathNSResolver", "native", testWebKitDOMXPathNSResolverNative);
     WebViewTest::add("WebKitDOMXPathNSResolver", "custom", testWebKitDOMXPathNSResolverCustom);

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDownloads.cpp (176255 => 176256)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDownloads.cpp	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDownloads.cpp	2014-11-18 14:19:15 UTC (rev 176256)
@@ -31,8 +31,6 @@
 #include <wtf/gobject/GUniquePtr.h>
 #include <wtf/text/CString.h>
 
-static char* kTempDirectory;
-
 class DownloadTest: public Test {
 public:
     MAKE_GLIB_TEST_FIXTURE(DownloadTest);
@@ -105,17 +103,16 @@
     }
 
     DownloadTest()
-        : m_webContext(webkit_web_context_get_default())
-        , m_mainLoop(g_main_loop_new(0, TRUE))
+        : m_mainLoop(g_main_loop_new(nullptr, TRUE))
         , m_downloadSize(0)
         , m_allowOverwrite(false)
     {
-        g_signal_connect(m_webContext, "download-started", G_CALLBACK(downloadStartedCallback), this);
+        g_signal_connect(m_webContext.get(), "download-started", G_CALLBACK(downloadStartedCallback), this);
     }
 
     ~DownloadTest()
     {
-        g_signal_handlers_disconnect_matched(m_webContext, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+        g_signal_handlers_disconnect_matched(m_webContext.get(), G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
         g_main_loop_unref(m_mainLoop);
     }
 
@@ -157,14 +154,14 @@
 
     virtual void decideDestination(WebKitDownload* download, const gchar* suggestedFilename)
     {
-        GUniquePtr<char> destination(g_build_filename(kTempDirectory, suggestedFilename, NULL));
+        GUniquePtr<char> destination(g_build_filename(Test::dataDirectory(), suggestedFilename, nullptr));
         GUniquePtr<char> destinationURI(g_filename_to_uri(destination.get(), 0, 0));
         webkit_download_set_destination(download, destinationURI.get());
     }
 
     WebKitDownload* downloadURIAndWaitUntilFinishes(const CString& requestURI)
     {
-        WebKitDownload* download = webkit_web_context_download_uri(m_webContext, requestURI.data());
+        WebKitDownload* download = webkit_web_context_download_uri(m_webContext.get(), requestURI.data());
         assertObjectIsDeletedWhenTestFinishes(G_OBJECT(download));
 
         g_assert(!webkit_download_get_allow_overwrite(download));
@@ -191,7 +188,6 @@
         g_file_delete(destFile.get(), 0, 0);
     }
 
-    WebKitWebContext* m_webContext;
     GMainLoop* m_mainLoop;
     Vector<DownloadEvent> m_downloadEvents;
     guint64 m_downloadSize;
@@ -235,7 +231,7 @@
 
 static void createFileAtDestination(const char* filename)
 {
-    GUniquePtr<char> path(g_build_filename(kTempDirectory, filename, nullptr));
+    GUniquePtr<char> path(g_build_filename(Test::dataDirectory(), filename, nullptr));
     GRefPtr<GFile> file = adoptGRef(g_file_new_for_path(path.get()));
     GUniqueOutPtr<GError> error;
     g_file_create(file.get(), G_FILE_CREATE_NONE, nullptr, &error.outPtr());
@@ -536,7 +532,7 @@
 
     static gboolean downloadDecideDestinationCallback(WebKitDownload* download, const gchar* suggestedFilename, WebViewDownloadTest* test)
     {
-        GUniquePtr<char> destination(g_build_filename(kTempDirectory, suggestedFilename, NULL));
+        GUniquePtr<char> destination(g_build_filename(Test::dataDirectory(), suggestedFilename, nullptr));
         GUniquePtr<char> destinationURI(g_filename_to_uri(destination.get(), 0, 0));
         webkit_download_set_destination(download, destinationURI.get());
         return TRUE;
@@ -621,9 +617,6 @@
     kServer = new WebKitTestServer();
     kServer->run(serverCallback);
 
-    kTempDirectory = g_dir_make_tmp("WebKit2Tests-XXXXXX", 0);
-    g_assert(kTempDirectory);
-
     DownloadTest::add("Downloads", "local-file", testDownloadLocalFile);
     DownloadTest::add("Downloads", "overwrite-destination-allowed", testDownloadOverwriteDestinationAllowed);
     DownloadErrorTest::add("Downloads", "overwrite-destination-disallowed", testDownloadOverwriteDestinationDisallowed);
@@ -637,5 +630,4 @@
 void afterAll()
 {
     delete kServer;
-    g_rmdir(kTempDirectory);
 }

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestFrame.cpp (176255 => 176256)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestFrame.cpp	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestFrame.cpp	2014-11-18 14:19:15 UTC (rev 176256)
@@ -35,7 +35,7 @@
     GVariantBuilder builder;
     g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
     g_variant_builder_add(&builder, "{sv}", "pageID", g_variant_new_uint64(webkit_web_view_get_page_id(test->m_webView)));
-    g_assert(testRunner->runTest("WebKitFrame", testName, g_variant_builder_end(&builder)));
+    g_assert(testRunner->runTest("WebKitFrame", testName, Test::s_webExtensionID, g_variant_builder_end(&builder)));
 }
 
 static void testWebKitFrameMainFrame(WebViewTest* test, gconstpointer)
@@ -56,7 +56,6 @@
 void beforeAll()
 {
     testRunner = new WebProcessTestRunner();
-    webkit_web_context_set_web_extensions_directory(webkit_web_context_get_default(), WEBKIT_TEST_WEB_EXTENSIONS_DIR);
 
     WebViewTest::add("WebKitFrame", "main-frame", testWebKitFrameMainFrame);
     WebViewTest::add("WebKitFrame", "uri", testWebKitFrameURI);

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp (176255 => 176256)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp	2014-11-18 14:19:15 UTC (rev 176256)
@@ -315,7 +315,8 @@
 
     WebPageURITest()
     {
-        GRefPtr<GDBusProxy> proxy = adoptGRef(bus->createProxy("org.webkit.gtk.WebExtensionTest",
+        GUniquePtr<char> extensionBusName(g_strdup_printf("org.webkit.gtk.WebExtensionTest%u", Test::s_webExtensionID));
+        GRefPtr<GDBusProxy> proxy = adoptGRef(bus->createProxy(extensionBusName.get(),
             "/org/webkit/gtk/WebExtensionTest", "org.webkit.gtk.WebExtensionTest", m_mainLoop));
         m_uriChangedSignalID = g_dbus_connection_signal_subscribe(
             g_dbus_proxy_get_connection(proxy.get()),
@@ -465,7 +466,6 @@
 
 void beforeAll()
 {
-    webkit_web_context_set_web_extensions_directory(webkit_web_context_get_default(), WEBKIT_TEST_WEB_EXTENSIONS_DIR);
     bus = new WebKitTestBus();
     if (!bus->run())
         return;

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp (176255 => 176256)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp	2014-11-18 14:19:15 UTC (rev 176256)
@@ -26,8 +26,6 @@
 #include <wtf/Vector.h>
 
 static const unsigned numViews = 2;
-static guint32 nextInitializationId = 1;
-static unsigned initializeWebExtensionsSignalCount;
 static WebKitTestBus* bus;
 
 class MultiprocessTest: public Test {
@@ -36,9 +34,19 @@
 
     MultiprocessTest()
         : m_mainLoop(g_main_loop_new(nullptr, TRUE))
+        , m_initializeWebExtensionsSignalCount(0)
         , m_webViewBusNames(numViews)
-        , m_webViews(numViews) { }
+        , m_webViews(numViews)
+    {
+        webkit_web_context_set_process_model(m_webContext.get(), WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
+    }
 
+    void initializeWebExtensions() override
+    {
+        Test::initializeWebExtensions();
+        m_initializeWebExtensionsSignalCount++;
+    }
+
     static void loadChanged(WebKitWebView* webView, WebKitLoadEvent loadEvent, MultiprocessTest* test)
     {
         if (loadEvent != WEBKIT_LOAD_FINISHED)
@@ -51,11 +59,11 @@
     {
         g_assert_cmpuint(index, <, numViews);
 
-        m_webViewBusNames[index] = GUniquePtr<char>(g_strdup_printf("org.webkit.gtk.WebExtensionTest%u", nextInitializationId));
-
-        m_webViews[index] = WEBKIT_WEB_VIEW(webkit_web_view_new());
+        m_webViews[index] = WEBKIT_WEB_VIEW(webkit_web_view_new_with_context(m_webContext.get()));
         assertObjectIsDeletedWhenTestFinishes(G_OBJECT(m_webViews[index].get()));
 
+        m_webViewBusNames[index] = GUniquePtr<char>(g_strdup_printf("org.webkit.gtk.WebExtensionTest%u", Test::s_webExtensionID));
+
         webkit_web_view_load_html(m_webViews[index].get(), "<html></html>", nullptr);
         g_signal_connect(m_webViews[index].get(), "load-changed", G_CALLBACK(loadChanged), this);
         g_main_loop_run(m_mainLoop);
@@ -98,6 +106,7 @@
     }
 
     GMainLoop* m_mainLoop;
+    unsigned m_initializeWebExtensionsSignalCount;
     Vector<GUniquePtr<char>, numViews> m_webViewBusNames;
     Vector<GRefPtr<WebKitWebView>, numViews> m_webViews;
 };
@@ -116,7 +125,7 @@
         g_assert(test->m_webViewBusNames[i]);
     }
 
-    g_assert_cmpuint(initializeWebExtensionsSignalCount, ==, numViews);
+    g_assert_cmpuint(test->m_initializeWebExtensionsSignalCount, ==, numViews);
     g_assert_cmpstr(test->m_webViewBusNames[0].get(), !=, test->m_webViewBusNames[1].get());
     g_assert_cmpuint(test->webProcessPid(0), !=, test->webProcessPid(1));
 
@@ -128,7 +137,7 @@
     }
 }
 
-class UIClientMultiprocessTest: public WebViewTest {
+class UIClientMultiprocessTest: public Test {
 public:
     MAKE_GLIB_TEST_FIXTURE(UIClientMultiprocessTest);
 
@@ -154,16 +163,28 @@
     }
 
     UIClientMultiprocessTest()
+        : m_mainLoop(g_main_loop_new(nullptr, TRUE))
+        , m_initializeWebExtensionsSignalCount(0)
     {
+        webkit_web_context_set_process_model(m_webContext.get(), WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
+        m_webView = WEBKIT_WEB_VIEW(g_object_ref_sink(webkit_web_view_new_with_context(m_webContext.get())));
         webkit_settings_set_javascript_can_open_windows_automatically(webkit_web_view_get_settings(m_webView), TRUE);
+
         g_signal_connect(m_webView, "create", G_CALLBACK(viewCreateCallback), this);
     }
 
     ~UIClientMultiprocessTest()
     {
         g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+        gtk_widget_destroy(GTK_WIDGET(m_webView));
     }
 
+    void initializeWebExtensions() override
+    {
+        Test::initializeWebExtensions();
+        m_initializeWebExtensionsSignalCount++;
+    }
+
     GtkWidget* viewCreate(WebKitWebView* webView)
     {
         g_assert(webView == m_webView);
@@ -199,16 +220,15 @@
         g_main_loop_run(m_mainLoop);
     }
 
+    WebKitWebView* m_webView;
+    GMainLoop* m_mainLoop;
+    unsigned m_initializeWebExtensionsSignalCount;
     Vector<WebViewEvents> m_webViewEvents;
 };
 
 static void testMultiprocessWebViewCreateReadyClose(UIClientMultiprocessTest* test, gconstpointer)
 {
-    // At this point the web process of the current view has already been created.
-    // We save it here to check that after window.open() the number of processes
-    // is the same.
-    guint32 processCountBefore = nextInitializationId - 1;
-    test->loadHtml("<html><body _onLoad_=\"window.open().close();\"></html>", nullptr);
+    webkit_web_view_load_html(test->m_webView, "<html><body _onLoad_=\"window.open().close();\"></html>", nullptr);
     test->waitUntilNewWebViewClose();
 
     Vector<UIClientMultiprocessTest::WebViewEvents>& events = test->m_webViewEvents;
@@ -217,23 +237,11 @@
     g_assert_cmpint(events[1], ==, UIClientMultiprocessTest::ReadyToShow);
     g_assert_cmpint(events[2], ==, UIClientMultiprocessTest::Close);
 
-    guint32 processesCountAfter =  nextInitializationId - 1;
-    g_assert_cmpuint(processesCountAfter, ==, processCountBefore);
+    g_assert_cmpuint(test->m_initializeWebExtensionsSignalCount, ==, 1);
 }
 
-static void initializeWebExtensions(WebKitWebContext* context, gpointer)
-{
-    initializeWebExtensionsSignalCount++;
-    webkit_web_context_set_web_extensions_directory(context, WEBKIT_TEST_WEB_EXTENSIONS_DIR);
-    webkit_web_context_set_web_extensions_initialization_user_data(context,
-        g_variant_new_uint32(nextInitializationId++));
-}
-
 void beforeAll()
 {
-    g_signal_connect(webkit_web_context_get_default(),
-        "initialize-web-extensions", G_CALLBACK(initializeWebExtensions), nullptr);
-
     // Check that default setting is the one stated in the documentation
     g_assert_cmpuint(webkit_web_context_get_process_model(webkit_web_context_get_default()),
         ==, WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS);
@@ -256,6 +264,4 @@
 void afterAll()
 {
     delete bus;
-    g_signal_handlers_disconnect_by_func(webkit_web_context_get_default(),
-        reinterpret_cast<void*>(initializeWebExtensions), nullptr);
 }

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestPrinting.cpp (176255 => 176256)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestPrinting.cpp	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestPrinting.cpp	2014-11-18 14:19:15 UTC (rev 176256)
@@ -26,8 +26,6 @@
 #include <gtk/gtkunixprint.h>
 #endif
 
-static char* kTempDirectory;
-
 static void testPrintOperationPrintSettings(WebViewTest* test, gconstpointer)
 {
     GRefPtr<WebKitPrintOperation> printOperation = adoptGRef(webkit_print_operation_new(test->m_webView));
@@ -134,7 +132,7 @@
         return;
     }
 
-    GUniquePtr<char> outputFilename(g_build_filename(kTempDirectory, "webkit-print.pdf", NULL));
+    GUniquePtr<char> outputFilename(g_build_filename(Test::dataDirectory(), "webkit-print.pdf", nullptr));
     GRefPtr<GFile> outputFile = adoptGRef(g_file_new_for_path(outputFilename.get()));
     GUniquePtr<char> outputURI(g_file_get_uri(outputFile.get()));
 
@@ -228,7 +226,7 @@
 
     GtkWidget* createWebView()
     {
-        GtkWidget* newWebView = webkit_web_view_new();
+        GtkWidget* newWebView = webkit_web_view_new_with_context(m_webContext.get());
         g_object_ref_sink(newWebView);
 
         assertObjectIsDeletedWhenTestFinishes(G_OBJECT(newWebView));
@@ -247,7 +245,7 @@
             return;
         }
 
-        GUniquePtr<char> outputFilename(g_build_filename(kTempDirectory, "webkit-close-after-print.pdf", NULL));
+        GUniquePtr<char> outputFilename(g_build_filename(Test::dataDirectory(), "webkit-close-after-print.pdf", nullptr));
         m_outputFile = adoptGRef(g_file_new_for_path(outputFilename.get()));
         GUniquePtr<char> outputURI(g_file_get_uri(m_outputFile.get()));
 
@@ -292,9 +290,6 @@
 
 void beforeAll()
 {
-    kTempDirectory = g_dir_make_tmp("WebKit2Tests-XXXXXX", 0);
-    g_assert(kTempDirectory);
-
     WebViewTest::add("WebKitPrintOperation", "printing-settings", testPrintOperationPrintSettings);
     WebViewTest::add("WebKitWebView", "print", testWebViewPrint);
 #ifdef HAVE_GTK_UNIX_PRINTING
@@ -306,5 +301,4 @@
 
 void afterAll()
 {
-    g_rmdir(kTempDirectory);
 }

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestResources.cpp (176255 => 176256)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestResources.cpp	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestResources.cpp	2014-11-18 14:19:15 UTC (rev 176256)
@@ -770,8 +770,6 @@
     kServer = new WebKitTestServer();
     kServer->run(serverCallback);
 
-    webkit_web_context_set_web_extensions_directory(webkit_web_context_get_default(), WEBKIT_TEST_WEB_EXTENSIONS_DIR);
-
     ResourcesTest::add("WebKitWebView", "resources", testWebViewResources);
     SingleResourceLoadTest::add("WebKitWebResource", "loading", testWebResourceLoading);
     SingleResourceLoadTest::add("WebKitWebResource", "response", testWebResourceResponse);

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestSSL.cpp (176255 => 176256)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestSSL.cpp	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestSSL.cpp	2014-11-18 14:19:15 UTC (rev 176256)
@@ -403,9 +403,6 @@
 
     SSLTest::add("WebKitWebView", "ssl", testSSL);
     InsecureContentTest::add("WebKitWebView", "insecure-content", testInsecureContent);
-    // In this case the order of the tests does matter because tls-errors-policy expects
-    // that no exception will have been added for this certificate and host pair as is
-    // done in the load-failed-with-tls-errors test.
     SSLTest::add("WebKitWebView", "tls-errors-policy", testTLSErrorsPolicy);
     SSLTest::add("WebKitWebView", "tls-errors-redirect-to-http", testTLSErrorsRedirect);
     SSLTest::add("WebKitWebView", "tls-http-auth", testTLSErrorsHTTPAuth);

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebExtensions.cpp (176255 => 176256)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebExtensions.cpp	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebExtensions.cpp	2014-11-18 14:19:15 UTC (rev 176256)
@@ -32,8 +32,9 @@
     test->loadHtml("<html><head><title>WebKitGTK+ Web Extensions Test</title></head><body></body></html>", 0);
     test->waitUntilLoadFinished();
 
-    GRefPtr<GDBusProxy> proxy = adoptGRef(bus->createProxy("org.webkit.gtk.WebExtensionTest",
-        "/org/webkit/gtk/WebExtensionTest" , "org.webkit.gtk.WebExtensionTest", test->m_mainLoop));
+    GUniquePtr<char> extensionBusName(g_strdup_printf("org.webkit.gtk.WebExtensionTest%u", Test::s_webExtensionID));
+    GRefPtr<GDBusProxy> proxy = adoptGRef(bus->createProxy(extensionBusName.get(),
+        "/org/webkit/gtk/WebExtensionTest", "org.webkit.gtk.WebExtensionTest", test->m_mainLoop));
     GRefPtr<GVariant> result = adoptGRef(g_dbus_proxy_call_sync(
         proxy.get(),
         "GetTitle",
@@ -54,7 +55,8 @@
 
 static void testDocumentLoadedSignal(WebViewTest* test, gconstpointer)
 {
-    GRefPtr<GDBusProxy> proxy = adoptGRef(bus->createProxy("org.webkit.gtk.WebExtensionTest",
+    GUniquePtr<char> extensionBusName(g_strdup_printf("org.webkit.gtk.WebExtensionTest%u", Test::s_webExtensionID));
+    GRefPtr<GDBusProxy> proxy = adoptGRef(bus->createProxy(extensionBusName.get(),
         "/org/webkit/gtk/WebExtensionTest", "org.webkit.gtk.WebExtensionTest", test->m_mainLoop));
     GDBusConnection* connection = g_dbus_proxy_get_connection(proxy.get());
     guint id = g_dbus_connection_signal_subscribe(connection,
@@ -89,7 +91,8 @@
     g_signal_connect(test->m_webView, "web-process-crashed",
         G_CALLBACK(webProcessCrashedCallback), test);
 
-    GRefPtr<GDBusProxy> proxy = adoptGRef(bus->createProxy("org.webkit.gtk.WebExtensionTest",
+    GUniquePtr<char> extensionBusName(g_strdup_printf("org.webkit.gtk.WebExtensionTest%u", Test::s_webExtensionID));
+    GRefPtr<GDBusProxy> proxy = adoptGRef(bus->createProxy(extensionBusName.get(),
         "/org/webkit/gtk/WebExtensionTest", "org.webkit.gtk.WebExtensionTest", test->m_mainLoop));
 
     GRefPtr<GVariant> result = adoptGRef(g_dbus_proxy_call_sync(
@@ -152,7 +155,8 @@
         "document.getElementById('console').innerHTML = top.foo;\n"
         "window.open = function () { alert('Isolated World'); }\n"
         "document.open(1, 2, 3);";
-    GRefPtr<GDBusProxy> proxy = adoptGRef(bus->createProxy("org.webkit.gtk.WebExtensionTest",
+    GUniquePtr<char> extensionBusName(g_strdup_printf("org.webkit.gtk.WebExtensionTest%u", Test::s_webExtensionID));
+    GRefPtr<GDBusProxy> proxy = adoptGRef(bus->createProxy(extensionBusName.get(),
         "/org/webkit/gtk/WebExtensionTest" , "org.webkit.gtk.WebExtensionTest", test->m_mainLoop));
     g_dbus_proxy_call(proxy.get(),
         "RunJavaScriptInIsolatedWorld",
@@ -173,44 +177,12 @@
     g_signal_handler_disconnect(test->m_webView, scriptDialogID);
 }
 
-static void testWebExtensionInitializationUserData(WebViewTest* test, gconstpointer)
-{
-    test->loadHtml("<html></html>", 0);
-    test->waitUntilLoadFinished();
-
-    GRefPtr<GDBusProxy> proxy = adoptGRef(bus->createProxy("org.webkit.gtk.WebExtensionTest",
-        "/org/webkit/gtk/WebExtensionTest", "org.webkit.gtk.WebExtensionTest", test->m_mainLoop));
-
-    GRefPtr<GVariant> result = adoptGRef(g_dbus_proxy_call_sync(
-        proxy.get(),
-        "GetInitializationUserData",
-        nullptr,
-        G_DBUS_CALL_FLAGS_NONE,
-        -1, 0, 0));
-    g_assert(result);
-
-    const gchar* userData = nullptr;
-    g_variant_get(result.get(), "(&s)", &userData);
-    g_assert_cmpstr(userData, ==, webExtensionsUserData);
-}
-
-static void initializeWebExtensions(WebKitWebContext* context, gpointer)
-{
-    webkit_web_context_set_web_extensions_directory(context, WEBKIT_TEST_WEB_EXTENSIONS_DIR);
-    webkit_web_context_set_web_extensions_initialization_user_data(context,
-        g_variant_new("&s", webExtensionsUserData));
-}
-
 void beforeAll()
 {
-    g_signal_connect(webkit_web_context_get_default(),
-        "initialize-web-extensions", G_CALLBACK(initializeWebExtensions), nullptr);
-
     bus = new WebKitTestBus();
     if (!bus->run())
         return;
 
-    WebViewTest::add("WebKitWebContext", "initialization-user-data", testWebExtensionInitializationUserData);
     WebViewTest::add("WebKitWebExtension", "dom-document-title", testWebExtensionGetTitle);
     WebViewTest::add("WebKitWebExtension", "document-loaded-signal", testDocumentLoadedSignal);
     WebViewTest::add("WebKitWebView", "web-process-crashed", testWebKitWebViewProcessCrashed);

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitFaviconDatabase.cpp (176255 => 176256)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitFaviconDatabase.cpp	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitFaviconDatabase.cpp	2014-11-18 14:19:15 UTC (rev 176256)
@@ -26,18 +26,16 @@
 #include <wtf/gobject/GUniquePtr.h>
 
 static WebKitTestServer* kServer;
-static char* kTempDirectory;
 
 class FaviconDatabaseTest: public WebViewTest {
 public:
     MAKE_GLIB_TEST_FIXTURE(FaviconDatabaseTest);
 
     FaviconDatabaseTest()
-        : m_webContext(webkit_web_context_get_default())
-        , m_favicon(0)
+        : m_favicon(nullptr)
         , m_faviconNotificationReceived(false)
     {
-        WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(m_webContext);
+        WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(m_webContext.get());
         g_signal_connect(database, "favicon-changed", G_CALLBACK(faviconChangedCallback), this);
     }
 
@@ -46,7 +44,7 @@
         if (m_favicon)
             cairo_surface_destroy(m_favicon);
 
-        WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(m_webContext);
+        WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(m_webContext.get());
         g_signal_handlers_disconnect_matched(database, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
     }
 
@@ -67,7 +65,7 @@
     static void getFaviconCallback(GObject* sourceObject, GAsyncResult* result, void* data)
     {
         FaviconDatabaseTest* test = static_cast<FaviconDatabaseTest*>(data);
-        WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(test->m_webContext);
+        WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(test->m_webContext.get());
         test->m_favicon = webkit_favicon_database_get_favicon_finish(database, result, &test->m_error.outPtr());
         test->quitMainLoop();
     }
@@ -87,12 +85,11 @@
             m_favicon = 0;
         }
 
-        WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(m_webContext);
+        WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(m_webContext.get());
         webkit_favicon_database_get_favicon(database, pageURI, 0, getFaviconCallback, this);
         g_main_loop_run(m_mainLoop);
     }
 
-    WebKitWebContext* m_webContext;
     cairo_surface_t* m_favicon;
     CString m_faviconURI;
     GUniqueOutPtr<GError> m_error;
@@ -142,13 +139,13 @@
 
 static void testSetDirectory(FaviconDatabaseTest* test)
 {
-    webkit_web_context_set_favicon_database_directory(test->m_webContext, kTempDirectory);
-    g_assert_cmpstr(kTempDirectory, ==, webkit_web_context_get_favicon_database_directory(test->m_webContext));
+    webkit_web_context_set_favicon_database_directory(test->m_webContext.get(), Test::dataDirectory());
+    g_assert_cmpstr(Test::dataDirectory(), ==, webkit_web_context_get_favicon_database_directory(test->m_webContext.get()));
 }
 
 static void testClearDatabase(FaviconDatabaseTest* test)
 {
-    WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(test->m_webContext);
+    WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(test->m_webContext.get());
     webkit_favicon_database_clear(database);
 
     GUniquePtr<char> iconURI(webkit_favicon_database_get_favicon_uri(database, kServer->getURIForPath("/foo").data()));
@@ -198,7 +195,7 @@
 
 static void testGetFaviconURI(FaviconDatabaseTest* test)
 {
-    WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(test->m_webContext);
+    WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(test->m_webContext.get());
 
     CString baseURI = kServer->getURIForPath("/foo");
     GUniquePtr<char> iconURI(webkit_favicon_database_get_favicon_uri(database, baseURI.data()));
@@ -243,30 +240,11 @@
     kServer = new WebKitTestServer();
     kServer->run(serverCallback);
 
-    kTempDirectory = g_dir_make_tmp("WebKit2Tests-XXXXXX", 0);
-    g_assert(kTempDirectory);
-
     // Add tests to the suite.
     FaviconDatabaseTest::add("WebKitFaviconDatabase", "favicon-database-test", testFaviconDatabase);
 }
 
-static void webkitFaviconDatabaseFinalizedCallback(gpointer, GObject*)
-{
-    if (!g_file_test(kTempDirectory, G_FILE_TEST_IS_DIR))
-        return;
-
-    GUniquePtr<char> filename(g_build_filename(kTempDirectory, "WebpageIcons.db", nullptr));
-    g_unlink(filename.get());
-
-    g_rmdir(kTempDirectory);
-}
-
 void afterAll()
 {
     delete kServer;
-
-    // Delete the temporary files after the IconDatabase has been
-    // closed, that is, once WebKitFaviconDatabase is being destroyed.
-    WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(webkit_web_context_get_default());
-    g_object_weak_ref(G_OBJECT(database), webkitFaviconDatabaseFinalizedCallback, 0);
 }

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitUserContentManager.cpp (176255 => 176256)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitUserContentManager.cpp	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitUserContentManager.cpp	2014-11-18 14:19:15 UTC (rev 176256)
@@ -32,7 +32,7 @@
     MAKE_GLIB_TEST_FIXTURE(UserContentManagerTest);
 
     UserContentManagerTest()
-        : WebViewTest(WEBKIT_WEB_VIEW(webkit_web_view_new_with_user_content_manager(webkit_user_content_manager_new())))
+        : WebViewTest(webkit_user_content_manager_new())
     {
         // A reference is leaked when passing the result of webkit_user_content_manager_new()
         // directly to webkit_web_view_new_with_user_content_manager() above. Adopting the
@@ -367,7 +367,6 @@
 
 void beforeAll()
 {
-    webkit_web_context_set_web_extensions_directory(webkit_web_context_get_default(), WEBKIT_TEST_WEB_EXTENSIONS_DIR);
     kServer = new WebKitTestServer();
     kServer->run(serverCallback);
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp (176255 => 176256)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp	2014-11-18 14:19:15 UTC (rev 176256)
@@ -34,6 +34,7 @@
 {
     // Check there's a single instance of the default web context.
     g_assert(webkit_web_context_get_default() == webkit_web_context_get_default());
+    g_assert(webkit_web_context_get_default() != test->m_webContext.get());
 }
 
 class PluginsTest: public Test {
@@ -41,11 +42,10 @@
     MAKE_GLIB_TEST_FIXTURE(PluginsTest);
 
     PluginsTest()
-        : m_context(webkit_web_context_get_default())
-        , m_mainLoop(g_main_loop_new(0, TRUE))
-        , m_plugins(0)
+        : m_mainLoop(g_main_loop_new(nullptr, TRUE))
+        , m_plugins(nullptr)
     {
-        webkit_web_context_set_additional_plugins_directory(m_context, WEBKIT_TEST_PLUGIN_DIR);
+        webkit_web_context_set_additional_plugins_directory(m_webContext.get(), WEBKIT_TEST_PLUGIN_DIR);
     }
 
     ~PluginsTest()
@@ -56,19 +56,18 @@
 
     static void getPluginsAsyncReadyCallback(GObject*, GAsyncResult* result, PluginsTest* test)
     {
-        test->m_plugins = webkit_web_context_get_plugins_finish(test->m_context, result, 0);
+        test->m_plugins = webkit_web_context_get_plugins_finish(test->m_webContext.get(), result, nullptr);
         g_main_loop_quit(test->m_mainLoop);
     }
 
     GList* getPlugins()
     {
         g_list_free_full(m_plugins, g_object_unref);
-        webkit_web_context_get_plugins(m_context, 0, reinterpret_cast<GAsyncReadyCallback>(getPluginsAsyncReadyCallback), this);
+        webkit_web_context_get_plugins(m_webContext.get(), nullptr, reinterpret_cast<GAsyncReadyCallback>(getPluginsAsyncReadyCallback), this);
         g_main_loop_run(m_mainLoop);
         return m_plugins;
     }
 
-    WebKitWebContext* m_context;
     GMainLoop* m_mainLoop;
     GList* m_plugins;
 };
@@ -177,7 +176,7 @@
     void registerURISchemeHandler(const char* scheme, const char* reply, int replyLength, const char* mimeType)
     {
         m_handlersMap.set(String::fromUTF8(scheme), URISchemeHandler(reply, replyLength, mimeType));
-        webkit_web_context_register_uri_scheme(webkit_web_context_get_default(), scheme, uriSchemeRequestCallback, this, 0);
+        webkit_web_context_register_uri_scheme(m_webContext.get(), scheme, uriSchemeRequestCallback, this, 0);
     }
 
     GRefPtr<WebKitURISchemeRequest> m_uriSchemeRequest;
@@ -236,7 +235,7 @@
 
 static void testWebContextSpellChecker(Test* test, gconstpointer)
 {
-    WebKitWebContext* webContext = webkit_web_context_get_default();
+    WebKitWebContext* webContext = test->m_webContext.get();
 
     // Check what happens if no spell checking language has been set.
     const gchar* const* currentLanguage = webkit_web_context_get_spell_checking_languages(webContext);
@@ -302,7 +301,7 @@
     g_ptr_array_add(languages.get(), const_cast<gpointer>(static_cast<const void*>("ES_es")));
     g_ptr_array_add(languages.get(), const_cast<gpointer>(static_cast<const void*>("dE")));
     g_ptr_array_add(languages.get(), 0);
-    webkit_web_context_set_preferred_languages(webkit_web_context_get_default(), reinterpret_cast<const char* const*>(languages->pdata));
+    webkit_web_context_set_preferred_languages(test->m_webContext.get(), reinterpret_cast<const char* const*>(languages->pdata));
 
     static const char* expectedLanguages = "en, es-es;q=0.90, de;q=0.80";
     test->loadURI(kServer->getURIForPath("/").data());
@@ -343,7 +342,7 @@
     };
 
     SecurityPolicyTest()
-        : m_manager(webkit_web_context_get_security_manager(webkit_web_context_get_default()))
+        : m_manager(webkit_web_context_get_security_manager(m_webContext.get()))
     {
     }
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp (176255 => 176256)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp	2014-11-18 14:19:15 UTC (rev 176256)
@@ -51,9 +51,6 @@
     "   <arg type='t' name='pageID' direction='in'/>"
     "   <arg type='s' name='script' direction='in'/>"
     "  </method>"
-    "  <method name='GetInitializationUserData'>"
-    "   <arg type='s' name='userData' direction='out'/>"
-    "  </method>"
     "  <method name='GetProcessIdentifier'>"
     "   <arg type='u' name='identifier' direction='out'/>"
     "  </method>"
@@ -64,9 +61,7 @@
     " </interface>"
     "</node>";
 
-static GRefPtr<GVariant> initializationUserData;
 
-
 typedef enum {
     DocumentLoadedSignal,
     URIChangedSignal,
@@ -304,11 +299,6 @@
         g_dbus_method_invocation_return_value(invocation, 0);
     } else if (!g_strcmp0(methodName, "AbortProcess")) {
         abort();
-    } else if (!g_strcmp0(methodName, "GetInitializationUserData")) {
-        g_assert(initializationUserData);
-        g_assert(g_variant_is_of_type(initializationUserData.get(), G_VARIANT_TYPE_STRING));
-        g_dbus_method_invocation_return_value(invocation, g_variant_new("(s)",
-            g_variant_get_string(initializationUserData.get(), nullptr)));
     } else if (!g_strcmp0(methodName, "GetProcessIdentifier")) {
         g_dbus_method_invocation_return_value(invocation,
             g_variant_new("(u)", static_cast<guint32>(getCurrentProcessID())));
@@ -351,26 +341,14 @@
     }
 }
 
-static GUniquePtr<char> makeBusName(GVariant* userData)
-{
-    // When the web extension is used by TestMultiprocess, an uint32
-    // identifier is passed as user data. It uniquely identifies
-    // the web process, and the UI side expects it added as suffix to
-    // the bus name.
-    if (userData && g_variant_is_of_type(userData, G_VARIANT_TYPE_UINT32))
-        return GUniquePtr<char>(g_strdup_printf("org.webkit.gtk.WebExtensionTest%u", g_variant_get_uint32(userData)));
-
-    return GUniquePtr<char>(g_strdup("org.webkit.gtk.WebExtensionTest"));
-}
-
 extern "C" void webkit_web_extension_initialize_with_user_data(WebKitWebExtension* extension, GVariant* userData)
 {
-    initializationUserData = userData;
-
     g_signal_connect(extension, "page-created", G_CALLBACK(pageCreatedCallback), extension);
     g_signal_connect(webkit_script_world_get_default(), "window-object-cleared", G_CALLBACK(windowObjectCleared), 0);
 
-    GUniquePtr<char> busName(makeBusName(userData));
+    g_assert(userData);
+    g_assert(g_variant_is_of_type(userData, G_VARIANT_TYPE_UINT32));
+    GUniquePtr<char> busName(g_strdup_printf("org.webkit.gtk.WebExtensionTest%u", g_variant_get_uint32(userData)));
     g_bus_own_name(
         G_BUS_TYPE_SESSION,
         busName.get(),

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.cpp (176255 => 176256)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.cpp	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.cpp	2014-11-18 14:19:15 UTC (rev 176256)
@@ -93,11 +93,14 @@
         g_warning("Failed to register object: %s\n", error->message);
 }
 
-extern "C" void webkit_web_extension_initialize(WebKitWebExtension* extension)
+extern "C" void webkit_web_extension_initialize_with_user_data(WebKitWebExtension* extension, GVariant* userData)
 {
+    g_assert(userData);
+    g_assert(g_variant_is_of_type(userData, G_VARIANT_TYPE_UINT32));
+    GUniquePtr<char> busName(g_strdup_printf("org.webkit.gtk.WebProcessTest%u", g_variant_get_uint32(userData)));
     g_bus_own_name(
         G_BUS_TYPE_SESSION,
-        "org.webkit.gtk.WebProcessTest",
+        busName.get(),
         G_BUS_NAME_OWNER_FLAGS_NONE,
         busAcquiredCallback,
         0, 0,

Modified: trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/TestMain.cpp (176255 => 176256)


--- trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/TestMain.cpp	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/TestMain.cpp	2014-11-18 14:19:15 UTC (rev 176256)
@@ -22,12 +22,19 @@
 
 #include <glib/gstdio.h>
 #include <gtk/gtk.h>
-#include <webkit2/webkit2.h>
-#include <wtf/gobject/GUniquePtr.h>
 
+uint32_t Test::s_webExtensionID = 0;
+
 void beforeAll();
 void afterAll();
 
+static GUniquePtr<char> testDataDirectory(g_dir_make_tmp("WebKit2GtkTests-XXXXXX", nullptr));
+
+const char* Test::dataDirectory()
+{
+    return testDataDirectory.get();
+}
+
 static void registerGResource(void)
 {
     GUniquePtr<char> resourcesPath(g_build_filename(WEBKIT_EXEC_PATH, "TestWebKitAPI", "WebKit2Gtk", "resources", "webkit2gtk-tests-resources.gresource", nullptr));
@@ -45,7 +52,10 @@
     const char* fileName;
     while ((fileName = g_dir_read_name(directory))) {
         GUniquePtr<char> filePath(g_build_filename(directoryPath, fileName, nullptr));
-        g_unlink(filePath.get());
+        if (g_file_test(filePath.get(), G_FILE_TEST_IS_DIR))
+            removeNonEmptyDirectory(filePath.get());
+        else
+            g_unlink(filePath.get());
     }
     g_dir_close(directory);
     g_rmdir(directoryPath);
@@ -66,15 +76,12 @@
 
     registerGResource();
 
-    GUniquePtr<char> diskCacheTempDirectory(g_dir_make_tmp("WebKit2TestsDiskCache-XXXXXX", 0));
-    g_assert(diskCacheTempDirectory.get());
-    webkit_web_context_set_disk_cache_directory(webkit_web_context_get_default(), diskCacheTempDirectory.get());
-
     beforeAll();
     int returnValue = g_test_run();
     afterAll();
 
-    removeNonEmptyDirectory(diskCacheTempDirectory.get());
+    removeNonEmptyDirectory(testDataDirectory.get());
 
     return returnValue;
 }
+

Modified: trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/TestMain.h (176255 => 176256)


--- trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/TestMain.h	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/TestMain.h	2014-11-18 14:19:15 UTC (rev 176256)
@@ -22,7 +22,9 @@
 
 #include <cairo.h>
 #include <glib-object.h>
+#include <webkit2/webkit2.h>
 #include <wtf/HashSet.h>
+#include <wtf/gobject/GRefPtr.h>
 #include <wtf/gobject/GUniquePtr.h>
 #include <wtf/text/CString.h>
 
@@ -56,8 +58,24 @@
 public:
     MAKE_GLIB_TEST_FIXTURE(Test);
 
+    static const char* dataDirectory();
+
+    static void initializeWebExtensionsCallback(WebKitWebContext* context, Test* test)
+    {
+        test->initializeWebExtensions();
+    }
+
+    Test()
+        : m_webContext(adoptGRef(webkit_web_context_new()))
+    {
+        g_signal_connect(m_webContext.get(), "initialize-web-extensions", G_CALLBACK(initializeWebExtensionsCallback), this);
+        GUniquePtr<char> diskCacheDirectory(g_build_filename(dataDirectory(), "disk-cache", nullptr));
+        webkit_web_context_set_disk_cache_directory(m_webContext.get(), diskCacheDirectory.get());
+    }
+
     ~Test()
     {
+        g_signal_handlers_disconnect_matched(m_webContext.get(), G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this);
         if (m_watchedObjects.isEmpty())
             return;
 
@@ -70,6 +88,12 @@
         g_assert(m_watchedObjects.isEmpty());
     }
 
+    virtual void initializeWebExtensions()
+    {
+        webkit_web_context_set_web_extensions_directory(m_webContext.get(), WEBKIT_TEST_WEB_EXTENSIONS_DIR);
+        webkit_web_context_set_web_extensions_initialization_user_data(m_webContext.get(), g_variant_new_uint32(++s_webExtensionID));
+    }
+
     static void objectFinalized(Test* test, GObject* finalizedObject)
     {
         test->m_watchedObjects.remove(finalizedObject);
@@ -113,6 +137,8 @@
     }
 
     HashSet<GObject*> m_watchedObjects;
+    GRefPtr<WebKitWebContext> m_webContext;
+    static uint32_t s_webExtensionID;
 };
 
 #endif // TestMain_h

Modified: trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.cpp (176255 => 176256)


--- trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.cpp	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.cpp	2014-11-18 14:19:15 UTC (rev 176256)
@@ -39,8 +39,8 @@
     g_main_loop_unref(m_mainLoop);
 
     // g_test_dbus_down waits until the connection is freed, so release our refs explicitly before calling it.
-    m_connection = 0;
-    m_proxy = 0;
+    m_connection = nullptr;
+    m_proxy = nullptr;
     g_test_dbus_down(m_bus.get());
 }
 
@@ -50,20 +50,6 @@
     g_main_loop_quit(testRunner->m_mainLoop);
 }
 
-GDBusProxy* WebProcessTestRunner::proxy()
-{
-    if (m_proxy)
-        return m_proxy.get();
-
-    g_dbus_proxy_new(m_connection.get(), G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, 0,
-        "org.webkit.gtk.WebProcessTest", "/org/webkit/gtk/WebProcessTest", "org.webkit.gtk.WebProcessTest",
-        0, reinterpret_cast<GAsyncReadyCallback>(WebProcessTestRunner::proxyCreatedCallback), this);
-    g_main_loop_run(m_mainLoop);
-    g_assert(m_proxy.get());
-
-    return m_proxy.get();
-}
-
 void WebProcessTestRunner::onNameAppeared(GDBusConnection*, const char*, const char*, gpointer userData)
 {
     WebProcessTestRunner* testRunner = static_cast<WebProcessTestRunner*>(userData);
@@ -84,18 +70,25 @@
     testRunner->finishTest(testResult);
 }
 
-bool WebProcessTestRunner::runTest(const char* suiteName, const char* testName, GVariant* args)
+bool WebProcessTestRunner::runTest(const char* suiteName, const char* testName, uint32_t testID, GVariant* args)
 {
     g_assert(g_variant_is_of_type(args, G_VARIANT_TYPE_VARDICT));
 
-    unsigned watcherID = g_bus_watch_name_on_connection(m_connection.get(), "org.webkit.gtk.WebProcessTest", G_BUS_NAME_WATCHER_FLAGS_NONE,
+    GUniquePtr<char> testBusName(g_strdup_printf("org.webkit.gtk.WebProcessTest%u", testID));
+    unsigned watcherID = g_bus_watch_name_on_connection(m_connection.get(), testBusName.get(), G_BUS_NAME_WATCHER_FLAGS_NONE,
         WebProcessTestRunner::onNameAppeared, WebProcessTestRunner::onNameVanished, this, 0);
     g_main_loop_run(m_mainLoop);
 
+    g_dbus_proxy_new(m_connection.get(), G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, nullptr,
+        testBusName.get(), "/org/webkit/gtk/WebProcessTest", "org.webkit.gtk.WebProcessTest",
+        nullptr, reinterpret_cast<GAsyncReadyCallback>(WebProcessTestRunner::proxyCreatedCallback), this);
+    g_main_loop_run(m_mainLoop);
+    g_assert(m_proxy.get());
+
     m_testResult = false;
     GUniquePtr<char> testPath(g_strdup_printf("%s/%s", suiteName, testName));
     g_dbus_proxy_call(
-        proxy(),
+        m_proxy.get(),
         "RunTest",
         g_variant_new("(s@a{sv})", testPath.get(), args),
         G_DBUS_CALL_FLAGS_NONE,

Modified: trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.h (176255 => 176256)


--- trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.h	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.h	2014-11-18 14:19:15 UTC (rev 176256)
@@ -29,7 +29,7 @@
     WebProcessTestRunner();
     ~WebProcessTestRunner();
 
-    bool runTest(const char* suiteName, const char* testName, GVariant* args);
+    bool runTest(const char* suiteName, const char* testName, uint32_t testID, GVariant* args);
 
 private:
     static void proxyCreatedCallback(GObject*, GAsyncResult*, WebProcessTestRunner*);
@@ -37,7 +37,6 @@
     static void onNameVanished(GDBusConnection*, const char*, gpointer);
     static void testFinishedCallback(GDBusProxy*, GAsyncResult*, WebProcessTestRunner*);
 
-    GDBusProxy* proxy();
     void finishTest(bool result);
 
     GMainLoop* m_mainLoop;

Modified: trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp (176255 => 176256)


--- trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp	2014-11-18 14:19:15 UTC (rev 176256)
@@ -24,16 +24,13 @@
 #include <_javascript_Core/JSRetainPtr.h>
 #include <WebCore/GUniquePtrGtk.h>
 
-WebViewTest::WebViewTest()
-    : WebViewTest(WEBKIT_WEB_VIEW(webkit_web_view_new())) { }
-
-WebViewTest::WebViewTest(WebKitWebView* webView)
-    : m_webView(WEBKIT_WEB_VIEW(g_object_ref_sink(webView)))
-    , m_mainLoop(g_main_loop_new(0, TRUE))
-    , m_parentWindow(0)
-    , m_javascriptResult(0)
+WebViewTest::WebViewTest(WebKitUserContentManager* userContentManager)
+    : m_webView(WEBKIT_WEB_VIEW(g_object_ref_sink(g_object_new(WEBKIT_TYPE_WEB_VIEW, "web-context", m_webContext.get(), "user-content-manager", userContentManager, nullptr))))
+    , m_mainLoop(g_main_loop_new(nullptr, TRUE))
+    , m_parentWindow(nullptr)
+    , m_javascriptResult(nullptr)
     , m_resourceDataSize(0)
-    , m_surface(0)
+    , m_surface(nullptr)
 {
     assertObjectIsDeletedWhenTestFinishes(G_OBJECT(m_webView));
 }

Modified: trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h (176255 => 176256)


--- trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h	2014-11-18 13:40:49 UTC (rev 176255)
+++ trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h	2014-11-18 14:19:15 UTC (rev 176256)
@@ -28,8 +28,7 @@
 class WebViewTest: public Test {
 public:
     MAKE_GLIB_TEST_FIXTURE(WebViewTest);
-    WebViewTest(WebKitWebView*);
-    WebViewTest();
+    WebViewTest(WebKitUserContentManager* = nullptr);
     virtual ~WebViewTest();
 
     virtual void loadURI(const char* uri);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to