<!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>[207958] releases/WebKitGTK/webkit-2.14</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/207958">207958</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2016-10-27 01:27:20 -0700 (Thu, 27 Oct 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/207325">r207325</a> - WebView and WebPage URLs not updated after URL is modified by InjectedBundlePageResourceLoadClient::willSendRequestForFrame
https://bugs.webkit.org/show_bug.cgi?id=146306

Reviewed by Darin Adler.

Source/WebCore:

Notify about the provisional URL change when new request set for main resource load in DocumentLoader has a
different URL than the previous one.

* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::setRequest):

Tools:

Add unit test to check that the committed URL is updated when changed in willSendRequest callback.

* TestWebKitAPI/CMakeLists.txt:
* TestWebKitAPI/PlatformEfl.cmake:
* TestWebKitAPI/PlatformGTK.cmake:
* TestWebKitAPI/Tests/WebKit2/ProvisionalURLAfterWillSendRequestCallback.cpp: Added.
(TestWebKitAPI::didCommitLoadForFrame):
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebKit2/ProvisionalURLAfterWillSendRequestCallback_Bundle.cpp: Added.
(TestWebKitAPI::ProvisionalURLAfterWillSendRequestCallbackTest::ProvisionalURLAfterWillSendRequestCallbackTest):
(TestWebKitAPI::ProvisionalURLAfterWillSendRequestCallbackTest::willSendRequestForFrame):
(TestWebKitAPI::ProvisionalURLAfterWillSendRequestCallbackTest::didCommitLoadForFrame):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit214SourceWebCoreChangeLog">releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit214SourceWebCoreloaderDocumentLoadercpp">releases/WebKitGTK/webkit-2.14/Source/WebCore/loader/DocumentLoader.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit214ToolsChangeLog">releases/WebKitGTK/webkit-2.14/Tools/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit214ToolsTestWebKitAPICMakeListstxt">releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/CMakeLists.txt</a></li>
<li><a href="#releasesWebKitGTKwebkit214ToolsTestWebKitAPIPlatformEflcmake">releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/PlatformEfl.cmake</a></li>
<li><a href="#releasesWebKitGTKwebkit214ToolsTestWebKitAPIPlatformGTKcmake">releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/PlatformGTK.cmake</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit214ToolsTestWebKitAPITestsWebKit2ProvisionalURLAfterWillSendRequestCallbackcpp">releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/Tests/WebKit2/ProvisionalURLAfterWillSendRequestCallback.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit214ToolsTestWebKitAPITestsWebKit2ProvisionalURLAfterWillSendRequestCallback_Bundlecpp">releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/Tests/WebKit2/ProvisionalURLAfterWillSendRequestCallback_Bundle.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit214SourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog (207957 => 207958)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog        2016-10-27 08:25:16 UTC (rev 207957)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog        2016-10-27 08:27:20 UTC (rev 207958)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2016-10-13  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        WebView and WebPage URLs not updated after URL is modified by InjectedBundlePageResourceLoadClient::willSendRequestForFrame
+        https://bugs.webkit.org/show_bug.cgi?id=146306
+
+        Reviewed by Darin Adler.
+
+        Notify about the provisional URL change when new request set for main resource load in DocumentLoader has a
+        different URL than the previous one.
+
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::setRequest):
+
</ins><span class="cx"> 2016-10-13  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Clean RenderTree] LayoutTests/imported/blink/fast/table/crash-bad-child-table-continuation.html fails.
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit214SourceWebCoreloaderDocumentLoadercpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/loader/DocumentLoader.cpp (207957 => 207958)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/Source/WebCore/loader/DocumentLoader.cpp        2016-10-27 08:25:16 UTC (rev 207957)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/loader/DocumentLoader.cpp        2016-10-27 08:27:20 UTC (rev 207958)
</span><span class="lines">@@ -228,8 +228,11 @@
</span><span class="cx"> 
</span><span class="cx">     handlingUnreachableURL = m_substituteData.isValid() &amp;&amp; !m_substituteData.failingURL().isEmpty();
</span><span class="cx"> 
</span><ins>+    bool shouldNotifyAboutProvisionalURLChange = false;
</ins><span class="cx">     if (handlingUnreachableURL)
</span><span class="cx">         m_committed = false;
</span><ins>+    else if (isLoadingMainResource() &amp;&amp; req.url() != m_request.url())
+        shouldNotifyAboutProvisionalURLChange = true;
</ins><span class="cx"> 
</span><span class="cx">     // We should never be getting a redirect callback after the data
</span><span class="cx">     // source is committed, except in the unreachable URL case. It 
</span><span class="lines">@@ -237,6 +240,8 @@
</span><span class="cx">     ASSERT(!m_committed);
</span><span class="cx"> 
</span><span class="cx">     m_request = req;
</span><ins>+    if (shouldNotifyAboutProvisionalURLChange)
+        frameLoader()-&gt;client().dispatchDidChangeProvisionalURL();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void DocumentLoader::setMainDocumentError(const ResourceError&amp; error)
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit214ToolsChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.14/Tools/ChangeLog (207957 => 207958)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/Tools/ChangeLog        2016-10-27 08:25:16 UTC (rev 207957)
+++ releases/WebKitGTK/webkit-2.14/Tools/ChangeLog        2016-10-27 08:27:20 UTC (rev 207958)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2016-10-13  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        WebView and WebPage URLs not updated after URL is modified by InjectedBundlePageResourceLoadClient::willSendRequestForFrame
+        https://bugs.webkit.org/show_bug.cgi?id=146306
+
+        Reviewed by Darin Adler.
+
+        Add unit test to check that the committed URL is updated when changed in willSendRequest callback.
+
+        * TestWebKitAPI/CMakeLists.txt:
+        * TestWebKitAPI/PlatformEfl.cmake:
+        * TestWebKitAPI/PlatformGTK.cmake:
+        * TestWebKitAPI/Tests/WebKit2/ProvisionalURLAfterWillSendRequestCallback.cpp: Added.
+        (TestWebKitAPI::didCommitLoadForFrame):
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebKit2/ProvisionalURLAfterWillSendRequestCallback_Bundle.cpp: Added.
+        (TestWebKitAPI::ProvisionalURLAfterWillSendRequestCallbackTest::ProvisionalURLAfterWillSendRequestCallbackTest):
+        (TestWebKitAPI::ProvisionalURLAfterWillSendRequestCallbackTest::willSendRequestForFrame):
+        (TestWebKitAPI::ProvisionalURLAfterWillSendRequestCallbackTest::didCommitLoadForFrame):
+
</ins><span class="cx"> 2016-10-07  Andreas Kling  &lt;akling@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [WK2] didRemoveFrameFromHierarchy callback doesn't fire for subframes when evicting from PageCache.
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit214ToolsTestWebKitAPICMakeListstxt"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/CMakeLists.txt (207957 => 207958)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/CMakeLists.txt        2016-10-27 08:25:16 UTC (rev 207957)
+++ releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/CMakeLists.txt        2016-10-27 08:27:20 UTC (rev 207958)
</span><span class="lines">@@ -147,6 +147,7 @@
</span><span class="cx">         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/NewFirstVisuallyNonEmptyLayoutFrames_Bundle.cpp
</span><span class="cx">         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/NewFirstVisuallyNonEmptyLayout_Bundle.cpp
</span><span class="cx">         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ParentFrame_Bundle.cpp
</span><ins>+        ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ProvisionalURLAfterWillSendRequestCallback_Bundle.cpp
</ins><span class="cx">         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ResponsivenessTimerDoesntFireEarly_Bundle.cpp
</span><span class="cx">         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ShouldGoToBackForwardListItem_Bundle.cpp
</span><span class="cx">         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/TextFieldDidBeginAndEndEditing_Bundle.cpp
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit214ToolsTestWebKitAPIPlatformEflcmake"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/PlatformEfl.cmake (207957 => 207958)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/PlatformEfl.cmake        2016-10-27 08:25:16 UTC (rev 207957)
+++ releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/PlatformEfl.cmake        2016-10-27 08:27:20 UTC (rev 207958)
</span><span class="lines">@@ -97,6 +97,7 @@
</span><span class="cx">     PendingAPIRequestURL
</span><span class="cx">     PreventEmptyUserAgent
</span><span class="cx">     PrivateBrowsingPushStateNoHistoryCallback
</span><ins>+    ProvisionalURLAfterWillSendRequestCallback
</ins><span class="cx">     ResponsivenessTimerDoesntFireEarly
</span><span class="cx">     ShouldGoToBackForwardListItem
</span><span class="cx">     TerminateTwice
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit214ToolsTestWebKitAPIPlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/PlatformGTK.cmake (207957 => 207958)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/PlatformGTK.cmake        2016-10-27 08:25:16 UTC (rev 207957)
+++ releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/PlatformGTK.cmake        2016-10-27 08:27:20 UTC (rev 207958)
</span><span class="lines">@@ -101,6 +101,7 @@
</span><span class="cx">     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/PendingAPIRequestURL.cpp
</span><span class="cx">     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/PreventEmptyUserAgent.cpp
</span><span class="cx">     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/PrivateBrowsingPushStateNoHistoryCallback.cpp
</span><ins>+    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ProvisionalURLAfterWillSendRequestCallback.cpp
</ins><span class="cx">     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ReloadPageAfterCrash.cpp
</span><span class="cx">     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ResizeWindowAfterCrash.cpp
</span><span class="cx">     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/RestoreSessionStateContainingFormData.cpp
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit214ToolsTestWebKitAPITestsWebKit2ProvisionalURLAfterWillSendRequestCallbackcpp"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/Tests/WebKit2/ProvisionalURLAfterWillSendRequestCallback.cpp (0 => 207958)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/Tests/WebKit2/ProvisionalURLAfterWillSendRequestCallback.cpp                                (rev 0)
+++ releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/Tests/WebKit2/ProvisionalURLAfterWillSendRequestCallback.cpp        2016-10-27 08:27:20 UTC (rev 207958)
</span><span class="lines">@@ -0,0 +1,89 @@
</span><ins>+/*
+ * Copyright (C) 2016 Igalia S.L.
+ *
+ * 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 &quot;config.h&quot;
+
+#if WK_HAVE_C_SPI
+
+#include &quot;PlatformUtilities.h&quot;
+#include &quot;PlatformWebView.h&quot;
+#include &quot;Test.h&quot;
+#include &lt;WebKit/WKContext.h&gt;
+#include &lt;WebKit/WKFrame.h&gt;
+#include &lt;WebKit/WKRetainPtr.h&gt;
+
+namespace TestWebKitAPI {
+
+static bool committedLoad;
+
+static void didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void*)
+{
+    if (!WKFrameIsMainFrame(frame))
+        return;
+
+    // The provisional URL should be null.
+    EXPECT_NULL(WKFrameCopyProvisionalURL(frame));
+
+    // The committed URL is the last known provisional URL.
+    WKRetainPtr&lt;WKURLRef&gt; committedURL = adoptWK(WKFrameCopyURL(frame));
+    ASSERT_NOT_NULL(committedURL.get());
+    WKRetainPtr&lt;WKURLRef&gt; activeURL = adoptWK(WKPageCopyActiveURL(page));
+    ASSERT_NOT_NULL(activeURL.get());
+    EXPECT_TRUE(WKURLIsEqual(committedURL.get(), activeURL.get()));
+    assert(WKGetTypeID(userData) == WKURLGetTypeID());
+    EXPECT_TRUE(WKURLIsEqual(committedURL.get(), static_cast&lt;WKURLRef&gt;(userData)));
+
+    WKRetainPtr&lt;WKURLRef&gt; url(AdoptWK, Util::createURLForResource(&quot;simple2&quot;, &quot;html&quot;));
+    EXPECT_TRUE(WKURLIsEqual(committedURL.get(), url.get()));
+
+    committedLoad = true;
+}
+
+TEST(WebKit2, ProvisionalURLAfterWillSendRequestCallback)
+{
+    WKRetainPtr&lt;WKContextRef&gt; context(AdoptWK, Util::createContextForInjectedBundleTest(&quot;ProvisionalURLAfterWillSendRequestCallbackTest&quot;));
+
+    WKContextInjectedBundleClientV0 injectedBundleClient;
+    memset(&amp;injectedBundleClient, 0, sizeof(injectedBundleClient));
+    injectedBundleClient.base.version = 0;
+    WKContextSetInjectedBundleClient(context.get(), &amp;injectedBundleClient.base);
+
+    PlatformWebView webView(context.get());
+
+    WKPageLoaderClientV0 loaderClient;
+    memset(&amp;loaderClient, 0, sizeof(loaderClient));
+
+    loaderClient.base.version = 0;
+    loaderClient.didCommitLoadForFrame = didCommitLoadForFrame;
+    WKPageSetPageLoaderClient(webView.page(), &amp;loaderClient.base);
+
+    WKRetainPtr&lt;WKURLRef&gt; url(AdoptWK, Util::createURLForResource(&quot;simple&quot;, &quot;html&quot;));
+    WKPageLoadURL(webView.page(), url.get());
+    Util::run(&amp;committedLoad);
+}
+
+} // namespace TestWebKitAPI
+
+#endif
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit214ToolsTestWebKitAPITestsWebKit2ProvisionalURLAfterWillSendRequestCallback_Bundlecpp"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/Tests/WebKit2/ProvisionalURLAfterWillSendRequestCallback_Bundle.cpp (0 => 207958)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/Tests/WebKit2/ProvisionalURLAfterWillSendRequestCallback_Bundle.cpp                                (rev 0)
+++ releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/Tests/WebKit2/ProvisionalURLAfterWillSendRequestCallback_Bundle.cpp        2016-10-27 08:27:20 UTC (rev 207958)
</span><span class="lines">@@ -0,0 +1,85 @@
</span><ins>+/*
+ * Copyright (C) 2016 Igalia S.L.
+ *
+ * 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 &quot;config.h&quot;
+
+#if WK_HAVE_C_SPI
+
+#include &quot;InjectedBundleTest.h&quot;
+#include &quot;PlatformUtilities.h&quot;
+#include &quot;Test.h&quot;
+#include &lt;WebKit/WKBundleFrame.h&gt;
+#include &lt;WebKit/WKBundlePage.h&gt;
+#include &lt;WebKit/WKRetainPtr.h&gt;
+
+namespace TestWebKitAPI {
+
+class ProvisionalURLAfterWillSendRequestCallbackTest : public InjectedBundleTest {
+public:
+    ProvisionalURLAfterWillSendRequestCallbackTest(const std::string&amp; identifier)
+        : InjectedBundleTest(identifier)
+    {
+    }
+
+    static WKURLRequestRef willSendRequestForFrame(WKBundlePageRef, WKBundleFrameRef frame, uint64_t resourceIdentifier, WKURLRequestRef request, WKURLResponseRef redirectResponse, const void*)
+    {
+        if (!WKBundleFrameIsMainFrame(frame)) {
+            WKRetainPtr&lt;WKURLRequestRef&gt; newRequest = request;
+            return newRequest.leakRef();
+        }
+
+        // Change the main frame URL.
+        WKRetainPtr&lt;WKURLRef&gt; url(AdoptWK, Util::createURLForResource(&quot;simple2&quot;, &quot;html&quot;));
+        return WKURLRequestCreateWithWKURL(url.get());
+    }
+
+    static void didCommitLoadForFrame(WKBundlePageRef, WKBundleFrameRef frame, WKTypeRef* userData, const void*)
+    {
+        if (!WKBundleFrameIsMainFrame(frame))
+            return;
+        *userData = WKBundleFrameCopyURL(frame);
+    }
+
+    void didCreatePage(WKBundleRef bundle, WKBundlePageRef page) override
+    {
+        WKBundlePageResourceLoadClientV0 resourceLoadClient;
+        memset(&amp;resourceLoadClient, 0, sizeof(resourceLoadClient));
+        resourceLoadClient.base.version = 0;
+        resourceLoadClient.willSendRequestForFrame = willSendRequestForFrame;
+        WKBundlePageSetResourceLoadClient(page, &amp;resourceLoadClient.base);
+
+        WKBundlePageLoaderClientV0 pageLoaderClient;
+        memset(&amp;pageLoaderClient, 0, sizeof(pageLoaderClient));
+        pageLoaderClient.base.version = 0;
+        pageLoaderClient.didCommitLoadForFrame = didCommitLoadForFrame;
+        WKBundlePageSetPageLoaderClient(page, &amp;pageLoaderClient.base);
+    }
+};
+
+static InjectedBundleTest::Register&lt;ProvisionalURLAfterWillSendRequestCallbackTest&gt; registrar(&quot;ProvisionalURLAfterWillSendRequestCallbackTest&quot;);
+
+} // namespace TestWebKitAPI
+
+#endif
</ins></span></pre>
</div>
</div>

</body>
</html>