Title: [95440] trunk
Revision
95440
Author
jber...@webkit.org
Date
2011-09-19 11:00:45 -0700 (Mon, 19 Sep 2011)

Log Message

Sites that use history pushState or replaceState are recorded in history in Private Browsing
mode.
https://bugs.webkit.org/show_bug.cgi?id=68208

Reviewed by Brady Eidson.

Source/WebCore:

Test: TestWebKitAPI/Tests/WebKit2/PrivateBrowsingPushStateNoHistoryCallback.

Add the privateBrowsingEnabled check that is used in other places in HistoryController
before calling addVisitedLink and FrameLoaderClient::updateGlobalHistory.

* loader/HistoryController.cpp:
(WebCore::HistoryController::pushState):
(WebCore::HistoryController::replaceState):

Tools:

Add a test that the WKContextDidNavigateWithNavigationDataCallback (which is invoked by
updateGlobalHistory) is not called in Private Browsing when the page does history.pushState.

* TestWebKitAPI/Tests/WebKit2/PrivateBrowsingPushStateNoHistoryCallback.cpp: Added.
(TestWebKitAPI::didNavigateWithNavigationData):
This is a context history client callback, so it should not be called when in Private
Browsing. Add a call to FAIL().
(TestWebKitAPI::didSameDocumentNavigationForFrame):
This is a page load client callback that happens after the didNavigateWithNavigationData
callback. End the test.
(TestWebKitAPI::TEST):
Enable Private Browsing and load a page that uses history.pushState.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
Add PrivateBrowsingPushStateNoHistoryCallback.cpp and push-state.html.
* TestWebKitAPI/Tests/WebKit2/push-state.html: Added.
Ditto.
* TestWebKitAPI/win/TestWebKitAPI.vcproj:
Ditto.
* TestWebKitAPI/win/copy-resources.cmd:
Ditto.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (95439 => 95440)


--- trunk/Source/WebCore/ChangeLog	2011-09-19 17:41:51 UTC (rev 95439)
+++ trunk/Source/WebCore/ChangeLog	2011-09-19 18:00:45 UTC (rev 95440)
@@ -1,3 +1,20 @@
+2011-09-19  Jessie Berlin  <jber...@apple.com>
+
+        Sites that use history pushState or replaceState are recorded in history in Private Browsing
+        mode.
+        https://bugs.webkit.org/show_bug.cgi?id=68208
+
+        Reviewed by Brady Eidson.
+
+        Test: TestWebKitAPI/Tests/WebKit2/PrivateBrowsingPushStateNoHistoryCallback.
+
+        Add the privateBrowsingEnabled check that is used in other places in HistoryController
+        before calling addVisitedLink and FrameLoaderClient::updateGlobalHistory.
+
+        * loader/HistoryController.cpp:
+        (WebCore::HistoryController::pushState):
+        (WebCore::HistoryController::replaceState):
+
 2011-09-19  Leandro Pereira  <lean...@profusion.mobi>
 
         Unreviewed: ScrollbarThemeMock.cpp is already referenced in the

Modified: trunk/Source/WebCore/loader/HistoryController.cpp (95439 => 95440)


--- trunk/Source/WebCore/loader/HistoryController.cpp	2011-09-19 17:41:51 UTC (rev 95439)
+++ trunk/Source/WebCore/loader/HistoryController.cpp	2011-09-19 18:00:45 UTC (rev 95440)
@@ -830,6 +830,10 @@
 
     page->backForward()->addItem(topItem.release());
 
+    Settings* settings = m_frame->settings();
+    if (!settings || settings->privateBrowsingEnabled())
+        return;
+
     addVisitedLink(page, KURL(ParsedURLString, urlString));
     m_frame->loader()->client()->updateGlobalHistory();
 
@@ -845,6 +849,10 @@
     m_currentItem->setTitle(title);
     m_currentItem->setStateObject(stateObject);
 
+    Settings* settings = m_frame->settings();
+    if (!settings || settings->privateBrowsingEnabled())
+        return;
+
     ASSERT(m_frame->page());
     addVisitedLink(m_frame->page(), KURL(ParsedURLString, urlString));
     m_frame->loader()->client()->updateGlobalHistory();

Modified: trunk/Tools/ChangeLog (95439 => 95440)


