<!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>[199472] releases/WebKitGTK/webkit-2.12</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/199472">199472</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2016-04-13 06:24:37 -0700 (Wed, 13 Apr 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/198956">r198956</a> - WebKit should dispatchDidFailProvisionalLoad while loading invalid URLs
https://bugs.webkit.org/show_bug.cgi?id=155995
&lt;rdar://problem/14967004&gt;

Reviewed by Andy Estes.

Source/WebCore:

Added API Tests.

If a loading request contains an invalid URL, DocumentLoader will now dispatch
cannotShowURLError to the clients.

* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::startLoadingMainResource):

Source/WebKit2:

Ensure that alternative HTML string will not be loaded back to back for
failing provisional loads.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::loadAlternateHTMLString):
(WebKit::WebPageProxy::didFinishLoadForFrame):
* UIProcess/WebPageProxy.h:

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/LoadAlternateHTMLString.mm:
(-[LoadAlternateHTMLStringFromProvisionalLoadErrorController webView:didFailProvisionalNavigation:withError:]):
(-[LoadAlternateHTMLStringFromProvisionalLoadErrorController webView:didStartProvisionalNavigation:]):
(TEST):
* TestWebKitAPI/Tests/WebKit2Cocoa/LoadInvalidURLRequest.mm: Added.
(literalURL):
(-[LoadInvalidURLNavigationActionDelegate webView:didCommitNavigation:]):
(-[LoadInvalidURLNavigationActionDelegate webView:didFailProvisionalNavigation:withError:]):
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/mac/LoadInvalidURLRequest.html: Added.
* TestWebKitAPI/Tests/mac/LoadInvalidURLRequest.mm: Added.
(-[LoadInvalidURLWebFrameLoadDelegate webView:didCommitLoadForFrame:]):
(-[LoadInvalidURLWebFrameLoadDelegate webView:didFailProvisionalLoadWithError:forFrame:]):
(TestWebKitAPI::TEST):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit212SourceWebCoreChangeLog">releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourceWebCoreloaderDocumentLoadercpp">releases/WebKitGTK/webkit-2.12/Source/WebCore/loader/DocumentLoader.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourceWebCoreloaderFrameLoadercpp">releases/WebKitGTK/webkit-2.12/Source/WebCore/loader/FrameLoader.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourceWebKit2ChangeLog">releases/WebKitGTK/webkit-2.12/Source/WebKit2/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourceWebKit2UIProcessWebPageProxycpp">releases/WebKitGTK/webkit-2.12/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourceWebKit2UIProcessWebPageProxyh">releases/WebKitGTK/webkit-2.12/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#releasesWebKitGTKwebkit212ToolsChangeLog">releases/WebKitGTK/webkit-2.12/Tools/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit212ToolsTestWebKitAPITestsWebKit2CocoaLoadAlternateHTMLStringmm">releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LoadAlternateHTMLString.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit212ToolsTestWebKitAPITestsWebKit2CocoaLoadInvalidURLRequestmm">releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LoadInvalidURLRequest.mm</a></li>
<li><a href="#releasesWebKitGTKwebkit212ToolsTestWebKitAPITestsmacLoadInvalidURLRequesthtml">releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/mac/LoadInvalidURLRequest.html</a></li>
<li><a href="#releasesWebKitGTKwebkit212ToolsTestWebKitAPITestsmacLoadInvalidURLRequestmm">releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/mac/LoadInvalidURLRequest.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit212SourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog (199471 => 199472)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog        2016-04-13 13:14:40 UTC (rev 199471)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog        2016-04-13 13:24:37 UTC (rev 199472)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2016-04-01  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        WebKit should dispatchDidFailProvisionalLoad while loading invalid URLs
+        https://bugs.webkit.org/show_bug.cgi?id=155995
+        &lt;rdar://problem/14967004&gt;
+
+        Reviewed by Andy Estes.
+
+        Added API Tests.
+
+        If a loading request contains an invalid URL, DocumentLoader will now dispatch
+        cannotShowURLError to the clients.
+
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::startLoadingMainResource):
+
</ins><span class="cx"> 2016-03-31  Daniel Bates  &lt;dabates@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (r195605): ASSERTION FAILED: !NoEventDispatchAssertion::isEventDispatchForbidden()
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourceWebCoreloaderDocumentLoadercpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/loader/DocumentLoader.cpp (199471 => 199472)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/WebCore/loader/DocumentLoader.cpp        2016-04-13 13:14:40 UTC (rev 199471)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/loader/DocumentLoader.cpp        2016-04-13 13:24:37 UTC (rev 199472)
</span><span class="lines">@@ -1502,6 +1502,11 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     if (!m_mainResource) {
</span><ins>+        if (!m_request.url().isValid()) {
+            cancelMainResourceLoad(frameLoader()-&gt;client().cannotShowURLError(m_request));
+            return;
+        }
+
</ins><span class="cx">         setRequest(ResourceRequest());
</span><span class="cx">         // If the load was aborted by clearing m_request, it's possible the ApplicationCacheHost
</span><span class="cx">         // is now in a state where starting an empty load will be inconsistent. Replace it with
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourceWebCoreloaderFrameLoadercpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/loader/FrameLoader.cpp (199471 => 199472)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/WebCore/loader/FrameLoader.cpp        2016-04-13 13:14:40 UTC (rev 199471)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/loader/FrameLoader.cpp        2016-04-13 13:24:37 UTC (rev 199472)
</span><span class="lines">@@ -2187,6 +2187,10 @@
</span><span class="cx"> 
</span><span class="cx">     switch (m_state) {
</span><span class="cx">         case FrameStateProvisional: {
</span><ins>+            // FIXME: Prohibiting any provisional load failures from being sent to clients
+            // while handling provisional load failures is too heavy. For example, the current
+            // load will fail to cancel another ongoing load. That might prevent clients' page
+            // load state being handled properly.
</ins><span class="cx">             if (!m_provisionalLoadErrorBeingHandledURL.isEmpty())
</span><span class="cx">                 return;
</span><span class="cx"> 
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/WebKit2/ChangeLog (199471 => 199472)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/WebKit2/ChangeLog        2016-04-13 13:14:40 UTC (rev 199471)
+++ releases/WebKitGTK/webkit-2.12/Source/WebKit2/ChangeLog        2016-04-13 13:24:37 UTC (rev 199472)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2016-04-01  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        WebKit should dispatchDidFailProvisionalLoad while loading invalid URLs
+        https://bugs.webkit.org/show_bug.cgi?id=155995
+        &lt;rdar://problem/14967004&gt;
+
+        Reviewed by Andy Estes.
+
+        Ensure that alternative HTML string will not be loaded back to back for
+        failing provisional loads.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::loadAlternateHTMLString):
+        (WebKit::WebPageProxy::didFinishLoadForFrame):
+        * UIProcess/WebPageProxy.h:
+
</ins><span class="cx"> 2016-03-30  Brady Eidson  &lt;beidson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Make BlobData use ThreadSafeSharedBuffer instead of RawData.
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/WebKit2/UIProcess/WebPageProxy.cpp (199471 => 199472)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-04-13 13:14:40 UTC (rev 199471)
+++ releases/WebKitGTK/webkit-2.12/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-04-13 13:24:37 UTC (rev 199472)
</span><span class="lines">@@ -1003,9 +1003,15 @@
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::loadAlternateHTMLString(const String&amp; htmlString, const String&amp; baseURL, const String&amp; unreachableURL, API::Object* userData)
</span><span class="cx"> {
</span><del>-    if (m_isClosed)
</del><ins>+    // When the UIProcess is in the process of handling a failing provisional load, do not attempt to
+    // start a second alternative HTML load as this will prevent the page load state from being
+    // handled properly.
+    if (m_isClosed || m_isLoadingAlternateHTMLStringForFailingProvisionalLoad)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    if (!m_failingProvisionalLoadURL.isEmpty())
+        m_isLoadingAlternateHTMLStringForFailingProvisionalLoad = true;
+
</ins><span class="cx">     if (!isValid())
</span><span class="cx">         reattachToWebProcess();
</span><span class="cx"> 
</span><span class="lines">@@ -3126,6 +3132,8 @@
</span><span class="cx"> 
</span><span class="cx">     if (isMainFrame)
</span><span class="cx">         m_pageClient.didFinishLoadForMainFrame();
</span><ins>+
+    m_isLoadingAlternateHTMLStringForFailingProvisionalLoad = false;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::didFailLoadForFrame(uint64_t frameID, uint64_t navigationID, const ResourceError&amp; error, const UserData&amp; userData)
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/WebKit2/UIProcess/WebPageProxy.h (199471 => 199472)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/WebKit2/UIProcess/WebPageProxy.h        2016-04-13 13:14:40 UTC (rev 199471)
+++ releases/WebKitGTK/webkit-2.12/Source/WebKit2/UIProcess/WebPageProxy.h        2016-04-13 13:24:37 UTC (rev 199472)
</span><span class="lines">@@ -1507,6 +1507,7 @@
</span><span class="cx"> 
</span><span class="cx">     std::unique_ptr&lt;WebNavigationState&gt; m_navigationState;
</span><span class="cx">     String m_failingProvisionalLoadURL;
</span><ins>+    bool m_isLoadingAlternateHTMLStringForFailingProvisionalLoad { false };
</ins><span class="cx"> 
</span><span class="cx">     std::unique_ptr&lt;DrawingAreaProxy&gt; m_drawingArea;
</span><span class="cx"> #if ENABLE(ASYNC_SCROLLING)
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212ToolsChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Tools/ChangeLog (199471 => 199472)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Tools/ChangeLog        2016-04-13 13:14:40 UTC (rev 199471)
+++ releases/WebKitGTK/webkit-2.12/Tools/ChangeLog        2016-04-13 13:24:37 UTC (rev 199472)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2016-04-01  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        WebKit should dispatchDidFailProvisionalLoad while loading invalid URLs
+        https://bugs.webkit.org/show_bug.cgi?id=155995
+        &lt;rdar://problem/14967004&gt;
+
+        Reviewed by Andy Estes.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/LoadAlternateHTMLString.mm:
+        (-[LoadAlternateHTMLStringFromProvisionalLoadErrorController webView:didFailProvisionalNavigation:withError:]):
+        (-[LoadAlternateHTMLStringFromProvisionalLoadErrorController webView:didStartProvisionalNavigation:]):
+        (TEST):
+        * TestWebKitAPI/Tests/WebKit2Cocoa/LoadInvalidURLRequest.mm: Added.
+        (literalURL):
+        (-[LoadInvalidURLNavigationActionDelegate webView:didCommitNavigation:]):
+        (-[LoadInvalidURLNavigationActionDelegate webView:didFailProvisionalNavigation:withError:]):
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/mac/LoadInvalidURLRequest.html: Added.
+        * TestWebKitAPI/Tests/mac/LoadInvalidURLRequest.mm: Added.
+        (-[LoadInvalidURLWebFrameLoadDelegate webView:didCommitLoadForFrame:]):
+        (-[LoadInvalidURLWebFrameLoadDelegate webView:didFailProvisionalLoadWithError:forFrame:]):
+        (TestWebKitAPI::TEST):
+
</ins><span class="cx"> 2016-03-29  Benjamin Poulain  &lt;bpoulain@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [WTF] Removing a smart pointer from HashTable issues two stores to the same location
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212ToolsTestWebKitAPITestsWebKit2CocoaLoadAlternateHTMLStringmm"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LoadAlternateHTMLString.mm (199471 => 199472)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LoadAlternateHTMLString.mm        2016-04-13 13:14:40 UTC (rev 199471)
+++ releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LoadAlternateHTMLString.mm        2016-04-13 13:24:37 UTC (rev 199472)
</span><span class="lines">@@ -30,10 +30,12 @@
</span><span class="cx"> 
</span><span class="cx"> #import &quot;PlatformUtilities.h&quot;
</span><span class="cx"> #import &quot;Test.h&quot;
</span><ins>+#import &lt;WebCore/WebCoreNSURLExtras.h&gt;
</ins><span class="cx"> #import &lt;WebKit/WKWebViewPrivate.h&gt;
</span><span class="cx"> #import &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> 
</span><span class="cx"> static bool isDone;
</span><ins>+static int provisionalLoadCount;
</ins><span class="cx"> 
</span><span class="cx"> @interface LoadAlternateHTMLStringFromProvisionalLoadErrorController : NSObject &lt;WKNavigationDelegate&gt;
</span><span class="cx"> @end
</span><span class="lines">@@ -42,7 +44,8 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error
</span><span class="cx"> {
</span><del>-    [webView _loadAlternateHTMLString:@&quot;error page&quot; baseURL:nil forUnreachableURL:[NSURL URLWithString:@&quot;data:&quot;]];
</del><ins>+    if (error.code != NSURLErrorCancelled)
+        [webView _loadAlternateHTMLString:@&quot;error page&quot; baseURL:nil forUnreachableURL:error.userInfo[@&quot;NSErrorFailingURLKey&quot;]];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
</span><span class="lines">@@ -50,6 +53,11 @@
</span><span class="cx">     isDone = true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(null_unspecified WKNavigation *)navigation
+{
+    provisionalLoadCount++;
+}
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> static NSString *unloadableURL = @&quot;data:&quot;;
</span><span class="lines">@@ -93,4 +101,24 @@
</span><span class="cx">     EXPECT_STREQ([[list.currentItem URL] absoluteString].UTF8String, loadableURL.UTF8String);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+TEST(WKWebView, LoadAlternateHTMLStringFromProvisionalLoadErrorBackToBack)
+{
+    @autoreleasepool {
+        RetainPtr&lt;WKWebView&gt; webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+        RetainPtr&lt;LoadAlternateHTMLStringFromProvisionalLoadErrorController&gt; delegate = adoptNS([[LoadAlternateHTMLStringFromProvisionalLoadErrorController alloc] init]);
+        [webView setNavigationDelegate:delegate.get()];
+
+        char literal[] = &quot;https://www.example.com&lt;&gt;/&quot;;
+        NSURL* targetURL = WebCore::URLWithData([NSData dataWithBytes:literal length:strlen(literal)], nil);
+        [webView loadRequest:[NSURLRequest requestWithURL:targetURL]];
+        [webView loadRequest:[NSURLRequest requestWithURL:targetURL]];
+
+        isDone = false;
+        TestWebKitAPI::Util::run(&amp;isDone);
+        // In success, we should only start 3 provisional loads: 2 for the loadRequest, and *only 1* for the _loadAlternateHTMLString.
+        EXPECT_EQ(3, provisionalLoadCount);
+    }
+}
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212ToolsTestWebKitAPITestsWebKit2CocoaLoadInvalidURLRequestmm"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LoadInvalidURLRequest.mm (0 => 199472)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LoadInvalidURLRequest.mm                                (rev 0)
+++ releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LoadInvalidURLRequest.mm        2016-04-13 13:24:37 UTC (rev 199472)
</span><span class="lines">@@ -0,0 +1,88 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+
+#if WK_API_ENABLED
+
+#import &quot;PlatformUtilities.h&quot;
+#import &lt;WebCore/WebCoreNSURLExtras.h&gt;
+#import &lt;WebKit/WKNavigationPrivate.h&gt;
+#import &lt;WebKit/WKWebView.h&gt;
+#import &lt;wtf/RetainPtr.h&gt;
+
+static bool didFinishTest;
+static bool didFailProvisionalLoad;
+static const char literal[] = &quot;https://www.example.com&lt;&gt;/&quot;;
+
+static NSURL *literalURL(const char* literal)
+{
+    return WebCore::URLWithData([NSData dataWithBytes:literal length:strlen(literal)], nil);
+}
+
+@interface LoadInvalidURLNavigationActionDelegate : NSObject &lt;WKNavigationDelegate&gt;
+@end
+
+@implementation LoadInvalidURLNavigationActionDelegate
+
+- (void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation
+{
+    didFinishTest = true;
+}
+
+- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error
+{
+    if ([error.domain isEqual:@&quot;WebKitErrorDomain&quot;]
+        &amp;&amp; error.code == WebKitErrorCannotShowURL
+        &amp;&amp; [error.userInfo[@&quot;NSErrorFailingURLKey&quot;] isEqual:literalURL(literal)])
+        didFailProvisionalLoad = true;
+    didFinishTest = true;
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+TEST(WebKit2, LoadInvalidURLRequest)
+{
+    @autoreleasepool {
+        RetainPtr&lt;WKWebView&gt; webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+        RetainPtr&lt;LoadInvalidURLNavigationActionDelegate&gt; delegate = adoptNS([[LoadInvalidURLNavigationActionDelegate alloc] init]);
+        [webView setNavigationDelegate:delegate.get()];
+        [webView loadRequest:[NSURLRequest requestWithURL:literalURL(literal)]];
+
+        didFinishTest = false;
+        didFailProvisionalLoad = false;
+        Util::run(&amp;didFinishTest);
+
+        EXPECT_TRUE(didFailProvisionalLoad);
+    }
+}
+
+} // namespace TestWebKitAPI
+
+#endif
+
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit212ToolsTestWebKitAPITestsmacLoadInvalidURLRequesthtml"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/mac/LoadInvalidURLRequest.html (0 => 199472)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/mac/LoadInvalidURLRequest.html                                (rev 0)
+++ releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/mac/LoadInvalidURLRequest.html        2016-04-13 13:24:37 UTC (rev 199472)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;a id=&quot;href&quot; href=&quot;https://www.example.com&lt;&gt;/&quot;&gt;https://www.example.com&amp;lt;&amp;gt;/&lt;/a&gt;
+    &lt;script&gt;
+        var element = document.getElementById(&quot;href&quot;);
+        element.click();
+    &lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit212ToolsTestWebKitAPITestsmacLoadInvalidURLRequestmm"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/mac/LoadInvalidURLRequest.mm (0 => 199472)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/mac/LoadInvalidURLRequest.mm                                (rev 0)
+++ releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/mac/LoadInvalidURLRequest.mm        2016-04-13 13:24:37 UTC (rev 199472)
</span><span class="lines">@@ -0,0 +1,83 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+
+#import &quot;PlatformUtilities.h&quot;
+#import &lt;WebCore/WebCoreNSURLExtras.h&gt;
+#import &lt;WebKit/WKNavigationPrivate.h&gt;
+#import &lt;WebKit/WKWebView.h&gt;
+#import &lt;wtf/RetainPtr.h&gt;
+
+static bool didFinishTest;
+static bool didFailProvisionalLoad;
+
+@interface LoadInvalidURLWebFrameLoadDelegate : NSObject &lt;WebFrameLoadDelegate&gt; {
+}
+@end
+
+@implementation LoadInvalidURLWebFrameLoadDelegate
+
+- (void)webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame
+{
+    didFinishTest = true;
+}
+
+- (void)webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame
+{
+    static char literal[] = &quot;https://www.example.com&lt;&gt;/&quot;;
+    NSURL *failedURL = WebCore::URLWithData([NSData dataWithBytes:literal length:strlen(literal)], nil);
+    if ([error.domain isEqual:@&quot;WebKitErrorDomain&quot;]
+        &amp;&amp; error.code == WebKitErrorCannotShowURL
+        &amp;&amp; [error.userInfo[@&quot;NSErrorFailingURLKey&quot;] isEqual:failedURL])
+        didFailProvisionalLoad = true;
+    didFinishTest = true;
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+TEST(WebKit1, LoadInvalidURLRequest)
+{
+    @autoreleasepool {
+        RetainPtr&lt;WebView&gt; webView = adoptNS([[WebView alloc] init]);
+
+        RetainPtr&lt;LoadInvalidURLWebFrameLoadDelegate&gt; delegate = adoptNS([[LoadInvalidURLWebFrameLoadDelegate alloc] init]);
+        [webView setFrameLoadDelegate:delegate.get()];
+
+        NSURL *contentURL = [[NSBundle mainBundle] URLForResource:@&quot;LoadInvalidURLRequest&quot; withExtension:@&quot;html&quot; subdirectory:@&quot;TestWebKitAPI.resources&quot;];
+        [[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:contentURL]];
+
+        didFinishTest = false;
+        didFailProvisionalLoad = false;
+        Util::run(&amp;didFinishTest);
+
+        EXPECT_TRUE(didFailProvisionalLoad);
+    }
+}
+
+} // namespace TestWebKitAPI
+
</ins></span></pre>
</div>
</div>

</body>
</html>