Title: [123823] trunk
Revision
123823
Author
[email protected]
Date
2012-07-26 17:52:32 -0700 (Thu, 26 Jul 2012)

Log Message

Reloading substitute-data/alternate html string for unreachableURL will add an item to the back-forward-history for each reload
https://bugs.webkit.org/show_bug.cgi?id=84041

Reviewed by Brady Eidson.

Source/WebCore:

Previously, loadAlternateHTMLString:baseURL:forUnreachableURL: would insert a new history item, regardless of
the load type of the original frame load. This could cause navigation to a broken website to make back and
forward navigation difficult to use. This change ensures that a reload type makes it through all the way.

Added API test 'mac/BackForwardList.mm'.

* loader/FrameLoader.cpp:
(WebCore::FrameLoader::load): Prevent m_loadType from being overwritten early and check if it's a reload.
* loader/HistoryController.cpp:
(WebCore::HistoryController::updateForCommit): Amend check when committing the provisional item for a reload.
(WebCore::HistoryController::isReloadTypeWithProvisionalItem): Check that a reload type has a provisional item.
(WebCore):
* loader/HistoryController.h:
(HistoryController): Add prototype for isReloadTypeWithProvisionalItem.

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/mac/BackForwardList.mm: Added.
(-[BackForwardListTest webView:didFinishLoadForFrame:]):
(-[BackForwardListTest webView:didFailProvisionalLoadWithError:forFrame:]):
(TestWebKitAPI):
(TestWebKitAPI::TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (123822 => 123823)


--- trunk/Source/WebCore/ChangeLog	2012-07-27 00:48:15 UTC (rev 123822)
+++ trunk/Source/WebCore/ChangeLog	2012-07-27 00:52:32 UTC (rev 123823)
@@ -1,3 +1,25 @@
+2012-07-26  Jeffrey Pfau  <[email protected]>
+
+        Reloading substitute-data/alternate html string for unreachableURL will add an item to the back-forward-history for each reload
+        https://bugs.webkit.org/show_bug.cgi?id=84041
+
+        Reviewed by Brady Eidson.
+
+        Previously, loadAlternateHTMLString:baseURL:forUnreachableURL: would insert a new history item, regardless of
+        the load type of the original frame load. This could cause navigation to a broken website to make back and
+        forward navigation difficult to use. This change ensures that a reload type makes it through all the way.
+
+        Added API test 'mac/BackForwardList.mm'.
+
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::load): Prevent m_loadType from being overwritten early and check if it's a reload.
+        * loader/HistoryController.cpp:
+        (WebCore::HistoryController::updateForCommit): Amend check when committing the provisional item for a reload.
+        (WebCore::HistoryController::isReloadTypeWithProvisionalItem): Check that a reload type has a provisional item.
+        (WebCore):
+        * loader/HistoryController.h:
+        (HistoryController): Add prototype for isReloadTypeWithProvisionalItem.
+
 2012-07-26  Silvia Pfeiffer  <[email protected]>
 
         [Chromium] Regression: Global-buffer-overflow in WebCore::mediaControlElementType

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (123822 => 123823)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2012-07-27 00:48:15 UTC (rev 123822)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2012-07-27 00:52:32 UTC (rev 123823)
@@ -1234,8 +1234,6 @@
     if (m_inStopAllLoaders)
         return;
         
-    // FIXME: is this the right place to reset loadType? Perhaps this should be done after loading is finished or aborted.
-    m_loadType = FrameLoadTypeStandard;
     RefPtr<DocumentLoader> loader = m_client->createDocumentLoader(request, substituteData);
     if (lockHistory && m_documentLoader)
         loader->setClientRedirectSourceForHistory(m_documentLoader->didCreateGlobalHistoryEntry() ? m_documentLoader->urlForHistory().string() : m_documentLoader->clientRedirectSourceForHistory());
