Diff
Modified: trunk/Source/WebKit2/ChangeLog (114142 => 114143)
--- trunk/Source/WebKit2/ChangeLog 2012-04-13 17:43:58 UTC (rev 114142)
+++ trunk/Source/WebKit2/ChangeLog 2012-04-13 17:46:05 UTC (rev 114143)
@@ -1,3 +1,46 @@
+2012-04-13 Brady Eidson <beid...@apple.com>
+
+ <rdar://problem/11176921> and https://bugs.webkit.org/show_bug.cgi?id=83600
+ Need WebKit2 API to notify whether history loads are in the page cache
+
+ - Add a new WKBundlePageLoaderClient callback allowing the bundle to be notified
+ of back/forward navigations (and deny them if it chooses)
+ - Add a new API to WKBundleBackForwardListItem to probe if the item is in the page cache.
+
+ Reviewed by Darin Adler.
+
+ Add the new WKBundleBackForwardListItem API:
+ * WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.cpp:
+ (WKBundleBackForwardListItemIsInPageCache):
+ * WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.h:
+ * WebProcess/InjectedBundle/InjectedBundleBackForwardListItem.h:
+ (WebKit::InjectedBundleBackForwardListItem::isInPageCache):
+
+ Update the UI page loader client to allow for a user data object to be passed from the bundle:
+ * UIProcess/API/C/WKPage.h:
+ * UIProcess/WebLoaderClient.cpp:
+ (WebKit::WebLoaderClient::shouldGoToBackForwardListItem): Update a comment typo.
+ (WebKit::WebLoaderClient::willGoToBackForwardListItem): Update for the user data field.
+ * UIProcess/WebLoaderClient.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::willGoToBackForwardListItem):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in:
+
+ Add the new callback to the bundle loader client:
+ * WebProcess/InjectedBundle/API/c/WKBundlePage.h:
+ * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp:
+ (WebKit::InjectedBundlePageLoaderClient::shouldGoToBackForwardListItem):
+ * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h:
+ (InjectedBundlePageLoaderClient):
+
+ Call the bundle client before doing anything else, possibly canceling the navigation:
+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+ (WebKit::WebFrameLoaderClient::shouldGoToHistoryItem):
+
+ * WebProcess/qt/QtBuiltinBundlePage.cpp:
+ (WebKit::QtBuiltinBundlePage::QtBuiltinBundlePage) Adopt new bundle client interface.
+
2012-04-13 Dinu Jacob <dinu.ja...@nokia.com>
[Qt][WK2] Title in MiniBrowser is not updated for a page with no title
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.h (114142 => 114143)
--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.h 2012-04-13 17:43:58 UTC (rev 114142)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.h 2012-04-13 17:46:05 UTC (rev 114143)
@@ -71,7 +71,7 @@
typedef bool (*WKPageShouldGoToBackForwardListItemCallback)(WKPageRef page, WKBackForwardListItemRef item, const void *clientInfo);
typedef void (*WKPageDidFailToInitializePluginCallback)(WKPageRef page, WKStringRef mimeType, const void* clientInfo);
typedef void (*WKPageDidNewFirstVisuallyNonEmptyLayoutCallback)(WKPageRef page, WKTypeRef userData, const void *clientInfo);
-typedef void (*WKPageWillGoToBackForwardListItemCallback)(WKPageRef page, WKBackForwardListItemRef item, const void *clientInfo);
+typedef void (*WKPageWillGoToBackForwardListItemCallback)(WKPageRef page, WKBackForwardListItemRef item, WKTypeRef userData, const void *clientInfo);
struct WKPageLoaderClient {
int version;
Modified: trunk/Source/WebKit2/UIProcess/WebLoaderClient.cpp (114142 => 114143)
--- trunk/Source/WebKit2/UIProcess/WebLoaderClient.cpp 2012-04-13 17:43:58 UTC (rev 114142)
+++ trunk/Source/WebKit2/UIProcess/WebLoaderClient.cpp 2012-04-13 17:46:05 UTC (rev 114143)
@@ -243,17 +243,17 @@
{
// We should only even considering sending the shouldGoToBackForwardListItem() client callback
// for version 0 clients. Later versioned clients should get willGoToBackForwardListItem() instead,
- // but do to XPC race conditions this one might have been called instead.
+ // but due to XPC race conditions this one might have been called instead.
if (m_client.version > 0 || !m_client.shouldGoToBackForwardListItem)
return true;
return m_client.shouldGoToBackForwardListItem(toAPI(page), toAPI(item), m_client.clientInfo);
}
-void WebLoaderClient::willGoToBackForwardListItem(WebPageProxy* page, WebBackForwardListItem* item)
+void WebLoaderClient::willGoToBackForwardListItem(WebPageProxy* page, WebBackForwardListItem* item, APIObject* userData)
{
if (m_client.willGoToBackForwardListItem)
- m_client.willGoToBackForwardListItem(toAPI(page), toAPI(item), m_client.clientInfo);
+ m_client.willGoToBackForwardListItem(toAPI(page), toAPI(item), toAPI(userData), m_client.clientInfo);
}
void WebLoaderClient::didFailToInitializePlugin(WebPageProxy* page, const String& mimeType)
Modified: trunk/Source/WebKit2/UIProcess/WebLoaderClient.h (114142 => 114143)
--- trunk/Source/WebKit2/UIProcess/WebLoaderClient.h 2012-04-13 17:43:58 UTC (rev 114142)
+++ trunk/Source/WebKit2/UIProcess/WebLoaderClient.h 2012-04-13 17:46:05 UTC (rev 114143)
@@ -83,7 +83,7 @@
void didChangeBackForwardList(WebPageProxy*, WebBackForwardListItem* addedItem, Vector<RefPtr<APIObject> >* removedItems);
bool shouldGoToBackForwardListItem(WebPageProxy*, WebBackForwardListItem*);
- void willGoToBackForwardListItem(WebPageProxy*, WebBackForwardListItem*);
+ void willGoToBackForwardListItem(WebPageProxy*, WebBackForwardListItem*, APIObject*);
void didFailToInitializePlugin(WebPageProxy*, const String& mimeType);
};
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (114142 => 114143)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2012-04-13 17:43:58 UTC (rev 114142)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2012-04-13 17:46:05 UTC (rev 114143)
@@ -642,10 +642,15 @@
shouldGoToBackForwardItem = item && m_loaderClient.shouldGoToBackForwardListItem(this, item);
}
-void WebPageProxy::willGoToBackForwardListItem(uint64_t itemID)
+void WebPageProxy::willGoToBackForwardListItem(uint64_t itemID, CoreIPC::ArgumentDecoder* arguments)
{
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
if (WebBackForwardListItem* item = process()->webBackForwardItem(itemID))
- m_loaderClient.willGoToBackForwardListItem(this, item);
+ m_loaderClient.willGoToBackForwardListItem(this, item, userData.get());
}
String WebPageProxy::activeURL() const
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (114142 => 114143)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2012-04-13 17:43:58 UTC (rev 114142)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2012-04-13 17:46:05 UTC (rev 114143)
@@ -272,7 +272,7 @@
void tryRestoreScrollPosition();
void didChangeBackForwardList(WebBackForwardListItem* addedItem, Vector<RefPtr<APIObject> >* removedItems);
void shouldGoToBackForwardListItem(uint64_t itemID, bool& shouldGoToBackForwardListItem);
- void willGoToBackForwardListItem(uint64_t itemID);
+ void willGoToBackForwardListItem(uint64_t itemID, CoreIPC::ArgumentDecoder* arguments);
String activeURL() const;
String provisionalURL() const;
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (114142 => 114143)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in 2012-04-13 17:43:58 UTC (rev 114142)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in 2012-04-13 17:46:05 UTC (rev 114143)
@@ -166,7 +166,7 @@
BackForwardForwardListCount() -> (int32_t count)
BackForwardClear()
ShouldGoToBackForwardListItem(uint64_t itemID) -> (bool shouldGoToBackForwardListItem)
- WillGoToBackForwardListItem(uint64_t itemID)
+ WillGoToBackForwardListItem(uint64_t itemID, WebKit::InjectedBundleUserMessageEncoder userData)
# Undo/Redo messages
RegisterEditCommandForUndo(uint64_t commandID, uint32_t editAction)
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.cpp (114142 => 114143)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.cpp 2012-04-13 17:43:58 UTC (rev 114142)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.cpp 2012-04-13 17:46:05 UTC (rev 114143)
@@ -67,6 +67,11 @@
return toImpl(itemRef)->isTargetItem();
}
+bool WKBundleBackForwardListItemIsInPageCache(WKBundleBackForwardListItemRef itemRef)
+{
+ return toImpl(itemRef)->isInPageCache();
+}
+
WKArrayRef WKBundleBackForwardListItemCopyChildren(WKBundleBackForwardListItemRef itemRef)
{
return toAPI(toImpl(itemRef)->children().leakRef());
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.h (114142 => 114143)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.h 2012-04-13 17:43:58 UTC (rev 114142)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.h 2012-04-13 17:46:05 UTC (rev 114143)
@@ -43,6 +43,8 @@
WK_EXPORT WKStringRef WKBundleBackForwardListItemCopyTarget(WKBundleBackForwardListItemRef item);
WK_EXPORT bool WKBundleBackForwardListItemIsTargetItem(WKBundleBackForwardListItemRef item);
+WK_EXPORT bool WKBundleBackForwardListItemIsInPageCache(WKBundleBackForwardListItemRef item);
+
WK_EXPORT WKArrayRef WKBundleBackForwardListItemCopyChildren(WKBundleBackForwardListItemRef item);
#ifdef __cplusplus
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h (114142 => 114143)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h 2012-04-13 17:43:58 UTC (rev 114142)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h 2012-04-13 17:46:05 UTC (rev 114143)
@@ -101,6 +101,7 @@
typedef void (*WKBundlePageDidCancelClientRedirectForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo);
typedef void (*WKBundlePageWillPerformClientRedirectForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKURLRef url, double delay, double date, const void *clientInfo);
typedef void (*WKBundlePageDidHandleOnloadEventsForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo);
+typedef bool (*WKBundlePageShouldGoToBackForwardListItemCallback)(WKBundlePageRef page, WKBundleBackForwardListItemRef item, WKTypeRef* userData, const void *clientInfo);
struct WKBundlePageLoaderClient {
int version;
@@ -130,6 +131,7 @@
WKBundlePageDidLayoutForFrameCallback didLayoutForFrame;
WKBundlePageDidNewFirstVisuallyNonEmptyLayoutCallback didNewFirstVisuallyNonEmptyLayout;
WKBundlePageDidDetectXSSForFrameCallback didDetectXSSForFrame;
+ WKBundlePageShouldGoToBackForwardListItemCallback shouldGoToBackForwardListItem;
};
typedef struct WKBundlePageLoaderClient WKBundlePageLoaderClient;
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardListItem.h (114142 => 114143)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardListItem.h 2012-04-13 17:43:58 UTC (rev 114142)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardListItem.h 2012-04-13 17:46:05 UTC (rev 114143)
@@ -53,6 +53,7 @@
const String& target() const { return m_item->target(); }
bool isTargetItem() const { return m_item->isTargetItem(); }
+ bool isInPageCache() const { return m_item->isInPageCache(); }
PassRefPtr<ImmutableArray> children() const;
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp (114142 => 114143)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp 2012-04-13 17:43:58 UTC (rev 114142)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp 2012-04-13 17:46:05 UTC (rev 114143)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011, 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
@@ -36,6 +36,18 @@
namespace WebKit {
+bool InjectedBundlePageLoaderClient::shouldGoToBackForwardListItem(WebPage* page, InjectedBundleBackForwardListItem* item, RefPtr<APIObject>& userData)
+{
+ if (!m_client.shouldGoToBackForwardListItem)
+ return true;
+
+ WKTypeRef userDataToPass = 0;
+ bool result = m_client.shouldGoToBackForwardListItem(toAPI(page), toAPI(item), &userDataToPass, m_client.clientInfo);
+ userData = adoptRef(toImpl(userDataToPass));
+
+ return result;
+}
+
void InjectedBundlePageLoaderClient::didStartProvisionalLoadForFrame(WebPage* page, WebFrame* frame, RefPtr<APIObject>& userData)
{
if (!m_client.didStartProvisionalLoadForFrame)
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h (114142 => 114143)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h 2012-04-13 17:43:58 UTC (rev 114142)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h 2012-04-13 17:46:05 UTC (rev 114143)
@@ -42,11 +42,13 @@
namespace WebKit {
class APIObject;
+class InjectedBundleBackForwardListItem;
class WebPage;
class WebFrame;
class InjectedBundlePageLoaderClient : public APIClient<WKBundlePageLoaderClient, kWKBundlePageLoaderClientCurrentVersion> {
public:
+ bool shouldGoToBackForwardListItem(WebPage*, InjectedBundleBackForwardListItem*, RefPtr<APIObject>& userData);
void didStartProvisionalLoadForFrame(WebPage*, WebFrame*, RefPtr<APIObject>& userData);
void didReceiveServerRedirectForProvisionalLoadForFrame(WebPage*, WebFrame*, RefPtr<APIObject>& userData);
void didFailProvisionalLoadWithErrorForFrame(WebPage*, WebFrame*, const WebCore::ResourceError&, RefPtr<APIObject>& userData);
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (114142 => 114143)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp 2012-04-13 17:43:58 UTC (rev 114142)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp 2012-04-13 17:46:05 UTC (rev 114143)
@@ -28,6 +28,7 @@
#include "AuthenticationManager.h"
#include "DataReference.h"
+#include "InjectedBundleBackForwardListItem.h"
#include "InjectedBundleNavigationAction.h"
#include "InjectedBundleUserMessageCoders.h"
#include "PlatformCertificateInfo.h"
@@ -930,13 +931,20 @@
ASSERT_NOT_REACHED();
return false;
}
+
+ RefPtr<InjectedBundleBackForwardListItem> bundleItem = InjectedBundleBackForwardListItem::create(item);
+ RefPtr<APIObject> userData;
+
+ // Ask the bundle client first
+ bool shouldGoToBackForwardListItem = webPage->injectedBundleLoaderClient().shouldGoToBackForwardListItem(webPage, bundleItem.get(), userData);
+ if (!shouldGoToBackForwardListItem)
+ return false;
if (webPage->willGoToBackForwardItemCallbackEnabled()) {
- webPage->send(Messages::WebPageProxy::WillGoToBackForwardListItem(itemID));
+ webPage->send(Messages::WebPageProxy::WillGoToBackForwardListItem(itemID, InjectedBundleUserMessageEncoder(userData.get())));
return true;
}
- bool shouldGoToBackForwardListItem;
if (!webPage->sendSync(Messages::WebPageProxy::ShouldGoToBackForwardListItem(itemID), Messages::WebPageProxy::ShouldGoToBackForwardListItem::Reply(shouldGoToBackForwardListItem)))
return false;
Modified: trunk/Source/WebKit2/WebProcess/qt/QtBuiltinBundlePage.cpp (114142 => 114143)
--- trunk/Source/WebKit2/WebProcess/qt/QtBuiltinBundlePage.cpp 2012-04-13 17:43:58 UTC (rev 114142)
+++ trunk/Source/WebKit2/WebProcess/qt/QtBuiltinBundlePage.cpp 2012-04-13 17:46:05 UTC (rev 114143)
@@ -69,6 +69,7 @@
0, // didLayoutForFrame
0, // didNewFirstVisuallyNonEmptyLayoutForFrame
0, // didDetectXSSForFrame
+ 0, // shouldGoToBackForwardListItem
};
WKBundlePageSetPageLoaderClient(m_page, &loaderClient);
}
Modified: trunk/Tools/ChangeLog (114142 => 114143)
--- trunk/Tools/ChangeLog 2012-04-13 17:43:58 UTC (rev 114142)
+++ trunk/Tools/ChangeLog 2012-04-13 17:46:05 UTC (rev 114143)
@@ -1,3 +1,28 @@
+2012-04-10 Brady Eidson <beid...@apple.com>
+
+ <rdar://problem/11176921> and https://bugs.webkit.org/show_bug.cgi?id=83600
+ Need WebKit2 API to notify whether history loads are in the page cache
+
+ Add a test ShouldGoToBackForwardListItem that exercises the new BundlePageLoaderClient
+ callback as well as the new WKBundleBackForwardListItemIsInPageCache() API.
+
+ Reviewed by Darin Adler.
+
+ * TestWebKitAPI/Tests/WebKit2/ShouldGoToBackForwardListItem.cpp: Added.
+ (TestWebKitAPI::didFinishLoadForFrame):
+ (TestWebKitAPI::willGoToBackForwardListItem):
+ (TestWebKitAPI::setPageLoaderClient):
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/Tests/WebKit2/ShouldGoToBackForwardListItem_Bundle.cpp: Added.
+ (ShouldGoToBackForwardListItemTest):
+ (TestWebKitAPI::shouldGoToBackForwardListItemCallback):
+ (TestWebKitAPI::ShouldGoToBackForwardListItemTest::ShouldGoToBackForwardListItemTest):
+ (TestWebKitAPI::ShouldGoToBackForwardListItemTest::didCreatePage):
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+
+ * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+ (WTR::InjectedBundlePage::InjectedBundlePage): Update for the new client.
+
2012-04-13 Dominik Röttsches <dominik.rottsc...@linux.intel.com>
Group EFL bots into a category on the buildbot master
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (114142 => 114143)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2012-04-13 17:43:58 UTC (rev 114142)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2012-04-13 17:46:05 UTC (rev 114143)
@@ -43,6 +43,8 @@
517E7DFC15110EA600D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 517E7DFB15110EA600D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.mm */; };
517E7E04151119C100D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 517E7E031511187500D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.html */; };
51FBBB4D1513D4E900822738 /* WebViewCanPasteURL.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51FBBB4C1513D4E900822738 /* WebViewCanPasteURL.mm */; };
+ 51FCF79A1534AC6D00104491 /* ShouldGoToBackForwardListItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51FCF7981534AC6D00104491 /* ShouldGoToBackForwardListItem.cpp */; };
+ 51FCF7A11534B2A000104491 /* ShouldGoToBackForwardListItem_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51FCF7971534AC6D00104491 /* ShouldGoToBackForwardListItem_Bundle.cpp */; };
520BCF4C141EB09E00937EA8 /* WebArchive_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 520BCF4A141EB09E00937EA8 /* WebArchive_Bundle.cpp */; };
520BCF4D141EB09E00937EA8 /* WebArchive.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 520BCF4B141EB09E00937EA8 /* WebArchive.cpp */; };
52CB47411448FB9300873995 /* LoadAlternateHTMLStringWithNonDirectoryURL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52CB47401448FB9300873995 /* LoadAlternateHTMLStringWithNonDirectoryURL.cpp */; };
@@ -233,6 +235,8 @@
517E7DFB15110EA600D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryCachePruneWithinResourceLoadDelegate.mm; sourceTree = "<group>"; };
517E7E031511187500D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = MemoryCachePruneWithinResourceLoadDelegate.html; sourceTree = "<group>"; };
51FBBB4C1513D4E900822738 /* WebViewCanPasteURL.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebViewCanPasteURL.mm; sourceTree = "<group>"; };
+ 51FCF7971534AC6D00104491 /* ShouldGoToBackForwardListItem_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShouldGoToBackForwardListItem_Bundle.cpp; sourceTree = "<group>"; };
+ 51FCF7981534AC6D00104491 /* ShouldGoToBackForwardListItem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShouldGoToBackForwardListItem.cpp; sourceTree = "<group>"; };
520BCF4A141EB09E00937EA8 /* WebArchive_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebArchive_Bundle.cpp; sourceTree = "<group>"; };
520BCF4B141EB09E00937EA8 /* WebArchive.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebArchive.cpp; sourceTree = "<group>"; };
52CB47401448FB9300873995 /* LoadAlternateHTMLStringWithNonDirectoryURL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadAlternateHTMLStringWithNonDirectoryURL.cpp; sourceTree = "<group>"; };
@@ -519,6 +523,8 @@
C0BD669C131D3CF700E18F2A /* ResponsivenessTimerDoesntFireEarly.cpp */,
C0BD669E131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp */,
C0ADBE8212FCA6AA00D2C129 /* RestoreSessionStateContainingFormData.cpp */,
+ 51FCF7981534AC6D00104491 /* ShouldGoToBackForwardListItem.cpp */,
+ 51FCF7971534AC6D00104491 /* ShouldGoToBackForwardListItem_Bundle.cpp */,
C02B77F1126612140026BF0F /* SpacebarScrolling.cpp */,
BC22D31314DC689800FFB1DD /* UserMessage.cpp */,
BC22D31714DC68B800FFB1DD /* UserMessage_Bundle.cpp */,
@@ -839,6 +845,7 @@
51FBBB4D1513D4E900822738 /* WebViewCanPasteURL.mm in Sources */,
5142B2711517C88B00C32B19 /* ContextMenuCanCopyURL.mm in Sources */,
C540F776152E4DA000A40C8C /* SimplifyMarkup.mm in Sources */,
+ 51FCF79A1534AC6D00104491 /* ShouldGoToBackForwardListItem.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -867,6 +874,7 @@
93F7E86F14DC8E5C00C84A99 /* NewFirstVisuallyNonEmptyLayoutFrames_Bundle.cpp in Sources */,
BC22D31914DC68B900FFB1DD /* UserMessage_Bundle.cpp in Sources */,
93AF4ECE1506F064007FD57E /* NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp in Sources */,
+ 51FCF7A11534B2A000104491 /* ShouldGoToBackForwardListItem_Bundle.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/ShouldGoToBackForwardListItem.cpp (0 => 114143)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/ShouldGoToBackForwardListItem.cpp (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/ShouldGoToBackForwardListItem.cpp 2012-04-13 17:46:05 UTC (rev 114143)
@@ -0,0 +1,92 @@
+/*
+ * 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 "Test.h"
+
+#include <WebKit2/WKString.h>
+
+namespace TestWebKitAPI {
+
+static bool finished = false;
+static bool receivedProperBackForwardCallbacks = false;
+
+static void didFinishLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef, const void*)
+{
+ // Only mark finished when the main frame loads
+ if (WKFrameGetParentFrame(frame))
+ return;
+
+ finished = true;
+}
+
+static void willGoToBackForwardListItem(WKPageRef, WKBackForwardListItemRef, WKTypeRef userData, const void*)
+{
+ if (WKGetTypeID(userData) == WKStringGetTypeID()) {
+ if (WKStringIsEqualToUTF8CString((WKStringRef)userData, "shouldGoToBackForwardListItemCallback called as expected"))
+ receivedProperBackForwardCallbacks = true;
+ }
+
+ finished = true;
+}
+
+static void setPageLoaderClient(WKPageRef page)
+{
+ WKPageLoaderClient loaderClient;
+ memset(&loaderClient, 0, sizeof(loaderClient));
+ loaderClient.version = 1;
+ loaderClient.clientInfo = 0;
+ loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
+ loaderClient.willGoToBackForwardListItem = willGoToBackForwardListItem;
+
+ WKPageSetPageLoaderClient(page, &loaderClient);
+}
+
+TEST(WebKit2, ShouldGoToBackForwardListItem)
+{
+ WKRetainPtr<WKContextRef> context = adoptWK(Util::createContextForInjectedBundleTest("ShouldGoToBackForwardListItemTest"));
+ // Enable the page cache so we can test the WKBundleBackForwardListItemIsInPageCache API
+ WKContextSetCacheModel(context.get(), kWKCacheModelDocumentBrowser);
+
+ PlatformWebView webView(context.get());
+ setPageLoaderClient(webView.page());
+
+ WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("simple", "html")).get());
+ Util::run(&finished);
+
+ finished = false;
+ WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("simple-iframe", "html")).get());
+ Util::run(&finished);
+
+ finished = false;
+ WKPageGoBack(webView.page());
+ Util::run(&finished);
+
+ EXPECT_EQ(receivedProperBackForwardCallbacks, true);
+}
+
+} // namespace TestWebKitAPI
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/ShouldGoToBackForwardListItem_Bundle.cpp (0 => 114143)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/ShouldGoToBackForwardListItem_Bundle.cpp (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/ShouldGoToBackForwardListItem_Bundle.cpp 2012-04-13 17:46:05 UTC (rev 114143)
@@ -0,0 +1,70 @@
+/*
+ * 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 "InjectedBundleTest.h"
+
+#include "PlatformUtilities.h"
+#include <WebKit2/WKBundlePage.h>
+#include <WebKit2/WKBundleBackForwardListItem.h>
+
+namespace TestWebKitAPI {
+
+class ShouldGoToBackForwardListItemTest : public InjectedBundleTest {
+public:
+ ShouldGoToBackForwardListItemTest(const std::string& identifier);
+
+ virtual void didCreatePage(WKBundleRef bundle, WKBundlePageRef page);
+};
+
+static InjectedBundleTest::Register<ShouldGoToBackForwardListItemTest> registrar("ShouldGoToBackForwardListItemTest");
+
+static bool shouldGoToBackForwardListItemCallback(WKBundlePageRef, WKBundleBackForwardListItemRef item, WKTypeRef* userData, const void*)
+{
+ // The item should be in the page cache
+ if (WKBundleBackForwardListItemIsInPageCache(item))
+ *userData = WKStringCreateWithUTF8CString("shouldGoToBackForwardListItemCallback called as expected");
+
+ return true;
+}
+
+ShouldGoToBackForwardListItemTest::ShouldGoToBackForwardListItemTest(const std::string& identifier)
+ : InjectedBundleTest(identifier)
+{
+}
+
+void ShouldGoToBackForwardListItemTest::didCreatePage(WKBundleRef bundle, WKBundlePageRef page)
+{
+ WKBundlePageLoaderClient pageLoaderClient;
+ memset(&pageLoaderClient, 0, sizeof(pageLoaderClient));
+
+ pageLoaderClient.version = 1;
+ pageLoaderClient.clientInfo = this;
+ pageLoaderClient.shouldGoToBackForwardListItem = shouldGoToBackForwardListItemCallback;
+
+ WKBundlePageSetPageLoaderClient(page, &pageLoaderClient);
+}
+
+} // namespace TestWebKitAPI
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp (114142 => 114143)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp 2012-04-13 17:43:58 UTC (rev 114142)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp 2012-04-13 17:46:05 UTC (rev 114143)
@@ -235,6 +235,7 @@
0, // didLayoutForFrame
0, // didNewFirstVisuallyNonEmptyLayoutForFrame
didDetectXSSForFrame,
+ 0, // shouldGoToBackForwardListItem
};
WKBundlePageSetPageLoaderClient(m_page, &loaderClient);