<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[175618] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/175618">175618</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2014-11-05 02:54:05 -0800 (Wed, 05 Nov 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>[GTK] Add WebKitWebResource::failed-with-tls-errors signal
https://bugs.webkit.org/show_bug.cgi?id=137862
Reviewed by Gustavo Noronha Silva.
Source/WebKit2:
When a resource load fails due to TLS errors emit WebKitWebResource::failed-with-tls-errors
signal instead of WebKitWebResource::failed so that TLS errors information and certificate
are provided.
* UIProcess/API/gtk/WebKitInjectedBundleClient.cpp:
(didReceiveWebViewMessageFromInjectedBundle): Check if the error
is a TLS failure to emit failed-with-tls-errors instead of failed.
* UIProcess/API/gtk/WebKitWebResource.cpp:
(webkit_web_resource_class_init): Add WebKitWebResource::failed-with-tls-errors signal.
(webkitWebResourceFailedWithTLSErrors): Emit failed-with-tls-errors and finish signals.
* UIProcess/API/gtk/WebKitWebResourcePrivate.h:
Tools:
Add a test case to check that WebKitWebResource::failed-with-tls-errors
is emitted when a subresource load fails due to TLS errors.
* TestWebKitAPI/Tests/WebKit2Gtk/TestSSL.cpp:
(TLSSubresourceTest::resourceLoadStartedCallback):
(TLSSubresourceTest::TLSSubresourceTest):
(TLSSubresourceTest::subresourceFailedCallback):
(TLSSubresourceTest::subresourceFailedWithTLSErrorsCallback):
(TLSSubresourceTest::subresourceLoadStarted):
(TLSSubresourceTest::subresourceFailedWithTLSErrors):
(TLSSubresourceTest::waitUntilSubresourceLoadFail):
(testSubresourceLoadFailedWithTLSErrors):
(httpsServerCallback):
(httpServerCallback):
(beforeAll):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitInjectedBundleClientcpp">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitInjectedBundleClient.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebResourcecpp">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebResource.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebResourcePrivateh">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebResourcePrivate.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestSSLcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestSSL.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (175617 => 175618)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-11-05 10:12:42 UTC (rev 175617)
+++ trunk/Source/WebKit2/ChangeLog        2014-11-05 10:54:05 UTC (rev 175618)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2014-11-05 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ [GTK] Add WebKitWebResource::failed-with-tls-errors signal
+ https://bugs.webkit.org/show_bug.cgi?id=137862
+
+ Reviewed by Gustavo Noronha Silva.
+
+ When a resource load fails due to TLS errors emit WebKitWebResource::failed-with-tls-errors
+ signal instead of WebKitWebResource::failed so that TLS errors information and certificate
+ are provided.
+
+ * UIProcess/API/gtk/WebKitInjectedBundleClient.cpp:
+ (didReceiveWebViewMessageFromInjectedBundle): Check if the error
+ is a TLS failure to emit failed-with-tls-errors instead of failed.
+ * UIProcess/API/gtk/WebKitWebResource.cpp:
+ (webkit_web_resource_class_init): Add WebKitWebResource::failed-with-tls-errors signal.
+ (webkitWebResourceFailedWithTLSErrors): Emit failed-with-tls-errors and finish signals.
+ * UIProcess/API/gtk/WebKitWebResourcePrivate.h:
+
</ins><span class="cx"> 2014-11-05 Shivakumar JM <shiva.jm@samsung.com>
</span><span class="cx">
</span><span class="cx"> Fix build warning in WebKit2/WebProcess module.
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitInjectedBundleClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitInjectedBundleClient.cpp (175617 => 175618)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitInjectedBundleClient.cpp        2014-11-05 10:12:42 UTC (rev 175617)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitInjectedBundleClient.cpp        2014-11-05 10:54:05 UTC (rev 175618)
</span><span class="lines">@@ -89,8 +89,11 @@
</span><span class="cx"> const ResourceError& platformError = webError->platformError();
</span><span class="cx"> GUniquePtr<GError> resourceError(g_error_new_literal(g_quark_from_string(platformError.domain().utf8().data()),
</span><span class="cx"> toWebKitError(platformError.errorCode()), platformError.localizedDescription().utf8().data()));
</span><ins>+ if (platformError.tlsErrors())
+ webkitWebResourceFailedWithTLSErrors(resource.get(), static_cast<GTlsCertificateFlags>(platformError.tlsErrors()), platformError.certificate());
+ else
+ webkitWebResourceFailed(resource.get(), resourceError.get());
</ins><span class="cx">
</span><del>- webkitWebResourceFailed(resource.get(), resourceError.get());
</del><span class="cx"> webkitWebViewRemoveLoadingWebResource(webView, resourceIdentifier->value());
</span><span class="cx"> } else if (g_str_equal(messageName, "DidGetSnapshot")) {
</span><span class="cx"> API::UInt64* callbackID = static_cast<API::UInt64*>(message.get("CallbackID"));
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebResourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebResource.cpp (175617 => 175618)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebResource.cpp        2014-11-05 10:12:42 UTC (rev 175617)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebResource.cpp        2014-11-05 10:54:05 UTC (rev 175618)
</span><span class="lines">@@ -53,6 +53,7 @@
</span><span class="cx"> RECEIVED_DATA,
</span><span class="cx"> FINISHED,
</span><span class="cx"> FAILED,
</span><ins>+ FAILED_WITH_TLS_ERRORS,
</ins><span class="cx">
</span><span class="cx"> LAST_SIGNAL
</span><span class="cx"> };
</span><span class="lines">@@ -197,6 +198,26 @@
</span><span class="cx"> g_cclosure_marshal_VOID__POINTER,
</span><span class="cx"> G_TYPE_NONE, 1,
</span><span class="cx"> G_TYPE_POINTER);
</span><ins>+
+ /**
+ * WebKitWebResource::failed-with-tls-errors:
+ * @resource: the #WebKitWebResource
+ * @certificate: a #GTlsCertificate
+ * @errors: a #GTlsCertificateFlags with the verification status of @certificate
+ *
+ * This signal is emitted when a TLS error occurs during the resource load operation.
+ *
+ * Since: 2.8
+ */
+ signals[FAILED_WITH_TLS_ERRORS] =
+ g_signal_new("failed-with-tls-errors",
+ G_TYPE_FROM_CLASS(objectClass),
+ G_SIGNAL_RUN_LAST,
+ 0, nullptr, nullptr,
+ g_cclosure_marshal_generic,
+ G_TYPE_NONE, 2,
+ G_TYPE_TLS_CERTIFICATE,
+ G_TYPE_TLS_CERTIFICATE_FLAGS);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void webkitWebResourceUpdateURI(WebKitWebResource* resource, const CString& requestURI)
</span><span class="lines">@@ -246,6 +267,12 @@
</span><span class="cx"> g_signal_emit(resource, signals[FINISHED], 0, NULL);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void webkitWebResourceFailedWithTLSErrors(WebKitWebResource* resource, GTlsCertificateFlags tlsErrors, GTlsCertificate* certificate)
+{
+ g_signal_emit(resource, signals[FAILED_WITH_TLS_ERRORS], 0, certificate, tlsErrors);
+ g_signal_emit(resource, signals[FINISHED], 0, nullptr);
+}
+
</ins><span class="cx"> WebFrameProxy* webkitWebResourceGetFrame(WebKitWebResource* resource)
</span><span class="cx"> {
</span><span class="cx"> return resource->priv->frame.get();
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebResourcePrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebResourcePrivate.h (175617 => 175618)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebResourcePrivate.h        2014-11-05 10:12:42 UTC (rev 175617)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebResourcePrivate.h        2014-11-05 10:54:05 UTC (rev 175618)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> void webkitWebResourceNotifyProgress(WebKitWebResource*, guint64 bytesReceived);
</span><span class="cx"> void webkitWebResourceFinished(WebKitWebResource*);
</span><span class="cx"> void webkitWebResourceFailed(WebKitWebResource*, GError*);
</span><ins>+void webkitWebResourceFailedWithTLSErrors(WebKitWebResource*, GTlsCertificateFlags, GTlsCertificate*);
</ins><span class="cx"> WebKit::WebFrameProxy* webkitWebResourceGetFrame(WebKitWebResource*);
</span><span class="cx">
</span><span class="cx">
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (175617 => 175618)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2014-11-05 10:12:42 UTC (rev 175617)
+++ trunk/Tools/ChangeLog        2014-11-05 10:54:05 UTC (rev 175618)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2014-11-05 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ [GTK] Add WebKitWebResource::failed-with-tls-errors signal
+ https://bugs.webkit.org/show_bug.cgi?id=137862
+
+ Reviewed by Gustavo Noronha Silva.
+
+ Add a test case to check that WebKitWebResource::failed-with-tls-errors
+ is emitted when a subresource load fails due to TLS errors.
+
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestSSL.cpp:
+ (TLSSubresourceTest::resourceLoadStartedCallback):
+ (TLSSubresourceTest::TLSSubresourceTest):
+ (TLSSubresourceTest::subresourceFailedCallback):
+ (TLSSubresourceTest::subresourceFailedWithTLSErrorsCallback):
+ (TLSSubresourceTest::subresourceLoadStarted):
+ (TLSSubresourceTest::subresourceFailedWithTLSErrors):
+ (TLSSubresourceTest::waitUntilSubresourceLoadFail):
+ (testSubresourceLoadFailedWithTLSErrors):
+ (httpsServerCallback):
+ (httpServerCallback):
+ (beforeAll):
+
</ins><span class="cx"> 2014-11-05 Alexey Proskuryakov <ap@apple.com>
</span><span class="cx">
</span><span class="cx"> Build fix for some compiler versions.
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestSSLcpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestSSL.cpp (175617 => 175618)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestSSL.cpp        2014-11-05 10:12:42 UTC (rev 175617)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestSSL.cpp        2014-11-05 10:54:05 UTC (rev 175618)
</span><span class="lines">@@ -259,7 +259,71 @@
</span><span class="cx"> webkit_web_context_set_tls_errors_policy(context, originalPolicy);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+class TLSSubresourceTest : public WebViewTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(TLSSubresourceTest);
</ins><span class="cx">
</span><ins>+ static void resourceLoadStartedCallback(WebKitWebView* webView, WebKitWebResource* resource, WebKitURIRequest* request, TLSSubresourceTest* test)
+ {
+ if (webkit_web_view_get_main_resource(test->m_webView) == resource)
+ return;
+
+ // Ignore favicons.
+ if (g_str_has_suffix(webkit_uri_request_get_uri(request), "favicon.ico"))
+ return;
+
+ test->subresourceLoadStarted(resource);
+ }
+
+ TLSSubresourceTest()
+ : m_tlsErrors(static_cast<GTlsCertificateFlags>(0))
+ {
+ g_signal_connect(m_webView, "resource-load-started", G_CALLBACK(resourceLoadStartedCallback), this);
+ }
+
+ static void subresourceFailedCallback(WebKitWebResource*, GError*)
+ {
+ g_assert_not_reached();
+ }
+
+ static void subresourceFailedWithTLSErrorsCallback(WebKitWebResource* resource, GTlsCertificate* certificate, GTlsCertificateFlags tlsErrors, TLSSubresourceTest* test)
+ {
+ test->subresourceFailedWithTLSErrors(resource, certificate, tlsErrors);
+ }
+
+ void subresourceLoadStarted(WebKitWebResource* resource)
+ {
+ g_signal_connect(resource, "failed", G_CALLBACK(subresourceFailedCallback), nullptr);
+ g_signal_connect(resource, "failed-with-tls-errors", G_CALLBACK(subresourceFailedWithTLSErrorsCallback), this);
+ }
+
+ void subresourceFailedWithTLSErrors(WebKitWebResource* resource, GTlsCertificate* certificate, GTlsCertificateFlags tlsErrors)
+ {
+ m_certificate = certificate;
+ m_tlsErrors = tlsErrors;
+ g_main_loop_quit(m_mainLoop);
+ }
+
+ void waitUntilSubresourceLoadFail()
+ {
+ g_main_loop_run(m_mainLoop);
+ }
+
+ GRefPtr<GTlsCertificate> m_certificate;
+ GTlsCertificateFlags m_tlsErrors;
+};
+
+static void testSubresourceLoadFailedWithTLSErrors(TLSSubresourceTest* test, gconstpointer)
+{
+ WebKitWebContext* context = webkit_web_view_get_context(test->m_webView);
+ webkit_web_context_set_tls_errors_policy(context, WEBKIT_TLS_ERRORS_POLICY_FAIL);
+
+ test->loadURI(kHttpServer->getURIForPath("/").data());
+ test->waitUntilSubresourceLoadFail();
+ g_assert(G_IS_TLS_CERTIFICATE(test->m_certificate.get()));
+ g_assert_cmpuint(test->m_tlsErrors, ==, G_TLS_CERTIFICATE_UNKNOWN_CA);
+}
+
</ins><span class="cx"> static void httpsServerCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer)
</span><span class="cx"> {
</span><span class="cx"> if (message->method != SOUP_METHOD_GET) {
</span><span class="lines">@@ -286,6 +350,10 @@
</span><span class="cx"> } else if (g_str_equal(path, "/auth")) {
</span><span class="cx"> soup_message_set_status(message, SOUP_STATUS_UNAUTHORIZED);
</span><span class="cx"> soup_message_headers_append(message->response_headers, "WWW-Authenticate", "Basic realm=\"HTTPS auth\"");
</span><ins>+ } else if (g_str_equal(path, "/style.css")) {
+ soup_message_set_status(message, SOUP_STATUS_OK);
+ static const char* styleCSS = "body { color: black; }";
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, styleCSS, strlen(styleCSS));
</ins><span class="cx"> } else
</span><span class="cx"> soup_message_set_status(message, SOUP_STATUS_NOT_FOUND);
</span><span class="cx"> }
</span><span class="lines">@@ -315,6 +383,12 @@
</span><span class="cx"> soup_message_body_append(message->response_body, SOUP_MEMORY_TAKE, contents, length);
</span><span class="cx"> soup_message_set_status(message, SOUP_STATUS_OK);
</span><span class="cx"> soup_message_body_complete(message->response_body);
</span><ins>+ } else if (g_str_equal(path, "/")) {
+ soup_message_set_status(message, SOUP_STATUS_OK);
+ char* responseHTML = g_strdup_printf("<html><head><link rel='stylesheet' href='%s' type='text/css'></head><body>SSL subresource test</body></html>",
+ kHttpsServer->getURIForPath("/style.css").data());
+ soup_message_body_append(message->response_body, SOUP_MEMORY_TAKE, responseHTML, strlen(responseHTML));
+ soup_message_body_complete(message->response_body);
</ins><span class="cx"> } else
</span><span class="cx"> soup_message_set_status(message, SOUP_STATUS_NOT_FOUND);
</span><span class="cx"> }
</span><span class="lines">@@ -335,6 +409,7 @@
</span><span class="cx"> SSLTest::add("WebKitWebView", "tls-errors-policy", testTLSErrorsPolicy);
</span><span class="cx"> SSLTest::add("WebKitWebView", "tls-errors-redirect-to-http", testTLSErrorsRedirect);
</span><span class="cx"> SSLTest::add("WebKitWebView", "tls-http-auth", testTLSErrorsHTTPAuth);
</span><ins>+ TLSSubresourceTest::add("WebKitWebView", "tls-subresource", testSubresourceLoadFailedWithTLSErrors);
</ins><span class="cx"> TLSErrorsTest::add("WebKitWebView", "load-failed-with-tls-errors", testLoadFailedWithTLSErrors);
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>