Diff
Modified: trunk/Source/WebCore/ChangeLog (183697 => 183698)
--- trunk/Source/WebCore/ChangeLog 2015-05-01 23:38:18 UTC (rev 183697)
+++ trunk/Source/WebCore/ChangeLog 2015-05-01 23:47:03 UTC (rev 183698)
@@ -1,3 +1,36 @@
+2015-05-01 Dan Bernstein <m...@apple.com>
+
+ WebCore part of <rdar://problem/8636045> Back/forward navigation to an error page in Safari breaks the back-forward list
+ https://bugs.webkit.org/show_bug.cgi?id=144501
+
+ Reviewed by Darin Adler.
+
+ Test: TestWebKitAPI/Tests/WebKit2Cocoa/LoadAlternateHTMLString.mm
+
+ Normally, loading substitute data (such as an error page) creates a new back-forward list
+ item. FrameLoader has a mechanism that detects when a substitute data load occurs during
+ handling of a provisional load error and prevents the creation of a new back-forwards list
+ item in that case if the unreachable URL is the same as the failing provisional URL. This
+ mechanism was broken in WebKit2, where handling the provisional load error is asynchronous.
+
+ The fix is to capture some state (namely, the failing provisional URL) when dispatching the
+ load error and allow it to be restored when loading the substitute data.
+
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::FrameLoader): Removed initialization of
+ m_delegateIsHandlingProvisionalLoadError.
+ (WebCore::FrameLoader::shouldReloadToHandleUnreachableURL): Instead of checking
+ m_delegateIsHandlingProvisionalLoadError and if true using the provisional document loader’s
+ URL, check m_provisionalLoadErrorBeingHandledURL.
+ (WebCore::FrameLoader::checkLoadCompleteForThisFrame): Instead of checking and setting
+ m_delegateIsHandlingProvisionalLoadError, use m_provisionalLoadErrorBeingHandledURL.
+ * loader/FrameLoader.h:
+ (WebCore::FrameLoader::provisionalLoadErrorBeingHandledURL): Added this getter. The client
+ can call this from its override of dispatchDidFailProvisionalLoad and store the result.
+ (WebCore::FrameLoader::setProvisionalLoadErrorBeingHandledURL): Added this setter. The
+ client can call this prior to loading substitute data if it’s done as part of handling a
+ previously-dispatched didFailProvisionalLoad.
+
2015-05-01 Martin Robinson <mrobin...@igalia.com>
USE(...) macro should expect unprefixed variables
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (183697 => 183698)
--- trunk/Source/WebCore/loader/FrameLoader.cpp 2015-05-01 23:38:18 UTC (rev 183697)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2015-05-01 23:47:03 UTC (rev 183698)
@@ -220,7 +220,6 @@
, m_mixedContentChecker(frame)
, m_state(FrameStateProvisional)
, m_loadType(FrameLoadType::Standard)
- , m_delegateIsHandlingProvisionalLoadError(false)
, m_quickRedirectComing(false)
, m_sentRedirectNotification(false)
, m_inStopAllLoaders(false)
@@ -1510,13 +1509,10 @@
// case handles well-formed URLs that can't be loaded, and the latter
// case handles malformed URLs and unknown schemes. Loading alternate content
// at other times behaves like a standard load.
- DocumentLoader* compareDocumentLoader = 0;
if (policyChecker().delegateIsDecidingNavigationPolicy() || policyChecker().delegateIsHandlingUnimplementablePolicy())
- compareDocumentLoader = m_policyDocumentLoader.get();
- else if (m_delegateIsHandlingProvisionalLoadError)
- compareDocumentLoader = m_provisionalDocumentLoader.get();
+ return m_policyDocumentLoader && unreachableURL == m_policyDocumentLoader->request().url();
- return compareDocumentLoader && unreachableURL == compareDocumentLoader->request().url();
+ return unreachableURL == m_provisionalLoadErrorBeingHandledURL;
}
void FrameLoader::reloadWithOverrideEncoding(const String& encoding)
@@ -2170,7 +2166,7 @@
switch (m_state) {
case FrameStateProvisional: {
- if (m_delegateIsHandlingProvisionalLoadError)
+ if (!m_provisionalLoadErrorBeingHandledURL.isEmpty())
return;
RefPtr<DocumentLoader> pdl = m_provisionalDocumentLoader;
@@ -2192,9 +2188,9 @@
// Only reset if we aren't already going to a new provisional item.
bool shouldReset = !history().provisionalItem();
if (!pdl->isLoadingInAPISense() || pdl->isStopping()) {
- m_delegateIsHandlingProvisionalLoadError = true;
+ m_provisionalLoadErrorBeingHandledURL = m_provisionalDocumentLoader->url();
m_client.dispatchDidFailProvisionalLoad(error);
- m_delegateIsHandlingProvisionalLoadError = false;
+ m_provisionalLoadErrorBeingHandledURL = { };
ASSERT(!pdl->isLoading());
Modified: trunk/Source/WebCore/loader/FrameLoader.h (183697 => 183698)
--- trunk/Source/WebCore/loader/FrameLoader.h 2015-05-01 23:38:18 UTC (rev 183697)
+++ trunk/Source/WebCore/loader/FrameLoader.h 2015-05-01 23:47:03 UTC (rev 183698)
@@ -291,6 +291,9 @@
void setOverrideResourceLoadPriorityForTesting(ResourceLoadPriority priority) { m_overrideResourceLoadPriorityForTesting = priority; }
WEBCORE_EXPORT void clearTestingOverrides();
+ const URL& provisionalLoadErrorBeingHandledURL() const { return m_provisionalLoadErrorBeingHandledURL; }
+ void setProvisionalLoadErrorBeingHandledURL(const URL& url) { m_provisionalLoadErrorBeingHandledURL = url; }
+
private:
enum FormSubmissionCacheLoadPolicy {
MayAttemptCacheOnlyLoadForFormSubmissionItem,
@@ -402,7 +405,7 @@
RefPtr<DocumentLoader> m_provisionalDocumentLoader;
RefPtr<DocumentLoader> m_policyDocumentLoader;
- bool m_delegateIsHandlingProvisionalLoadError;
+ URL m_provisionalLoadErrorBeingHandledURL;
bool m_quickRedirectComing;
bool m_sentRedirectNotification;
Modified: trunk/Source/WebKit2/ChangeLog (183697 => 183698)
--- trunk/Source/WebKit2/ChangeLog 2015-05-01 23:38:18 UTC (rev 183697)
+++ trunk/Source/WebKit2/ChangeLog 2015-05-01 23:47:03 UTC (rev 183698)
@@ -1,3 +1,34 @@
+2015-05-01 Dan Bernstein <m...@apple.com>
+
+ WebKit2 part of <rdar://problem/8636045> Back/forward navigation to an error page in Safari breaks the back-forward list
+ https://bugs.webkit.org/show_bug.cgi?id=144501
+
+ Reviewed by Darin Adler.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::loadAlternateHTMLString): If this is called during
+ didFailProvisionalLoadForFrame, send back the provisional URL captured at the time of
+ failure.
+ (WebKit::WebPageProxy::didFailProvisionalLoadForFrame): Get the provisioinal URL and keep
+ it in new member variable m_failingProvisionalLoadURL for the duration of the client’s
+ handling of this message.
+ * UIProcess/WebPageProxy.h:
+
+ * UIProcess/WebPageProxy.messages.in: Added provisionalURL parameter to
+ DidFailProvisionalLoadForFrame.
+
+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+ (WebKit::WebFrameLoaderClient::dispatchDidFailProvisionalLoad): Send the URL for this error
+ to the UI process.
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::loadAlternateHTMLString): Temporarily restore the loader’s state to
+ reflect the provisional load error being handled.
+
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in: Added provisionalLoadErrorURL parameter to
+ LoadAlternateHTMLString.
+
2015-05-01 Martin Robinson <mrobin...@igalia.com>
USE(...) macro should expect unprefixed variables
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (183697 => 183698)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2015-05-01 23:38:18 UTC (rev 183697)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2015-05-01 23:47:03 UTC (rev 183698)
@@ -958,7 +958,7 @@
m_process->assumeReadAccessToBaseURL(baseURL);
m_process->assumeReadAccessToBaseURL(unreachableURL);
- m_process->send(Messages::WebPage::LoadAlternateHTMLString(htmlString, baseURL, unreachableURL, UserData(process().transformObjectsToHandles(userData).get())), m_pageID);
+ m_process->send(Messages::WebPage::LoadAlternateHTMLString(htmlString, baseURL, unreachableURL, m_failingProvisionalLoadURL, UserData(process().transformObjectsToHandles(userData).get())), m_pageID);
m_process->responsivenessTimer()->start();
}
@@ -2821,7 +2821,7 @@
m_loaderClient->didReceiveServerRedirectForProvisionalLoadForFrame(*this, *frame, navigation.get(), m_process->transformHandlesToObjects(userData.object()).get());
}
-void WebPageProxy::didFailProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, const ResourceError& error, const UserData& userData)
+void WebPageProxy::didFailProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, const String& provisionalURL, const ResourceError& error, const UserData& userData)
{
WebFrameProxy* frame = m_process->webFrame(frameID);
MESSAGE_CHECK(frame);
@@ -2839,6 +2839,10 @@
frame->didFailProvisionalLoad();
m_pageLoadState.commitChanges();
+
+ ASSERT(!m_failingProvisionalLoadURL);
+ m_failingProvisionalLoadURL = provisionalURL;
+
if (m_navigationClient) {
if (frame->isMainFrame())
m_navigationClient->didFailProvisionalNavigationWithError(*this, *frame, navigation.get(), error, m_process->transformHandlesToObjects(userData.object()).get());
@@ -2848,6 +2852,8 @@
}
} else
m_loaderClient->didFailProvisionalLoadWithErrorForFrame(*this, *frame, navigation.get(), error, m_process->transformHandlesToObjects(userData.object()).get());
+
+ m_failingProvisionalLoadURL = { };
}
void WebPageProxy::clearLoadDependentCallbacks()
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (183697 => 183698)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2015-05-01 23:38:18 UTC (rev 183697)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2015-05-01 23:47:03 UTC (rev 183698)
@@ -1078,7 +1078,7 @@
void didStartProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, const String& url, const String& unreachableURL, const UserData&);
void didReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, const String&, const UserData&);
- void didFailProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, const WebCore::ResourceError&, const UserData&);
+ void didFailProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, const String& provisionalURL, const WebCore::ResourceError&, const UserData&);
void didCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, const String& mimeType, bool frameHasCustomContentProvider, uint32_t frameLoadType, const WebCore::CertificateInfo&, const UserData&);
void didFinishDocumentLoadForFrame(uint64_t frameID, uint64_t navigationID, const UserData&);
void didFinishLoadForFrame(uint64_t frameID, uint64_t navigationID, const UserData&);
@@ -1450,6 +1450,7 @@
std::unique_ptr<WebPageInjectedBundleClient> m_injectedBundleClient;
std::unique_ptr<WebNavigationState> m_navigationState;
+ String m_failingProvisionalLoadURL;
std::unique_ptr<DrawingAreaProxy> m_drawingArea;
#if ENABLE(ASYNC_SCROLLING)
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (183697 => 183698)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in 2015-05-01 23:38:18 UTC (rev 183697)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in 2015-05-01 23:47:03 UTC (rev 183698)
@@ -129,7 +129,7 @@
# Frame load messages
DidStartProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, String url, String unreachableURL, WebKit::UserData userData)
DidReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, String url, WebKit::UserData userData)
- DidFailProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, WebCore::ResourceError error, WebKit::UserData userData)
+ DidFailProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, String provisionalURL, WebCore::ResourceError error, WebKit::UserData userData)
DidCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, String mimeType, bool hasCustomContentProvider, uint32_t loadType, WebCore::CertificateInfo certificateInfo, WebKit::UserData userData)
DidFailLoadForFrame(uint64_t frameID, uint64_t navigationID, WebCore::ResourceError error, WebKit::UserData userData)
DidFinishDocumentLoadForFrame(uint64_t frameID, uint64_t navigationID, WebKit::UserData userData)
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (183697 => 183698)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp 2015-05-01 23:38:18 UTC (rev 183697)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp 2015-05-01 23:47:03 UTC (rev 183698)
@@ -483,7 +483,7 @@
navigationID = static_cast<WebDocumentLoader*>(documentLoader)->navigationID();
// Notify the UIProcess.
- webPage->send(Messages::WebPageProxy::DidFailProvisionalLoadForFrame(m_frame->frameID(), navigationID, error, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
+ webPage->send(Messages::WebPageProxy::DidFailProvisionalLoadForFrame(m_frame->frameID(), navigationID, m_frame->coreFrame()->loader().provisionalLoadErrorBeingHandledURL(), error, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
// If we have a load listener, notify it.
if (WebFrame::LoadListener* loadListener = m_frame->loadListener())
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (183697 => 183698)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2015-05-01 23:38:18 UTC (rev 183697)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2015-05-01 23:47:03 UTC (rev 183698)
@@ -1068,11 +1068,14 @@
loadString(navigationID, htmlString, ASCIILiteral("text/html"), baseURL, URL(), userData);
}
-void WebPage::loadAlternateHTMLString(const String& htmlString, const String& baseURLString, const String& unreachableURLString, const UserData& userData)
+void WebPage::loadAlternateHTMLString(const String& htmlString, const String& baseURLString, const String& unreachableURLString, const String& provisionalLoadErrorURLString, const UserData& userData)
{
URL baseURL = baseURLString.isEmpty() ? blankURL() : URL(URL(), baseURLString);
URL unreachableURL = unreachableURLString.isEmpty() ? URL() : URL(URL(), unreachableURLString);
+ URL provisionalLoadErrorURL = provisionalLoadErrorURLString.isEmpty() ? URL() : URL(URL(), provisionalLoadErrorURLString);
+ m_mainFrame->coreFrame()->loader().setProvisionalLoadErrorBeingHandledURL(provisionalLoadErrorURL);
loadString(0, htmlString, ASCIILiteral("text/html"), baseURL, unreachableURL, userData);
+ m_mainFrame->coreFrame()->loader().setProvisionalLoadErrorBeingHandledURL({ });
}
void WebPage::loadPlainTextString(const String& string, const UserData& userData)
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (183697 => 183698)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2015-05-01 23:38:18 UTC (rev 183697)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2015-05-01 23:47:03 UTC (rev 183698)
@@ -932,7 +932,7 @@
void loadRequest(uint64_t navigationID, const WebCore::ResourceRequest&, const SandboxExtension::Handle&, const UserData&);
void loadData(const IPC::DataReference&, const String& MIMEType, const String& encodingName, const String& baseURL, const UserData&);
void loadHTMLString(uint64_t navigationID, const String& htmlString, const String& baseURL, const UserData&);
- void loadAlternateHTMLString(const String& htmlString, const String& baseURL, const String& unreachableURL, const UserData&);
+ void loadAlternateHTMLString(const String& htmlString, const String& baseURL, const String& unreachableURL, const String& provisionalLoadErrorURL, const UserData&);
void loadPlainTextString(const String&, const UserData&);
void loadWebArchiveData(const IPC::DataReference&, const UserData&);
void navigateToURLWithSimulatedClick(const String& url, WebCore::IntPoint documentPoint, WebCore::IntPoint screenPoint);
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (183697 => 183698)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in 2015-05-01 23:38:18 UTC (rev 183697)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in 2015-05-01 23:47:03 UTC (rev 183698)
@@ -128,7 +128,7 @@
LoadRequest(uint64_t navigationID, WebCore::ResourceRequest request, WebKit::SandboxExtension::Handle sandboxExtensionHandle, WebKit::UserData userData)
LoadData(IPC::DataReference data, String MIMEType, String encoding, String baseURL, WebKit::UserData userData)
LoadHTMLString(uint64_t navigationID, String htmlString, String baseURL, WebKit::UserData userData)
- LoadAlternateHTMLString(String htmlString, String baseURL, String unreachableURL, WebKit::UserData userData)
+ LoadAlternateHTMLString(String htmlString, String baseURL, String unreachableURL, String provisionalLoadErrorURL, WebKit::UserData userData)
LoadPlainTextString(String string, WebKit::UserData userData)
LoadWebArchiveData(IPC::DataReference webArchiveData, WebKit::UserData userData)
NavigateToURLWithSimulatedClick(String url, WebCore::IntPoint documentPoint, WebCore::IntPoint screenPoint)
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (183697 => 183698)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2015-05-01 23:38:18 UTC (rev 183697)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2015-05-01 23:47:03 UTC (rev 183698)
@@ -41,6 +41,7 @@
378E64771632655E00B6C676 /* InjectedBundleFrameHitTest_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 378E64751632655D00B6C676 /* InjectedBundleFrameHitTest_Bundle.cpp */; };
378E64791632707400B6C676 /* link-with-title.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 378E647816326FDF00B6C676 /* link-with-title.html */; };
379028B914FAC24C007E6B43 /* acceptsFirstMouse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 379028B814FABE49007E6B43 /* acceptsFirstMouse.html */; };
+ 37D36ED71AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37D36ED61AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm */; };
37DC6791140D7D7600ABCCDB /* DOMRangeOfString.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 37DC678F140D7D3A00ABCCDB /* DOMRangeOfString.html */; };
37E1064C1697681800B78BD0 /* DOMHTMLTableCellElementCellAbove.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 37E1064B169767F700B78BD0 /* DOMHTMLTableCellElementCellAbove.html */; };
4BFDFFA71314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BFDFFA61314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp */; };
@@ -487,6 +488,7 @@
3799AD3914120A43005EB0C6 /* StringByEvaluatingJavaScriptFromString.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StringByEvaluatingJavaScriptFromString.mm; sourceTree = "<group>"; };
37A6895D148A9B50005100FA /* SubresourceErrorCrash.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SubresourceErrorCrash.mm; sourceTree = "<group>"; };
37C784DE197C8F2E0010A496 /* RenderedImageFromDOMNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RenderedImageFromDOMNode.mm; sourceTree = "<group>"; };
+ 37D36ED61AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LoadAlternateHTMLString.mm; sourceTree = "<group>"; };
37DC678B140D7C5000ABCCDB /* DOMRangeOfString.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMRangeOfString.mm; sourceTree = "<group>"; };
37DC678F140D7D3A00ABCCDB /* DOMRangeOfString.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DOMRangeOfString.html; sourceTree = "<group>"; };
37E1064A1697676400B78BD0 /* DOMHTMLTableCellCellAbove.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMHTMLTableCellCellAbove.mm; sourceTree = "<group>"; };
@@ -832,6 +834,7 @@
C95501BE19AD2FAF0049BE3E /* Preferences.mm */,
7CC3E1FA197E234100BE6252 /* UserContentController.mm */,
0F3B94A51A77266C00DE3272 /* WKWebViewEvaluateJavaScript.mm */,
+ 37D36ED61AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm */,
);
name = "WebKit2 Cocoa";
path = WebKit2Cocoa;
@@ -1547,6 +1550,7 @@
7CCE7EDD1A411A9200447C4C /* TimeRanges.cpp in Sources */,
7CCE7ED31A411A7E00447C4C /* TypingStyleCrash.mm in Sources */,
7CCE7EDE1A411A9200447C4C /* URL.cpp in Sources */,
+ 37D36ED71AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm in Sources */,
7CCE7EB01A411A4400447C4C /* URLExtras.mm in Sources */,
7CCE7F271A411AF600447C4C /* UserContentController.mm in Sources */,
7CCE7F2D1A411B1000447C4C /* UserContentTest.mm in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LoadAlternateHTMLString.mm (0 => 183698)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LoadAlternateHTMLString.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/LoadAlternateHTMLString.mm 2015-05-01 23:47:03 UTC (rev 183698)
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+#import "config.h"
+#import <WebKit/WKFoundation.h>
+
+#if WK_API_ENABLED
+
+#import "PlatformUtilities.h"
+#import "Test.h"
+#import <WebKit/WKWebViewPrivate.h>
+#import <wtf/RetainPtr.h>
+
+static bool isDone;
+
+@interface LoadAlternateHTMLStringFromProvisionalLoadErrorController : NSObject <WKNavigationDelegate>
+@end
+
+@implementation LoadAlternateHTMLStringFromProvisionalLoadErrorController
+
+- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error
+{
+ [webView _loadAlternateHTMLString:@"error page" baseURL:nil forUnreachableURL:[NSURL URLWithString:@"data:"]];
+}
+
+- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
+{
+ isDone = true;
+}
+
+@end
+
+static NSString *unloadableURL = @"data:";
+static NSString *loadableURL = @"data:text/html,no%20error";
+
+TEST(WKWebView, LoadAlternateHTMLStringFromProvisionalLoadError)
+{
+ auto webView = adoptNS([[WKWebView alloc] init]);
+ auto controller = adoptNS([[LoadAlternateHTMLStringFromProvisionalLoadErrorController alloc] init]);
+ [webView setNavigationDelegate:controller.get()];
+
+ [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:unloadableURL]]];
+ TestWebKitAPI::Util::run(&isDone);
+ isDone = false;
+
+ [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:loadableURL]]];
+ TestWebKitAPI::Util::run(&isDone);
+ isDone = false;
+
+ [webView goBack];
+ TestWebKitAPI::Util::run(&isDone);
+ isDone = false;
+
+ WKBackForwardList *list = [webView backForwardList];
+ EXPECT_EQ((NSUInteger)0, list.backList.count);
+ EXPECT_EQ((NSUInteger)1, list.forwardList.count);
+ EXPECT_STREQ([[list.forwardList.firstObject URL] absoluteString].UTF8String, loadableURL.UTF8String);
+ EXPECT_STREQ([[list.currentItem URL] absoluteString].UTF8String, unloadableURL.UTF8String);
+
+ EXPECT_TRUE([webView canGoForward]);
+ if (![webView canGoForward])
+ return;
+
+ [webView goForward];
+ TestWebKitAPI::Util::run(&isDone);
+ isDone = false;
+
+ EXPECT_EQ((NSUInteger)1, list.backList.count);
+ EXPECT_EQ((NSUInteger)0, list.forwardList.count);
+ EXPECT_STREQ([[list.backList.firstObject URL] absoluteString].UTF8String, unloadableURL.UTF8String);
+ EXPECT_STREQ([[list.currentItem URL] absoluteString].UTF8String, loadableURL.UTF8String);
+}
+
+#endif