Changeset 106445 in webkit


Ignore:
Timestamp:
Feb 1, 2012 1:29:03 AM (12 years ago)
Author:
Philippe Normand
Message:

Source/WebKit/gtk: Patch by Philippe Normand <pnormand@igalia.com> and Sergio Villar Senin <svillar@igalia.com> on 2012-02-01
Reviewed by Martin Robinson.

[GTK] Improve FrameLoader signals. Resource loading
https://bugs.webkit.org/show_bug.cgi?id=49543

New signals:
WebKitWebFrame::resource-request-starting
WebKitWebFrame::resource-response-received
WebKitWebFrame::resource-load-finished
WebKitWebFrame::resource-content-length-received
WebKitWebFrame::resource-load-failed
WebKitWebResource::response-received
WebKitWebResource::load-failed
WebKitWebResource::load-finished
WebKitWebResource::content-length-received
WebKitWebView::resource-response-received
WebKitWebView::resource-load-finished
WebKitWebView::resource-content-length-received
WebKitWebView::resource-load-failed

  • WebCoreSupport/FrameLoaderClientGtk.cpp:

(WebKit::FrameLoaderClient::dispatchWillSendRequest):
(WebKit::FrameLoaderClient::dispatchDidReceiveResponse):
(WebKit::FrameLoaderClient::dispatchDidReceiveContentLength):
(WebKit::FrameLoaderClient::dispatchDidFinishLoading):
(WebKit::FrameLoaderClient::dispatchDidFailLoading):

  • webkit/webkitwebframe.cpp:

(webkit_web_frame_class_init):

  • webkit/webkitwebresource.cpp:

(webkit_web_resource_class_init):

  • webkit/webkitwebview.cpp:

(webkit_web_view_class_init):

  • webkitmarshal.list:

Tools: Patch by Philippe Normand <pnormand@igalia.com> and Sergio Villar Senin <svillar@igalia.com> on 2012-02-01
Reviewed by Martin Robinson.

[GTK] Improve FrameLoader signals. Resource loading
https://bugs.webkit.org/show_bug.cgi?id=49543

Support for the new loader signals in DRT.

  • DumpRenderTree/gtk/DumpRenderTree.cpp:

(urlPath):
(willSendRequestCallback):
(urlSuitableForTestResult):
(descriptionSuitableForTestResult):
(didReceiveResponse):
(didFinishLoading):
(didFailLoadingWithError):
(createWebView):

LayoutTests: Reviewed by Martin Robinson.

[GTK] Improve FrameLoader signals. Resource loading
https://bugs.webkit.org/show_bug.cgi?id=49543

Unskip tests now passing.

  • platform/gtk/Skipped:
  • platform/gtk/fast/loader/file-protocol-fragment-expected.txt: Added.
  • platform/gtk/http/tests/misc/willCacheResponse-delegate-callback-expected.txt:
