Title: [169196] releases/WebKitGTK/webkit-2.4
Revision
169196
Author
[email protected]
Date
2014-05-22 04:59:42 -0700 (Thu, 22 May 2014)

Log Message

Merge r169112 - [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):

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.4/Source/WebKit2/ChangeLog (169195 => 169196)


--- releases/WebKitGTK/webkit-2.4/Source/WebKit2/ChangeLog	2014-05-22 11:54:24 UTC (rev 169195)
+++ releases/WebKitGTK/webkit-2.4/Source/WebKit2/ChangeLog	2014-05-22 11:59:42 UTC (rev 169196)
@@ -1,3 +1,19 @@
+2014-05-20  Carlos Garcia Campos  <[email protected]>
+
+        [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.
+
+        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.
+
 2014-04-28  Zan Dobersek  <[email protected]>
 
         [WK2][X11] NetscapePluginModule::scanPlugin() should write UTF-8 strings to stdout

Modified: releases/WebKitGTK/webkit-2.4/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp (169195 => 169196)


--- releases/WebKitGTK/webkit-2.4/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp	2014-05-22 11:54:24 UTC (rev 169195)
+++ releases/WebKitGTK/webkit-2.4/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp	2014-05-22 11:59:42 UTC (rev 169196)
@@ -163,7 +163,8 @@
 static WKURLRequestRef willSendRequestForFrame(WKBundlePageRef page, WKBundleFrameRef, uint64_t identifier, WKURLRequestRef wkRequest, WKURLResponseRef wkRedirectResponse, const void* clientInfo)
 {
     GRefPtr<WebKitURIRequest> request = adoptGRef(webkitURIRequestCreateForResourceRequest(toImpl(wkRequest)->resourceRequest()));
-    GRefPtr<WebKitURIResponse> redirectResponse = wkRedirectResponse ? adoptGRef(webkitURIResponseCreateForResourceResponse(toImpl(wkRedirectResponse)->resourceResponse())) : 0;
+    const ResourceResponse& redirectResourceResponse = toImpl(wkRedirectResponse)->resourceResponse();
+    GRefPtr<WebKitURIResponse> redirectResponse = !redirectResourceResponse.isNull() ? adoptGRef(webkitURIResponseCreateForResourceResponse(redirectResourceResponse)) : nullptr;
 
     gboolean returnValue;
     g_signal_emit(WEBKIT_WEB_PAGE(clientInfo), signals[SEND_REQUEST], 0, request.get(), redirectResponse.get(), &returnValue);
@@ -179,7 +180,7 @@
     message.set(String::fromUTF8("Page"), toImpl(page));
     message.set(String::fromUTF8("Identifier"), API::UInt64::create(identifier));
     message.set(String::fromUTF8("Request"), newRequest.get());
-    if (!toImpl(wkRedirectResponse)->resourceResponse().isNull())
+    if (!redirectResourceResponse.isNull())
         message.set(String::fromUTF8("RedirectResponse"), toImpl(wkRedirectResponse));
     WebProcess::shared().injectedBundle()->postMessage(String::fromUTF8("WebPage.DidSendRequestForResource"), ImmutableDictionary::create(std::move(message)).get());
 

Modified: releases/WebKitGTK/webkit-2.4/Tools/ChangeLog (169195 => 169196)


--- releases/WebKitGTK/webkit-2.4/Tools/ChangeLog	2014-05-22 11:54:24 UTC (rev 169195)
+++ releases/WebKitGTK/webkit-2.4/Tools/ChangeLog	2014-05-22 11:59:42 UTC (rev 169196)
@@ -1,3 +1,20 @@
+2014-05-20  Carlos Garcia Campos  <[email protected]>
+
+        [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.
+
+        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):
+
 2014-05-22  Carlos Garcia Campos  <[email protected]>
 
         Unreviewed. Fix the build after r168707.

Modified: releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestResources.cpp (169195 => 169196)


--- releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestResources.cpp	2014-05-22 11:54:24 UTC (rev 169195)
+++ releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestResources.cpp	2014-05-22 11:59:42 UTC (rev 169196)
@@ -638,7 +638,7 @@
 
     // URI changed after a redirect.
     test->setExpectedNewResourceURI(kServer->getURIForPath("/redirected.js"));
-    test->setExpectedNewResourceURIAfterRedirection(kServer->getURIForPath("/_javascript_.js"));
+    test->setExpectedNewResourceURIAfterRedirection(kServer->getURIForPath("/_javascript_-after-redirection.js"));
     test->loadURI(kServer->getURIForPath("redirected-_javascript_.html").data());
     test->waitUntilResourceLoadFinished();
     g_assert(test->m_resource);
@@ -717,7 +717,7 @@
         soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, kStyleCSS, strlen(kStyleCSS));
         addCacheHTTPHeadersToResponse(message);
         soup_message_headers_append(message->response_headers, "Content-Type", "text/css");
-    } else if (g_str_equal(path, "/_javascript_.js")) {
+    } else if (g_str_equal(path, "/_javascript_.js") || g_str_equal(path, "/_javascript_-after-redirection.js")) {
         soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, kJavascript, strlen(kJavascript));
         soup_message_headers_append(message->response_headers, "Content-Type", "text/_javascript_");
         soup_message_headers_append(message->response_headers, "Content-Disposition", "filename=_javascript_.js");
