Title: [182475] releases/WebKitGTK/webkit-2.4/Tools
Revision
182475
Author
carlo...@webkit.org
Date
2015-04-07 09:32:23 -0700 (Tue, 07 Apr 2015)

Log Message

Merge r176563 - [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:

Modified Paths

Removed Paths

Diff

Modified: releases/WebKitGTK/webkit-2.4/Tools/ChangeLog (182474 => 182475)


--- releases/WebKitGTK/webkit-2.4/Tools/ChangeLog	2015-04-07 16:05:47 UTC (rev 182474)
+++ releases/WebKitGTK/webkit-2.4/Tools/ChangeLog	2015-04-07 16:32:23 UTC (rev 182475)
@@ -1,3 +1,80 @@
+2014-11-28  Carlos Garcia Campos  <cgar...@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:
+
 2015-01-19  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GTK] [WK2] TestWebKitWebView snapshot fails

Modified: releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/GNUmakefile.am (182474 => 182475)


--- releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/GNUmakefile.am	2015-04-07 16:05:47 UTC (rev 182474)
+++ releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/GNUmakefile.am	2015-04-07 16:32:23 UTC (rev 182475)
@@ -99,8 +99,6 @@
 	Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebKitTestBus.h \
 	Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebKitTestServer.cpp \
 	Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebKitTestServer.h \
-	Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.cpp \
-	Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.h \
 	Tools/TestWebKitAPI/gtk/WebKit2Gtk/TestMain.cpp \
 	Tools/TestWebKitAPI/gtk/WebKit2Gtk/TestMain.h \
 	Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp \

Modified: releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt (182474 => 182475)


--- releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt	2015-04-07 16:05:47 UTC (rev 182474)
+++ releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt	2015-04-07 16:32:23 UTC (rev 182475)
@@ -31,7 +31,6 @@
     ${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
 )

Modified: releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMNodeTest.cpp (182474 => 182475)


--- releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMNodeTest.cpp	2015-04-07 16:05:47 UTC (rev 182474)
+++ releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMNodeTest.cpp	2015-04-07 16:32:23 UTC (rev 182475)
@@ -26,29 +26,11 @@
 
 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 @@
         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 @@
         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 @@
         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;

Modified: releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/FrameTest.cpp (182474 => 182475)


--- releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/FrameTest.cpp	2015-04-07 16:05:47 UTC (rev 182474)
+++ releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/FrameTest.cpp	2015-04-07 16:32:23 UTC (rev 182475)
@@ -25,30 +25,11 @@
 
 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 @@
         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 @@
         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 @@
         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;

Modified: releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNode.cpp (182474 => 182475)


--- releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNode.cpp	2015-04-07 16:05:47 UTC (rev 182474)
+++ releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNode.cpp	2015-04-07 16:32:23 UTC (rev 182475)
@@ -19,23 +19,17 @@
 
 #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", g_variant_builder_end(&builder)));
+    g_assert(test->runWebProcessTest("WebKitDOMNode", "hierarchy-navigation"));
 }
 
 static void testWebKitDOMNodeInsertion(WebViewTest* test, gconstpointer)
@@ -44,10 +38,7 @@
     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", g_variant_builder_end(&builder)));
+    g_assert(test->runWebProcessTest("WebKitDOMNode", "insertion"));
 }
 
 static void testWebKitDOMNodeTagNames(WebViewTest* test, gconstpointer)
@@ -65,15 +56,11 @@
     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", g_variant_builder_end(&builder)));
+    g_assert(test->runWebProcessTest("WebKitDOMNode", "tag-names"));
 }
 
 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);
@@ -83,5 +70,4 @@
 
 void afterAll()
 {
-    delete testRunner;
 }

Modified: releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestFrame.cpp (182474 => 182475)


--- releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestFrame.cpp	2015-04-07 16:05:47 UTC (rev 182474)
+++ releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestFrame.cpp	2015-04-07 16:32:23 UTC (rev 182475)
@@ -19,23 +19,17 @@
 
 #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, g_variant_builder_end(&builder)));
+    g_assert(test->runWebProcessTest("WebKitFrame", testName));
 }
 
 static void testWebKitFrameMainFrame(WebViewTest* test, gconstpointer)
@@ -55,7 +49,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);
@@ -65,5 +58,4 @@
 
 void afterAll()
 {
-    delete testRunner;
 }

Modified: releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.cpp (182474 => 182475)


--- releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.cpp	2015-04-07 16:05:47 UTC (rev 182474)
+++ releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.cpp	2015-04-07 16:32:23 UTC (rev 182475)
@@ -20,87 +20,73 @@
 #include "config.h"
 #include "WebProcessTest.h"
 
+#include <_javascript_Core/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()
 {
-    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, std::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)
 {
-    static GDBusNodeInfo* introspectionData = 0;
-    if (!introspectionData)
-        introspectionData = g_dbus_node_info_new_for_xml(introspectionXML, 0);
+    g_object_unref(JSObjectGetPrivate(object));
+}
 
-    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);
+static void windowObjectClearedCallback(WebKitScriptWorld* world, WebKitWebPage* webPage, WebKitFrame* frame, WebKitWebExtension* extension)
+{
+    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;
+
+    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(WebKitWebExtension* extension)
 {
-    g_bus_own_name(
-        G_BUS_TYPE_SESSION,
-        "org.webkit.gtk.WebProcessTest",
-        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);
 }

Modified: releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.h (182474 => 182475)


--- releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.h	2015-04-07 16:05:47 UTC (rev 182474)
+++ releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebProcessTest.h	2015-04-07 16:32:23 UTC (rev 182475)
@@ -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>
@@ -27,10 +26,10 @@
 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) \

Deleted: releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.cpp (182474 => 182475)


--- releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.cpp	2015-04-07 16:05:47 UTC (rev 182474)
+++ releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.cpp	2015-04-07 16:32:23 UTC (rev 182475)
@@ -1,115 +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 = 0;
-    m_proxy = 0;
-    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);
-}
-
-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);
-    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, 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,
-        WebProcessTestRunner::onNameAppeared, WebProcessTestRunner::onNameVanished, this, 0);
-    g_main_loop_run(m_mainLoop);
-
-    m_testResult = false;
-    GUniquePtr<char> testPath(g_strdup_printf("%s/%s", suiteName, testName));
-    g_dbus_proxy_call(
-        proxy(),
-        "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);
-}

Deleted: releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.h (182474 => 182475)


--- releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.h	2015-04-07 16:05:47 UTC (rev 182474)
+++ releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebProcessTestRunner.h	2015-04-07 16:32:23 UTC (rev 182475)
@@ -1,50 +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, 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*);
-
-    GDBusProxy* proxy();
-    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

Modified: releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp (182474 => 182475)


--- releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp	2015-04-07 16:05:47 UTC (rev 182474)
+++ releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp	2015-04-07 16:32:23 UTC (rev 182475)
@@ -444,3 +444,12 @@
     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* _javascript_Result = runJavaScriptAndWaitUntilFinished(script.get(), &error.outPtr());
+    g_assert(!error);
+    return _javascript_ResultToBoolean(_javascript_Result);
+}

Modified: releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h (182474 => 182475)


--- releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h	2015-04-07 16:05:47 UTC (rev 182474)
+++ releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h	2015-04-07 16:32:23 UTC (rev 182475)
@@ -68,6 +68,8 @@
 
     cairo_surface_t* getSnapshotAndWaitUntilReady(WebKitSnapshotRegion, WebKitSnapshotOptions);
 
+    bool runWebProcessTest(const char* suiteName, const char* testName);
+
     WebKitWebView* m_webView;
     GMainLoop* m_mainLoop;
     CString m_activeURI;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to