--- trunk/Tools/ChangeLog	2011-09-19 17:41:51 UTC (rev 95439)
+++ trunk/Tools/ChangeLog	2011-09-19 18:00:45 UTC (rev 95440)
@@ -1,3 +1,33 @@
+2011-09-19  Jessie Berlin  <jber...@apple.com>
+
+        Sites that use history pushState or replaceState are recorded in history in Private Browsing
+        mode.
+        https://bugs.webkit.org/show_bug.cgi?id=68208
+
+        Reviewed by Brady Eidson.
+
+        Add a test that the WKContextDidNavigateWithNavigationDataCallback (which is invoked by
+        updateGlobalHistory) is not called in Private Browsing when the page does history.pushState.
+
+        * TestWebKitAPI/Tests/WebKit2/PrivateBrowsingPushStateNoHistoryCallback.cpp: Added.
+        (TestWebKitAPI::didNavigateWithNavigationData):
+        This is a context history client callback, so it should not be called when in Private
+        Browsing. Add a call to FAIL().
+        (TestWebKitAPI::didSameDocumentNavigationForFrame):
+        This is a page load client callback that happens after the didNavigateWithNavigationData
+        callback. End the test.
+        (TestWebKitAPI::TEST):
+        Enable Private Browsing and load a page that uses history.pushState.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        Add PrivateBrowsingPushStateNoHistoryCallback.cpp and push-state.html.
+        * TestWebKitAPI/Tests/WebKit2/push-state.html: Added.
+        Ditto.
+        * TestWebKitAPI/win/TestWebKitAPI.vcproj:
+        Ditto.
+        * TestWebKitAPI/win/copy-resources.cmd:
+        Ditto.
+
 2011-09-16  Elliot Poger  <epo...@google.com>
 
         add non-CG Webkit-Mac builds to flakiness dashboard

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (95439 => 95440)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2011-09-19 17:41:51 UTC (rev 95439)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2011-09-19 18:00:45 UTC (rev 95440)
@@ -87,6 +87,8 @@
 		C0BD669F131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0BD669E131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp */; };
 		F3FC3EE313678B7300126A65 /* libgtest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F3FC3EE213678B7300126A65 /* libgtest.a */; };
 		F6F3F29113342FEB00A6BF19 /* CookieManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6F3F29013342FEB00A6BF19 /* CookieManager.cpp */; };
+		F6FDDDD314241AD4004F1729 /* PrivateBrowsingPushStateNoHistoryCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6FDDDD214241AD4004F1729 /* PrivateBrowsingPushStateNoHistoryCallback.cpp */; };
+		F6FDDDD614241C6F004F1729 /* push-state.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F6FDDDD514241C48004F1729 /* push-state.html */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
@@ -119,6 +121,7 @@
 				1A9E52C913E65EF4006917F5 /* 18-characters.html in Copy Resources */,
 				C07E6CB213FD73930038B22B /* devicePixelRatio.html in Copy Resources */,
 				33E79E06137B5FD900E32D99 /* mouse-move-listener.html in Copy Resources */,
+				F6FDDDD614241C6F004F1729 /* push-state.html in Copy Resources */,
 				BCBD3737125ABBEB00D2C29F /* icon.png in Copy Resources */,
 				1A02C870125D4CFD00E3F4BD /* find.html in Copy Resources */,
 				BC909784125571CF00083756 /* simple.html in Copy Resources */,
@@ -228,6 +231,8 @@
 		C0BD669E131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResponsivenessTimerDoesntFireEarly_Bundle.cpp; sourceTree = "<group>"; };
 		F3FC3EE213678B7300126A65 /* libgtest.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libgtest.a; sourceTree = BUILT_PRODUCTS_DIR; };
 		F6F3F29013342FEB00A6BF19 /* CookieManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CookieManager.cpp; sourceTree = "<group>"; };
+		F6FDDDD214241AD4004F1729 /* PrivateBrowsingPushStateNoHistoryCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrivateBrowsingPushStateNoHistoryCallback.cpp; sourceTree = "<group>"; };
+		F6FDDDD514241C48004F1729 /* push-state.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "push-state.html"; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -361,6 +366,7 @@
 				BC909779125571AB00083756 /* PageLoadBasic.cpp */,
 				BC2D004812A9FDFA00E732A3 /* PageLoadDidChangeLocationWithinPageForFrame.cpp */,
 				333B9CE11277F23100FEFCE3 /* PreventEmptyUserAgent.cpp */,
+				F6FDDDD214241AD4004F1729 /* PrivateBrowsingPushStateNoHistoryCallback.cpp */,
 				C0BD669C131D3CF700E18F2A /* ResponsivenessTimerDoesntFireEarly.cpp */,
 				C0BD669E131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp */,
 				C0ADBE8212FCA6AA00D2C129 /* RestoreSessionStateContainingFormData.cpp */,
@@ -395,6 +401,7 @@
 				1A02C84B125D4A5E00E3F4BD /* find.html */,
 				BCBD372E125ABBE600D2C29F /* icon.png */,
 				33E79E05137B5FCE00E32D99 /* mouse-move-listener.html */,
+				F6FDDDD514241C48004F1729 /* push-state.html */,
 				1ADBEFBC130C6A0100D61D19 /* simple-accelerated-compositing.html */,
 				C0ADBE8412FCA6B600D2C129 /* simple-form.html */,
 				33DC890E1419539300747EF7 /* simple-iframe.html */,
