Title: [207958] releases/WebKitGTK/webkit-2.14
Revision
207958
Author
carlo...@webkit.org
Date
2016-10-27 01:27:20 -0700 (Thu, 27 Oct 2016)

Log Message

Merge r207325 - 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):

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog (207957 => 207958)


--- 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)
@@ -1,3 +1,16 @@
+2016-10-13  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        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):
+
 2016-10-13  Zalan Bujtas  <za...@apple.com>
 
         [Clean RenderTree] LayoutTests/imported/blink/fast/table/crash-bad-child-table-continuation.html fails.

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/loader/DocumentLoader.cpp (207957 => 207958)


--- 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)
@@ -228,8 +228,11 @@
 
     handlingUnreachableURL = m_substituteData.isValid() && !m_substituteData.failingURL().isEmpty();
 
+    bool shouldNotifyAboutProvisionalURLChange = false;
     if (handlingUnreachableURL)
         m_committed = false;
+    else if (isLoadingMainResource() && req.url() != m_request.url())
+        shouldNotifyAboutProvisionalURLChange = true;
 
     // We should never be getting a redirect callback after the data
     // source is committed, except in the unreachable URL case. It 
@@ -237,6 +240,8 @@
     ASSERT(!m_committed);
 
     m_request = req;
+    if (shouldNotifyAboutProvisionalURLChange)
+        frameLoader()->client().dispatchDidChangeProvisionalURL();
 }
 
 void DocumentLoader::setMainDocumentError(const ResourceError& error)

Modified: releases/WebKitGTK/webkit-2.14/Tools/ChangeLog (207957 => 207958)


--- 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)
@@ -1,3 +1,23 @@
+2016-10-13  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        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):
+
 2016-10-07  Andreas Kling  <akl...@apple.com>
 
         [WK2] didRemoveFrameFromHierarchy callback doesn't fire for subframes when evicting from PageCache.

Modified: releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/CMakeLists.txt (207957 => 207958)


--- 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)
@@ -147,6 +147,7 @@
         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/NewFirstVisuallyNonEmptyLayoutFrames_Bundle.cpp
         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/NewFirstVisuallyNonEmptyLayout_Bundle.cpp
         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ParentFrame_Bundle.cpp
+        ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ProvisionalURLAfterWillSendRequestCallback_Bundle.cpp
         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ResponsivenessTimerDoesntFireEarly_Bundle.cpp
         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ShouldGoToBackForwardListItem_Bundle.cpp
         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/TextFieldDidBeginAndEndEditing_Bundle.cpp

Modified: releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/PlatformEfl.cmake (207957 => 207958)


--- 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)
@@ -97,6 +97,7 @@
     PendingAPIRequestURL
     PreventEmptyUserAgent
     PrivateBrowsingPushStateNoHistoryCallback
+    ProvisionalURLAfterWillSendRequestCallback
     ResponsivenessTimerDoesntFireEarly
     ShouldGoToBackForwardListItem
     TerminateTwice

Modified: releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/PlatformGTK.cmake (207957 => 207958)


--- 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)
@@ -101,6 +101,7 @@
     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/PendingAPIRequestURL.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/PreventEmptyUserAgent.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/PrivateBrowsingPushStateNoHistoryCallback.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ProvisionalURLAfterWillSendRequestCallback.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ReloadPageAfterCrash.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ResizeWindowAfterCrash.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/RestoreSessionStateContainingFormData.cpp

Added: releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/Tests/WebKit2/ProvisionalURLAfterWillSendRequestCallback.cpp (0 => 207958)


