Changeset 229395 in webkit


Ignore:
Timestamp:
Mar 7, 2018 10:34:36 PM (6 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK][WPE] Leak checker is not working in WebKitGLib web process tests
https://bugs.webkit.org/show_bug.cgi?id=183404

Reviewed by Michael Catanzaro.

Source/WebKit:

Add private helper for testing to do a garbage collection when the page is closing.

  • WebProcess/InjectedBundle/API/glib/WebKitWebExtension.cpp:

(webkitWebExtensionSetGarbageCollectOnPageDestroy):

  • WebProcess/InjectedBundle/API/glib/WebKitWebExtensionPrivate.h:
  • WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMClientRectList.h: Fix annotation of

webkit_dom_client_rect_list_item(), it should be transfer full.

Tools:

This might have regressed when we started to use the JSC garbage collector timers. The thing is that we expect
that the WebProcessTester object that we expose to JavaScript is released when the web frame is destroyed, but
that's no longer the case. On window object cleared a GC is scheduled, but JSC timers do the actual garbage
collection later. In the case of tests that never happens because the web process finishes quickly after the
test. We need to force a garbage collection at some point when the web page is destroyed. We can't use the
WebKitWebPage destroy signal, since we are also checking that WebKitWebPage isn't leaked. The
API::InjectedBundle::Client::willDestroyPage() always happen when the page is closed, even if WebKitWebPage is
still alive, so we can force the GC at that point. The only problem is that the frame is detached right after
that point, so we can't check WebKitFrame leaks. The only frame in the tests is the main one, so we can assume
that if WebKitWebPage is released, the frame is too.

  • TestWebKitAPI/Tests/WebKitGLib/FrameTest.cpp:

(WebKitFrameTest::testMainFrame): Stop checking we don't leak WebKitFrame.
(WebKitFrameTest::testURI): Ditto.
(WebKitFrameTest::testJavaScriptContext): Ditto.

  • TestWebKitAPI/Tests/WebKitGLib/TestFrame.cpp:

(testWebKitFrameMainFrame): Use new WebViewTest::runWebProcessTest() API.
(testWebKitFrameURI): Ditto.
(testWebKitFrameJavaScriptContext): Ditto.
(webkitFrameTestRun): Deleted.

  • TestWebKitAPI/Tests/WebKitGLib/WebProcessTest.cpp:

(runTest): We no longer need the special case for dom-cache test.
(windowObjectClearedCallback): Only expose test runner object to JavaScript when loading tests.
(webkit_web_extension_initialize): Call webkitWebExtensionSetGarbageCollectOnPageDestroy() to ensure a garbage
collection is performed when the page is closing.

  • TestWebKitAPI/Tests/WebKitGtk/DOMClientRectTest.cpp:

(WebKitDOMClientRectTest::testDivClientRectsPositionAndLength): Fix memory leak,
webkit_dom_client_rect_list_item() returns a full reference.

  • TestWebKitAPI/Tests/WebKitGtk/TestAutocleanups.cpp:

(testWebProcessAutocleanups):Use new WebViewTest::runWebProcessTest() API.

  • TestWebKitAPI/Tests/WebKitGtk/TestDOMClientRect.cpp:

(testWebKitDOMClientRectDivBoundingClientRectPosition): Use new WebViewTest::runWebProcessTest() API.
(testWebKitDOMClientRectDivClientRectsPositionAndLength): Use new WebViewTest::runWebProcessTest() API.
(prepareDOMForClientRectPositionTests): Deleted.

  • TestWebKitAPI/Tests/WebKitGtk/TestDOMNode.cpp:

(testWebKitDOMNodeHierarchyNavigation): Use new WebViewTest::runWebProcessTest() API.
(testWebKitDOMNodeInsertion): Ditto.
(testWebKitDOMNodeTagNamesNodeList): Ditto.
(testWebKitDOMNodeTagNamesHTMLCollection): Ditto.
(testWebKitDOMObjectCache): We no longer need to run the test several times, since runWebProcessTest() loads
about blank after every test.
(prepareDOMForTagNamesTests): Deleted.

  • TestWebKitAPI/Tests/WebKitGtk/TestDOMNodeFilter.cpp:

