<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[168407] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/168407">168407</a></dd>
<dt>Author</dt> <dd>beidson@apple.com</dd>
<dt>Date</dt> <dd>2014-05-06 21:50:57 -0700 (Tue, 06 May 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add WK2 SPI to prevent the previous back/forward item from remaining in the list
<rdar://problem/16248710> and https://bugs.webkit.org/show_bug.cgi?id=132636
Reviewed by Sam Weinig.
Source/WebKit2:
Add new PageLoaderClient SPI to keep the current back/forward item from remaining in the list:
* UIProcess/API/APILoaderClient.h:
(API::LoaderClient::shouldKeepCurrentBackForwardListItemInList):
* UIProcess/API/C/WKPage.cpp:
(WKPageSetPageLoaderClient):
* UIProcess/API/C/WKPageLoaderClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::shouldKeepCurrentBackForwardListItemInList):
* UIProcess/WebPageProxy.h:
* UIProcess/WebBackForwardList.cpp:
(WebKit::WebBackForwardList::addItem): Use that SPI to determine whether we should insert the new item after
the previous item, or simply replace the previous item.
(WebKit::WebBackForwardList::goToItem): Use that SPI to determine whether the previous item stays or goes.
Tools:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2/ShouldKeepCurrentBackForwardListItemInList.cpp: Added.
(TestWebKitAPI::itemURLLastComponentIsString):
(TestWebKitAPI::didFinishLoadForFrame):
(TestWebKitAPI::willGoToBackForwardListItem):
(TestWebKitAPI::shouldKeepCurrentBackForwardListItemInList):
(TestWebKitAPI::setPageLoaderClient):
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebKit2/simple2.html: Added.
* TestWebKitAPI/Tests/WebKit2/simple3.html: Added.
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::createWebViewWithOptions): Update for new client layout.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIAPILoaderClienth">trunk/Source/WebKit2/UIProcess/API/APILoaderClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICWKPagecpp">trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICWKPageLoaderClienth">trunk/Source/WebKit2/UIProcess/API/C/WKPageLoaderClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebBackForwardListcpp">trunk/Source/WebKit2/UIProcess/WebBackForwardList.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkToolsWebKitTestRunnerTestControllercpp">trunk/Tools/WebKitTestRunner/TestController.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2ShouldKeepCurrentBackForwardListItemInListcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2/ShouldKeepCurrentBackForwardListItemInList.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2simple2html">trunk/Tools/TestWebKitAPI/Tests/WebKit2/simple2.html</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2simple3html">trunk/Tools/TestWebKitAPI/Tests/WebKit2/simple3.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (168406 => 168407)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-05-07 04:01:25 UTC (rev 168406)
+++ trunk/Source/WebKit2/ChangeLog        2014-05-07 04:50:57 UTC (rev 168407)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2014-05-06 Brady Eidson <beidson@apple.com>
+
+ Add WK2 SPI to prevent the previous back/forward item from remaining in the list
+ <rdar://problem/16248710> and https://bugs.webkit.org/show_bug.cgi?id=132636
+
+ Reviewed by Sam Weinig.
+
+ Add new PageLoaderClient SPI to keep the current back/forward item from remaining in the list:
+ * UIProcess/API/APILoaderClient.h:
+ (API::LoaderClient::shouldKeepCurrentBackForwardListItemInList):
+ * UIProcess/API/C/WKPage.cpp:
+ (WKPageSetPageLoaderClient):
+ * UIProcess/API/C/WKPageLoaderClient.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::shouldKeepCurrentBackForwardListItemInList):
+ * UIProcess/WebPageProxy.h:
+
+ * UIProcess/WebBackForwardList.cpp:
+ (WebKit::WebBackForwardList::addItem): Use that SPI to determine whether we should insert the new item after
+ the previous item, or simply replace the previous item.
+ (WebKit::WebBackForwardList::goToItem): Use that SPI to determine whether the previous item stays or goes.
+
</ins><span class="cx"> 2014-05-06 Dan Bernstein <mitz@apple.com>
</span><span class="cx">
</span><span class="cx"> -[WKWebView isLoading] is NO immediately after -loadRequest: until the provisional load starts
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIAPILoaderClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/APILoaderClient.h (168406 => 168407)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/APILoaderClient.h        2014-05-07 04:01:25 UTC (rev 168406)
+++ trunk/Source/WebKit2/UIProcess/API/APILoaderClient.h        2014-05-07 04:50:57 UTC (rev 168407)
</span><span class="lines">@@ -90,6 +90,7 @@
</span><span class="cx"> virtual void processDidCrash(WebKit::WebPageProxy*) { }
</span><span class="cx">
</span><span class="cx"> virtual void didChangeBackForwardList(WebKit::WebPageProxy*, WebKit::WebBackForwardListItem*, Vector<RefPtr<WebKit::WebBackForwardListItem>>) { }
</span><ins>+ virtual bool shouldKeepCurrentBackForwardListItemInList(WebKit::WebPageProxy*, WebKit::WebBackForwardListItem*) { return true; }
</ins><span class="cx"> virtual void willGoToBackForwardListItem(WebKit::WebPageProxy*, WebKit::WebBackForwardListItem*, API::Object*) { }
</span><span class="cx">
</span><span class="cx"> virtual PassRefPtr<Data> webCryptoMasterKey(WebKit::WebPageProxy&) { return nullptr; }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICWKPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp (168406 => 168407)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp        2014-05-07 04:01:25 UTC (rev 168406)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp        2014-05-07 04:50:57 UTC (rev 168407)
</span><span class="lines">@@ -968,6 +968,14 @@
</span><span class="cx"> m_client.didChangeBackForwardList(toAPI(page), toAPI(addedItem), toAPI(removedItemsArray.get()), m_client.base.clientInfo);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ virtual bool shouldKeepCurrentBackForwardListItemInList(WebKit::WebPageProxy* page, WebKit::WebBackForwardListItem* item) override
+ {
+ if (!m_client.shouldKeepCurrentBackForwardListItemInList)
+ return false;
+
+ return m_client.shouldKeepCurrentBackForwardListItemInList(toAPI(page), toAPI(item));
+ }
+
</ins><span class="cx"> virtual void willGoToBackForwardListItem(WebPageProxy* page, WebBackForwardListItem* item, API::Object* userData) override
</span><span class="cx"> {
</span><span class="cx"> if (m_client.willGoToBackForwardListItem)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICWKPageLoaderClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPageLoaderClient.h (168406 => 168407)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/C/WKPageLoaderClient.h        2014-05-07 04:01:25 UTC (rev 168406)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPageLoaderClient.h        2014-05-07 04:50:57 UTC (rev 168407)
</span><span class="lines">@@ -69,6 +69,7 @@
</span><span class="cx"> typedef void (*WKPageDidReceiveAuthenticationChallengeInFrameCallback)(WKPageRef page, WKFrameRef frame, WKAuthenticationChallengeRef authenticationChallenge, const void *clientInfo);
</span><span class="cx"> typedef void (*WKPageDidChangeBackForwardListCallback)(WKPageRef page, WKBackForwardListItemRef addedItem, WKArrayRef removedItems, const void *clientInfo);
</span><span class="cx"> typedef bool (*WKPageShouldGoToBackForwardListItemCallback)(WKPageRef page, WKBackForwardListItemRef item, const void *clientInfo);
</span><ins>+typedef bool (*WKPageShouldKeepCurrentBackForwardListItemInListCallback)(WKPageRef page, WKBackForwardListItemRef item);
</ins><span class="cx"> typedef void (*WKPageWillGoToBackForwardListItemCallback)(WKPageRef page, WKBackForwardListItemRef item, WKTypeRef userData, const void *clientInfo);
</span><span class="cx"> typedef void (*WKPageDidLayoutCallback)(WKPageRef page, WKLayoutMilestones milestones, WKTypeRef userData, const void *clientInfo);
</span><span class="cx"> typedef WKPluginLoadPolicy (*WKPagePluginLoadPolicyCallback)(WKPageRef page, WKPluginLoadPolicy currentPluginLoadPolicy, WKDictionaryRef pluginInfoDictionary, WKStringRef* unavailabilityDescription, const void* clientInfo);
</span><span class="lines">@@ -332,6 +333,7 @@
</span><span class="cx"> // Version 4
</span><span class="cx"> WKPageWebGLLoadPolicyCallback webGLLoadPolicy;
</span><span class="cx"> WKPageWebGLLoadPolicyCallback resolveWebGLLoadPolicy;
</span><ins>+ WKPageShouldKeepCurrentBackForwardListItemInListCallback shouldKeepCurrentBackForwardListItemInList;
</ins><span class="cx"> } WKPageLoaderClientV4;
</span><span class="cx">
</span><span class="cx"> // FIXME: These should be deprecated.
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebBackForwardListcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebBackForwardList.cpp (168406 => 168407)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebBackForwardList.cpp        2014-05-07 04:01:25 UTC (rev 168406)
+++ trunk/Source/WebKit2/UIProcess/WebBackForwardList.cpp        2014-05-07 04:50:57 UTC (rev 168407)
</span><span class="lines">@@ -113,20 +113,35 @@
</span><span class="cx"> }
</span><span class="cx"> m_entries.clear();
</span><span class="cx"> }
</span><del>-
</del><ins>+
+ bool shouldKeepCurrentItem = true;
+
</ins><span class="cx"> if (!m_hasCurrentIndex) {
</span><span class="cx"> ASSERT(m_entries.isEmpty());
</span><span class="cx"> m_currentIndex = 0;
</span><span class="cx"> m_hasCurrentIndex = true;
</span><del>- } else
- m_currentIndex++;
</del><ins>+ } else {
+ shouldKeepCurrentItem = m_page->shouldKeepCurrentBackForwardListItemInList(m_entries[m_currentIndex].get());
+ if (shouldKeepCurrentItem)
+ m_currentIndex++;
+ }
</ins><span class="cx">
</span><del>- // m_current never be pointing more than 1 past the end of the entries Vector.
- // If it is, something has gone wrong and we should not try to insert the new item.
- ASSERT(m_currentIndex <= m_entries.size());
- if (m_currentIndex <= m_entries.size())
- m_entries.insert(m_currentIndex, newItem);
</del><ins>+ if (!shouldKeepCurrentItem) {
+ // m_current never be pointing past the end of the entries Vector.
+ // If it is, something has gone wrong and we should not try to swap in the new item.
+ ASSERT(m_currentIndex < m_entries.size());
</ins><span class="cx">
</span><ins>+ removedItems.append(m_entries[m_currentIndex]);
+ m_entries[m_currentIndex] = newItem;
+ } else {
+ // m_current never be pointing more than 1 past the end of the entries Vector.
+ // If it is, something has gone wrong and we should not try to insert the new item.
+ ASSERT(m_currentIndex <= m_entries.size());
+
+ if (m_currentIndex <= m_entries.size())
+ m_entries.insert(m_currentIndex, newItem);
+ }
+
</ins><span class="cx"> m_page->didChangeBackForwardList(newItem, std::move(removedItems));
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -136,16 +151,32 @@
</span><span class="cx">
</span><span class="cx"> if (!m_entries.size() || !item || !m_page || !m_hasCurrentIndex)
</span><span class="cx"> return;
</span><del>-
- unsigned index = 0;
- for (; index < m_entries.size(); ++index) {
- if (m_entries[index] == item)
- break;
</del><ins>+
+ size_t targetIndex = m_entries.find(item);
+
+ // If the target item wasn't even in the list, there's nothing else to do.
+ if (targetIndex == notFound)
+ return;
+
+ // If we're going to an item different from the current item, ask the client if the current
+ // item should remain in the list.
+ WebBackForwardListItem* currentItem = m_entries[m_currentIndex].get();
+ bool shouldKeepCurrentItem = true;
+ if (currentItem != item)
+ shouldKeepCurrentItem = m_page->shouldKeepCurrentBackForwardListItemInList(m_entries[m_currentIndex].get());
+
+ // If the client said to remove the current item, remove it and then update the target index.
+ Vector<RefPtr<WebBackForwardListItem>> removedItems;
+ if (!shouldKeepCurrentItem) {
+ removedItems.append(currentItem);
+ m_entries.remove(m_currentIndex);
+ targetIndex = m_entries.find(item);
+
+ ASSERT(targetIndex != notFound);
</ins><span class="cx"> }
</span><del>- if (index < m_entries.size()) {
- m_currentIndex = index;
- m_page->didChangeBackForwardList(nullptr, { });
- }
</del><ins>+
+ m_currentIndex = targetIndex;
+ m_page->didChangeBackForwardList(nullptr, removedItems);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> WebBackForwardListItem* WebBackForwardList::currentItem() const
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (168406 => 168407)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2014-05-07 04:01:25 UTC (rev 168406)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2014-05-07 04:50:57 UTC (rev 168407)
</span><span class="lines">@@ -908,6 +908,11 @@
</span><span class="cx"> m_loaderClient->willGoToBackForwardListItem(this, item, userData.get());
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+bool WebPageProxy::shouldKeepCurrentBackForwardListItemInList(WebBackForwardListItem* item)
+{
+ return m_loaderClient->shouldKeepCurrentBackForwardListItemInList(this, item);
+}
+
</ins><span class="cx"> bool WebPageProxy::canShowMIMEType(const String& mimeType)
</span><span class="cx"> {
</span><span class="cx"> if (MIMETypeRegistry::canShowMIMEType(mimeType))
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (168406 => 168407)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-05-07 04:01:25 UTC (rev 168406)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-05-07 04:50:57 UTC (rev 168407)
</span><span class="lines">@@ -524,6 +524,8 @@
</span><span class="cx"> void didChangeBackForwardList(WebBackForwardListItem* addedItem, Vector<RefPtr<WebBackForwardListItem>> removed);
</span><span class="cx"> void willGoToBackForwardListItem(uint64_t itemID, IPC::MessageDecoder&);
</span><span class="cx">
</span><ins>+ bool shouldKeepCurrentBackForwardListItemInList(WebBackForwardListItem*);
+
</ins><span class="cx"> bool willHandleHorizontalScrollEvents() const;
</span><span class="cx">
</span><span class="cx"> bool canShowMIMEType(const String& mimeType);
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (168406 => 168407)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2014-05-07 04:01:25 UTC (rev 168406)
+++ trunk/Tools/ChangeLog        2014-05-07 04:50:57 UTC (rev 168407)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2014-05-06 Brady Eidson <beidson@apple.com>
+
+ Add WK2 SPI to prevent the previous back/forward item from remaining in the list
+ <rdar://problem/16248710> and https://bugs.webkit.org/show_bug.cgi?id=132636
+
+ Reviewed by Sam Weinig.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+
+ * TestWebKitAPI/Tests/WebKit2/ShouldKeepCurrentBackForwardListItemInList.cpp: Added.
+ (TestWebKitAPI::itemURLLastComponentIsString):
+ (TestWebKitAPI::didFinishLoadForFrame):
+ (TestWebKitAPI::willGoToBackForwardListItem):
+ (TestWebKitAPI::shouldKeepCurrentBackForwardListItemInList):
+ (TestWebKitAPI::setPageLoaderClient):
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/Tests/WebKit2/simple2.html: Added.
+ * TestWebKitAPI/Tests/WebKit2/simple3.html: Added.
+
+ * WebKitTestRunner/TestController.cpp:
+ (WTR::TestController::createWebViewWithOptions): Update for new client layout.
+
</ins><span class="cx"> 2014-05-06 Darin Adler <darin@apple.com>
</span><span class="cx">
</span><span class="cx"> Try to fix iOS build.
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (168406 => 168407)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2014-05-07 04:01:25 UTC (rev 168406)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2014-05-07 04:50:57 UTC (rev 168407)
</span><span class="lines">@@ -96,6 +96,9 @@
</span><span class="cx">                 5142B2731517C8C800C32B19 /* ContextMenuCanCopyURL.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5142B2721517C89100C32B19 /* ContextMenuCanCopyURL.html */; };
</span><span class="cx">                 517E7DFC15110EA600D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 517E7DFB15110EA600D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.mm */; };
</span><span class="cx">                 517E7E04151119C100D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 517E7E031511187500D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.html */; };
</span><ins>+                51E5C7021919C3B200D8B3E1 /* simple2.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51E780361919AFF8001829A2 /* simple2.html */; };
+                51E5C7031919C3B200D8B3E1 /* simple3.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51E780371919AFF8001829A2 /* simple3.html */; };
+                51E5C7051919EA5F00D8B3E1 /* ShouldKeepCurrentBackForwardListItemInList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51E5C7041919EA5F00D8B3E1 /* ShouldKeepCurrentBackForwardListItemInList.cpp */; };
</ins><span class="cx">                 51E93017156B13E1004C99DF /* WKPageGetScaleFactorNotZero.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51E93016156B13E1004C99DF /* WKPageGetScaleFactorNotZero.cpp */; };
</span><span class="cx">                 51FBBB4D1513D4E900822738 /* WebViewCanPasteURL.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51FBBB4C1513D4E900822738 /* WebViewCanPasteURL.mm */; };
</span><span class="cx">                 51FCF79A1534AC6D00104491 /* ShouldGoToBackForwardListItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51FCF7981534AC6D00104491 /* ShouldGoToBackForwardListItem.cpp */; };
</span><span class="lines">@@ -279,6 +282,8 @@
</span><span class="cx">                         dstPath = TestWebKitAPI.resources;
</span><span class="cx">                         dstSubfolderSpec = 7;
</span><span class="cx">                         files = (
</span><ins>+                                51E5C7021919C3B200D8B3E1 /* simple2.html in Copy Resources */,
+                                51E5C7031919C3B200D8B3E1 /* simple3.html in Copy Resources */,
</ins><span class="cx">                                 290A9BB91735F63800D71BBC /* OpenNewWindow.html in Copy Resources */,
</span><span class="cx">                                 290F4275172A221C00939FF0 /* custom-protocol-sync-xhr.html in Copy Resources */,
</span><span class="cx">                                 C2CF975B16CEC71B0054E99D /* JSContextBackForwardCache1.html in Copy Resources */,
</span><span class="lines">@@ -426,6 +431,9 @@
</span><span class="cx">                 5142B2721517C89100C32B19 /* ContextMenuCanCopyURL.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = ContextMenuCanCopyURL.html; sourceTree = "<group>"; };
</span><span class="cx">                 517E7DFB15110EA600D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryCachePruneWithinResourceLoadDelegate.mm; sourceTree = "<group>"; };
</span><span class="cx">                 517E7E031511187500D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = MemoryCachePruneWithinResourceLoadDelegate.html; sourceTree = "<group>"; };
</span><ins>+                51E5C7041919EA5F00D8B3E1 /* ShouldKeepCurrentBackForwardListItemInList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShouldKeepCurrentBackForwardListItemInList.cpp; sourceTree = "<group>"; };
+                51E780361919AFF8001829A2 /* simple2.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = simple2.html; sourceTree = "<group>"; };
+                51E780371919AFF8001829A2 /* simple3.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = simple3.html; sourceTree = "<group>"; };
</ins><span class="cx">                 51E93016156B13E1004C99DF /* WKPageGetScaleFactorNotZero.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKPageGetScaleFactorNotZero.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 51FBBB4C1513D4E900822738 /* WebViewCanPasteURL.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebViewCanPasteURL.mm; sourceTree = "<group>"; };
</span><span class="cx">                 51FCF7971534AC6D00104491 /* ShouldGoToBackForwardListItem_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShouldGoToBackForwardListItem_Bundle.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -541,7 +549,7 @@
</span><span class="cx">                 BCC8B95A12611F4700DE46A4 /* FailedLoad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FailedLoad.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 C01363C713C3997300EF3964 /* StringOperators.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringOperators.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 C02B77F1126612140026BF0F /* SpacebarScrolling.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpacebarScrolling.cpp; sourceTree = "<group>"; };
</span><del>-                C02B7853126613AE0026BF0F /* Carbon.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Carbon.framework; sourceTree = SDKROOT; };
</del><ins>+                C02B7853126613AE0026BF0F /* Carbon.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Carbon.framework; sourceTree = SDKROOT; };
</ins><span class="cx">                 C02B7882126615410026BF0F /* spacebar-scrolling.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "spacebar-scrolling.html"; sourceTree = "<group>"; };
</span><span class="cx">                 C045F9441385C2E900C0F3CD /* DownloadDecideDestinationCrash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DownloadDecideDestinationCrash.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 C045F9461385C2F800C0F3CD /* 18-characters.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "18-characters.html"; sourceTree = "<group>"; };
</span><span class="lines">@@ -826,6 +834,7 @@
</span><span class="cx">                                 2D640B5417875DFF00BFAF99 /* ScrollPinningBehaviors.cpp */,
</span><span class="cx">                                 51FCF7981534AC6D00104491 /* ShouldGoToBackForwardListItem.cpp */,
</span><span class="cx">                                 51FCF7971534AC6D00104491 /* ShouldGoToBackForwardListItem_Bundle.cpp */,
</span><ins>+                                51E5C7041919EA5F00D8B3E1 /* ShouldKeepCurrentBackForwardListItemInList.cpp */,
</ins><span class="cx">                                 C02B77F1126612140026BF0F /* SpacebarScrolling.cpp */,
</span><span class="cx">                                 1AE72F47173EB214006362F0 /* TerminateTwice.cpp */,
</span><span class="cx">                                 BC22D31314DC689800FFB1DD /* UserMessage.cpp */,
</span><span class="lines">@@ -911,6 +920,8 @@
</span><span class="cx">                                 33DC890E1419539300747EF7 /* simple-iframe.html */,
</span><span class="cx">                                 BCAA485514A021640088FAC4 /* simple-tall.html */,
</span><span class="cx">                                 BC909778125571AB00083756 /* simple.html */,
</span><ins>+                                51E780361919AFF8001829A2 /* simple2.html */,
+                                51E780371919AFF8001829A2 /* simple3.html */,
</ins><span class="cx">                                 C02B7882126615410026BF0F /* spacebar-scrolling.html */,
</span><span class="cx">                         );
</span><span class="cx">                         name = Resources;
</span><span class="lines">@@ -1249,6 +1260,7 @@
</span><span class="cx">                                 52E5CE4614D21E9D003B2BD8 /* ParentFrame.cpp in Sources */,
</span><span class="cx">                                 C54237F016B8955800E638FC /* PasteboardNotifications.mm in Sources */,
</span><span class="cx">                                 BC575BC0126F5752006F0F12 /* PlatformUtilities.cpp in Sources */,
</span><ins>+                                51E5C7051919EA5F00D8B3E1 /* ShouldKeepCurrentBackForwardListItemInList.cpp in Sources */,
</ins><span class="cx">                                 BC131885117114B600B69727 /* PlatformUtilitiesMac.mm in Sources */,
</span><span class="cx">                                 BC90955D125548AA00083756 /* PlatformWebViewMac.mm in Sources */,
</span><span class="cx">                                 333B9CE21277F23100FEFCE3 /* PreventEmptyUserAgent.cpp in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2ShouldKeepCurrentBackForwardListItemInListcpp"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/ShouldKeepCurrentBackForwardListItemInList.cpp (0 => 168407)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/ShouldKeepCurrentBackForwardListItemInList.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/ShouldKeepCurrentBackForwardListItemInList.cpp        2014-05-07 04:50:57 UTC (rev 168407)
</span><span class="lines">@@ -0,0 +1,158 @@
</span><ins>+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "PlatformUtilities.h"
+#include "PlatformWebView.h"
+#include "Test.h"
+
+// This test navigates from simple.html, to simple2.html, to simple3.html
+// When navigating from simple2 to simple3, it disallows the simple2 back/forward list item from staying in the list
+// It then navigates back from simple3, expecting to land at simple.
+
+namespace TestWebKitAPI {
+
+static bool finished = false;
+static bool successfulSoFar = true;
+static int navigationNumber = 0;
+
+static bool itemURLLastComponentIsString(WKBackForwardListItemRef item, const char* string)
+{
+ WKRetainPtr<WKURLRef> url = adoptWK(WKBackForwardListItemCopyURL(item));
+ WKRetainPtr<WKStringRef> path = adoptWK(WKURLCopyLastPathComponent(url.get()));
+
+ return WKStringIsEqualToUTF8CString(path.get(), string);
+}
+
+static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef, const void*)
+{
+ // Only mark finished when the main frame loads
+ if (!WKFrameIsMainFrame(frame))
+ return;
+
+ finished = true;
+ navigationNumber++;
+
+ WKBackForwardListRef list = WKPageGetBackForwardList(page);
+ WKBackForwardListItemRef currentItem = WKBackForwardListGetCurrentItem(list);
+ WKBackForwardListItemRef backItem = WKBackForwardListGetBackItem(list);
+ WKBackForwardListItemRef forwardItem = WKBackForwardListGetForwardItem(list);
+ unsigned forwardCount = WKBackForwardListGetForwardListCount(list);
+
+ // This test should never have a forward list.
+ if (forwardCount)
+ successfulSoFar = false;
+
+ if (navigationNumber == 1) {
+ // We've only performed 1 navigation, we should only have a current item.
+ if (!currentItem || !itemURLLastComponentIsString(currentItem, "simple.html"))
+ successfulSoFar = false;
+ if (backItem || forwardItem)
+ successfulSoFar = false;
+ } else if (navigationNumber == 2) {
+ // On the second navigation, simple2 should be current and simple should be the back item.
+ if (!currentItem || !itemURLLastComponentIsString(currentItem, "simple2.html"))
+ successfulSoFar = false;
+ if (!backItem || !itemURLLastComponentIsString(backItem, "simple.html"))
+ successfulSoFar = false;
+ if (forwardItem)
+ successfulSoFar = false;
+ } else if (navigationNumber == 3) {
+ // On the third navigation the item for simple2 should have been removed.
+ // So simple3 should be current and simple should still be the back item.
+ if (!currentItem || !itemURLLastComponentIsString(currentItem, "simple3.html"))
+ successfulSoFar = false;
+ if (!backItem || !itemURLLastComponentIsString(backItem, "simple.html"))
+ successfulSoFar = false;
+ if (forwardItem)
+ successfulSoFar = false;
+ } else if (navigationNumber == 4) {
+ // After the fourth navigation (which was a "back" navigation), the item for simple3 should have been removed.
+ // So simple should be current and there should be no other items.
+ if (!currentItem || !itemURLLastComponentIsString(currentItem, "simple.html"))
+ successfulSoFar = false;
+ if (backItem || forwardItem)
+ successfulSoFar = false;
+ }
+}
+
+static void willGoToBackForwardListItem(WKPageRef, WKBackForwardListItemRef item, WKTypeRef userData, const void*)
+{
+ if (!itemURLLastComponentIsString(item, "simple.html"))
+ successfulSoFar = false;
+}
+
+static bool shouldKeepCurrentBackForwardListItemInList(WKPageRef page, WKBackForwardListItemRef item)
+{
+ // We make sure the item for "simple2.html" is removed when we navigate to "simple3.html"
+ // We also want to make sure the item for "simple3.html" is removed when we go back to "simple.html"
+ // So we only want to keep "simple.html"
+ return itemURLLastComponentIsString(item, "simple.html");
+}
+
+static void setPageLoaderClient(WKPageRef page)
+{
+ WKPageLoaderClientV4 loaderClient;
+ memset(&loaderClient, 0, sizeof(loaderClient));
+
+ loaderClient.base.version = 4;
+ loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
+ loaderClient.shouldKeepCurrentBackForwardListItemInList = shouldKeepCurrentBackForwardListItemInList;
+ loaderClient.willGoToBackForwardListItem = willGoToBackForwardListItem;
+
+ WKPageSetPageLoaderClient(page, &loaderClient.base);
+}
+
+TEST(WebKit2, ShouldKeepCurrentBackForwardListItemInList)
+{
+ WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
+
+ PlatformWebView webView(context.get());
+ setPageLoaderClient(webView.page());
+
+ WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("simple", "html")).get());
+ Util::run(&finished);
+ EXPECT_EQ(successfulSoFar, true);
+
+ finished = false;
+ WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("simple2", "html")).get());
+ Util::run(&finished);
+ EXPECT_EQ(successfulSoFar, true);
+
+ finished = false;
+ WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("simple3", "html")).get());
+ Util::run(&finished);
+ EXPECT_EQ(successfulSoFar, true);
+
+ finished = false;
+ WKPageGoBack(webView.page());
+ Util::run(&finished);
+
+ EXPECT_EQ(successfulSoFar, true);
+ EXPECT_EQ(navigationNumber, 4);
+}
+
+} // namespace TestWebKitAPI
+
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2simple2html"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/simple2.html (0 => 168407)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/simple2.html         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/simple2.html        2014-05-07 04:50:57 UTC (rev 168407)
</span><span class="lines">@@ -0,0 +1,5 @@
</span><ins>+<html>
+<body>
+ Second simple HTML file.
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2simple3html"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/simple3.html (0 => 168407)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/simple3.html         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/simple3.html        2014-05-07 04:50:57 UTC (rev 168407)
</span><span class="lines">@@ -0,0 +1,5 @@
</span><ins>+<html>
+<body>
+ Third simple HTML file.
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (168406 => 168407)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/TestController.cpp        2014-05-07 04:01:25 UTC (rev 168406)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp        2014-05-07 04:50:57 UTC (rev 168407)
</span><span class="lines">@@ -499,6 +499,7 @@
</span><span class="cx"> pluginLoadPolicy, // pluginLoadPolicy
</span><span class="cx"> 0, // webGLLoadPolicy
</span><span class="cx"> 0, // resolveWebGLLoadPolicy
</span><ins>+ 0, // shouldKeepCurrentBackForwardListItemInList
</ins><span class="cx"> };
</span><span class="cx"> WKPageSetPageLoaderClient(m_mainWebView->page(), &pageLoaderClient.base);
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>