[GTK] Notify WebProcess in WebKitURISchemeRequest when we fail to read the user Input...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 May 2013 13:32:07 +0000 (13:32 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 May 2013 13:32:07 +0000 (13:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=114347

Patch by Manuel Rego Casasnovas <rego@igalia.com> on 2013-05-27
Reviewed by Carlos Garcia Campos.

While processing a WebKitURISchemeRequest if there is any error reading
the InputStream provided by the user (for example the stream is already
closed) we have to notify the WebProcess that the request has failed.

* UIProcess/API/gtk/WebKitURISchemeRequest.cpp:
(webkitURISchemeRequestReadCallback): Get the error from
g_input_stream_read_finish() and use it to call
webkit_uri_scheme_request_finish_error() in order to finish the failing
WebKitURISchemeRequest properly.
* UIProcess/API/gtk/tests/TestWebKitWebContext.cpp:
(testWebContextURIScheme): Modify test to check the new situation using
an already closed InputStream.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@150753 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/gtk/WebKitURISchemeRequest.cpp
Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp

index c6d8650..ea5d66d 100644 (file)
@@ -1,3 +1,23 @@
+2013-05-27  Manuel Rego Casasnovas  <rego@igalia.com>
+
+        [GTK] Notify WebProcess in WebKitURISchemeRequest when we fail to read the user InputStream
+        https://bugs.webkit.org/show_bug.cgi?id=114347
+
+        Reviewed by Carlos Garcia Campos.
+
+        While processing a WebKitURISchemeRequest if there is any error reading
+        the InputStream provided by the user (for example the stream is already
+        closed) we have to notify the WebProcess that the request has failed.
+
+        * UIProcess/API/gtk/WebKitURISchemeRequest.cpp:
+        (webkitURISchemeRequestReadCallback): Get the error from
+        g_input_stream_read_finish() and use it to call
+        webkit_uri_scheme_request_finish_error() in order to finish the failing
+        WebKitURISchemeRequest properly.
+        * UIProcess/API/gtk/tests/TestWebKitWebContext.cpp:
+        (testWebContextURIScheme): Modify test to check the new situation using
+        an already closed InputStream.
+
 2013-05-27  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Unreviewed. Fix make distcheck.
index f4e5b80..0e52181 100644 (file)
@@ -163,10 +163,10 @@ WebKitWebView* webkit_uri_scheme_request_get_web_view(WebKitURISchemeRequest* re
 static void webkitURISchemeRequestReadCallback(GInputStream* inputStream, GAsyncResult* result, WebKitURISchemeRequest* schemeRequest)
 {
     GRefPtr<WebKitURISchemeRequest> request = adoptGRef(schemeRequest);
-    gssize bytesRead = g_input_stream_read_finish(inputStream, result, 0);
-    // FIXME: notify the WebProcess that we failed to read from the user stream.
+    GOwnPtr<GError> error;
+    gssize bytesRead = g_input_stream_read_finish(inputStream, result, &error.outPtr());
     if (bytesRead == -1) {
-        webkitWebContextDidFinishURIRequest(request->priv->webContext, request->priv->requestID);
+        webkit_uri_scheme_request_finish_error(request.get(), error.get());
         return;
     }
 
index 78a7e6e..54e44d6 100644 (file)
@@ -166,7 +166,9 @@ public:
         if (!g_strcmp0(scheme, "echo")) {
             char* replyHTML = g_strdup_printf(handler.reply.data(), webkit_uri_scheme_request_get_path(request));
             g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(inputStream.get()), replyHTML, strlen(replyHTML), g_free);
-        } else if (!handler.reply.isNull())
+        } else if (!g_strcmp0(scheme, "closed"))
+            g_input_stream_close(inputStream.get(), 0, 0);
+        else if (!handler.reply.isNull())
             g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(inputStream.get()), handler.reply.data(), handler.reply.length(), 0);
 
         webkit_uri_scheme_request_finish(request, inputStream.get(), handler.replyLength, handler.mimeType.data());
@@ -222,6 +224,14 @@ static void testWebContextURIScheme(URISchemeTest* test, gconstpointer)
     g_assert(test->m_loadFailed);
     g_assert_error(test->m_error.get(), g_quark_from_string(errorDomain), errorCode);
     g_assert_cmpstr(test->m_error->message, ==, errorMessage);
+
+    test->registerURISchemeHandler("closed", 0, 0, 0);
+    test->m_loadEvents.clear();
+    test->loadURI("closed:input-stream");
+    test->waitUntilLoadFinished();
+    g_assert(test->m_loadEvents.contains(LoadTrackingTest::ProvisionalLoadFailed));
+    g_assert(test->m_loadFailed);
+    g_assert_error(test->m_error.get(), G_IO_ERROR, G_IO_ERROR_CLOSED);
 }
 
 static void testWebContextSpellChecker(Test* test, gconstpointer)