(testWebKitDOMNodeFilterTreeWalker): Use new WebViewTest::runWebProcessTest() API.
(testWebKitDOMNodeFilterNodeIterator): Ditto.
(runTest): Deleted.

  • TestWebKitAPI/Tests/WebKitGtk/TestDOMXPathNSResolver.cpp:

(testWebKitDOMXPathNSResolverNative): Use new WebViewTest::runWebProcessTest() API.
(testWebKitDOMXPathNSResolverCustom): Ditto.

  • TestWebKitAPI/Tests/WebKitGtk/TestEditor.cpp:

(testWebKitWebEditorSelectionChanged): Use new WebViewTest::runWebProcessTest() API.

  • TestWebKitAPI/glib/WebKitGLib/WebViewTest.cpp:

(WebViewTest::runWebProcessTest): It now receives the contents, so it automatically loads the view using
"webprocess://test" as base URI, used to detect tests in the web process. It also loads about:blank after every
test to ensure that window object is cleared.

  • TestWebKitAPI/glib/WebKitGLib/WebViewTest.h:
Location:
trunk
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r229390 r229395  
     12018-03-07  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK][WPE] Leak checker is not working in WebKitGLib web process tests
     4        https://bugs.webkit.org/show_bug.cgi?id=183404
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        Add private helper for testing to do a garbage collection when the page is closing.
     9
     10        * WebProcess/InjectedBundle/API/glib/WebKitWebExtension.cpp:
     11        (webkitWebExtensionSetGarbageCollectOnPageDestroy):
     12        * WebProcess/InjectedBundle/API/glib/WebKitWebExtensionPrivate.h:
     13        * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMClientRectList.h: Fix annotation of
     14        webkit_dom_client_rect_list_item(), it should be transfer full.
     15
    1162018-03-07  Youenn Fablet  <youenn@apple.com>
    217
  • trunk/Source/WebKit/WebProcess/InjectedBundle/API/glib/WebKitWebExtension.cpp

    r218487 r229395  
    2727#include "WebKitWebPagePrivate.h"
    2828#include "WebProcess.h"
     29#include <WebCore/GCController.h>
    2930#include <wtf/HashMap.h>
    3031#include <wtf/glib/GRefPtr.h>
     
    119120struct _WebKitWebExtensionPrivate {
    120121    WebPageMap pages;
     122#if ENABLE(DEVELOPER_MODE)
     123    bool garbageCollectOnPageDestroy;
     124#endif
    121125};
    122126
     
    163167    {
    164168        m_extension->priv->pages.remove(&page);
     169#if ENABLE(DEVELOPER_MODE)
     170        if (m_extension->priv->garbageCollectOnPageDestroy)
     171            WebCore::GCController::singleton().garbageCollectNow();
     172#endif
    165173    }
    166174
     
    193201}
    194202
     203void webkitWebExtensionSetGarbageCollectOnPageDestroy(WebKitWebExtension* extension)
     204{
     205#if ENABLE(DEVELOPER_MODE)
     206    extension->priv->garbageCollectOnPageDestroy = true;
     207#endif
     208}
     209
    195210/**
    196211 * webkit_web_extension_get_page:
  • trunk/Source/WebKit/WebProcess/InjectedBundle/API/glib/WebKitWebExtensionPrivate.h

    r218487 r229395  
    1818 */
    1919
    20 #ifndef WebKitWebExtensionPrivate_h
    21 #define WebKitWebExtensionPrivate_h
     20#pragma once
    2221
    2322#include "InjectedBundle.h"
     
    2524
    2625WebKitWebExtension* webkitWebExtensionCreate(WebKit::InjectedBundle*);
    27 
    28 #endif // WebKitWebExtensionPrivate_h
     26void webkitWebExtensionSetGarbageCollectOnPageDestroy(WebKitWebExtension*);
  • trunk/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMClientRectList.h

    r214215 r229395  
    6969 * Returns the #WebKitDOMClientRect object that @self contains at @index.
    7070 *
    71  * Returns: (transfer none): A #WebKitDOMClientRect
     71 * Returns: (transfer full): A #WebKitDOMClientRect
    7272 *
    7373 * Since: 2.18
  • trunk/Tools/ChangeLog

    r229390 r229395  
     12018-03-07  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK][WPE] Leak checker is not working in WebKitGLib web process tests
     4        https://bugs.webkit.org/show_bug.cgi?id=183404
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        This might have regressed when we started to use the JSC garbage collector timers. The thing is that we expect
     9        that the WebProcessTester object that we expose to JavaScript is released when the web frame is destroyed, but
     10        that's no longer the case. On window object cleared a GC is scheduled, but JSC timers do the actual garbage
     11        collection later. In the case of tests that never happens because the web process finishes quickly after the
     12        test. We need to force a garbage collection at some point when the web page is destroyed. We can't use the
     13        WebKitWebPage destroy signal, since we are also checking that WebKitWebPage isn't leaked. The
     14        API::InjectedBundle::Client::willDestroyPage() always happen when the page is closed, even if WebKitWebPage is
     15        still alive, so we can force the GC at that point. The only problem is that the frame is detached right after
     16        that point, so we can't check WebKitFrame leaks. The only frame in the tests is the main one, so we can assume
     17        that if WebKitWebPage is released, the frame is too.
     18
     19        * TestWebKitAPI/Tests/WebKitGLib/FrameTest.cpp:
     20        (WebKitFrameTest::testMainFrame): Stop checking we don't leak WebKitFrame.
     21        (WebKitFrameTest::testURI): Ditto.
     22        (WebKitFrameTest::testJavaScriptContext): Ditto.
     23        * TestWebKitAPI/Tests/WebKitGLib/TestFrame.cpp:
     24        (testWebKitFrameMainFrame): Use new WebViewTest::runWebProcessTest() API.
     25        (testWebKitFrameURI): Ditto.
     26        (testWebKitFrameJavaScriptContext): Ditto.
     27        (webkitFrameTestRun): Deleted.
     28        * TestWebKitAPI/Tests/WebKitGLib/WebProcessTest.cpp:
     29        (runTest): We no longer need the special case for dom-cache test.
     30        (windowObjectClearedCallback): Only expose test runner object to JavaScript when loading tests.
     31        (webkit_web_extension_initialize): Call webkitWebExtensionSetGarbageCollectOnPageDestroy() to ensure a garbage
     32        collection is performed when the page is closing.
     33        * TestWebKitAPI/Tests/WebKitGtk/DOMClientRectTest.cpp:
     34        (WebKitDOMClientRectTest::testDivClientRectsPositionAndLength): Fix memory leak,
     35        webkit_dom_client_rect_list_item() returns a full reference.
     36        * TestWebKitAPI/Tests/WebKitGtk/TestAutocleanups.cpp:
     37        (testWebProcessAutocleanups):Use new WebViewTest::runWebProcessTest() API.
     38        * TestWebKitAPI/Tests/WebKitGtk/TestDOMClientRect.cpp:
     39        (testWebKitDOMClientRectDivBoundingClientRectPosition): Use new WebViewTest::runWebProcessTest() API.
     40        (testWebKitDOMClientRectDivClientRectsPositionAndLength): Use new WebViewTest::runWebProcessTest() API.
     41        (prepareDOMForClientRectPositionTests): Deleted.
     42        * TestWebKitAPI/Tests/WebKitGtk/TestDOMNode.cpp:
     43        (testWebKitDOMNodeHierarchyNavigation): Use new WebViewTest::runWebProcessTest() API.
     44        (testWebKitDOMNodeInsertion): Ditto.
     45        (testWebKitDOMNodeTagNamesNodeList): Ditto.
     46        (testWebKitDOMNodeTagNamesHTMLCollection): Ditto.
     47        (testWebKitDOMObjectCache): We no longer need to run the test several times, since runWebProcessTest() loads
     48        about blank after every test.
     49        (prepareDOMForTagNamesTests): Deleted.
     50        * TestWebKitAPI/Tests/WebKitGtk/TestDOMNodeFilter.cpp:
     51        (testWebKitDOMNodeFilterTreeWalker): Use new WebViewTest::runWebProcessTest() API.
     52        (testWebKitDOMNodeFilterNodeIterator): Ditto.
     53        (runTest): Deleted.
     54        * TestWebKitAPI/Tests/WebKitGtk/TestDOMXPathNSResolver.cpp:
     55        (testWebKitDOMXPathNSResolverNative): Use new WebViewTest::runWebProcessTest() API.
     56        (testWebKitDOMXPathNSResolverCustom): Ditto.
     57        * TestWebKitAPI/Tests/WebKitGtk/TestEditor.cpp:
     58        (testWebKitWebEditorSelectionChanged): Use new WebViewTest::runWebProcessTest() API.
     59        * TestWebKitAPI/glib/WebKitGLib/WebViewTest.cpp:
     60        (WebViewTest::runWebProcessTest): It now receives the contents, so it automatically loads the view using
     61        "webprocess://test" as base URI, used to detect tests in the web process. It also loads about:blank after every
     62        test to ensure that window object is cleared.
     63        * TestWebKitAPI/glib/WebKitGLib/WebViewTest.h:
     64
    1652018-03-07  Youenn Fablet  <youenn@apple.com>
    266
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/FrameTest.cpp

    r218686 r229395  
    3232        WebKitFrame* frame = webkit_web_page_get_main_frame(page);
    3333        g_assert(WEBKIT_IS_FRAME(frame));
    34         assertObjectIsDeletedWhenTestFinishes(G_OBJECT(frame));
    3534        g_assert(webkit_frame_is_main_frame(frame));
    3635
     
    4241        WebKitFrame* frame = webkit_web_page_get_main_frame(page);
    4342        g_assert(WEBKIT_IS_FRAME(frame));
    44         assertObjectIsDeletedWhenTestFinishes(G_OBJECT(frame));
    4543        g_assert_cmpstr(webkit_web_page_get_uri(page), ==, webkit_frame_get_uri(frame));
    4644
     
    5250        WebKitFrame* frame = webkit_web_page_get_main_frame(page);
    5351        g_assert(WEBKIT_IS_FRAME(frame));
    54         assertObjectIsDeletedWhenTestFinishes(G_OBJECT(frame));
    5552        g_assert(webkit_frame_get_javascript_global_context(frame));
    5653
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestFrame.cpp

    r218686 r229395  
    2222#include "WebViewTest.h"
    2323
    24 static void webkitFrameTestRun(WebViewTest* test, const char* testName)
    25 {
    26     static const char* testHTML = "<html><body></body></html>";
    27     test->loadHtml(testHTML, 0);
    28     test->waitUntilLoadFinished();
    29 
    30     g_assert(test->runWebProcessTest("WebKitFrame", testName));
    31 }
    32 
    3324static void testWebKitFrameMainFrame(WebViewTest* test, gconstpointer)
    3425{
    35     webkitFrameTestRun(test, "main-frame");
     26    g_assert(test->runWebProcessTest("WebKitFrame", "main-frame"));
    3627}
    3728
    3829static void testWebKitFrameURI(WebViewTest* test, gconstpointer)
    3930{
    40     webkitFrameTestRun(test, "uri");
     31    g_assert(test->runWebProcessTest("WebKitFrame", "uri"));
    4132}
    4233
    4334static void testWebKitFrameJavaScriptContext(WebViewTest* test, gconstpointer)
    4435{
    45     webkitFrameTestRun(test, "javascript-context");
     36    g_assert(test->runWebProcessTest("WebKitFrame", "javascript-context"));
    4637}
    4738
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/WebProcessTest.cpp

    r218685 r229395  
    2121#include "WebProcessTest.h"
    2222
     23#include "WebKitWebExtensionPrivate.h"
    2324#include <JavaScriptCore/JSRetainPtr.h>
    2425#include <gio/gio.h>
     
    6566    WebKitWebPage* webPage = WEBKIT_WEB_PAGE(JSObjectGetPrivate(thisObject));
    6667    g_assert(WEBKIT_IS_WEB_PAGE(webPage));
    67     // Test /WebKitDOMNode/dom-cache is an exception, because it's called 3 times, so
    68     // the WebPage is destroyed after the third time.
    69     if (g_str_equal(testPath.get(), "WebKitDOMNode/dom-cache")) {
    70         static unsigned domCacheTestRunCount = 0;
    71         if (++domCacheTestRunCount == 3)
    72             WebProcessTest::assertObjectIsDeletedWhenTestFinishes(G_OBJECT(webPage));
    73     } else
    74         WebProcessTest::assertObjectIsDeletedWhenTestFinishes(G_OBJECT(webPage));
     68    WebProcessTest::assertObjectIsDeletedWhenTestFinishes(G_OBJECT(webPage));
    7569
    7670    std::unique_ptr<WebProcessTest> test = WebProcessTest::create(String::fromUTF8(testPath.get()));
     
    10195static void windowObjectClearedCallback(WebKitScriptWorld* world, WebKitWebPage* webPage, WebKitFrame* frame, WebKitWebExtension* extension)
    10296{
     97    if (g_strcmp0(webkit_web_page_get_uri(webPage), "webprocess://test"))
     98        return;
     99
    103100    JSGlobalContextRef context = webkit_frame_get_javascript_context_for_script_world(frame, world);
    104101    JSObjectRef globalObject = JSContextGetGlobalObject(context);
     
    118115extern "C" void webkit_web_extension_initialize(WebKitWebExtension* extension)
    119116{
     117    webkitWebExtensionSetGarbageCollectOnPageDestroy(extension);
    120118    g_signal_connect(webkit_script_world_get_default(), "window-object-cleared", G_CALLBACK(windowObjectClearedCallback), extension);
    121119}
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/DOMClientRectTest.cpp

    r214215 r229395  
    7575        g_assert_cmpuint(webkit_dom_client_rect_list_get_length(clientRectList.get()), ==, 1);
    7676
    77         WebKitDOMClientRect* clientRect = webkit_dom_client_rect_list_item(clientRectList.get(), 0);
    78         g_assert(WEBKIT_DOM_IS_CLIENT_RECT(clientRect));
    79         assertObjectIsDeletedWhenTestFinishes(G_OBJECT(clientRect));
    80         checkClientRectPosition(clientRect);
     77        GRefPtr<WebKitDOMClientRect> clientRect = adoptGRef(webkit_dom_client_rect_list_item(clientRectList.get(), 0));
     78        g_assert(WEBKIT_DOM_IS_CLIENT_RECT(clientRect.get()));
     79        assertObjectIsDeletedWhenTestFinishes(G_OBJECT(clientRect.get()));
     80        checkClientRectPosition(clientRect.get());
    8181
    8282        // Getting the clientRect twice should return the same pointer.
    83         g_assert(webkit_dom_client_rect_list_item(clientRectList.get(), 0) == webkit_dom_client_rect_list_item(clientRectList.get(), 0));
     83        GRefPtr<WebKitDOMClientRect> clientRect2 = adoptGRef(webkit_dom_client_rect_list_item(clientRectList.get(), 0));
     84        g_assert(clientRect.get() == clientRect2.get());
    8485
    8586        return true;
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestAutocleanups.cpp

    r196844 r229395  
    4545static void testWebProcessAutocleanups(WebViewTest* test, gconstpointer)
    4646{
    47     static const char* testHTML = "<html><body></body></html>";
    48     test->loadHtml(testHTML, nullptr);
    49     test->waitUntilLoadFinished();
    50 
    5147    g_assert(test->runWebProcessTest("Autocleanups", "web-process-autocleanups"));
    5248}
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestDOMClientRect.cpp

    r214215 r229395  
    2323#include <webkit2/webkit2.h>
    2424
    25 static void prepareDOMForClientRectPositionTests(WebViewTest* test)
    26 {
    27     static const char* testHTML = "<html><head></head><body>"
    28         "<style>"
    29         "    #rect { position: fixed; top: -25px; left: -50px; width: 100px; height: 200px; }"
    30         "</style>"
    31         "<div id=rect></div></body></html>";
    32     test->loadHtml(testHTML, nullptr);
    33     test->waitUntilLoadFinished();
    34 }
     25static const char* testHTML = "<html><head></head><body>"
     26    "<style>"
     27    "    #rect { position: fixed; top: -25px; left: -50px; width: 100px; height: 200px; }"
     28    "</style>"
     29    "<div id=rect></div></body></html>";
    3530
    3631static void testWebKitDOMClientRectDivBoundingClientRectPosition(WebViewTest* test, gconstpointer)
    3732{
    38     prepareDOMForClientRectPositionTests(test);
    39     g_assert(test->runWebProcessTest("WebKitDOMClientRect", "div-bounding-client-rect-position"));
     33    g_assert(test->runWebProcessTest("WebKitDOMClientRect", "div-bounding-client-rect-position", testHTML));
    4034}
    4135
    4236static void testWebKitDOMClientRectDivClientRectsPositionAndLength(WebViewTest* test, gconstpointer)
    4337{
    44     prepareDOMForClientRectPositionTests(test);
    45     g_assert(test->runWebProcessTest("WebKitDOMClientRect", "div-client-rects-position-and-length"));
     38    g_assert(test->runWebProcessTest("WebKitDOMClientRect", "div-client-rects-position-and-length", testHTML));
    4639}
    4740
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestDOMNode.cpp

    r190346 r229395  
    2727{
    2828    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>";
    29     test->loadHtml(testHTML, 0);
    30     test->waitUntilLoadFinished();
    31 
    32     g_assert(test->runWebProcessTest("WebKitDOMNode", "hierarchy-navigation"));
     29    g_assert(test->runWebProcessTest("WebKitDOMNode", "hierarchy-navigation", testHTML));
    3330}
    3431
    3532static void testWebKitDOMNodeInsertion(WebViewTest* test, gconstpointer)
    3633{
    37     static const char* testHTML = "<html><body></body></html>";
    38     test->loadHtml(testHTML, 0);
    39     test->waitUntilLoadFinished();
    40 
    4134    g_assert(test->runWebProcessTest("WebKitDOMNode", "insertion"));
    4235}
    4336
    44 static void prepareDOMForTagNamesTests(WebViewTest* test)
    45 {
    46     static const char* testHTML = "<html><head></head><body>"
    47         "<video id='video' preload='none'>"
    48         "    <source src='movie.ogg' type='video/ogg'>"
    49         "        Your browser does not support the video tag."
    50         "</video>"
    51         "<video id='video2' preload='none'>"
    52         "     <source src='movie.ogg' type='video/ogg'>"
    53         "        Your browser does not support the video tag."
    54         "</video>"
    55         "<input type='hidden' id='test' name='finish' value='false'></body></html>";
    56     test->loadHtml(testHTML, nullptr);
    57     test->waitUntilLoadFinished();
    58 }
     37static const char* tagNamesTestHTML = "<html><head></head><body>"
     38    "<video id='video' preload='none'>"
     39    "    <source src='movie.ogg' type='video/ogg'>"
     40    "        Your browser does not support the video tag."
     41    "</video>"
     42    "<video id='video2' preload='none'>"
     43    "     <source src='movie.ogg' type='video/ogg'>"
     44    "        Your browser does not support the video tag."
     45    "</video>"
     46    "<input type='hidden' id='test' name='finish' value='false'></body></html>";
    5947
    6048static void testWebKitDOMNodeTagNamesNodeList(WebViewTest* test, gconstpointer)
    6149{
    62     prepareDOMForTagNamesTests(test);
    63     g_assert(test->runWebProcessTest("WebKitDOMNode", "tag-names-node-list"));
     50    g_assert(test->runWebProcessTest("WebKitDOMNode", "tag-names-node-list", tagNamesTestHTML));
    6451}
    6552
    6653static void testWebKitDOMNodeTagNamesHTMLCollection(WebViewTest* test, gconstpointer)
    6754{
    68     prepareDOMForTagNamesTests(test);
    69     g_assert(test->runWebProcessTest("WebKitDOMNode", "tag-names-html-collection"));
     55    g_assert(test->runWebProcessTest("WebKitDOMNode", "tag-names-html-collection", tagNamesTestHTML));
    7056}
    7157
     
    7359{
    7460    static const char* testHTML = "<html><body><div id='container'><p>DOM Cache test</p><a id='link href='#'>link</a></div></body></html>";
    75 
    76     // Run the test 3 times to make sure the DOM objects are correctly released when the
    77     // document is detached from the frame for every new document created.
    78     for (unsigned i = 0; i < 3; ++i) {
    79         test->loadHtml(testHTML, nullptr);
    80         test->waitUntilLoadFinished();
    81 
    82         g_assert(test->runWebProcessTest("WebKitDOMNode", "dom-cache"));
    83     }
     61    g_assert(test->runWebProcessTest("WebKitDOMNode", "dom-cache", testHTML));
    8462}
    8563
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestDOMNodeFilter.cpp

    r176563 r229395  
    2727    "<body><input type='button' name='push' value='push'><input type='button' name='clear' value='clear'><br></body></html>";
    2828
    29 static void runTest(WebViewTest* test, const char* name)
    30 {
    31     test->loadHtml(testHTML, nullptr);
    32     test->waitUntilLoadFinished();
    33 
    34     g_assert(test->runWebProcessTest("WebKitDOMNodeFilter", name));
    35 }
    36 
    3729static void testWebKitDOMNodeFilterTreeWalker(WebViewTest* test, gconstpointer)
    3830{
    39     runTest(test, "tree-walker");
     31    g_assert(test->runWebProcessTest("WebKitDOMNodeFilter", "tree-walker", testHTML));
    4032}
    4133
    4234static void testWebKitDOMNodeFilterNodeIterator(WebViewTest* test, gconstpointer)
    4335{
    44     runTest(test, "node-iterator");
     36    g_assert(test->runWebProcessTest("WebKitDOMNodeFilter", "node-iterator", testHTML));
    4537}
    4638
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestDOMXPathNSResolver.cpp

    r176563 r229395  
    2727{
    2828    static const char* nativeXML = "<root xmlns:foo='http://www.example.org'><foo:child>SUCCESS</foo:child></root>";
    29     GRefPtr<GBytes> bytes = adoptGRef(g_bytes_new_static(nativeXML, strlen(nativeXML)));
    30     test->loadBytes(bytes.get(), "text/xml", nullptr, nullptr);
    31     test->waitUntilLoadFinished();
    32     g_assert(test->runWebProcessTest("WebKitDOMXPathNSResolver", "native"));
     29    g_assert(test->runWebProcessTest("WebKitDOMXPathNSResolver", "native", nativeXML, "text/xml"));
    3330}
    3431
     
    3633{
    3734    static const char* customXML = "<root xmlns='http://www.example.com'><child>SUCCESS</child></root>";
    38     GRefPtr<GBytes> bytes = adoptGRef(g_bytes_new_static(customXML, strlen(customXML)));
    39     test->loadBytes(bytes.get(), "text/xml", nullptr, nullptr);
    40     test->waitUntilLoadFinished();
    41     g_assert(test->runWebProcessTest("WebKitDOMXPathNSResolver", "custom"));
     35    g_assert(test->runWebProcessTest("WebKitDOMXPathNSResolver", "custom", customXML, "text/xml"));
    4236}
    4337
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestEditor.cpp

    r187024 r229395  
    2727{
    2828    static const gchar* testHTML = "<html><body>All work and no play make Jack a dull boy.</body></html>";
    29     test->loadHtml(testHTML, nullptr);
    30     test->waitUntilLoadFinished();
    31 
    32     g_assert(test->runWebProcessTest("WebKitWebEditor", "selection-changed"));
     29    g_assert(test->runWebProcessTest("WebKitWebEditor", "selection-changed", testHTML));
    3330}
    3431
  • trunk/Tools/TestWebKitAPI/glib/WebKitGLib/WebViewTest.cpp

    r226019 r229395  
    398398#endif
    399399
    400 bool WebViewTest::runWebProcessTest(const char* suiteName, const char* testName)
    401 {
     400bool WebViewTest::runWebProcessTest(const char* suiteName, const char* testName, const char* contents, const char* contentType)
     401{
     402    if (!contentType) {
     403        static const char* emptyHTML = "<html><body></body></html>";
     404        loadHtml(contents ? contents : emptyHTML, "webprocess://test");
     405    } else {
     406        GRefPtr<GBytes> bytes = adoptGRef(g_bytes_new_static(contents, strlen(contents)));
     407        loadBytes(bytes.get(), contentType, nullptr, "webprocess://test");
     408    }
     409    waitUntilLoadFinished();
     410
    402411    GUniquePtr<char> script(g_strdup_printf("WebProcessTestRunner.runTest('%s/%s');", suiteName, testName));
    403412    GUniqueOutPtr<GError> error;
    404413    WebKitJavascriptResult* javascriptResult = runJavaScriptAndWaitUntilFinished(script.get(), &error.outPtr());
    405414    g_assert(!error);
     415    loadURI("about:blank");
     416    waitUntilLoadFinished();
    406417    return javascriptResultToBoolean(javascriptResult);
    407418}
  • trunk/Tools/TestWebKitAPI/glib/WebKitGLib/WebViewTest.h

    r226019 r229395  
    8585#endif
    8686
    87     bool runWebProcessTest(const char* suiteName, const char* testName);
     87    bool runWebProcessTest(const char* suiteName, const char* testName, const char* contents = nullptr, const char* contentType = nullptr);
    8888
    8989    // Prohibit overrides because this is called when the web view is created
Note: See TracChangeset for help on using the changeset viewer.