Location:
trunk
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r106444 r106445  
     12012-02-01  Philippe Normand  <pnormand@igalia.com>
     2
     3        Reviewed by Martin Robinson.
     4
     5        [GTK] Improve FrameLoader signals. Resource loading
     6        https://bugs.webkit.org/show_bug.cgi?id=49543
     7
     8        Unskip tests now passing.
     9
     10        * platform/gtk/Skipped:
     11        * platform/gtk/fast/loader/file-protocol-fragment-expected.txt: Added.
     12        * platform/gtk/http/tests/misc/willCacheResponse-delegate-callback-expected.txt:
     13
    1142012-02-01  Balazs Ankes  <Ankes.Balazs@stud.u-szeged.hu>
    215
  • trunk/LayoutTests/platform/gtk/Skipped

    r106345 r106445  
    458458
    459459# Missing delegates:
    460 # Need proper frame loader callbacks reporting
    461 # See https://bugs.webkit.org/show_bug.cgi?id=32170
    462 fast/loader/file-protocol-fragment.html
    463 # Tests failing because of missing resource load delegate callbacks.
    464 fast/loader/main-document-url-for-non-http-loads.html
    465 http/tests/misc/link-rel-icon-beforeload.html
     460
    466461# Tests failing because of missing policy delegate callbacks.
    467462fast/loader/onload-policy-ignore-for-frame.html
     
    695690fast/images/support-broken-image-delegate.html
    696691
    697 # Fail due to an extra "CONSOLE MESSAGE: line 1: SyntaxError: Parse error"
    698 fast/loader/onload-willSendRequest-null-for-script.html
    699 fast/loader/willSendRequest-null-for-preload.html
    700 
    701692# Requires willSendRequestReturnsNullOnRedirect + willSendRequest + didFinishLoading
    702693http/tests/misc/will-send-request-returns-null-on-redirect.html
    703 http/tests/misc/favicon-loads-with-icon-loading-override.html
    704694# Requires willPerformClientRedirectToURL
    705695# https://bugs.webkit.org/show_bug.cgi?id=58526
     
    808798# https://bugs.webkit.org/show_bug.cgi?id=54189
    809799fast/replaced/border-radius-clip.html
    810 
    811 # New test needs enhanced frameloader delegate logging in DRT
    812 # Discussed in https://bugs.webkit.org/show_bug.cgi?id=38928
    813 fast/loader/recursive-before-unload-crash.html
    814 fast/loader/null-request-after-willSendRequest.html
    815800
    816801# Need to dump context menu items on eventSender.contextClick(true).
     
    13011286fast/events/dropzone-002.html
    13021287fast/events/dropzone-005.html
    1303 
    1304 # [GTK] DumpRenderTree doesn't block external requests
    1305 # https://bugs.webkit.org/show_bug.cgi?id=62585
    1306 fast/workers/worker-crash-with-invalid-location.html
    13071288
    13081289# https://bugs.webkit.org/show_bug.cgi?id=64085
  • trunk/LayoutTests/platform/gtk/http/tests/misc/willCacheResponse-delegate-callback-expected.txt

    r78279 r106445  
     1http://127.0.0.1:8000/misc/resources/willCacheResponse-success.html - willSendRequest <NSURLRequest URL http://127.0.0.1:8000/misc/resources/willCacheResponse-success.html, main document URL http://127.0.0.1:8000/misc/willCacheResponse-delegate-callback.html, http method GET> redirectResponse (null)
     2http://127.0.0.1:8000/misc/resources/willCacheResponse-success.html - didReceiveResponse <NSURLResponse http://127.0.0.1:8000/misc/resources/willCacheResponse-success.html, http status code 200>
    13This tests for the willCacheResponse resource delegate callback as added for radar 5008925.
    24The test is only meaningful if you are running it under DumpRenderTree
  • trunk/Source/WebKit/gtk/ChangeLog

    r105607 r106445  
     12012-02-01  Philippe Normand  <pnormand@igalia.com> and Sergio Villar Senin  <svillar@igalia.com>
     2
     3        Reviewed by Martin Robinson.
     4
     5        [GTK] Improve FrameLoader signals. Resource loading
     6        https://bugs.webkit.org/show_bug.cgi?id=49543
     7
     8        New signals:
     9        WebKitWebFrame::resource-request-starting
     10        WebKitWebFrame::resource-response-received
     11        WebKitWebFrame::resource-load-finished
     12        WebKitWebFrame::resource-content-length-received
     13        WebKitWebFrame::resource-load-failed
     14        WebKitWebResource::response-received
     15        WebKitWebResource::load-failed
     16        WebKitWebResource::load-finished
     17        WebKitWebResource::content-length-received
     18        WebKitWebView::resource-response-received
     19        WebKitWebView::resource-load-finished
     20        WebKitWebView::resource-content-length-received
     21        WebKitWebView::resource-load-failed
     22
     23        * WebCoreSupport/FrameLoaderClientGtk.cpp:
     24        (WebKit::FrameLoaderClient::dispatchWillSendRequest):
     25        (WebKit::FrameLoaderClient::dispatchDidReceiveResponse):
     26        (WebKit::FrameLoaderClient::dispatchDidReceiveContentLength):
     27        (WebKit::FrameLoaderClient::dispatchDidFinishLoading):
     28        (WebKit::FrameLoaderClient::dispatchDidFailLoading):
     29        * webkit/webkitwebframe.cpp:
     30        (webkit_web_frame_class_init):
     31        * webkit/webkitwebresource.cpp:
     32        (webkit_web_resource_class_init):
     33        * webkit/webkitwebview.cpp:
     34        (webkit_web_view_class_init):
     35        * webkitmarshal.list:
     36
    1372012-01-23  Mario Sanchez Prada  <msanchez@igalia.com>
    238
  • trunk/Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp

    r102062 r106445  
    234234        webResource->priv->uri = g_strdup(request.url().string().utf8().data());
    235235    }
    236    
     236
    237237    g_signal_emit_by_name(webView, "resource-request-starting", m_frame, webResource, networkRequest.get(), networkResponse.get());
     238    g_signal_emit_by_name(m_frame, "resource-request-starting", webResource, networkRequest.get(), networkResponse.get());
    238239
    239240    // Feed any changes back into the ResourceRequest object.
     
    299300}
    300301
    301 void FrameLoaderClient::dispatchDidReceiveResponse(WebCore::DocumentLoader* loader, unsigned long, const ResourceResponse& response)
     302void FrameLoaderClient::dispatchDidReceiveResponse(WebCore::DocumentLoader* loader, unsigned long identifier, const ResourceResponse& response)
    302303{
    303304    // Update our knowledge of request soup flags - some are only set
     
    306307
    307308    m_response = response;
     309
     310    WebKitWebView* webView = getViewFromFrame(m_frame);
     311    GOwnPtr<gchar> identifierString(toString(identifier));
     312    WebKitWebResource* webResource = webkit_web_view_get_resource(webView, identifierString.get());
     313    GRefPtr<WebKitNetworkResponse> networkResponse(adoptGRef(kitNew(response)));
     314
     315    g_signal_emit_by_name(webResource, "response-received", networkResponse.get());
     316    g_signal_emit_by_name(m_frame, "resource-response-received", webResource, networkResponse.get());
     317    g_signal_emit_by_name(webView, "resource-response-received", m_frame, webResource, networkResponse.get());
    308318}
    309319
     
    9931003void FrameLoaderClient::dispatchDidReceiveContentLength(WebCore::DocumentLoader*, unsigned long identifier, int dataLength)
    9941004{
    995     notImplemented();
     1005    WebKitWebView* webView = getViewFromFrame(m_frame);
     1006    GOwnPtr<gchar> identifierString(toString(identifier));
     1007    WebKitWebResource* webResource = webkit_web_view_get_resource(webView, identifierString.get());
     1008
     1009    g_signal_emit_by_name(webResource, "content-length-received", dataLength);
     1010    g_signal_emit_by_name(m_frame, "resource-content-length-received", webResource, dataLength);
     1011    g_signal_emit_by_name(webView, "resource-content-length-received", m_frame, webResource, dataLength);
    9961012}
    9971013
     
    10221038    webkit_web_resource_init_with_core_resource(webResource, coreResource.get());
    10231039
    1024     // FIXME: This function should notify the application that the resource
    1025     // finished loading, maybe using a load-status property in the
    1026     // WebKitWebResource object, similar to what we do for WebKitWebFrame'
    1027     // signal.
    1028     notImplemented();
     1040    g_signal_emit_by_name(webResource, "load-finished");
     1041    g_signal_emit_by_name(m_frame, "resource-load-finished", webResource);
     1042    g_signal_emit_by_name(webView, "resource-load-finished", m_frame, webResource);
    10291043}
    10301044
     
    10331047    static_cast<WebKit::DocumentLoader*>(loader)->decreaseLoadCount(identifier);
    10341048
    1035     // FIXME: This function should notify the application that the resource failed
    1036     // loading, maybe a 'load-error' signal in the WebKitWebResource object.
    1037     notImplemented();
     1049    WebKitWebView* webView = getViewFromFrame(m_frame);
     1050    GOwnPtr<gchar> identifierString(toString(identifier));
     1051    WebKitWebResource* webResource = webkit_web_view_get_resource(webView, identifierString.get());
     1052    GOwnPtr<GError> webError(g_error_new_literal(g_quark_from_string(error.domain().utf8().data()),
     1053                                                 error.errorCode(),
     1054                                                 error.localizedDescription().utf8().data()));
     1055
     1056    g_signal_emit_by_name(webResource, "load-failed", webError.get());
     1057    g_signal_emit_by_name(m_frame, "resource-load-failed", webResource, webError.get());
     1058    g_signal_emit_by_name(webView, "resource-load-failed", m_frame, webResource, webError.get());
    10381059}
    10391060
  • trunk/Source/WebKit/gtk/webkit/webkitwebframe.cpp

    r105604 r106445  
    6161#include "webkitglobalsprivate.h"
    6262#include "webkitmarshal.h"
     63#include "webkitnetworkresponse.h"
    6364#include "webkitnetworkrequestprivate.h"
    6465#include "webkitnetworkresponseprivate.h"
    6566#include "webkitsecurityoriginprivate.h"
    6667#include "webkitwebframeprivate.h"
     68#include "webkitwebresource.h"
    6769#include "webkitwebview.h"
    6870#include "webkitwebviewprivate.h"
     
    105107    HOVERING_OVER_LINK,
    106108    SCROLLBARS_POLICY_CHANGED,
     109    // Resource loading signals
     110    RESOURCE_REQUEST_STARTING,
     111    RESOURCE_RESPONSE_RECEIVED,
     112    RESOURCE_LOAD_FINISHED,
     113    RESOURCE_CONTENT_LENGTH_RECEIVED,
     114    RESOURCE_LOAD_FAILED,
     115
    107116    LAST_SIGNAL
    108117};
     
    302311            G_TYPE_BOOLEAN, 0);
    303312
     313
     314    /**
     315     * WebKitWebFrame::resource-request-starting:
     316     * @web_frame: the #WebKitWebFrame whose load dispatched this request
     317     * @web_resource: an empty #WebKitWebResource object
     318     * @request: the #WebKitNetworkRequest that will be dispatched
     319     * @response: the #WebKitNetworkResponse representing the redirect
     320     * response, if any
     321     *
     322     * Emitted when a request is about to be sent. You can modify the
     323     * request while handling this signal. You can set the URI in the
     324     * #WebKitNetworkRequest object itself, and add/remove/replace
     325     * headers using the #SoupMessage object it carries, if it is
     326     * present. See webkit_network_request_get_message(). Setting the
     327     * request URI to "about:blank" will effectively cause the request
     328     * to load nothing, and can be used to disable the loading of
     329     * specific resources.
     330     *
     331     * Notice that information about an eventual redirect is available
     332     * in @response's #SoupMessage, not in the #SoupMessage carried by
     333     * the @request. If @response is %NULL, then this is not a
     334     * redirected request.
     335     *
     336     * The #WebKitWebResource object will be the same throughout all
     337     * the lifetime of the resource, but the contents may change
     338     * between signal emissions.
     339     *
     340     * Since: 1.7.5
     341     */
     342    webkit_web_frame_signals[RESOURCE_REQUEST_STARTING] = g_signal_new("resource-request-starting",
     343            G_TYPE_FROM_CLASS(frameClass),
     344            G_SIGNAL_RUN_LAST,
     345            0,
     346            0, 0,
     347            webkit_marshal_VOID__OBJECT_OBJECT_OBJECT,
     348            G_TYPE_NONE, 3,
     349            WEBKIT_TYPE_WEB_RESOURCE,
     350            WEBKIT_TYPE_NETWORK_REQUEST,
     351            WEBKIT_TYPE_NETWORK_RESPONSE);
     352
     353    /*
     354     * WebKitWebFrame::resource-response-received
     355     * @webFrame: the #WebKitWebFrame the response was received for
     356     * @webResource: the #WebKitWebResource being loaded
     357     * @response: the #WebKitNetworkResponse that was received.
     358     *
     359     * Emitted when the first byte of data arrives
     360     *
     361     * Since: 1.7.5
     362     */
     363    webkit_web_frame_signals[RESOURCE_RESPONSE_RECEIVED] = g_signal_new("resource-response-received",
     364            G_TYPE_FROM_CLASS(frameClass),
     365            G_SIGNAL_RUN_LAST,
     366            0,
     367            0, 0,
     368            webkit_marshal_VOID__OBJECT_OBJECT,
     369            G_TYPE_NONE, 2,
     370            WEBKIT_TYPE_WEB_RESOURCE,
     371            WEBKIT_TYPE_NETWORK_RESPONSE);
     372
     373    /*
     374     * WebKitWebFrame::resource-load-finished
     375     * @webFrame: the #WebKitWebFrame the response was received for
     376     * @webResource: the #WebKitWebResource being loaded
     377     *
     378     * Emitted when all the data for the resource was loaded.
     379     *
     380     * Since: 1.7.5
     381     */
     382    webkit_web_frame_signals[RESOURCE_LOAD_FINISHED] = g_signal_new("resource-load-finished",
     383            G_TYPE_FROM_CLASS(frameClass),
     384            G_SIGNAL_RUN_LAST,
     385            0,
     386            0, 0,
     387            g_cclosure_marshal_VOID__OBJECT,
     388            G_TYPE_NONE, 1,
     389            WEBKIT_TYPE_WEB_RESOURCE);
     390
     391    /*
     392     * WebKitWebFrame::resource-content-length-received
     393     * @webFrame: the #WebKitWebFrame the response was received for
     394     * @webResource: the #WebKitWebResource that was loaded
     395     * @lengthReceived: the resource data length in bytes
     396     *
     397     * Emitted when all the data for the resource was loaded.
     398     *
     399     * Since: 1.7.5
     400     */
     401    webkit_web_frame_signals[RESOURCE_CONTENT_LENGTH_RECEIVED] = g_signal_new("resource-content-length-received",
     402            G_TYPE_FROM_CLASS(frameClass),
     403            G_SIGNAL_RUN_LAST,
     404            0,
     405            0, 0,
     406            webkit_marshal_VOID__OBJECT_INT,
     407            G_TYPE_NONE, 2,
     408            WEBKIT_TYPE_WEB_RESOURCE,
     409            G_TYPE_INT);
     410
     411    /*
     412     * WebKitWebFrame::resource-load-failed
     413     * @webFrame: the #WebKitWebFrame the response was received for
     414     * @webResource: the #WebKitWebResource that was loaded
     415     * @webError: the #GError that was triggered
     416     *
     417     * Invoked when a resource failed to load.
     418     *
     419     * Since: 1.7.5
     420     */
     421    webkit_web_frame_signals[RESOURCE_LOAD_FAILED] = g_signal_new("resource-load-failed",
     422            G_TYPE_FROM_CLASS(frameClass),
     423            G_SIGNAL_RUN_LAST,
     424            0,
     425            0, 0,
     426            webkit_marshal_VOID__OBJECT_POINTER,
     427            G_TYPE_NONE, 2,
     428            WEBKIT_TYPE_WEB_RESOURCE,
     429            G_TYPE_POINTER);
     430
    304431    /*
    305432     * implementations of virtual methods
  • trunk/Source/WebKit/gtk/webkit/webkitwebresource.cpp

    r99239 r106445  
    2828#include "webkitglobalsprivate.h"
    2929#include "webkitmarshal.h"
     30#include "webkitnetworkresponse.h"
    3031#include "webkitwebresourceprivate.h"
    3132#include <glib.h>
     
    4647
    4748enum {
     49    // Resource loading
     50    RESPONSE_RECEIVED,
     51    LOAD_FINISHED,
     52    CONTENT_LENGTH_RECEIVED,
     53    LOAD_FAILED,
     54
     55    LAST_SIGNAL
     56};
     57
     58enum {
    4859    PROP_0,
    49 
    5060    PROP_URI,
    5161    PROP_MIME_TYPE,
     
    5464};
    5565
     66static guint webkit_web_resource_signals[LAST_SIGNAL] = { 0, };
     67
    5668G_DEFINE_TYPE(WebKitWebResource, webkit_web_resource, G_TYPE_OBJECT);
    5769
     
    102114}
    103115
    104 static void webkit_web_resource_class_init(WebKitWebResourceClass* klass)
    105 {
    106     GObjectClass* gobject_class = G_OBJECT_CLASS(klass);
     116static void webkit_web_resource_class_init(WebKitWebResourceClass* webResourceClass)
     117{
     118    GObjectClass* gobject_class = G_OBJECT_CLASS(webResourceClass);
    107119
    108120    gobject_class->dispose = webkit_web_resource_dispose;
     
    110122    gobject_class->get_property = webkit_web_resource_get_property;
    111123    gobject_class->set_property = webkit_web_resource_set_property;
     124
     125    /*
     126     * WebKitWebResource::response-received
     127     * @webResource: the #WebKitWebResource being loaded
     128     * @response: the #WebKitNetworkResponse that was received
     129     *
     130     * Emitted when the first byte of data arrives
     131     *
     132     * Since: 1.7.5
     133     */
     134    webkit_web_resource_signals[RESPONSE_RECEIVED] = g_signal_new("response-received",
     135            G_TYPE_FROM_CLASS(webResourceClass),
     136            G_SIGNAL_RUN_LAST,
     137            0,
     138            0, 0,
     139            g_cclosure_marshal_VOID__OBJECT,
     140            G_TYPE_NONE, 1,
     141            WEBKIT_TYPE_NETWORK_RESPONSE);
     142
     143    /*
     144     * WebKitWebResource::load-failed
     145     * @webResource: the #WebKitWebResource that was loaded
     146     * @webError: the #GError that was triggered
     147     *
     148     * Invoked when a resource failed to load
     149     *
     150     * Since: 1.7.5
     151     */
     152    webkit_web_resource_signals[LOAD_FAILED] = g_signal_new("load-failed",
     153            G_TYPE_FROM_CLASS(webResourceClass),
     154            G_SIGNAL_RUN_LAST,
     155            0,
     156            0, 0,
     157            g_cclosure_marshal_VOID__OBJECT,
     158            G_TYPE_NONE, 1,
     159            G_TYPE_POINTER);
     160
     161    /*
     162     * WebKitWebResource::load-finished
     163     * @webResource: the #WebKitWebResource being loaded
     164     *
     165     * Emitted when all the data for the resource was loaded
     166     *
     167     * Since: 1.7.5
     168     */
     169    webkit_web_resource_signals[LOAD_FINISHED] = g_signal_new("load-finished",
     170            G_TYPE_FROM_CLASS(webResourceClass),
     171            G_SIGNAL_RUN_LAST,
     172            0,
     173            0, 0,
     174            g_cclosure_marshal_VOID__VOID,
     175            G_TYPE_NONE, 0);
     176
     177    /*
     178     * WebKitWebResource::content-length-received
     179     * @webResource: the #WebKitWebResource that was loaded
     180     * @lengthReceived: the resource data length in bytes
     181     *
     182     * Emitted when all the data for the resource was loaded
     183     *
     184     * Since: 1.7.5
     185     */
     186    webkit_web_resource_signals[CONTENT_LENGTH_RECEIVED] = g_signal_new("content-length-received",
     187            G_TYPE_FROM_CLASS(webResourceClass),
     188            G_SIGNAL_RUN_LAST,
     189            0,
     190            0, 0,
     191            g_cclosure_marshal_VOID__INT,
     192            G_TYPE_NONE, 1,
     193            G_TYPE_INT);
    112194
    113195    /**
  • trunk/Source/WebKit/gtk/webkit/webkitwebview.cpp

    r105289 r106445  
    209209    VIEWPORT_ATTRIBUTES_RECOMPUTE_REQUESTED,
    210210    VIEWPORT_ATTRIBUTES_CHANGED,
     211    RESOURCE_RESPONSE_RECEIVED,
     212    RESOURCE_LOAD_FINISHED,
     213    RESOURCE_CONTENT_LENGTH_RECEIVED,
     214    RESOURCE_LOAD_FAILED,
    211215
    212216    LAST_SIGNAL
     
    26072611            G_TYPE_NONE, 1,
    26082612            WEBKIT_TYPE_VIEWPORT_ATTRIBUTES);
     2613
     2614    /*
     2615     * WebKitWebView::resource-response-received
     2616     * @webView: the object which received the signal
     2617     * @webFrame: the #WebKitWebFrame the response was received for
     2618     * @webResource: the #WebKitWebResource being loaded
     2619     * @response: the #WebKitNetworkResponse that was received
     2620     *
     2621     * Emitted when the first byte of data arrives
     2622     *
     2623     * Since: 1.7.5
     2624     */
     2625    webkit_web_view_signals[RESOURCE_RESPONSE_RECEIVED] = g_signal_new("resource-response-received",
     2626            G_TYPE_FROM_CLASS(webViewClass),
     2627            G_SIGNAL_RUN_LAST,
     2628            0,
     2629            0, 0,
     2630            webkit_marshal_VOID__OBJECT_OBJECT_OBJECT,
     2631            G_TYPE_NONE, 3,
     2632            WEBKIT_TYPE_WEB_FRAME,
     2633            WEBKIT_TYPE_WEB_RESOURCE,
     2634            WEBKIT_TYPE_NETWORK_RESPONSE);
     2635
     2636    /*
     2637     * WebKitWebView::resource-load-finished
     2638     * @webView: the object which received the signal
     2639     * @webFrame: the #WebKitWebFrame the response was received for
     2640     * @webResource: the #WebKitWebResource that was loaded
     2641     *
     2642     * Emitted when all the data for the resource was loaded
     2643     *
     2644     * Since: 1.7.5
     2645     */
     2646    webkit_web_view_signals[RESOURCE_LOAD_FINISHED] = g_signal_new("resource-load-finished",
     2647            G_TYPE_FROM_CLASS(webViewClass),
     2648            G_SIGNAL_RUN_LAST,
     2649            0,
     2650            0, 0,
     2651            webkit_marshal_VOID__OBJECT_OBJECT,
     2652            G_TYPE_NONE, 2,
     2653            WEBKIT_TYPE_WEB_FRAME,
     2654            WEBKIT_TYPE_WEB_RESOURCE);
     2655
     2656    /*
     2657     * WebKitWebView::resource-content-length-received
     2658     * @webView: the object which received the signal
     2659     * @webFrame: the #WebKitWebFrame the response was received for
     2660     * @webResource: the #WebKitWebResource that was loaded
     2661     * @lengthReceived: the resource data length in bytes
     2662     *
     2663     * Emitted when the HTTP Content-Length response header has been
     2664     * received and parsed successfully.
     2665     *
     2666     * Since: 1.7.5
     2667     */
     2668    webkit_web_view_signals[RESOURCE_CONTENT_LENGTH_RECEIVED] = g_signal_new("resource-content-length-received",
     2669            G_TYPE_FROM_CLASS(webViewClass),
     2670            G_SIGNAL_RUN_LAST,
     2671            0,
     2672            0, 0,
     2673            webkit_marshal_VOID__OBJECT_OBJECT_INT,
     2674            G_TYPE_NONE, 3,
     2675            WEBKIT_TYPE_WEB_FRAME,
     2676            WEBKIT_TYPE_WEB_RESOURCE,
     2677            G_TYPE_INT);
     2678
     2679    /*
     2680     * WebKitWebView::resource-load-failed
     2681     * @webView: the object which received the signal
     2682     * @webFrame: the #WebKitWebFrame the response was received for
     2683     * @webResource: the #WebKitWebResource that was loaded
     2684     * @webError: the #GError that was triggered
     2685     *
     2686     * Invoked when a resource failed to load
     2687     *
     2688     * Since: 1.7.5
     2689     */
     2690    webkit_web_view_signals[RESOURCE_LOAD_FAILED] = g_signal_new("resource-load-failed",
     2691            G_TYPE_FROM_CLASS(webViewClass),
     2692            G_SIGNAL_RUN_LAST,
     2693            0,
     2694            0, 0,
     2695            webkit_marshal_VOID__OBJECT_OBJECT_POINTER,
     2696            G_TYPE_NONE, 3,
     2697            WEBKIT_TYPE_WEB_FRAME,
     2698            WEBKIT_TYPE_WEB_RESOURCE,
     2699            G_TYPE_POINTER);
    26092700
    26102701    /*
  • trunk/Source/WebKit/gtk/webkitmarshal.list

    r72675 r106445  
    1818OBJECT:VOID
    1919VOID:OBJECT,OBJECT
     20VOID:OBJECT,OBJECT,INT
     21VOID:OBJECT,OBJECT,OBJECT
     22VOID:OBJECT,OBJECT,POINTER
    2023VOID:OBJECT,OBJECT,OBJECT,OBJECT
    2124VOID:OBJECT,POINTER,POINTER
     25VOID:OBJECT,INT
     26VOID:OBJECT,POINTER
    2227VOID:OBJECT,STRING
    2328VOID:STRING
    2429VOID:STRING,STRING
    25 
  • trunk/Tools/ChangeLog

    r106442 r106445  
     12012-02-01  Philippe Normand  <pnormand@igalia.com> and Sergio Villar Senin  <svillar@igalia.com>
     2
     3        Reviewed by Martin Robinson.
     4
     5        [GTK] Improve FrameLoader signals. Resource loading
     6        https://bugs.webkit.org/show_bug.cgi?id=49543
     7
     8        Support for the new loader signals in DRT.
     9
     10        * DumpRenderTree/gtk/DumpRenderTree.cpp:
     11        (urlPath):
     12        (willSendRequestCallback):
     13        (urlSuitableForTestResult):
     14        (descriptionSuitableForTestResult):
     15        (didReceiveResponse):
     16        (didFinishLoading):
     17        (didFailLoadingWithError):
     18        (createWebView):
     19
    1202012-02-01  Ryosuke Niwa  <rniwa@webkit.org>
    221
  • trunk/Tools/DumpRenderTree/gtk/DumpRenderTree.cpp

    r106126 r106445  
    10641064}
    10651065
    1066 static void willSendRequestCallback(WebKitWebView* webView, WebKitWebFrame*, WebKitWebResource*, WebKitNetworkRequest* request, WebKitNetworkResponse*)
    1067 {
     1066
     1067static CString pathFromSoupURI(SoupURI* uri)
     1068{
     1069    if (!uri)
     1070        return CString();
     1071
     1072    if (g_str_equal(uri->scheme, "http")) {
     1073        GOwnPtr<char> uriString(soup_uri_to_string(uri, FALSE));
     1074        return CString(uriString.get());
     1075    }
     1076
     1077    GOwnPtr<gchar> pathDirname(g_path_get_basename(g_path_get_dirname(uri->path)));
     1078    GOwnPtr<gchar> pathBasename(g_path_get_basename(uri->path));
     1079    GOwnPtr<gchar> urlPath(g_strdup_printf("%s/%s", pathDirname.get(), pathBasename.get()));
     1080    return CString(urlPath.get());
     1081}
     1082
     1083static CString convertSoupMessageToURLPath(SoupMessage* soupMessage)
     1084{
     1085    if (!soupMessage)
     1086        return CString();
     1087    if (SoupURI* requestURI = soup_message_get_uri(soupMessage))
     1088        return pathFromSoupURI(requestURI);
     1089    return CString();
     1090}
     1091
     1092static CString convertNetworkRequestToURLPath(WebKitNetworkRequest* request)
     1093{
     1094    return convertSoupMessageToURLPath(webkit_network_request_get_message(request));
     1095}
     1096
     1097static CString convertWebResourceToURLPath(WebKitWebResource* webResource)
     1098{
     1099    SoupURI* uri = soup_uri_new(webkit_web_resource_get_uri(webResource));
     1100    CString urlPath(pathFromSoupURI(uri));
     1101    soup_uri_free(uri);
     1102    return urlPath;
     1103}
     1104
     1105static CString urlSuitableForTestResult(const char* uriString)
     1106{
     1107    if (!g_str_has_prefix(uriString, "file://"))
     1108        return CString(uriString);
     1109
     1110    GOwnPtr<gchar> basename(g_path_get_basename(uriString));
     1111    return CString(basename.get());
     1112}
     1113
     1114static CString descriptionSuitableForTestResult(SoupURI* uri)
     1115{
     1116    if (!uri)
     1117        return CString("");
     1118
     1119    GOwnPtr<char> uriString(soup_uri_to_string(uri, false));
     1120    return urlSuitableForTestResult(uriString.get());
     1121}
     1122
     1123static CString descriptionSuitableForTestResult(WebKitWebView* webView, WebKitWebFrame* webFrame, WebKitWebResource* webResource)
     1124{
     1125    SoupURI* uri = soup_uri_new(webkit_web_resource_get_uri(webResource));
     1126    CString description;
     1127    WebKitWebDataSource* dataSource = webkit_web_frame_get_data_source(webFrame);
     1128
     1129    if (webResource == webkit_web_data_source_get_main_resource(dataSource)
     1130        && (!webkit_web_view_get_progress(webView) || g_str_equal(uri->scheme, "file")))
     1131        description = CString("<unknown>");
     1132    else
     1133        description = convertWebResourceToURLPath(webResource);
     1134
     1135    if (uri)
     1136        soup_uri_free(uri);
     1137
     1138    return description;
     1139}
     1140
     1141static CString descriptionSuitableForTestResult(GError* error, WebKitWebResource* webResource)
     1142{
     1143    const gchar* errorDomain = g_quark_to_string(error->domain);
     1144    CString resourceURIString(urlSuitableForTestResult(webkit_web_resource_get_uri(webResource)));
     1145
     1146    if (g_str_equal(errorDomain, "webkit-network-error-quark"))
     1147        errorDomain = "NSURLErrorDomain";
     1148
     1149    // TODO: the other ports get the failingURL from the ResourceError
     1150    GOwnPtr<char> errorString(g_strdup_printf("<NSError domain %s, code %d, failing URL \"%s\">",
     1151                                              errorDomain, error->code, resourceURIString.data()));
     1152    return CString(errorString.get());
     1153}
     1154
     1155static CString descriptionSuitableForTestResult(WebKitNetworkRequest* request)
     1156{
     1157    SoupMessage* soupMessage = webkit_network_request_get_message(request);
     1158
     1159    if (!soupMessage) {
     1160        g_printerr("GRR\n");
     1161        return CString("");
     1162    }
     1163
     1164    SoupURI* requestURI = soup_message_get_uri(soupMessage);
     1165    SoupURI* mainDocumentURI = soup_message_get_first_party(soupMessage);
     1166    CString requestURIString(descriptionSuitableForTestResult(requestURI));
     1167    CString mainDocumentURIString(descriptionSuitableForTestResult(mainDocumentURI));
     1168    CString path(convertNetworkRequestToURLPath(request));
     1169    GOwnPtr<char> description(g_strdup_printf("<NSURLRequest URL %s, main document URL %s, http method %s>",
     1170                                              path.data(), mainDocumentURIString.data(),
     1171                                              soupMessage ? soupMessage->method : "(none)"));
     1172    return CString(description.get());
     1173}
     1174
     1175static CString descriptionSuitableForTestResult(WebKitNetworkResponse* response)
     1176{
     1177    if (!response)
     1178        return CString("(null)");
     1179
     1180    int statusCode = 0;
     1181    CString responseURIString(urlSuitableForTestResult(webkit_network_response_get_uri(response)));
     1182    SoupMessage* soupMessage = webkit_network_response_get_message(response);
     1183    CString path;
     1184
     1185    if (soupMessage) {
     1186        statusCode = soupMessage->status_code;
     1187        path = convertSoupMessageToURLPath(soupMessage);
     1188    } else
     1189        path = CString("");
     1190
     1191    GOwnPtr<char> description(g_strdup_printf("<NSURLResponse %s, http status code %d>", path.data(), statusCode));
     1192    return CString(description.get());
     1193}
     1194
     1195static void willSendRequestCallback(WebKitWebView* webView, WebKitWebFrame* webFrame, WebKitWebResource* resource, WebKitNetworkRequest* request, WebKitNetworkResponse* response)
     1196{
     1197
     1198
    10681199    if (!done && gLayoutTestController->willSendRequestReturnsNull()) {
    10691200        // As requested by the LayoutTestController, don't perform the request.
     
    10721203    }
    10731204
     1205    if (!done && gLayoutTestController->dumpResourceLoadCallbacks())
     1206        printf("%s - willSendRequest %s redirectResponse %s\n",
     1207               convertNetworkRequestToURLPath(request).data(),
     1208               descriptionSuitableForTestResult(request).data(),
     1209               descriptionSuitableForTestResult(response).data());
     1210
    10741211    SoupMessage* soupMessage = webkit_network_request_get_message(request);
    10751212    SoupURI* uri = soup_uri_new(webkit_network_request_get_uri(request));
     
    10791216        && g_ascii_strncasecmp(uri->host, "localhost", 9)) {
    10801217        printf("Blocked access to external URL %s\n", soup_uri_to_string(uri, FALSE));
     1218        // Cancel load of blocked resource to avoid potential
     1219        // network-related timeouts in tests.
     1220        webkit_network_request_set_uri(request, "about:blank");
    10811221        soup_uri_free(uri);
    10821222        return;
    10831223    }
     1224
    10841225    if (uri)
    10851226        soup_uri_free(uri);
     
    10891230        for (set<string>::const_iterator header = clearHeaders.begin(); header != clearHeaders.end(); ++header)
    10901231            soup_message_headers_remove(soupMessage->request_headers, header->c_str());
     1232    }
     1233}
     1234
     1235
     1236static void didReceiveResponse(WebKitWebView* webView, WebKitWebFrame*, WebKitWebResource* webResource, WebKitNetworkResponse* response)
     1237{
     1238    if (!done && gLayoutTestController->dumpResourceLoadCallbacks()) {
     1239        CString responseDescription(descriptionSuitableForTestResult(response));
     1240        CString path(convertWebResourceToURLPath(webResource));
     1241        printf("%s - didReceiveResponse %s\n", path.data(), responseDescription.data());
     1242    }
     1243
     1244    // TODO: add "has MIME type" whenever dumpResourceResponseMIMETypes() is supported.
     1245    // See https://bugs.webkit.org/show_bug.cgi?id=58222.
     1246}
     1247
     1248static void didFinishLoading(WebKitWebView* webView, WebKitWebFrame* webFrame, WebKitWebResource* webResource)
     1249{
     1250    if (!done && gLayoutTestController->dumpResourceLoadCallbacks())
     1251        printf("%s - didFinishLoading\n", descriptionSuitableForTestResult(webView, webFrame, webResource).data());
     1252}
     1253
     1254static void didFailLoadingWithError(WebKitWebView* webView, WebKitWebFrame* webFrame, WebKitWebResource* webResource, GError* webError)
     1255{
     1256    if (!done && gLayoutTestController->dumpResourceLoadCallbacks()) {
     1257        CString webErrorString(descriptionSuitableForTestResult(webError, webResource));
     1258        printf("%s - didFailLoadingWithError: %s\n", descriptionSuitableForTestResult(webView, webFrame, webResource).data(),
     1259               webErrorString.data());
    10911260    }
    10921261}
     
    11231292                     "signal::frame-created", frameCreatedCallback, 0,
    11241293                     "signal::resource-request-starting", willSendRequestCallback, 0,
    1125 
     1294                     "signal::resource-response-received", didReceiveResponse, 0,
     1295                     "signal::resource-load-finished", didFinishLoading, 0,
     1296                     "signal::resource-load-failed", didFailLoadingWithError, 0,
    11261297                     NULL);
    11271298    connectEditingCallbacks(view);
Note: See TracChangeset for help on using the changeset viewer.