@@ -596,6 +603,7 @@
 				3799AD3A14120A43005EB0C6 /* StringByEvaluatingJavaScriptFromString.mm in Sources */,
 				33DC8911141953A300747EF7 /* LoadCanceledNoServerRedirectCallback.cpp in Sources */,
 				520BCF4D141EB09E00937EA8 /* WebArchive.cpp in Sources */,
+				F6FDDDD314241AD4004F1729 /* PrivateBrowsingPushStateNoHistoryCallback.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/PrivateBrowsingPushStateNoHistoryCallback.cpp (0 => 95440)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/PrivateBrowsingPushStateNoHistoryCallback.cpp	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/PrivateBrowsingPushStateNoHistoryCallback.cpp	2011-09-19 18:00:45 UTC (rev 95440)
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2011 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 "Test.h"
+#include <WebKit2/WKRetainPtr.h>
+
+namespace TestWebKitAPI {
+
+static bool testDone;
+
+static void didNavigateWithNavigationData(WKContextRef context, WKPageRef page, WKNavigationDataRef navigationData, WKFrameRef frame, const void* clientInfo)
+{
+    // This should never be called when navigating in Private Browsing.
+    FAIL();
+}
+
+static void didSameDocumentNavigationForFrame(WKPageRef page, WKFrameRef frame, WKSameDocumentNavigationType type, WKTypeRef userData, const void *clientInfo)
+{
+    testDone = true;
+}
+
+TEST(WebKit2, PrivateBrowsingPushStateNoHistoryCallback)
+{
+    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
+
+    WKContextHistoryClient historyClient;
+    memset(&historyClient, 0, sizeof(historyClient));
+
+    historyClient.version = 0;
+    historyClient.clientInfo = 0;
+    historyClient.didNavigateWithNavigationData = didNavigateWithNavigationData;
+    WKContextSetHistoryClient(context.get(), &historyClient);
+
+    PlatformWebView webView(context.get());
+
+    WKPageLoaderClient pageLoaderClient;
+    memset(&pageLoaderClient, 0, sizeof(pageLoaderClient));
+
+    pageLoaderClient.version = 0;
+    pageLoaderClient.clientInfo = 0;
+    pageLoaderClient.didSameDocumentNavigationForFrame = didSameDocumentNavigationForFrame;
+    WKPageSetPageLoaderClient(webView.page(), &pageLoaderClient);
+
+    WKRetainPtr<WKPreferencesRef> preferences(AdoptWK, WKPreferencesCreate());
+    WKPreferencesSetPrivateBrowsingEnabled(preferences.get(), true);
+
+    WKPageGroupRef pageGroup = WKPageGetPageGroup(webView.page());
+    WKPageGroupSetPreferences(pageGroup, preferences.get());
+
+    WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("push-state", "html"));
+    WKPageLoadURL(webView.page(), url.get());
+
+    Util::run(&testDone);
+}
+
+} // namespace TestWebKitAPI

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/push-state.html (0 => 95440)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/push-state.html	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/push-state.html	2011-09-19 18:00:45 UTC (rev 95440)
@@ -0,0 +1,3 @@
+<script type="text/_javascript_">
+history.pushState('newState', 0, '?newState');
+</script>

Modified: trunk/Tools/TestWebKitAPI/win/TestWebKitAPI.vcproj (95439 => 95440)


--- trunk/Tools/TestWebKitAPI/win/TestWebKitAPI.vcproj	2011-09-19 17:41:51 UTC (rev 95439)
+++ trunk/Tools/TestWebKitAPI/win/TestWebKitAPI.vcproj	2011-09-19 18:00:45 UTC (rev 95440)
@@ -508,6 +508,14 @@
 					>
 				</File>
 				<File
+					RelativePath="..\Tests\WebKit2\PrivateBrowsingPushStateNoHistoryCallback.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\Tests\WebKit2\push-state.html"
+					>
+				</File>
+				<File
 					RelativePath="..\Tests\WebKit2\ResponsivenessTimerDoesntFireEarly.cpp"
 					>
 				</File>

Modified: trunk/Tools/TestWebKitAPI/win/copy-resources.cmd (95439 => 95440)


--- trunk/Tools/TestWebKitAPI/win/copy-resources.cmd	2011-09-19 17:41:51 UTC (rev 95439)
+++ trunk/Tools/TestWebKitAPI/win/copy-resources.cmd	2011-09-19 18:00:45 UTC (rev 95440)
@@ -13,6 +13,7 @@
     ..\Tests\WebKit2\find.html
     ..\Tests\WebKit2\icon.png
     ..\Tests\WebKit2\mouse-move-listener.html
+    ..\Tests\WebKit2\push-state.html
     ..\Tests\WebKit2\simple.html
     ..\Tests\WebKit2\simple-accelerated-compositing.html
     ..\Tests\WebKit2\simple-form.html
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to