@@ -1280,7 +1278,9 @@
     if (shouldTreatURLAsSameAsCurrent(newDocumentLoader->originalRequest().url())) {
         r.setCachePolicy(ReloadIgnoringCacheData);
         type = FrameLoadTypeSame;
-    } else
+    } else if (shouldTreatURLAsSameAsCurrent(newDocumentLoader->unreachableURL()) && m_loadType == FrameLoadTypeReload)
+        type = FrameLoadTypeReload;
+    else
         type = FrameLoadTypeStandard;
 
     if (m_documentLoader)

Modified: trunk/Source/WebCore/loader/HistoryController.cpp (123822 => 123823)


--- trunk/Source/WebCore/loader/HistoryController.cpp	2012-07-27 00:48:15 UTC (rev 123822)
+++ trunk/Source/WebCore/loader/HistoryController.cpp	2012-07-27 00:52:32 UTC (rev 123823)
@@ -438,7 +438,7 @@
     FrameLoadType type = frameLoader->loadType();
     if (isBackForwardLoadType(type)
         || isReplaceLoadTypeWithProvisionalItem(type)
-        || ((type == FrameLoadTypeReload || type == FrameLoadTypeReloadFromOrigin) && !frameLoader->provisionalDocumentLoader()->unreachableURL().isEmpty())) {
+        || (isReloadTypeWithProvisionalItem(type) && !frameLoader->provisionalDocumentLoader()->unreachableURL().isEmpty())) {
         // Once committed, we want to use current item for saving DocState, and
         // the provisional item for restoring state.
         // Note previousItem must be set before we close the URL, which will
@@ -465,6 +465,11 @@
     return type == FrameLoadTypeReplace && m_provisionalItem;
 }
 
+bool HistoryController::isReloadTypeWithProvisionalItem(FrameLoadType type)
+{
+    return (type == FrameLoadTypeReload || type == FrameLoadTypeReloadFromOrigin) && m_provisionalItem;
+}
+
 void HistoryController::recursiveUpdateForCommit()
 {
     // The frame that navigated will now have a null provisional item.

Modified: trunk/Source/WebCore/loader/HistoryController.h (123822 => 123823)


--- trunk/Source/WebCore/loader/HistoryController.h	2012-07-27 00:48:15 UTC (rev 123822)
+++ trunk/Source/WebCore/loader/HistoryController.h	2012-07-27 00:52:32 UTC (rev 123823)
@@ -98,6 +98,7 @@
     void recursiveSetProvisionalItem(HistoryItem*, HistoryItem*, FrameLoadType);
     void recursiveGoToItem(HistoryItem*, HistoryItem*, FrameLoadType);
     bool isReplaceLoadTypeWithProvisionalItem(FrameLoadType);
+    bool isReloadTypeWithProvisionalItem(FrameLoadType);
     void recursiveUpdateForCommit();
     void recursiveUpdateForSameDocumentNavigation();
     bool itemsAreClones(HistoryItem*, HistoryItem*) const;

Modified: trunk/Tools/ChangeLog (123822 => 123823)


--- trunk/Tools/ChangeLog	2012-07-27 00:48:15 UTC (rev 123822)
+++ trunk/Tools/ChangeLog	2012-07-27 00:52:32 UTC (rev 123823)
@@ -1,3 +1,17 @@
+2012-07-26  Jeffrey Pfau  <[email protected]>
+
+        Reloading substitute-data/alternate html string for unreachableURL will add an item to the back-forward-history for each reload
+        https://bugs.webkit.org/show_bug.cgi?id=84041
+
+        Reviewed by Brady Eidson.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/mac/BackForwardList.mm: Added.
+        (-[BackForwardListTest webView:didFinishLoadForFrame:]):
+        (-[BackForwardListTest webView:didFailProvisionalLoadWithError:forFrame:]):
+        (TestWebKitAPI):
+        (TestWebKitAPI::TEST):
+
 2012-07-26  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r123799.

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (123822 => 123823)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2012-07-27 00:48:15 UTC (rev 123822)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2012-07-27 00:52:32 UTC (rev 123823)
@@ -7,6 +7,7 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
+		00CD9F6315BE312C002DA2CE /* BackForwardList.mm in Sources */ = {isa = PBXBuildFile; fileRef = 00CD9F6215BE312C002DA2CE /* BackForwardList.mm */; };
 		0BCD833514857CE400EA2003 /* HashMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0BCD833414857CE400EA2003 /* HashMap.cpp */; };
 		0BCD856A1485C98B00EA2003 /* TemporaryChange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0BCD85691485C98B00EA2003 /* TemporaryChange.cpp */; };
 		0F17BBD615AF6C4D007AB753 /* WebCoreStatisticsWithNoWebProcess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F17BBD415AF6C4D007AB753 /* WebCoreStatisticsWithNoWebProcess.cpp */; };