@@ -754,7 +754,7 @@
         soup_message_headers_append(message->response_headers, "Location", "/simple-style.css");
     } else if (g_str_equal(path, "/redirected.js")) {
         soup_message_set_status(message, SOUP_STATUS_MOVED_PERMANENTLY);
-        soup_message_headers_append(message->response_headers, "Location", "/remove-this/_javascript_.js");
+        soup_message_headers_append(message->response_headers, "Location", "/remove-this/_javascript_-after-redirection.js");
     } else if (g_str_equal(path, "/redirected-to-cancel.js")) {
         soup_message_set_status(message, SOUP_STATUS_MOVED_PERMANENTLY);
         soup_message_headers_append(message->response_headers, "Location", "/cancel-this.js");

Modified: releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp (169195 => 169196)


--- releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp	2014-05-22 11:54:24 UTC (rev 169195)
+++ releases/WebKitGTK/webkit-2.4/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp	2014-05-22 11:59:42 UTC (rev 169196)
@@ -129,7 +129,7 @@
         delayedSignalsQueue.append(adoptPtr(new DelayedSignal(URIChangedSignal, webkit_web_page_get_uri(webPage))));
 }
 
-static gboolean sendRequestCallback(WebKitWebPage*, WebKitURIRequest* request, WebKitURIResponse*, gpointer)
+static gboolean sendRequestCallback(WebKitWebPage*, WebKitURIRequest* request, WebKitURIResponse* redirectResponse, gpointer)
 {
     const char* requestURI = webkit_uri_request_get_uri(request);
     g_assert(requestURI);
@@ -138,6 +138,17 @@
         GUniquePtr<char> prefix(g_strndup(requestURI, strlen(requestURI) - strlen(suffix)));
         GUniquePtr<char> newURI(g_strdup_printf("%s/_javascript_.js", prefix.get()));
         webkit_uri_request_set_uri(request, newURI.get());
+    } else if (const char* suffix = g_strrstr(requestURI, "/remove-this/_javascript_-after-redirection.js")) {
+        // Redirected from /redirected.js, redirectResponse should be nullptr.
+        g_assert(WEBKIT_IS_URI_RESPONSE(redirectResponse));
+        g_assert(g_str_has_suffix(webkit_uri_response_get_uri(redirectResponse), "/redirected.js"));
+
+        GUniquePtr<char> prefix(g_strndup(requestURI, strlen(requestURI) - strlen(suffix)));
+        GUniquePtr<char> newURI(g_strdup_printf("%s/_javascript_-after-redirection.js", prefix.get()));
+        webkit_uri_request_set_uri(request, newURI.get());
+    } else if (g_str_has_suffix(requestURI, "/redirected.js")) {
+        // Original request, redirectResponse should be nullptr.
+        g_assert(!redirectResponse);
     } else if (g_str_has_suffix(requestURI, "/add-do-not-track-header")) {
         SoupMessageHeaders* headers = webkit_uri_request_get_http_headers(request);
         g_assert(headers);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to