Diff
Modified: trunk/Source/WebCore/ChangeLog (198955 => 198956)
--- 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)
@@ -1,3 +1,19 @@
+2016-04-01 Jiewen Tan <[email protected]>
+
+ 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):
+
2016-04-01 Frederic Wang <[email protected]>
Reset CSS spacing rules on the <math> element.
Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (198955 => 198956)
--- 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)
@@ -1511,6 +1511,11 @@
#endif
if (!m_mainResource) {
+ if (!m_request.url().isValid()) {
+ cancelMainResourceLoad(frameLoader()->client().cannotShowURLError(m_request));
+ return;
+ }
+
setRequest(ResourceRequest());
// If the load was aborted by clearing m_request, it's possible the ApplicationCacheHost
// is now in a state where starting an empty load will be inconsistent. Replace it with
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (198955 => 198956)
--- 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)
@@ -2206,6 +2206,10 @@
switch (m_state) {
case FrameStateProvisional: {
+ // 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.
if (!m_provisionalLoadErrorBeingHandledURL.isEmpty())
return;
Modified: trunk/Source/WebKit2/ChangeLog (198955 => 198956)
--- 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)
@@ -1,3 +1,19 @@
+2016-04-01 Jiewen Tan <[email protected]>
+
+ 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:
+
2016-04-01 Brent Fulgham <[email protected]>
Confirm <a download> satisfies specification criteria
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (198955 => 198956)
--- 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)
@@ -1001,9 +1001,15 @@
void WebPageProxy::loadAlternateHTMLString(const String& htmlString, const String& baseURL, const String& unreachableURL, API::Object* userData)
{
- if (m_isClosed)
+ // 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)
return;
+ if (!m_failingProvisionalLoadURL.isEmpty())
+ m_isLoadingAlternateHTMLStringForFailingProvisionalLoad = true;
+
if (!isValid())
reattachToWebProcess();
@@ -3143,6 +3149,8 @@
if (isMainFrame)
m_pageClient.didFinishLoadForMainFrame();
+
+ m_isLoadingAlternateHTMLStringForFailingProvisionalLoad = false;
}
void WebPageProxy::didFailLoadForFrame(uint64_t frameID, uint64_t navigationID, const ResourceError& error, const UserData& userData)
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (198955 => 198956)
--- 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)
@@ -1511,6 +1511,7 @@
std::unique_ptr<WebNavigationState> m_navigationState;
String m_failingProvisionalLoadURL;
+ bool m_isLoadingAlternateHTMLStringForFailingProvisionalLoad { false };
std::unique_ptr<DrawingAreaProxy> m_drawingArea;
#if ENABLE(ASYNC_SCROLLING)
Modified: trunk/Tools/ChangeLog (198955 => 198956)
--- trunk/Tools/ChangeLog 2016-04-01 21:10:41 UTC (rev 198955)
+++ trunk/Tools/ChangeLog 2016-04-01 21:40:20 UTC (rev 198956)
@@ -1,3 +1,27 @@
+2016-04-01 Jiewen Tan <[email protected]>
+
+ 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):
+
2016-04-01 Brent Fulgham <[email protected]>
Confirm <a download> satisfies specification criteria
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (198955 => 198956)
--- 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)
@@ -91,6 +91,9 @@
5714ECB91CA8B5B000051AC8 /* DownloadRequestOriginalURL.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5714ECB81CA8B58800051AC8 /* DownloadRequestOriginalURL.html */; };
5714ECBB1CA8BFE400051AC8 /* DownloadRequestOriginalURLFrame.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5714ECBA1CA8BFD100051AC8 /* DownloadRequestOriginalURLFrame.html */; };
5714ECBD1CA8C22A00051AC8 /* DownloadRequestOriginalURL2.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5714ECBC1CA8C21800051AC8 /* DownloadRequestOriginalURL2.html */; };
+ 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 */; };
57F10D931C7E7B3800ECDF30 /* IsNavigationActionTrusted.mm in Sources */ = {isa = PBXBuildFile; fileRef = 57F10D921C7E7B3800ECDF30 /* IsNavigationActionTrusted.mm */; };
57F56A5C1C7F8CC100F31D7E /* IsNavigationActionTrusted.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 57F56A5B1C7F8A4000F31D7E /* IsNavigationActionTrusted.html */; };
764322D71B61CCC30024F801 /* WordBoundaryTypingAttributes.mm in Sources */ = {isa = PBXBuildFile; fileRef = 764322D51B61CCA40024F801 /* WordBoundaryTypingAttributes.mm */; };
@@ -411,6 +414,7 @@
dstPath = TestWebKitAPI.resources;
dstSubfolderSpec = 7;
files = (
+ 57901FB11CAF142D00ED64F9 /* LoadInvalidURLRequest.html in Copy Resources */,
5714ECBD1CA8C22A00051AC8 /* DownloadRequestOriginalURL2.html in Copy Resources */,
5714ECBB1CA8BFE400051AC8 /* DownloadRequestOriginalURLFrame.html in Copy Resources */,
5714ECB91CA8B5B000051AC8 /* DownloadRequestOriginalURL.html in Copy Resources */,
@@ -656,6 +660,9 @@
5714ECB81CA8B58800051AC8 /* DownloadRequestOriginalURL.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DownloadRequestOriginalURL.html; sourceTree = "<group>"; };
5714ECBA1CA8BFD100051AC8 /* DownloadRequestOriginalURLFrame.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DownloadRequestOriginalURLFrame.html; sourceTree = "<group>"; };
5714ECBC1CA8C21800051AC8 /* DownloadRequestOriginalURL2.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DownloadRequestOriginalURL2.html; sourceTree = "<group>"; };
+ 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>"; };
57F10D921C7E7B3800ECDF30 /* IsNavigationActionTrusted.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IsNavigationActionTrusted.mm; sourceTree = "<group>"; };
57F56A5B1C7F8A4000F31D7E /* IsNavigationActionTrusted.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = IsNavigationActionTrusted.html; sourceTree = "<group>"; };
7560917719259C59009EF06E /* MemoryCacheAddImageToCacheIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryCacheAddImageToCacheIOS.mm; sourceTree = "<group>"; };
@@ -1024,6 +1031,7 @@
51BCEE491C84F4AF0042C82E /* IndexedDBMultiProcess.mm */,
51B1EE8D1C80F5880064FB98 /* IndexedDBPersistence.mm */,
37D36ED61AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm */,
+ 57901FAC1CAF12C200ED64F9 /* LoadInvalidURLRequest.mm */,
51CD1C6A1B38CE3600142CA5 /* ModalAlerts.mm */,
1ABC3DED1899BE6D004F0626 /* Navigation.mm */,
A1DF74301C41B65800A2F4D0 /* AlwaysRevalidatedURLSchemes.mm */,
@@ -1464,6 +1472,7 @@
C507E8A614C6545B005D6B3B /* InspectorBar.mm */,
57F10D921C7E7B3800ECDF30 /* IsNavigationActionTrusted.mm */,
4BB4160116815B2600824238 /* JSWrapperForNodeInWebFrame.mm */,
+ 57901FAE1CAF137100ED64F9 /* LoadInvalidURLRequest.mm */,
E1220D9F155B25480013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.mm */,
517E7DFB15110EA600D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.mm */,
7A99D9931AD4A29D00373141 /* MenuTypesForMouseEvents.mm */,
@@ -1513,6 +1522,7 @@
57F56A5B1C7F8A4000F31D7E /* IsNavigationActionTrusted.html */,
C2CF975816CEC69E0054E99D /* JSContextBackForwardCache1.html */,
C2CF975916CEC69E0054E99D /* JSContextBackForwardCache2.html */,
+ 57901FB01CAF141C00ED64F9 /* LoadInvalidURLRequest.html */,
E1220DC9155B287D0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html */,
517E7E031511187500D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.html */,
290A9BB81735F42300D71BBC /* OpenNewWindow.html */,
@@ -1945,6 +1955,7 @@
files = (
2D9A53AF1B31FA8D0074D5AA /* ShrinkToFit.mm in Sources */,
51B454EC1B4E236B0085EAA6 /* WebViewCloseInsideDidFinishLoadForFrame.mm in Sources */,
+ 57901FAD1CAF12C200ED64F9 /* LoadInvalidURLRequest.mm in Sources */,
7AA021BB1AB09EA70052953F /* DateMath.cpp in Sources */,
CE50D8CA1C8665CE0072EA5A /* OptionSet.cpp in Sources */,
2D1FE0B01AD465C1006CD9E6 /* FixedLayoutSize.mm in Sources */,
@@ -1953,6 +1964,7 @@
2D8104CC1BEC13E70020DA46 /* FindInPage.mm in Sources */,
CD225C081C45A69200140761 /* ParsedContentRange.cpp in Sources */,
41973B5D1AF22875006C7B36 /* SharedBuffer.cpp in Sources */,
+ 57901FAF1CAF137100ED64F9 /* LoadInvalidURLRequest.mm in Sources */,
51BCEE4A1C84F4AF0042C82E /* IndexedDBMultiProcess.mm in Sources */,
57F10D931C7E7B3800ECDF30 /* IsNavigationActionTrusted.mm in Sources */,
2DD355361BD08378005DF4A7 /* AutoLayoutIntegration.mm in Sources */,
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LoadAlternateHTMLString.mm (198955 => 198956)
--- 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)
@@ -30,10 +30,12 @@
#import "PlatformUtilities.h"
#import "Test.h"
+#import <WebCore/WebCoreNSURLExtras.h>
#import <WebKit/WKWebViewPrivate.h>
#import <wtf/RetainPtr.h>
static bool isDone;
+static int provisionalLoadCount;
@interface LoadAlternateHTMLStringFromProvisionalLoadErrorController : NSObject <WKNavigationDelegate>
@end
@@ -42,7 +44,8 @@
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error
{
- [webView _loadAlternateHTMLString:@"error page" baseURL:nil forUnreachableURL:[NSURL URLWithString:@"data:"]];
+ if (error.code != NSURLErrorCancelled)
+ [webView _loadAlternateHTMLString:@"error page" baseURL:nil forUnreachableURL:error.userInfo[@"NSErrorFailingURLKey"]];
}
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
@@ -50,6 +53,11 @@
isDone = true;
}
+- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(null_unspecified WKNavigation *)navigation
+{
+ provisionalLoadCount++;
+}
+
@end
static NSString *unloadableURL = @"data:";
@@ -93,4 +101,24 @@
EXPECT_STREQ([[list.currentItem URL] absoluteString].UTF8String, loadableURL.UTF8String);
}
+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);
+ }
+}
+
#endif
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LoadInvalidURLRequest.mm (0 => 198956)
--- 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)
@@ -0,0 +1,88 @@
+/*
+ * 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
+
Added: trunk/Tools/TestWebKitAPI/Tests/mac/LoadInvalidURLRequest.html (0 => 198956)
--- 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)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+ <a id="href" href=""
+ <script>
+ var element = document.getElementById("href");
+ element.click();
+ </script>
+</body>
+</html>
Added: trunk/Tools/TestWebKitAPI/Tests/mac/LoadInvalidURLRequest.mm (0 => 198956)
--- 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)
@@ -0,0 +1,83 @@
+/*
+ * 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
+