--- 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)
@@ -0,0 +1,89 @@
+/*
+ * 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 "config.h"
+
+#if WK_HAVE_C_SPI
+
+#include "PlatformUtilities.h"
+#include "PlatformWebView.h"
+#include "Test.h"
+#include <WebKit/WKContext.h>
+#include <WebKit/WKFrame.h>
+#include <WebKit/WKRetainPtr.h>
+
+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<WKURLRef> committedURL = adoptWK(WKFrameCopyURL(frame));
+    ASSERT_NOT_NULL(committedURL.get());
+    WKRetainPtr<WKURLRef> 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<WKURLRef>(userData)));
+
+    WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("simple2", "html"));
+    EXPECT_TRUE(WKURLIsEqual(committedURL.get(), url.get()));
+
+    committedLoad = true;
+}
+
+TEST(WebKit2, ProvisionalURLAfterWillSendRequestCallback)
+{
+    WKRetainPtr<WKContextRef> context(AdoptWK, Util::createContextForInjectedBundleTest("ProvisionalURLAfterWillSendRequestCallbackTest"));
+
+    WKContextInjectedBundleClientV0 injectedBundleClient;
+    memset(&injectedBundleClient, 0, sizeof(injectedBundleClient));
+    injectedBundleClient.base.version = 0;
+    WKContextSetInjectedBundleClient(context.get(), &injectedBundleClient.base);
+
+    PlatformWebView webView(context.get());
+
+    WKPageLoaderClientV0 loaderClient;
+    memset(&loaderClient, 0, sizeof(loaderClient));
+
+    loaderClient.base.version = 0;
+    loaderClient.didCommitLoadForFrame = didCommitLoadForFrame;
+    WKPageSetPageLoaderClient(webView.page(), &loaderClient.base);
+
+    WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("simple", "html"));
+    WKPageLoadURL(webView.page(), url.get());
+    Util::run(&committedLoad);
+}
+
+} // namespace TestWebKitAPI
+
+#endif

Added: releases/WebKitGTK/webkit-2.14/Tools/TestWebKitAPI/Tests/WebKit2/ProvisionalURLAfterWillSendRequestCallback_Bundle.cpp (0 => 207958)


--- 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)
@@ -0,0 +1,85 @@
+/*
+ * 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 "config.h"
+
+#if WK_HAVE_C_SPI
+
+#include "InjectedBundleTest.h"
+#include "PlatformUtilities.h"
+#include "Test.h"
+#include <WebKit/WKBundleFrame.h>
+#include <WebKit/WKBundlePage.h>
+#include <WebKit/WKRetainPtr.h>
+
+namespace TestWebKitAPI {
+
+class ProvisionalURLAfterWillSendRequestCallbackTest : public InjectedBundleTest {
+public:
+    ProvisionalURLAfterWillSendRequestCallbackTest(const std::string& identifier)
+        : InjectedBundleTest(identifier)
+    {
+    }
+
+    static WKURLRequestRef willSendRequestForFrame(WKBundlePageRef, WKBundleFrameRef frame, uint64_t resourceIdentifier, WKURLRequestRef request, WKURLResponseRef redirectResponse, const void*)
+    {
+        if (!WKBundleFrameIsMainFrame(frame)) {
+            WKRetainPtr<WKURLRequestRef> newRequest = request;
+            return newRequest.leakRef();
+        }
+
+        // Change the main frame URL.
+        WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("simple2", "html"));
+        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(&resourceLoadClient, 0, sizeof(resourceLoadClient));
+        resourceLoadClient.base.version = 0;
+        resourceLoadClient.willSendRequestForFrame = willSendRequestForFrame;
+        WKBundlePageSetResourceLoadClient(page, &resourceLoadClient.base);
+
+        WKBundlePageLoaderClientV0 pageLoaderClient;
+        memset(&pageLoaderClient, 0, sizeof(pageLoaderClient));
+        pageLoaderClient.base.version = 0;
+        pageLoaderClient.didCommitLoadForFrame = didCommitLoadForFrame;
+        WKBundlePageSetPageLoaderClient(page, &pageLoaderClient.base);
+    }
+};
+
+static InjectedBundleTest::Register<ProvisionalURLAfterWillSendRequestCallbackTest> registrar("ProvisionalURLAfterWillSendRequestCallbackTest");
+
+} // namespace TestWebKitAPI
+
+#endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to