@@ -233,6 +234,7 @@
 /* End PBXCopyFilesBuildPhase section */
 
 /* Begin PBXFileReference section */
+		00CD9F6215BE312C002DA2CE /* BackForwardList.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BackForwardList.mm; sourceTree = "<group>"; };
 		0BCD833414857CE400EA2003 /* HashMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HashMap.cpp; path = WTF/HashMap.cpp; sourceTree = "<group>"; };
 		0BCD85691485C98B00EA2003 /* TemporaryChange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TemporaryChange.cpp; path = WTF/TemporaryChange.cpp; sourceTree = "<group>"; };
 		0F17BBD415AF6C4D007AB753 /* WebCoreStatisticsWithNoWebProcess.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebCoreStatisticsWithNoWebProcess.cpp; sourceTree = "<group>"; };
@@ -713,6 +715,7 @@
 				E490296714E2E3A4002BEDD1 /* TypingStyleCrash.mm */,
 				51FBBB4C1513D4E900822738 /* WebViewCanPasteURL.mm */,
 				A5E2027215B2181900C13E14 /* WindowlessWebViewWithMedia.mm */,
+				00CD9F6215BE312C002DA2CE /* BackForwardList.mm */,
 			);
 			path = mac;
 			sourceTree = "<group>";
@@ -949,6 +952,7 @@
 				261516D615B0E60500A2C201 /* SetAndUpdateCacheModel.mm in Sources */,
 				A5E2027315B2181900C13E14 /* WindowlessWebViewWithMedia.mm in Sources */,
 				26B2DFF915BDE599004F691D /* HashSet.cpp in Sources */,
+				00CD9F6315BE312C002DA2CE /* BackForwardList.mm in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Added: trunk/Tools/TestWebKitAPI/Tests/mac/BackForwardList.mm (0 => 123823)


--- trunk/Tools/TestWebKitAPI/Tests/mac/BackForwardList.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/BackForwardList.mm	2012-07-27 00:52:32 UTC (rev 123823)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2012 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"
+#include "PlatformUtilities.h"
+#include "PlatformWebView.h"
+#include <wtf/RetainPtr.h>
+
+#include <WebKit/WebBackForwardList.h>
+
+@interface BackForwardListTest : NSObject {
+}
+@end
+
+static bool didFinishLoad;
+
+@implementation BackForwardListTest
+
+- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
+{
+    didFinishLoad = true;
+}
+
+- (void)webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame
+{
+    [frame loadAlternateHTMLString:@"<html></html>" baseURL:[NSURL URLWithString:@"about:blank"] forUnreachableURL:[[error userInfo] valueForKey:NSURLErrorFailingURLErrorKey]];
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+TEST(WebKit1, ReloadBackForward)
+{
+    RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
+    RetainPtr<BackForwardListTest> testController(AdoptNS, [BackForwardListTest new]);
+    webView.get().frameLoadDelegate = testController.get();
+    [[webView.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://does-not-exist.example"]]];
+    Util::run(&didFinishLoad);
+    didFinishLoad = false;
+
+    [[webView.get() mainFrame] reload];
+    Util::run(&didFinishLoad);
+    didFinishLoad = false;
+
+    WebBackForwardList *bfList = [webView.get() backForwardList];
+    EXPECT_EQ(0, [bfList backListCount]);
+}
+
+} // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to