Diff
Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog (199471 => 199472)
--- 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)
@@ -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-03-31 Daniel Bates <[email protected]>
REGRESSION (r195605): ASSERTION FAILED: !NoEventDispatchAssertion::isEventDispatchForbidden()
Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/loader/DocumentLoader.cpp (199471 => 199472)
--- 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)
@@ -1502,6 +1502,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: releases/WebKitGTK/webkit-2.12/Source/WebCore/loader/FrameLoader.cpp (199471 => 199472)
--- 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)
@@ -2187,6 +2187,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: releases/WebKitGTK/webkit-2.12/Source/WebKit2/ChangeLog (199471 => 199472)
--- 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)
@@ -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-03-30 Brady Eidson <[email protected]>
Make BlobData use ThreadSafeSharedBuffer instead of RawData.
Modified: releases/WebKitGTK/webkit-2.12/Source/WebKit2/UIProcess/WebPageProxy.cpp (199471 => 199472)
--- 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)
@@ -1003,9 +1003,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();
@@ -3126,6 +3132,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: releases/WebKitGTK/webkit-2.12/Source/WebKit2/UIProcess/WebPageProxy.h (199471 => 199472)
--- 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)
@@ -1507,6 +1507,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: releases/WebKitGTK/webkit-2.12/Tools/ChangeLog (199471 => 199472)
--- 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)
@@ -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-03-29 Benjamin Poulain <[email protected]>
[WTF] Removing a smart pointer from HashTable issues two stores to the same location
Modified: releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LoadAlternateHTMLString.mm (199471 => 199472)
--- 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)
@@ -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: releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LoadInvalidURLRequest.mm (0 => 199472)
--- 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)
@@ -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: releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/mac/LoadInvalidURLRequest.html (0 => 199472)
--- 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)
@@ -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: releases/WebKitGTK/webkit-2.12/Tools/TestWebKitAPI/Tests/mac/LoadInvalidURLRequest.mm (0 => 199472)
--- 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)
@@ -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
+