Changeset 169112 in webkit


Ignore:
Timestamp:
May 20, 2014 8:20:52 AM (10 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] WebKitWebPage::send-request always pass a valid pointer for redirected response
https://bugs.webkit.org/show_bug.cgi?id=133119

Reviewed by Sergio Villar Senin.

Source/WebKit2:
The problem is that we were checking whether the passed in
WKURLResponseRef is NULL or not, but it's always a valid object
that can contain a NULL WebCore::ResourceResponse.

  • WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp:

(willSendRequestForFrame): Pass NULL as redirect-response
parameter of WebKitWebPage::send-request signal when the
WebCore::ResourceResponse of the passed in WKURLResponseRef is NULL.

Tools:
Check that redirect response parameter of
WebKitWebPage::send-request signal is NULL when not redirecting
and a valid WebKitURIResponse object when redirecting.

  • TestWebKitAPI/Tests/WebKit2Gtk/TestResources.cpp:

(testWebResourceSendRequest):
(serverCallback):

  • TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp:

(sendRequestCallback):

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r169109 r169112  
     12014-05-20  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] WebKitWebPage::send-request always pass a valid pointer for redirected response
     4        https://bugs.webkit.org/show_bug.cgi?id=133119
     5
     6        Reviewed by Sergio Villar Senin.
     7
     8        The problem is that we were checking whether the passed in
     9        WKURLResponseRef is NULL or not, but it's always a valid object
     10        that can contain a NULL WebCore::ResourceResponse.
     11
     12        * WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp:
     13        (willSendRequestForFrame): Pass NULL as redirect-response
     14        parameter of WebKitWebPage::send-request signal when the
     15        WebCore::ResourceResponse of the passed in WKURLResponseRef is NULL.
     16
    1172014-05-20  Antti Koivisto  <antti@apple.com>
    218
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp

    r165760 r169112  
    164164{
    165165    GRefPtr<WebKitURIRequest> request = adoptGRef(webkitURIRequestCreateForResourceRequest(toImpl(wkRequest)->resourceRequest()));
    166     GRefPtr<WebKitURIResponse> redirectResponse = wkRedirectResponse ? adoptGRef(webkitURIResponseCreateForResourceResponse(toImpl(wkRedirectResponse)->resourceResponse())) : 0;
     166    const ResourceResponse& redirectResourceResponse = toImpl(wkRedirectResponse)->resourceResponse();
     167    GRefPtr<WebKitURIResponse> redirectResponse = !redirectResourceResponse.isNull() ? adoptGRef(webkitURIResponseCreateForResourceResponse(redirectResourceResponse)) : nullptr;
    167168
    168169    gboolean returnValue;
     
    180181    message.set(String::fromUTF8("Identifier"), API::UInt64::create(identifier));
    181182    message.set(String::fromUTF8("Request"), newRequest.get());
    182     if (!toImpl(wkRedirectResponse)->resourceResponse().isNull())
     183    if (!redirectResourceResponse.isNull())
    183184        message.set(String::fromUTF8("RedirectResponse"), toImpl(wkRedirectResponse));
    184185    WebProcess::shared().injectedBundle()->postMessage(String::fromUTF8("WebPage.DidSendRequestForResource"), ImmutableDictionary::create(std::move(message)).get());
  • trunk/Tools/ChangeLog

    r169106 r169112  
     12014-05-20  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] WebKitWebPage::send-request always pass a valid pointer for redirected response
     4        https://bugs.webkit.org/show_bug.cgi?id=133119
     5
     6        Reviewed by Sergio Villar Senin.
     7
     8        Check that redirect response parameter of
     9        WebKitWebPage::send-request signal is NULL when not redirecting
     10        and a valid WebKitURIResponse object when redirecting.
     11
     12        * TestWebKitAPI/Tests/WebKit2Gtk/TestResources.cpp:
     13        (testWebResourceSendRequest):
     14        (serverCallback):
     15        * TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp:
     16        (sendRequestCallback):
     17
    1182014-05-20  Carlos Garcia Campos  <cgarcia@igalia.com>
    219
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestResources.cpp

    r167008 r169112  
    639639    // URI changed after a redirect.
    640640    test->setExpectedNewResourceURI(kServer->getURIForPath("/redirected.js"));
    641     test->setExpectedNewResourceURIAfterRedirection(kServer->getURIForPath("/javascript.js"));
     641    test->setExpectedNewResourceURIAfterRedirection(kServer->getURIForPath("/javascript-after-redirection.js"));
    642642    test->loadURI(kServer->getURIForPath("redirected-javascript.html").data());
    643643    test->waitUntilResourceLoadFinished();
     
    718718        addCacheHTTPHeadersToResponse(message);
    719719        soup_message_headers_append(message->response_headers, "Content-Type", "text/css");
    720     } else if (g_str_equal(path, "/javascript.js")) {
     720    } else if (g_str_equal(path, "/javascript.js") || g_str_equal(path, "/javascript-after-redirection.js")) {
    721721        soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, kJavascript, strlen(kJavascript));
    722722        soup_message_headers_append(message->response_headers, "Content-Type", "text/javascript");
     
    755755    } else if (g_str_equal(path, "/redirected.js")) {
    756756        soup_message_set_status(message, SOUP_STATUS_MOVED_PERMANENTLY);
    757         soup_message_headers_append(message->response_headers, "Location", "/remove-this/javascript.js");
     757        soup_message_headers_append(message->response_headers, "Location", "/remove-this/javascript-after-redirection.js");
    758758    } else if (g_str_equal(path, "/redirected-to-cancel.js")) {
    759759        soup_message_set_status(message, SOUP_STATUS_MOVED_PERMANENTLY);
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp

    r163797 r169112  
    130130}
    131131
    132 static gboolean sendRequestCallback(WebKitWebPage*, WebKitURIRequest* request, WebKitURIResponse*, gpointer)
     132static gboolean sendRequestCallback(WebKitWebPage*, WebKitURIRequest* request, WebKitURIResponse* redirectResponse, gpointer)
    133133{
    134134    const char* requestURI = webkit_uri_request_get_uri(request);
     
    139139        GUniquePtr<char> newURI(g_strdup_printf("%s/javascript.js", prefix.get()));
    140140        webkit_uri_request_set_uri(request, newURI.get());
     141    } else if (const char* suffix = g_strrstr(requestURI, "/remove-this/javascript-after-redirection.js")) {
     142        // Redirected from /redirected.js, redirectResponse should be nullptr.
     143        g_assert(WEBKIT_IS_URI_RESPONSE(redirectResponse));
     144        g_assert(g_str_has_suffix(webkit_uri_response_get_uri(redirectResponse), "/redirected.js"));
     145
     146        GUniquePtr<char> prefix(g_strndup(requestURI, strlen(requestURI) - strlen(suffix)));
     147        GUniquePtr<char> newURI(g_strdup_printf("%s/javascript-after-redirection.js", prefix.get()));
     148        webkit_uri_request_set_uri(request, newURI.get());
     149    } else if (g_str_has_suffix(requestURI, "/redirected.js")) {
     150        // Original request, redirectResponse should be nullptr.
     151        g_assert(!redirectResponse);
    141152    } else if (g_str_has_suffix(requestURI, "/add-do-not-track-header")) {
    142153        SoupMessageHeaders* headers = webkit_uri_request_get_http_headers(request);
Note: See TracChangeset for help on using the changeset viewer.