[GTK] Use custom JavaScript instead of DBus to implement WebProcess tests
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Nov 2014 14:29:26 +0000 (14:29 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Nov 2014 14:29:26 +0000 (14:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=138834

Reviewed by Sergio Villar Senin.

It makes everyting simpler and the tests run faster too, since we
don't need to spawn the private bus and wait until the DBus name
is registered. The web extension registers a new JavaSCript class
with a status method to run the tests, similar to the DBus
method. In the UI process side, tests use webkit_web_view_run_java_script()
instead of sending a DBus message.

* TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt:
* TestWebKitAPI/Tests/WebKit2Gtk/DOMNodeFilterTest.cpp:
(WebKitDOMNodeFilterTest::create):
(WebKitDOMNodeFilterTest::testTreeWalker):
(WebKitDOMNodeFilterTest::testNodeIterator):
(WebKitDOMNodeFilterTest::webPageFromArgs): Deleted.
(WebKitDOMNodeFilterTest::runTest): Deleted.
* TestWebKitAPI/Tests/WebKit2Gtk/DOMNodeTest.cpp:
(WebKitDOMNodeTest::create):
(WebKitDOMNodeTest::testHierarchyNavigation):
(WebKitDOMNodeTest::testInsertion):
(WebKitDOMNodeTest::testTagNames):
(WebKitDOMNodeTest::webPageFromArgs): Deleted.
(WebKitDOMNodeTest::runTest): Deleted.
* TestWebKitAPI/Tests/WebKit2Gtk/DOMXPathNSResolverTest.cpp:
(WebKitDOMXPathNSResolverTest::create):
(WebKitDOMXPathNSResolverTest::testXPathNSResolverNative):
(WebKitDOMXPathNSResolverTest::testXPathNSResolverCustom):
(WebKitDOMXPathNSResolverTest::webPageFromArgs): Deleted.
(WebKitDOMXPathNSResolverTest::runTest): Deleted.
* TestWebKitAPI/Tests/WebKit2Gtk/FrameTest.cpp:
(WebKitFrameTest::create):
(WebKitFrameTest::testMainFrame):
(WebKitFrameTest::testURI):
(WebKitFrameTest::testJavaScriptContext):
(WebKitFrameTest::webPageFromArgs): Deleted.
(WebKitFrameTest::runTest): Deleted.
* TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNode.cpp:
(testWebKitDOMNodeHierarchyNavigation):
(testWebKitDOMNodeInsertion):
(testWebKitDOMNodeTagNames):
(beforeAll):
(afterAll):
* TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNodeFilter.cpp:
(runTest):
(beforeAll):
(afterAll):
* TestWebKitAPI/Tests/WebKit2Gtk/TestDOMXPathNSResolver.cpp:
(testWebKitDOMXPathNSResolverNative):
(testWebKitDOMXPathNSResolverCustom):
(beforeAll):
(afterAll):
(runTest): Deleted.
* TestWebKitAPI/Tests/WebKit2Gtk/TestFrame.cpp:
(webkitFrameTestRun):
(beforeAll):
(afterAll):
* TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.cpp:
(testsMap):
(WebProcessTest::add):
(WebProcessTest::create):
(runTest):
(windowObjectClearedCallback):
(webkit_web_extension_initialize):
(methodCallCallback): Deleted.
(webkit_web_extension_initialize_with_user_data): Deleted.
* TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.h:
* TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.cpp: Removed.
* TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.h: Removed.
* TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp:
(WebViewTest::runWebProcessTest):
* TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h:

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

16 files changed:
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt
Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMNodeFilterTest.cpp
Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMNodeTest.cpp
Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMXPathNSResolverTest.cpp
Tools/TestWebKitAPI/Tests/WebKit2Gtk/FrameTest.cpp
Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNode.cpp
Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNodeFilter.cpp
Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMXPathNSResolver.cpp
Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestFrame.cpp
Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.cpp
Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.h
Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.cpp [deleted file]
Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.h [deleted file]
Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp
Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h

index 8e8c6573a050e1307fb096cd5e5bb07ad126ae80..5fdc9ebf6da8d938b3707b23f6be93cd70e6d552 100644 (file)
@@ -1,3 +1,80 @@
+2014-11-28  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] Use custom JavaScript instead of DBus to implement WebProcess tests
+        https://bugs.webkit.org/show_bug.cgi?id=138834
+
+        Reviewed by Sergio Villar Senin.
+
+        It makes everyting simpler and the tests run faster too, since we
+        don't need to spawn the private bus and wait until the DBus name
+        is registered. The web extension registers a new JavaSCript class
+        with a status method to run the tests, similar to the DBus
+        method. In the UI process side, tests use webkit_web_view_run_java_script()
+        instead of sending a DBus message.
+
+        * TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt:
+        * TestWebKitAPI/Tests/WebKit2Gtk/DOMNodeFilterTest.cpp:
+        (WebKitDOMNodeFilterTest::create):
+        (WebKitDOMNodeFilterTest::testTreeWalker):
+        (WebKitDOMNodeFilterTest::testNodeIterator):
+        (WebKitDOMNodeFilterTest::webPageFromArgs): Deleted.
+        (WebKitDOMNodeFilterTest::runTest): Deleted.
+        * TestWebKitAPI/Tests/WebKit2Gtk/DOMNodeTest.cpp:
+        (WebKitDOMNodeTest::create):
+        (WebKitDOMNodeTest::testHierarchyNavigation):
+        (WebKitDOMNodeTest::testInsertion):
+        (WebKitDOMNodeTest::testTagNames):
+        (WebKitDOMNodeTest::webPageFromArgs): Deleted.
+        (WebKitDOMNodeTest::runTest): Deleted.
+        * TestWebKitAPI/Tests/WebKit2Gtk/DOMXPathNSResolverTest.cpp:
+        (WebKitDOMXPathNSResolverTest::create):
+        (WebKitDOMXPathNSResolverTest::testXPathNSResolverNative):
+        (WebKitDOMXPathNSResolverTest::testXPathNSResolverCustom):
+        (WebKitDOMXPathNSResolverTest::webPageFromArgs): Deleted.
+        (WebKitDOMXPathNSResolverTest::runTest): Deleted.
+        * TestWebKitAPI/Tests/WebKit2Gtk/FrameTest.cpp:
+        (WebKitFrameTest::create):
+        (WebKitFrameTest::testMainFrame):
+        (WebKitFrameTest::testURI):
+        (WebKitFrameTest::testJavaScriptContext):
+        (WebKitFrameTest::webPageFromArgs): Deleted.
+        (WebKitFrameTest::runTest): Deleted.
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNode.cpp:
+        (testWebKitDOMNodeHierarchyNavigation):
+        (testWebKitDOMNodeInsertion):
+        (testWebKitDOMNodeTagNames):
+        (beforeAll):
+        (afterAll):
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNodeFilter.cpp:
+        (runTest):
+        (beforeAll):
+        (afterAll):
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestDOMXPathNSResolver.cpp:
+        (testWebKitDOMXPathNSResolverNative):
+        (testWebKitDOMXPathNSResolverCustom):
+        (beforeAll):
+        (afterAll):
+        (runTest): Deleted.
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestFrame.cpp:
+        (webkitFrameTestRun):
+        (beforeAll):
+        (afterAll):
+        * TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.cpp:
+        (testsMap):
+        (WebProcessTest::add):
+        (WebProcessTest::create):
+        (runTest):
+        (windowObjectClearedCallback):
+        (webkit_web_extension_initialize):
+        (methodCallCallback): Deleted.
+        (webkit_web_extension_initialize_with_user_data): Deleted.
+        * TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.h:
+        * TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.cpp: Removed.
+        * TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.h: Removed.
+        * TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp:
+        (WebViewTest::runWebProcessTest):
+        * TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h:
+
 2014-11-28  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         [EFL] libseccomp should pick up CC environment variable to be conform to other jhbuild modules
index a9c1d64ced9b8fac07ae1b3bd4acd0e09bab3a3e..72ed45d1c6c50dedf58dc58b2034c87e0bdadf4f 100644 (file)
@@ -32,7 +32,6 @@ add_library(WebKit2APITestCore STATIC
     ${TOOLS_DIR}/TestWebKitAPI/gtk/WebKit2Gtk/LoadTrackingTest.cpp
     ${TOOLS_DIR}/TestWebKitAPI/gtk/WebKit2Gtk/WebKitTestBus.cpp
     ${TOOLS_DIR}/TestWebKitAPI/gtk/WebKit2Gtk/WebKitTestServer.cpp
-    ${TOOLS_DIR}/TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.cpp
     ${TOOLS_DIR}/TestWebKitAPI/gtk/WebKit2Gtk/TestMain.cpp
     ${TOOLS_DIR}/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp
 )
index 9a97827eada281ff03e044c57fedf7273b7c17f4..24b35896dca3de2cfe856e54d051fcd6b9e55e41 100644 (file)
@@ -59,29 +59,11 @@ static const char* expectedElementsNoInput[] = { "HTML", "HEAD", "TITLE", "BODY"
 
 class WebKitDOMNodeFilterTest : public WebProcessTest {
 public:
-    static PassOwnPtr<WebProcessTest> create() { return adoptPtr(new WebKitDOMNodeFilterTest()); }
+    static std::unique_ptr<WebProcessTest> create() { return std::unique_ptr<WebProcessTest>(new WebKitDOMNodeFilterTest()); }
 
 private:
-    guint64 webPageFromArgs(GVariant* args)
+    bool testTreeWalker(WebKitWebPage* page)
     {
-        GVariantIter iter;
-        g_variant_iter_init(&iter, args);
-
-        const char* key;
-        GVariant* value;
-        while (g_variant_iter_loop(&iter, "{&sv}", &key, &value)) {
-            if (!strcmp(key, "pageID") && g_variant_classify(value) == G_VARIANT_CLASS_UINT64)
-                return g_variant_get_uint64(value);
-        }
-
-        g_assert_not_reached();
-        return 0;
-    }
-
-    bool testTreeWalker(WebKitWebExtension* extension, GVariant* args)
-    {
-        WebKitWebPage* page = webkit_web_extension_get_page(extension, webPageFromArgs(args));
-        g_assert(WEBKIT_IS_WEB_PAGE(page));
         WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
         g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
 
@@ -131,10 +113,8 @@ private:
         return true;
     }
 
-    bool testNodeIterator(WebKitWebExtension* extension, GVariant* args)
+    bool testNodeIterator(WebKitWebPage* page)
     {
-        WebKitWebPage* page = webkit_web_extension_get_page(extension, webPageFromArgs(args));
-        g_assert(WEBKIT_IS_WEB_PAGE(page));
         WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
         g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
 
@@ -187,12 +167,12 @@ private:
         return true;
     }
 
-    virtual bool runTest(const char* testName, WebKitWebExtension* extension, GVariant* args)
+    bool runTest(const char* testName, WebKitWebPage* page) override
     {
         if (!strcmp(testName, "tree-walker"))
-            return testTreeWalker(extension, args);
+            return testTreeWalker(page);
         if (!strcmp(testName, "node-iterator"))
-            return testNodeIterator(extension, args);
+            return testNodeIterator(page);
 
         g_assert_not_reached();
         return false;
index d187c5901f8f63861ace71a4a60b4b6ba3342142..5f62e54934eff3e06efa0f14d0c509ec86c50c2b 100644 (file)
 
 class WebKitDOMNodeTest : public WebProcessTest {
 public:
-    static PassOwnPtr<WebProcessTest> create() { return adoptPtr(new WebKitDOMNodeTest()); }
+    static std::unique_ptr<WebProcessTest> create() { return std::unique_ptr<WebKitDOMNodeTest>(new WebKitDOMNodeTest()); }
 
 private:
-    guint64 webPageFromArgs(GVariant* args)
+    bool testHierarchyNavigation(WebKitWebPage* page)
     {
-        GVariantIter iter;
-        g_variant_iter_init(&iter, args);
-
-        const char* key;
-        GVariant* value;
-        while (g_variant_iter_loop(&iter, "{&sv}", &key, &value)) {
-            if (!strcmp(key, "pageID") && g_variant_classify(value) == G_VARIANT_CLASS_UINT64)
-                return g_variant_get_uint64(value);
-        }
-
-        g_assert_not_reached();
-        return 0;
-    }
-
-    bool testHierarchyNavigation(WebKitWebExtension* extension, GVariant* args)
-    {
-        WebKitWebPage* page = webkit_web_extension_get_page(extension, webPageFromArgs(args));
-        g_assert(WEBKIT_IS_WEB_PAGE(page));
         WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
         g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
 
@@ -95,10 +77,8 @@ private:
         return true;
     }
 
-    bool testInsertion(WebKitWebExtension* extension, GVariant* args)
+    bool testInsertion(WebKitWebPage* page)
     {
-        WebKitWebPage* page = webkit_web_extension_get_page(extension, webPageFromArgs(args));
-        g_assert(WEBKIT_IS_WEB_PAGE(page));
         WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
         g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
 
@@ -170,12 +150,10 @@ private:
         return true;
     }
 
-    bool testTagNames(WebKitWebExtension* extension, GVariant* args)
+    bool testTagNames(WebKitWebPage* page)
     {
         static const char* expectedTagNames[] = { "HTML", "HEAD", "BODY", "VIDEO", "SOURCE", "VIDEO", "SOURCE", "INPUT" };
 
-        WebKitWebPage* page = webkit_web_extension_get_page(extension, webPageFromArgs(args));
-        g_assert(WEBKIT_IS_WEB_PAGE(page));
         WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
         g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
 
@@ -192,14 +170,14 @@ private:
         return true;
     }
 
-    virtual bool runTest(const char* testName, WebKitWebExtension* extension, GVariant* args)
+    bool runTest(const char* testName, WebKitWebPage* page) override
     {
         if (!strcmp(testName, "hierarchy-navigation"))
-            return testHierarchyNavigation(extension, args);
+            return testHierarchyNavigation(page);
         if (!strcmp(testName, "insertion"))
-            return testInsertion(extension, args);
+            return testInsertion(page);
         if (!strcmp(testName, "tag-names"))
-            return testTagNames(extension, args);
+            return testTagNames(page);
 
         g_assert_not_reached();
         return false;
index f3ef5cfa947dd24d15a31fcedf16c2f3a7ac5aef..0434a8b10be8836cd0f6b16b1101185183b6c8d4 100644 (file)
@@ -57,25 +57,9 @@ static void webkit_xpath_ns_resolver_class_init(WebKitXPathNSResolverClass*)
 
 class WebKitDOMXPathNSResolverTest : public WebProcessTest {
 public:
-    static PassOwnPtr<WebProcessTest> create() { return adoptPtr(new WebKitDOMXPathNSResolverTest()); }
+    static std::unique_ptr<WebProcessTest> create() { return std::unique_ptr<WebProcessTest>(new WebKitDOMXPathNSResolverTest()); }
 
 private:
-    guint64 webPageFromArgs(GVariant* args)
-    {
-        GVariantIter iter;
-        g_variant_iter_init(&iter, args);
-
-        const char* key;
-        GVariant* value;
-        while (g_variant_iter_loop(&iter, "{&sv}", &key, &value)) {
-            if (!strcmp(key, "pageID") && g_variant_classify(value) == G_VARIANT_CLASS_UINT64)
-                return g_variant_get_uint64(value);
-        }
-
-        g_assert_not_reached();
-        return 0;
-    }
-
     void evaluateFooChildTextAndCheckResult(WebKitDOMDocument* document, WebKitDOMXPathNSResolver* resolver)
     {
         WebKitDOMElement* documentElement = webkit_dom_document_get_document_element(document);
@@ -91,10 +75,8 @@ private:
         g_assert_cmpstr(nodeValue.get(), ==, "SUCCESS");
     }
 
-    bool testXPathNSResolverNative(WebKitWebExtension* extension, GVariant* args)
+    bool testXPathNSResolverNative(WebKitWebPage* page)
     {
-        WebKitWebPage* page = webkit_web_extension_get_page(extension, webPageFromArgs(args));
-        g_assert(WEBKIT_IS_WEB_PAGE(page));
         WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
         g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
 
@@ -105,10 +87,8 @@ private:
         return true;
     }
 
-    bool testXPathNSResolverCustom(WebKitWebExtension* extension, GVariant* args)
+    bool testXPathNSResolverCustom(WebKitWebPage* page)
     {
-        WebKitWebPage* page = webkit_web_extension_get_page(extension, webPageFromArgs(args));
-        g_assert(WEBKIT_IS_WEB_PAGE(page));
         WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
         g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
 
@@ -118,12 +98,12 @@ private:
         return true;
     }
 
-    virtual bool runTest(const char* testName, WebKitWebExtension* extension, GVariant* args)
+    bool runTest(const char* testName, WebKitWebPage* page) override
     {
         if (!strcmp(testName, "native"))
-            return testXPathNSResolverNative(extension, args);
+            return testXPathNSResolverNative(page);
         if (!strcmp(testName, "custom"))
-            return testXPathNSResolverCustom(extension, args);
+            return testXPathNSResolverCustom(page);
 
         g_assert_not_reached();
         return false;
index 4d4850f521b39af72a3fe016db73e70b64ea9108..b9c86365bb062d1da79889f6da96d15281f1f83b 100644 (file)
 
 class WebKitFrameTest : public WebProcessTest {
 public:
-    static PassOwnPtr<WebProcessTest> create() { return adoptPtr(new WebKitFrameTest()); }
+    static std::unique_ptr<WebProcessTest> create() { return std::unique_ptr<WebProcessTest>(new WebKitFrameTest()); }
 
 private:
-    guint64 webPageFromArgs(GVariant* args)
+    bool testMainFrame(WebKitWebPage* page)
     {
-        GVariantIter iter;
-        g_variant_iter_init(&iter, args);
-
-        const char* key;
-        GVariant* value;
-        while (g_variant_iter_loop(&iter, "{&sv}", &key, &value)) {
-            if (!strcmp(key, "pageID") && g_variant_classify(value) == G_VARIANT_CLASS_UINT64)
-                return g_variant_get_uint64(value);
-        }
-
-        g_assert_not_reached();
-        return 0;
-    }
-
-    bool testMainFrame(WebKitWebExtension* extension, GVariant* args)
-    {
-        WebKitWebPage* page = webkit_web_extension_get_page(extension, webPageFromArgs(args));
-        g_assert(WEBKIT_IS_WEB_PAGE(page));
-
         WebKitFrame* frame = webkit_web_page_get_main_frame(page);
         g_assert(WEBKIT_IS_FRAME(frame));
         g_assert(webkit_frame_is_main_frame(frame));
@@ -56,11 +37,8 @@ private:
         return true;
     }
 
-    bool testURI(WebKitWebExtension* extension, GVariant* args)
+    bool testURI(WebKitWebPage* page)
     {
-        WebKitWebPage* page = webkit_web_extension_get_page(extension, webPageFromArgs(args));
-        g_assert(WEBKIT_IS_WEB_PAGE(page));
-
         WebKitFrame* frame = webkit_web_page_get_main_frame(page);
         g_assert(WEBKIT_IS_FRAME(frame));
         g_assert_cmpstr(webkit_web_page_get_uri(page), ==, webkit_frame_get_uri(frame));
@@ -68,11 +46,8 @@ private:
         return true;
     }
 
-    bool testJavaScriptContext(WebKitWebExtension* extension, GVariant* args)
+    bool testJavaScriptContext(WebKitWebPage* page)
     {
-        WebKitWebPage* page = webkit_web_extension_get_page(extension, webPageFromArgs(args));
-        g_assert(WEBKIT_IS_WEB_PAGE(page));
-
         WebKitFrame* frame = webkit_web_page_get_main_frame(page);
         g_assert(WEBKIT_IS_FRAME(frame));
         g_assert(webkit_frame_get_javascript_global_context(frame));
@@ -80,14 +55,14 @@ private:
         return true;
     }
 
-    virtual bool runTest(const char* testName, WebKitWebExtension* extension, GVariant* args)
+    bool runTest(const char* testName, WebKitWebPage* page) override
     {
         if (!strcmp(testName, "main-frame"))
-            return testMainFrame(extension, args);
+            return testMainFrame(page);
         if (!strcmp(testName, "uri"))
-            return testURI(extension, args);
+            return testURI(page);
         if (!strcmp(testName, "javascript-context"))
-            return testJavaScriptContext(extension, args);
+            return testJavaScriptContext(page);
 
         g_assert_not_reached();
         return false;
index 6327bde92a66dea3e427a3dd22ba1110c0314993..d42935a75f0ef4894def2d536f39014a1144c1e0 100644 (file)
 
 #include "config.h"
 
-#include "WebProcessTestRunner.h"
 #include "WebViewTest.h"
 #include <gtk/gtk.h>
 #include <webkit2/webkit2.h>
 
-static WebProcessTestRunner* testRunner;
-
 static void testWebKitDOMNodeHierarchyNavigation(WebViewTest* test, gconstpointer)
 {
     static const char* testHTML = "<html><head><title>This is the title</title></head><body><p>1</p><p>2</p><p>3</p></body></html>";
     test->loadHtml(testHTML, 0);
     test->waitUntilLoadFinished();
 
-    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", Test::s_webExtensionID, g_variant_builder_end(&builder)));
+    g_assert(test->runWebProcessTest("WebKitDOMNode", "hierarchy-navigation"));
 }
 
 static void testWebKitDOMNodeInsertion(WebViewTest* test, gconstpointer)
@@ -44,10 +38,7 @@ static void testWebKitDOMNodeInsertion(WebViewTest* test, gconstpointer)
     test->loadHtml(testHTML, 0);
     test->waitUntilLoadFinished();
 
-    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", Test::s_webExtensionID, g_variant_builder_end(&builder)));
+    g_assert(test->runWebProcessTest("WebKitDOMNode", "insertion"));
 }
 
 static void testWebKitDOMNodeTagNames(WebViewTest* test, gconstpointer)
@@ -65,16 +56,11 @@ static void testWebKitDOMNodeTagNames(WebViewTest* test, gconstpointer)
     test->loadHtml(testHTML, 0);
     test->waitUntilLoadFinished();
 
-    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", Test::s_webExtensionID, g_variant_builder_end(&builder)));
+    g_assert(test->runWebProcessTest("WebKitDOMNode", "tag-names"));
 }
 
 void beforeAll()
 {
-    testRunner = new WebProcessTestRunner();
-
     WebViewTest::add("WebKitDOMNode", "hierarchy-navigation", testWebKitDOMNodeHierarchyNavigation);
     WebViewTest::add("WebKitDOMNode", "insertion", testWebKitDOMNodeInsertion);
     WebViewTest::add("WebKitDOMNode", "tag-names", testWebKitDOMNodeTagNames);
@@ -82,5 +68,4 @@ void beforeAll()
 
 void afterAll()
 {
-    delete testRunner;
 }
index c0708c0d171302d168caea7c553d947fac6ee844..812946153f4db8fe883a5063d238834d3307629f 100644 (file)
 
 #include "config.h"
 
-#include "WebProcessTestRunner.h"
 #include "WebViewTest.h"
 #include <gtk/gtk.h>
 #include <webkit2/webkit2.h>
 
-static WebProcessTestRunner* testRunner;
-
 static const char* testHTML = "<html id='root'><head><title>DOMNodeTreeWalker</title></head>"
     "<body><input type='button' name='push' value='push'><input type='button' name='clear' value='clear'><br></body></html>";
 
@@ -34,10 +31,7 @@ static void runTest(WebViewTest* test, const char* name)
     test->loadHtml(testHTML, nullptr);
     test->waitUntilLoadFinished();
 
-    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, Test::s_webExtensionID, g_variant_builder_end(&builder)));
+    g_assert(test->runWebProcessTest("WebKitDOMNodeFilter", name));
 }
 
 static void testWebKitDOMNodeFilterTreeWalker(WebViewTest* test, gconstpointer)
@@ -52,13 +46,10 @@ static void testWebKitDOMNodeFilterNodeIterator(WebViewTest* test, gconstpointer
 
 void beforeAll()
 {
-    testRunner = new WebProcessTestRunner();
-
     WebViewTest::add("WebKitDOMNodeFilter", "tree-walker", testWebKitDOMNodeFilterTreeWalker);
     WebViewTest::add("WebKitDOMNodeFilter", "node-iterator", testWebKitDOMNodeFilterNodeIterator);
 }
 
 void afterAll()
 {
-    delete testRunner;
 }
index a45e701cb1c4eb63111a35d500b38eaef8453fe0..ff9a7719234fe768414ad6dfd6c50b00940f11fb 100644 (file)
 
 #include "config.h"
 
-#include "WebProcessTestRunner.h"
 #include "WebViewTest.h"
 #include <gtk/gtk.h>
 #include <webkit2/webkit2.h>
 
-static WebProcessTestRunner* testRunner;
-
-static void runTest(WebViewTest* test, const char* name)
-{
-    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, Test::s_webExtensionID, g_variant_builder_end(&builder)));
-}
-
 static void testWebKitDOMXPathNSResolverNative(WebViewTest* test, gconstpointer)
 {
     static const char* nativeXML = "<root xmlns:foo='http://www.example.org'><foo:child>SUCCESS</foo:child></root>";
     GRefPtr<GBytes> bytes = adoptGRef(g_bytes_new_static(nativeXML, strlen(nativeXML)));
     test->loadBytes(bytes.get(), "text/xml", nullptr, nullptr);
     test->waitUntilLoadFinished();
-    runTest(test, "native");
+    g_assert(test->runWebProcessTest("WebKitDOMXPathNSResolver", "native"));
 }
 
 static void testWebKitDOMXPathNSResolverCustom(WebViewTest* test, gconstpointer)
@@ -49,18 +38,15 @@ static void testWebKitDOMXPathNSResolverCustom(WebViewTest* test, gconstpointer)
     GRefPtr<GBytes> bytes = adoptGRef(g_bytes_new_static(customXML, strlen(customXML)));
     test->loadBytes(bytes.get(), "text/xml", nullptr, nullptr);
     test->waitUntilLoadFinished();
-    runTest(test, "custom");
+    g_assert(test->runWebProcessTest("WebKitDOMXPathNSResolver", "custom"));
 }
 
 void beforeAll()
 {
-    testRunner = new WebProcessTestRunner();
-
     WebViewTest::add("WebKitDOMXPathNSResolver", "native", testWebKitDOMXPathNSResolverNative);
     WebViewTest::add("WebKitDOMXPathNSResolver", "custom", testWebKitDOMXPathNSResolverCustom);
 }
 
 void afterAll()
 {
-    delete testRunner;
 }
index 094de2cd4dde71b5a048c6cf21ce21b6db8b164c..9145ab813ce2b32b58f545f985f50546c275437a 100644 (file)
 
 #include "config.h"
 
-#include "WebProcessTestRunner.h"
 #include "WebViewTest.h"
 #include <gtk/gtk.h>
 #include <webkit2/webkit2.h>
 
-static WebProcessTestRunner* testRunner;
-
 static void webkitFrameTestRun(WebViewTest* test, const char* testName)
 {
     static const char* testHTML = "<html><body></body></html>";
     test->loadHtml(testHTML, 0);
     test->waitUntilLoadFinished();
 
-    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, Test::s_webExtensionID, g_variant_builder_end(&builder)));
+    g_assert(test->runWebProcessTest("WebKitFrame", testName));
 }
 
 static void testWebKitFrameMainFrame(WebViewTest* test, gconstpointer)
@@ -55,8 +49,6 @@ static void testWebKitFrameJavaScriptContext(WebViewTest* test, gconstpointer)
 
 void beforeAll()
 {
-    testRunner = new WebProcessTestRunner();
-
     WebViewTest::add("WebKitFrame", "main-frame", testWebKitFrameMainFrame);
     WebViewTest::add("WebKitFrame", "uri", testWebKitFrameURI);
     WebViewTest::add("WebKitFrame", "javascript-context", testWebKitFrameJavaScriptContext);
@@ -64,5 +56,4 @@ void beforeAll()
 
 void afterAll()
 {
-    delete testRunner;
 }
index bb524071a29c0052394b779a32f6d9186bb50a5c..c6621c2a2437b8b2a2a2cb8c15704c8f32c1504e 100644 (file)
 #include "config.h"
 #include "WebProcessTest.h"
 
+#include <JavaScriptCore/JSRetainPtr.h>
 #include <gio/gio.h>
+#include <wtf/NeverDestroyed.h>
 #include <wtf/gobject/GUniquePtr.h>
 
-typedef HashMap<String, std::function<PassOwnPtr<WebProcessTest> ()>> TestsMap;
+typedef HashMap<String, std::function<std::unique_ptr<WebProcessTest> ()>> TestsMap;
 static TestsMap& testsMap()
 {
-    DEPRECATED_DEFINE_STATIC_LOCAL(TestsMap, s_testsMap, ());
+    static NeverDestroyed<TestsMap> s_testsMap;
     return s_testsMap;
 }
 
-void WebProcessTest::add(const String& testName, std::function<PassOwnPtr<WebProcessTest> ()> closure)
+void WebProcessTest::add(const String& testName, std::function<std::unique_ptr<WebProcessTest> ()> closure)
 {
-    testsMap().add(testName, std::forward<std::function<PassOwnPtr<WebProcessTest> ()>>(closure));
+    testsMap().add(testName, WTF::move(closure));
 }
 
-PassOwnPtr<WebProcessTest> WebProcessTest::create(const String& testName)
+std::unique_ptr<WebProcessTest> WebProcessTest::create(const String& testName)
 {
     g_assert(testsMap().contains(testName));
     return testsMap().get(testName)();
 }
 
-static const char introspectionXML[] =
-    "<node>"
-    " <interface name='org.webkit.gtk.WebProcessTest'>"
-    "  <method name='RunTest'>"
-    "   <arg type='s' name='path' direction='in'/>"
-    "   <arg type='a{sv}' name='args' direction='in'/>"
-    "   <arg type='b' name='result' direction='out'/>"
-    "  </method>"
-    " </interface>"
-    "</node>";
-
-static void methodCallCallback(GDBusConnection* connection, const char* sender, const char* objectPath, const char* interfaceName, const char* methodName, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer userData)
+static JSValueRef runTest(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-    if (g_strcmp0(interfaceName, "org.webkit.gtk.WebProcessTest"))
-        return;
+    JSRetainPtr<JSStringRef> stringValue(Adopt, JSValueToStringCopy(context, arguments[0], nullptr));
+    g_assert(stringValue);
+    size_t testPathLength = JSStringGetMaximumUTF8CStringSize(stringValue.get());
+    GUniquePtr<char> testPath(static_cast<char*>(g_malloc(testPathLength)));
+    JSStringGetUTF8CString(stringValue.get(), testPath.get(), testPathLength);
 
-    if (!g_strcmp0(methodName, "RunTest")) {
-        const char* testPath;
-        GVariant* args;
-        g_variant_get(parameters, "(&s@a{sv})", &testPath, &args);
-        OwnPtr<WebProcessTest> test = WebProcessTest::create(String::fromUTF8(testPath));
-        bool result = test->runTest(g_strrstr(testPath, "/") + 1, WEBKIT_WEB_EXTENSION(userData), args);
-        g_variant_unref(args);
+    WebKitWebPage* webPage = WEBKIT_WEB_PAGE(JSObjectGetPrivate(thisObject));
+    g_assert(WEBKIT_IS_WEB_PAGE(webPage));
 
-        g_dbus_method_invocation_return_value(invocation, g_variant_new("(b)", result));
-    } else
-        g_assert_not_reached();
+    std::unique_ptr<WebProcessTest> test = WebProcessTest::create(String::fromUTF8(testPath.get()));
+    return JSValueMakeBoolean(context, test->runTest(g_strrstr(testPath.get(), "/") + 1, webPage));
 }
 
-static const GDBusInterfaceVTable interfaceVirtualTable = {
-    methodCallCallback, 0, 0, { 0, }
+static const JSStaticFunction webProcessTestRunnerStaticFunctions[] =
+{
+    { "runTest", runTest, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+    { nullptr, nullptr, 0 }
 };
 
-static void busAcquiredCallback(GDBusConnection* connection, const char* name, gpointer userData)
+static void webProcessTestRunnerFinalize(JSObjectRef object)
+{
+    g_object_unref(JSObjectGetPrivate(object));
+}
+
+static void windowObjectClearedCallback(WebKitScriptWorld* world, WebKitWebPage* webPage, WebKitFrame* frame, WebKitWebExtension* extension)
 {
-    static GDBusNodeInfo* introspectionData = 0;
-    if (!introspectionData)
-        introspectionData = g_dbus_node_info_new_for_xml(introspectionXML, 0);
+    JSGlobalContextRef context = webkit_frame_get_javascript_context_for_script_world(frame, world);
+    JSObjectRef globalObject = JSContextGetGlobalObject(context);
+
+    JSClassDefinition classDefinition = kJSClassDefinitionEmpty;
+    classDefinition.className = "WebProcessTestRunner";
+    classDefinition.staticFunctions = webProcessTestRunnerStaticFunctions;
+    classDefinition.finalize = webProcessTestRunnerFinalize;
 
-    GUniqueOutPtr<GError> error;
-    unsigned registrationID = g_dbus_connection_register_object(
-        connection,
-        "/org/webkit/gtk/WebProcessTest",
-        introspectionData->interfaces[0],
-        &interfaceVirtualTable,
-        g_object_ref(userData),
-        static_cast<GDestroyNotify>(g_object_unref),
-        &error.outPtr());
-    if (!registrationID)
-        g_warning("Failed to register object: %s\n", error->message);
+    JSClassRef jsClass = JSClassCreate(&classDefinition);
+    JSObjectRef classObject = JSObjectMake(context, jsClass, g_object_ref(webPage));
+    JSRetainPtr<JSStringRef> propertyString(Adopt, JSStringCreateWithUTF8CString("WebProcessTestRunner"));
+    JSObjectSetProperty(context, globalObject, propertyString.get(), classObject, kJSPropertyAttributeNone, nullptr);
+    JSClassRelease(jsClass);
 }
 
-extern "C" void webkit_web_extension_initialize_with_user_data(WebKitWebExtension* extension, GVariant* userData)
+extern "C" void webkit_web_extension_initialize(WebKitWebExtension* extension)
 {
-    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,
-        busName.get(),
-        G_BUS_NAME_OWNER_FLAGS_NONE,
-        busAcquiredCallback,
-        0, 0,
-        g_object_ref(extension),
-        static_cast<GDestroyNotify>(g_object_unref));
+    g_signal_connect(webkit_script_world_get_default(), "window-object-cleared", G_CALLBACK(windowObjectClearedCallback), extension);
 }
index e3eedd0b41437d22e6efee05698792fbeea0b906..fb4dd5d33d26915e69f96e6bd6c29cc8cca31288 100644 (file)
@@ -19,7 +19,6 @@
 
 #include <webkit2/webkit-web-extension.h>
 #include <wtf/HashMap.h>
-#include <wtf/PassOwnPtr.h>
 #include <wtf/gobject/GRefPtr.h>
 #include <wtf/text/StringHash.h>
 #include <wtf/text/WTFString.h>
 class WebProcessTest {
 public:
     virtual ~WebProcessTest() { }
-    virtual bool runTest(const char* testName, WebKitWebExtension*, GVariant* args) = 0;
+    virtual bool runTest(const char* testName, WebKitWebPage*) = 0;
 
-    static void add(const String& testName, std::function<PassOwnPtr<WebProcessTest> ()>);
-    static PassOwnPtr<WebProcessTest> create(const String& testName);
+    static void add(const String& testName, std::function<std::unique_ptr<WebProcessTest> ()>);
+    static std::unique_ptr<WebProcessTest> create(const String& testName);
 };
 
 #define REGISTER_TEST(ClassName, TestName) \
diff --git a/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.cpp b/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.cpp
deleted file mode 100644 (file)
index 7ae6c66..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2013 Igalia S.L.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "WebProcessTestRunner.h"
-
-#include <wtf/gobject/GUniquePtr.h>
-
-WebProcessTestRunner::WebProcessTestRunner()
-    : m_mainLoop(g_main_loop_new(0, TRUE))
-    , m_bus(adoptGRef(g_test_dbus_new(G_TEST_DBUS_NONE)))
-{
-    // Save the DISPLAY env var to restore it after calling g_test_dbus_up() that unsets it.
-    // See https://bugs.webkit.org/show_bug.cgi?id=125621.
-    const char* display = g_getenv("DISPLAY");
-    g_test_dbus_up(m_bus.get());
-    g_setenv("DISPLAY", display, FALSE);
-    m_connection = adoptGRef(g_bus_get_sync(G_BUS_TYPE_SESSION, 0, 0));
-}
-
-WebProcessTestRunner::~WebProcessTestRunner()
-{
-    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 = nullptr;
-    m_proxy = nullptr;
-    g_test_dbus_down(m_bus.get());
-}
-
-void WebProcessTestRunner::proxyCreatedCallback(GObject*, GAsyncResult* result, WebProcessTestRunner* testRunner)
-{
-    testRunner->m_proxy = adoptGRef(g_dbus_proxy_new_finish(result, 0));
-    g_main_loop_quit(testRunner->m_mainLoop);
-}
-
-void WebProcessTestRunner::onNameAppeared(GDBusConnection*, const char*, const char*, gpointer userData)
-{
-    WebProcessTestRunner* testRunner = static_cast<WebProcessTestRunner*>(userData);
-    g_main_loop_quit(testRunner->m_mainLoop);
-}
-
-void WebProcessTestRunner::onNameVanished(GDBusConnection*, const char* name, gpointer userData)
-{
-    _exit(1);
-}
-
-void WebProcessTestRunner::testFinishedCallback(GDBusProxy* proxy, GAsyncResult* result, WebProcessTestRunner* testRunner)
-{
-    GRefPtr<GVariant> returnValue = adoptGRef(g_dbus_proxy_call_finish(proxy, result, 0));
-    g_assert(returnValue.get());
-    gboolean testResult;
-    g_variant_get(returnValue.get(), "(b)", &testResult);
-    testRunner->finishTest(testResult);
-}
-
-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));
-
-    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(
-        m_proxy.get(),
-        "RunTest",
-        g_variant_new("(s@a{sv})", testPath.get(), args),
-        G_DBUS_CALL_FLAGS_NONE,
-        -1, 0,
-        reinterpret_cast<GAsyncReadyCallback>(WebProcessTestRunner::testFinishedCallback),
-        this);
-    g_main_loop_run(m_mainLoop);
-    g_bus_unwatch_name(watcherID);
-
-    return m_testResult;
-}
-
-void WebProcessTestRunner::finishTest(bool result)
-{
-    m_testResult = result;
-    g_main_loop_quit(m_mainLoop);
-}
diff --git a/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.h b/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.h
deleted file mode 100644 (file)
index f2fc926..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2013 Igalia S.L.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef WebProcessTestRunner_h
-#define WebProcessTestRunner_h
-
-#include <gio/gio.h>
-#include <webkit2/webkit2.h>
-#include <wtf/gobject/GRefPtr.h>
-
-class WebProcessTestRunner {
-public:
-    WebProcessTestRunner();
-    ~WebProcessTestRunner();
-
-    bool runTest(const char* suiteName, const char* testName, uint32_t testID, GVariant* args);
-
-private:
-    static void proxyCreatedCallback(GObject*, GAsyncResult*, WebProcessTestRunner*);
-    static void onNameAppeared(GDBusConnection*, const char*, const char*, gpointer);
-    static void onNameVanished(GDBusConnection*, const char*, gpointer);
-    static void testFinishedCallback(GDBusProxy*, GAsyncResult*, WebProcessTestRunner*);
-
-    void finishTest(bool result);
-
-    GMainLoop* m_mainLoop;
-    GRefPtr<GTestDBus> m_bus;
-    GRefPtr<GDBusConnection> m_connection;
-    GRefPtr<GDBusProxy> m_proxy;
-    bool m_testResult;
-};
-
-#endif // WebProcessTestRunner_h
index 72e75b3a8488f44720af6136a69f39d6f1f667f7..ea8b6b3feb052e8766037e617c231673f0c1c3a3 100644 (file)
@@ -487,3 +487,12 @@ cairo_surface_t* WebViewTest::getSnapshotAndWaitUntilReady(WebKitSnapshotRegion
     g_main_loop_run(m_mainLoop);
     return m_surface;
 }
+
+bool WebViewTest::runWebProcessTest(const char* suiteName, const char* testName)
+{
+    GUniquePtr<char> script(g_strdup_printf("WebProcessTestRunner.runTest('%s/%s');", suiteName, testName));
+    GUniqueOutPtr<GError> error;
+    WebKitJavascriptResult* javascriptResult = runJavaScriptAndWaitUntilFinished(script.get(), &error.outPtr());
+    g_assert(!error);
+    return javascriptResultToBoolean(javascriptResult);
+}
index 5ad098dac735f000d8c77295c9ec6a498aa7e62d..2c3692a562e57480b90b7fffef7563982db26a3a 100644 (file)
@@ -69,6 +69,8 @@ public:
 
     cairo_surface_t* getSnapshotAndWaitUntilReady(WebKitSnapshotRegion, WebKitSnapshotOptions);
 
+    bool runWebProcessTest(const char* suiteName, const char* testName);
+
     WebKitWebView* m_webView;
     GMainLoop* m_mainLoop;
     CString m_activeURI;