<!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>[198956] 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/198956">198956</a></dd>
<dt>Author</dt> <dd>jiewen_tan@apple.com</dd>
<dt>Date</dt> <dd>2016-04-01 14:40:20 -0700 (Fri, 01 Apr 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>WebKit should dispatchDidFailProvisionalLoad while loading invalid URLs
https://bugs.webkit.org/show_bug.cgi?id=155995
<rdar://problem/14967004>
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="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreloaderDocumentLoadercpp">trunk/Source/WebCore/loader/DocumentLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderFrameLoadercpp">trunk/Source/WebCore/loader/FrameLoader.cpp</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2CocoaLoadAlternateHTMLStringmm">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LoadAlternateHTMLString.mm</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2CocoaLoadInvalidURLRequestmm">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LoadInvalidURLRequest.mm</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsmacLoadInvalidURLRequesthtml">trunk/Tools/TestWebKitAPI/Tests/mac/LoadInvalidURLRequest.html</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsmacLoadInvalidURLRequestmm">trunk/Tools/TestWebKitAPI/Tests/mac/LoadInvalidURLRequest.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (198955 => 198956)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-04-01 21:10:41 UTC (rev 198955)
+++ trunk/Source/WebCore/ChangeLog        2016-04-01 21:40:20 UTC (rev 198956)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2016-04-01 Jiewen Tan <jiewen_tan@apple.com>
+
+ WebKit should dispatchDidFailProvisionalLoad while loading invalid URLs
+ https://bugs.webkit.org/show_bug.cgi?id=155995
+ <rdar://problem/14967004>
+
+ 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-04-01 Frederic Wang <fwang@igalia.com>
</span><span class="cx">
</span><span class="cx"> Reset CSS spacing rules on the <math> element.
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderDocumentLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (198955 => 198956)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/DocumentLoader.cpp        2016-04-01 21:10:41 UTC (rev 198955)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp        2016-04-01 21:40:20 UTC (rev 198956)
</span><span class="lines">@@ -1511,6 +1511,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()->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="trunkSourceWebCoreloaderFrameLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (198955 => 198956)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/FrameLoader.cpp        2016-04-01 21:10:41 UTC (rev 198955)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp        2016-04-01 21:40:20 UTC (rev 198956)
</span><span class="lines">@@ -2206,6 +2206,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="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (198955 => 198956)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-04-01 21:10:41 UTC (rev 198955)
+++ trunk/Source/WebKit2/ChangeLog        2016-04-01 21:40:20 UTC (rev 198956)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2016-04-01 Jiewen Tan <jiewen_tan@apple.com>
+
+ WebKit should dispatchDidFailProvisionalLoad while loading invalid URLs
+ https://bugs.webkit.org/show_bug.cgi?id=155995
+ <rdar://problem/14967004>
+
+ 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-04-01 Brent Fulgham <bfulgham@apple.com>
</span><span class="cx">
</span><span class="cx"> Confirm <a download> satisfies specification criteria
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (198955 => 198956)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-04-01 21:10:41 UTC (rev 198955)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-04-01 21:40:20 UTC (rev 198956)
</span><span class="lines">@@ -1001,9 +1001,15 @@
</span><span class="cx">
</span><span class="cx"> void WebPageProxy::loadAlternateHTMLString(const String& htmlString, const String& baseURL, const String& 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">@@ -3143,6 +3149,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& error, const UserData& userData)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (198955 => 198956)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2016-04-01 21:10:41 UTC (rev 198955)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2016-04-01 21:40:20 UTC (rev 198956)
</span><span class="lines">@@ -1511,6 +1511,7 @@
</span><span class="cx">
</span><span class="cx"> std::unique_ptr<WebNavigationState> 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<DrawingAreaProxy> m_drawingArea;
</span><span class="cx"> #if ENABLE(ASYNC_SCROLLING)
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (198955 => 198956)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-04-01 21:10:41 UTC (rev 198955)
+++ trunk/Tools/ChangeLog        2016-04-01 21:40:20 UTC (rev 198956)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2016-04-01 Jiewen Tan <jiewen_tan@apple.com>
+
+ WebKit should dispatchDidFailProvisionalLoad while loading invalid URLs
+ https://bugs.webkit.org/show_bug.cgi?id=155995
+ <rdar://problem/14967004>
+
+ 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-04-01 Brent Fulgham <bfulgham@apple.com>
</span><span class="cx">
</span><span class="cx"> Confirm <a download> satisfies specification criteria
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (198955 => 198956)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-04-01 21:10:41 UTC (rev 198955)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-04-01 21:40:20 UTC (rev 198956)
</span><span class="lines">@@ -91,6 +91,9 @@
</span><span class="cx">                 5714ECB91CA8B5B000051AC8 /* DownloadRequestOriginalURL.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5714ECB81CA8B58800051AC8 /* DownloadRequestOriginalURL.html */; };
</span><span class="cx">                 5714ECBB1CA8BFE400051AC8 /* DownloadRequestOriginalURLFrame.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5714ECBA1CA8BFD100051AC8 /* DownloadRequestOriginalURLFrame.html */; };
</span><span class="cx">                 5714ECBD1CA8C22A00051AC8 /* DownloadRequestOriginalURL2.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5714ECBC1CA8C21800051AC8 /* DownloadRequestOriginalURL2.html */; };
</span><ins>+                57901FAD1CAF12C200ED64F9 /* LoadInvalidURLRequest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 57901FAC1CAF12C200ED64F9 /* LoadInvalidURLRequest.mm */; };
+                57901FAF1CAF137100ED64F9 /* LoadInvalidURLRequest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 57901FAE1CAF137100ED64F9 /* LoadInvalidURLRequest.mm */; };
+                57901FB11CAF142D00ED64F9 /* LoadInvalidURLRequest.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 57901FB01CAF141C00ED64F9 /* LoadInvalidURLRequest.html */; };
</ins><span class="cx">                 57F10D931C7E7B3800ECDF30 /* IsNavigationActionTrusted.mm in Sources */ = {isa = PBXBuildFile; fileRef = 57F10D921C7E7B3800ECDF30 /* IsNavigationActionTrusted.mm */; };
</span><span class="cx">                 57F56A5C1C7F8CC100F31D7E /* IsNavigationActionTrusted.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 57F56A5B1C7F8A4000F31D7E /* IsNavigationActionTrusted.html */; };
</span><span class="cx">                 764322D71B61CCC30024F801 /* WordBoundaryTypingAttributes.mm in Sources */ = {isa = PBXBuildFile; fileRef = 764322D51B61CCA40024F801 /* WordBoundaryTypingAttributes.mm */; };
</span><span class="lines">@@ -411,6 +414,7 @@
</span><span class="cx">                         dstPath = TestWebKitAPI.resources;
</span><span class="cx">                         dstSubfolderSpec = 7;
</span><span class="cx">                         files = (
</span><ins>+                                57901FB11CAF142D00ED64F9 /* LoadInvalidURLRequest.html in Copy Resources */,
</ins><span class="cx">                                 5714ECBD1CA8C22A00051AC8 /* DownloadRequestOriginalURL2.html in Copy Resources */,
</span><span class="cx">                                 5714ECBB1CA8BFE400051AC8 /* DownloadRequestOriginalURLFrame.html in Copy Resources */,
</span><span class="cx">                                 5714ECB91CA8B5B000051AC8 /* DownloadRequestOriginalURL.html in Copy Resources */,
</span><span class="lines">@@ -656,6 +660,9 @@
</span><span class="cx">                 5714ECB81CA8B58800051AC8 /* DownloadRequestOriginalURL.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DownloadRequestOriginalURL.html; sourceTree = "<group>"; };
</span><span class="cx">                 5714ECBA1CA8BFD100051AC8 /* DownloadRequestOriginalURLFrame.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DownloadRequestOriginalURLFrame.html; sourceTree = "<group>"; };
</span><span class="cx">                 5714ECBC1CA8C21800051AC8 /* DownloadRequestOriginalURL2.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DownloadRequestOriginalURL2.html; sourceTree = "<group>"; };
</span><ins>+                57901FAC1CAF12C200ED64F9 /* LoadInvalidURLRequest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LoadInvalidURLRequest.mm; sourceTree = "<group>"; };
+                57901FAE1CAF137100ED64F9 /* LoadInvalidURLRequest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LoadInvalidURLRequest.mm; sourceTree = "<group>"; };
+                57901FB01CAF141C00ED64F9 /* LoadInvalidURLRequest.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = LoadInvalidURLRequest.html; sourceTree = "<group>"; };
</ins><span class="cx">                 57F10D921C7E7B3800ECDF30 /* IsNavigationActionTrusted.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IsNavigationActionTrusted.mm; sourceTree = "<group>"; };
</span><span class="cx">                 57F56A5B1C7F8A4000F31D7E /* IsNavigationActionTrusted.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = IsNavigationActionTrusted.html; sourceTree = "<group>"; };
</span><span class="cx">                 7560917719259C59009EF06E /* MemoryCacheAddImageToCacheIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryCacheAddImageToCacheIOS.mm; sourceTree = "<group>"; };
</span><span class="lines">@@ -1024,6 +1031,7 @@
</span><span class="cx">                                 51BCEE491C84F4AF0042C82E /* IndexedDBMultiProcess.mm */,
</span><span class="cx">                                 51B1EE8D1C80F5880064FB98 /* IndexedDBPersistence.mm */,
</span><span class="cx">                                 37D36ED61AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm */,
</span><ins>+                                57901FAC1CAF12C200ED64F9 /* LoadInvalidURLRequest.mm */,
</ins><span class="cx">                                 51CD1C6A1B38CE3600142CA5 /* ModalAlerts.mm */,
</span><span class="cx">                                 1ABC3DED1899BE6D004F0626 /* Navigation.mm */,
</span><span class="cx">                                 A1DF74301C41B65800A2F4D0 /* AlwaysRevalidatedURLSchemes.mm */,
</span><span class="lines">@@ -1464,6 +1472,7 @@
</span><span class="cx">                                 C507E8A614C6545B005D6B3B /* InspectorBar.mm */,
</span><span class="cx">                                 57F10D921C7E7B3800ECDF30 /* IsNavigationActionTrusted.mm */,
</span><span class="cx">                                 4BB4160116815B2600824238 /* JSWrapperForNodeInWebFrame.mm */,
</span><ins>+                                57901FAE1CAF137100ED64F9 /* LoadInvalidURLRequest.mm */,
</ins><span class="cx">                                 E1220D9F155B25480013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.mm */,
</span><span class="cx">                                 517E7DFB15110EA600D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.mm */,
</span><span class="cx">                                 7A99D9931AD4A29D00373141 /* MenuTypesForMouseEvents.mm */,
</span><span class="lines">@@ -1513,6 +1522,7 @@
</span><span class="cx">                                 57F56A5B1C7F8A4000F31D7E /* IsNavigationActionTrusted.html */,
</span><span class="cx">                                 C2CF975816CEC69E0054E99D /* JSContextBackForwardCache1.html */,
</span><span class="cx">                                 C2CF975916CEC69E0054E99D /* JSContextBackForwardCache2.html */,
</span><ins>+                                57901FB01CAF141C00ED64F9 /* LoadInvalidURLRequest.html */,
</ins><span class="cx">                                 E1220DC9155B287D0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html */,
</span><span class="cx">                                 517E7E031511187500D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.html */,
</span><span class="cx">                                 290A9BB81735F42300D71BBC /* OpenNewWindow.html */,
</span><span class="lines">@@ -1945,6 +1955,7 @@
</span><span class="cx">                         files = (
</span><span class="cx">                                 2D9A53AF1B31FA8D0074D5AA /* ShrinkToFit.mm in Sources */,
</span><span class="cx">                                 51B454EC1B4E236B0085EAA6 /* WebViewCloseInsideDidFinishLoadForFrame.mm in Sources */,
</span><ins>+                                57901FAD1CAF12C200ED64F9 /* LoadInvalidURLRequest.mm in Sources */,
</ins><span class="cx">                                 7AA021BB1AB09EA70052953F /* DateMath.cpp in Sources */,
</span><span class="cx">                                 CE50D8CA1C8665CE0072EA5A /* OptionSet.cpp in Sources */,
</span><span class="cx">                                 2D1FE0B01AD465C1006CD9E6 /* FixedLayoutSize.mm in Sources */,
</span><span class="lines">@@ -1953,6 +1964,7 @@
</span><span class="cx">                                 2D8104CC1BEC13E70020DA46 /* FindInPage.mm in Sources */,
</span><span class="cx">                                 CD225C081C45A69200140761 /* ParsedContentRange.cpp in Sources */,
</span><span class="cx">                                 41973B5D1AF22875006C7B36 /* SharedBuffer.cpp in Sources */,
</span><ins>+                                57901FAF1CAF137100ED64F9 /* LoadInvalidURLRequest.mm in Sources */,
</ins><span class="cx">                                 51BCEE4A1C84F4AF0042C82E /* IndexedDBMultiProcess.mm in Sources */,
</span><span class="cx">                                 57F10D931C7E7B3800ECDF30 /* IsNavigationActionTrusted.mm in Sources */,
</span><span class="cx">                                 2DD355361BD08378005DF4A7 /* AutoLayoutIntegration.mm in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2CocoaLoadAlternateHTMLStringmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LoadAlternateHTMLString.mm (198955 => 198956)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LoadAlternateHTMLString.mm        2016-04-01 21:10:41 UTC (rev 198955)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LoadAlternateHTMLString.mm        2016-04-01 21:40:20 UTC (rev 198956)
</span><span class="lines">@@ -30,10 +30,12 @@
</span><span class="cx">
</span><span class="cx"> #import "PlatformUtilities.h"
</span><span class="cx"> #import "Test.h"
</span><ins>+#import <WebCore/WebCoreNSURLExtras.h>
</ins><span class="cx"> #import <WebKit/WKWebViewPrivate.h>
</span><span class="cx"> #import <wtf/RetainPtr.h>
</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 <WKNavigationDelegate>
</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:@"error page" baseURL:nil forUnreachableURL:[NSURL URLWithString:@"data:"]];
</del><ins>+ if (error.code != NSURLErrorCancelled)
+ [webView _loadAlternateHTMLString:@"error page" baseURL:nil forUnreachableURL:error.userInfo[@"NSErrorFailingURLKey"]];
</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 = @"data:";
</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<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+ RetainPtr<LoadAlternateHTMLStringFromProvisionalLoadErrorController> delegate = adoptNS([[LoadAlternateHTMLStringFromProvisionalLoadErrorController alloc] init]);
+ [webView setNavigationDelegate:delegate.get()];
+
+ char literal[] = "https://www.example.com<>/";
+ 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(&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="trunkToolsTestWebKitAPITestsWebKit2CocoaLoadInvalidURLRequestmm"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LoadInvalidURLRequest.mm (0 => 198956)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LoadInvalidURLRequest.mm         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LoadInvalidURLRequest.mm        2016-04-01 21:40:20 UTC (rev 198956)
</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 "config.h"
+
+#if WK_API_ENABLED
+
+#import "PlatformUtilities.h"
+#import <WebCore/WebCoreNSURLExtras.h>
+#import <WebKit/WKNavigationPrivate.h>
+#import <WebKit/WKWebView.h>
+#import <wtf/RetainPtr.h>
+
+static bool didFinishTest;
+static bool didFailProvisionalLoad;
+static const char literal[] = "https://www.example.com<>/";
+
+static NSURL *literalURL(const char* literal)
+{
+ return WebCore::URLWithData([NSData dataWithBytes:literal length:strlen(literal)], nil);
+}
+
+@interface LoadInvalidURLNavigationActionDelegate : NSObject <WKNavigationDelegate>
+@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:@"WebKitErrorDomain"]
+ && error.code == WebKitErrorCannotShowURL
+ && [error.userInfo[@"NSErrorFailingURLKey"] isEqual:literalURL(literal)])
+ didFailProvisionalLoad = true;
+ didFinishTest = true;
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+TEST(WebKit2, LoadInvalidURLRequest)
+{
+ @autoreleasepool {
+ RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+ RetainPtr<LoadInvalidURLNavigationActionDelegate> delegate = adoptNS([[LoadInvalidURLNavigationActionDelegate alloc] init]);
+ [webView setNavigationDelegate:delegate.get()];
+ [webView loadRequest:[NSURLRequest requestWithURL:literalURL(literal)]];
+
+ didFinishTest = false;
+ didFailProvisionalLoad = false;
+ Util::run(&didFinishTest);
+
+ EXPECT_TRUE(didFailProvisionalLoad);
+ }
+}
+
+} // namespace TestWebKitAPI
+
+#endif
+
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsmacLoadInvalidURLRequesthtml"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/mac/LoadInvalidURLRequest.html (0 => 198956)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/mac/LoadInvalidURLRequest.html         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/LoadInvalidURLRequest.html        2016-04-01 21:40:20 UTC (rev 198956)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+ <a id="href" href="https://www.example.com<>/">https://www.example.com&lt;&gt;/</a>
+ <script>
+ var element = document.getElementById("href");
+ element.click();
+ </script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsmacLoadInvalidURLRequestmm"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/mac/LoadInvalidURLRequest.mm (0 => 198956)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/mac/LoadInvalidURLRequest.mm         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/LoadInvalidURLRequest.mm        2016-04-01 21:40:20 UTC (rev 198956)
</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 "config.h"
+
+#import "PlatformUtilities.h"
+#import <WebCore/WebCoreNSURLExtras.h>
+#import <WebKit/WKNavigationPrivate.h>
+#import <WebKit/WKWebView.h>
+#import <wtf/RetainPtr.h>
+
+static bool didFinishTest;
+static bool didFailProvisionalLoad;
+
+@interface LoadInvalidURLWebFrameLoadDelegate : NSObject <WebFrameLoadDelegate> {
+}
+@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[] = "https://www.example.com<>/";
+ NSURL *failedURL = WebCore::URLWithData([NSData dataWithBytes:literal length:strlen(literal)], nil);
+ if ([error.domain isEqual:@"WebKitErrorDomain"]
+ && error.code == WebKitErrorCannotShowURL
+ && [error.userInfo[@"NSErrorFailingURLKey"] isEqual:failedURL])
+ didFailProvisionalLoad = true;
+ didFinishTest = true;
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+TEST(WebKit1, LoadInvalidURLRequest)
+{
+ @autoreleasepool {
+ RetainPtr<WebView> webView = adoptNS([[WebView alloc] init]);
+
+ RetainPtr<LoadInvalidURLWebFrameLoadDelegate> delegate = adoptNS([[LoadInvalidURLWebFrameLoadDelegate alloc] init]);
+ [webView setFrameLoadDelegate:delegate.get()];
+
+ NSURL *contentURL = [[NSBundle mainBundle] URLForResource:@"LoadInvalidURLRequest" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
+ [[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:contentURL]];
+
+ didFinishTest = false;
+ didFailProvisionalLoad = false;
+ Util::run(&didFinishTest);
+
+ EXPECT_TRUE(didFailProvisionalLoad);
+ }
+}
+
+} // namespace TestWebKitAPI
+
</ins></span></pre>
</div>
</div>
</body>
</html>