[GTK] WebKitWebPage URI not updated after URI is modified by InjectedBundlePageResour...
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 16 Oct 2016 09:11:18 +0000 (09:11 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 16 Oct 2016 09:11:18 +0000 (09:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=163389

Reviewed by Michael Catanzaro.

Source/WebKit2:

Update the page URI also when the load is committed.

* WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp:
(getDocumentLoaderURL):
(didStartProvisionalLoadForFrame):
(didReceiveServerRedirectForProvisionalLoadForFrame):
(didCommitLoadForFrame):
(webkitWebPageCreate):
(getProvisionalURLForFrame): Deleted.

Tools:

Update /webkit2/WebKitWebPage/get-uri test to check that web view and page uri always match even when request is
modified by WebKitWebPage::send-request signal.

* TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp:
(testWebPageURI):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207389 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp

index 1ca4c33..2ad046d 100644 (file)
@@ -1,3 +1,20 @@
+2016-10-16  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] WebKitWebPage URI not updated after URI is modified by InjectedBundlePageResourceLoadClient::willSendRequestForFrame
+        https://bugs.webkit.org/show_bug.cgi?id=163389
+
+        Reviewed by Michael Catanzaro.
+
+        Update the page URI also when the load is committed.
+
+        * WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp:
+        (getDocumentLoaderURL):
+        (didStartProvisionalLoadForFrame):
+        (didReceiveServerRedirectForProvisionalLoadForFrame):
+        (didCommitLoadForFrame):
+        (webkitWebPageCreate):
+        (getProvisionalURLForFrame): Deleted.
+
 2016-10-15  Simon Fraser  <simon.fraser@apple.com>
 
         Sort the project file.
index c6c921a..00d76a9 100644 (file)
@@ -129,9 +129,9 @@ static void webFrameDestroyed(WebFrame* webFrame)
     webFrameMap().remove(webFrame);
 }
 
-static CString getProvisionalURLForFrame(WebFrame* webFrame)
+static CString getDocumentLoaderURL(DocumentLoader* documentLoader)
 {
-    DocumentLoader* documentLoader = webFrame->coreFrame()->loader().provisionalDocumentLoader();
+    ASSERT(documentLoader);
     if (!documentLoader->unreachableURL().isEmpty())
         return documentLoader->unreachableURL().string().utf8();
 
@@ -158,7 +158,7 @@ static void didStartProvisionalLoadForFrame(WKBundlePageRef, WKBundleFrameRef fr
     if (!WKBundleFrameIsMainFrame(frame))
         return;
 
-    webkitWebPageSetURI(WEBKIT_WEB_PAGE(clientInfo), getProvisionalURLForFrame(toImpl(frame)));
+    webkitWebPageSetURI(WEBKIT_WEB_PAGE(clientInfo), getDocumentLoaderURL(toImpl(frame)->coreFrame()->loader().provisionalDocumentLoader()));
 }
 
 static void didReceiveServerRedirectForProvisionalLoadForFrame(WKBundlePageRef, WKBundleFrameRef frame, WKTypeRef* /* userData */, const void *clientInfo)
@@ -166,7 +166,7 @@ static void didReceiveServerRedirectForProvisionalLoadForFrame(WKBundlePageRef,
     if (!WKBundleFrameIsMainFrame(frame))
         return;
 
-    webkitWebPageSetURI(WEBKIT_WEB_PAGE(clientInfo), getProvisionalURLForFrame(toImpl(frame)));
+    webkitWebPageSetURI(WEBKIT_WEB_PAGE(clientInfo), getDocumentLoaderURL(toImpl(frame)->coreFrame()->loader().provisionalDocumentLoader()));
 }
 
 static void didSameDocumentNavigationForFrame(WKBundlePageRef, WKBundleFrameRef frame, WKSameDocumentNavigationType, WKTypeRef* /* userData */, const void *clientInfo)
@@ -177,6 +177,14 @@ static void didSameDocumentNavigationForFrame(WKBundlePageRef, WKBundleFrameRef
     webkitWebPageSetURI(WEBKIT_WEB_PAGE(clientInfo), toImpl(frame)->coreFrame()->document()->url().string().utf8());
 }
 
+static void didCommitLoadForFrame(WKBundlePageRef, WKBundleFrameRef frame, WKTypeRef* /* userData */, const void* clientInfo)
+{
+    if (!WKBundleFrameIsMainFrame(frame))
+        return;
+
+    webkitWebPageSetURI(WEBKIT_WEB_PAGE(clientInfo), getDocumentLoaderURL(toImpl(frame)->coreFrame()->loader().documentLoader()));
+}
+
 static void didFinishDocumentLoadForFrame(WKBundlePageRef, WKBundleFrameRef frame, WKTypeRef*, const void *clientInfo)
 {
     if (!WKBundleFrameIsMainFrame(frame))
@@ -485,7 +493,7 @@ WebKitWebPage* webkitWebPageCreate(WebPage* webPage)
         didStartProvisionalLoadForFrame,
         didReceiveServerRedirectForProvisionalLoadForFrame,
         0, // didFailProvisionalLoadWithErrorForFrame
-        0, // didCommitLoadForFrame
+        didCommitLoadForFrame,
         didFinishDocumentLoadForFrame,
         0, // didFinishLoadForFrame
         0, // didFailLoadWithErrorForFrame
index e7aaebf..b1fb2d2 100644 (file)
@@ -1,5 +1,18 @@
 2016-10-16  Carlos Garcia Campos  <cgarcia@igalia.com>
 
+        [GTK] WebKitWebPage URI not updated after URI is modified by InjectedBundlePageResourceLoadClient::willSendRequestForFrame
+        https://bugs.webkit.org/show_bug.cgi?id=163389
+
+        Reviewed by Michael Catanzaro.
+
+        Update /webkit2/WebKitWebPage/get-uri test to check that web view and page uri always match even when request is
+        modified by WebKitWebPage::send-request signal.
+
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp:
+        (testWebPageURI):
+
+2016-10-16  Carlos Garcia Campos  <cgarcia@igalia.com>
+
         Document request not updated after willSendRequest is called for a redirect
         https://bugs.webkit.org/show_bug.cgi?id=163436
 
index d124eba..7dd69f5 100644 (file)
@@ -405,6 +405,20 @@ public:
         g_dbus_connection_signal_unsubscribe(bus->connection(), m_uriChangedSignalID);
     }
 
+    void loadURI(const char* uri)
+    {
+        m_webPageURIs.clear();
+        m_webViewURIs.clear();
+        WebViewTest::loadURI(uri);
+    }
+
+    void checkViewAndPageURIsMatch() const
+    {
+        g_assert_cmpint(m_webPageURIs.size(), ==, m_webViewURIs.size());
+        for (size_t i = 0; i < m_webPageURIs.size(); ++i)
+            ASSERT_CMP_CSTRING(m_webPageURIs[i], ==, m_webViewURIs[i]);
+    }
+
     unsigned m_uriChangedSignalID;
     Vector<CString> m_webPageURIs;
     Vector<CString> m_webViewURIs;
@@ -412,17 +426,37 @@ public:
 
 static void testWebPageURI(WebPageURITest* test, gconstpointer)
 {
-    test->loadURI(kServer->getURIForPath("/redirect").data());
+    // Normal load.
+    test->loadURI(kServer->getURIForPath("/normal1").data());
     test->waitUntilLoadFinished();
+    test->checkViewAndPageURIsMatch();
+    g_assert_cmpint(test->m_webPageURIs.size(), ==, 1);
+    ASSERT_CMP_CSTRING(test->m_webPageURIs[0], ==, kServer->getURIForPath("/normal1"));
 
-    g_assert_cmpint(test->m_webPageURIs.size(), ==, test->m_webViewURIs.size());
-    for (size_t i = 0; i < test->m_webPageURIs.size(); ++i)
-        ASSERT_CMP_CSTRING(test->m_webPageURIs[i], ==, test->m_webViewURIs[i]);
-
+    // Redirect
+    test->loadURI(kServer->getURIForPath("/redirect").data());
+    test->waitUntilLoadFinished();
+    test->checkViewAndPageURIsMatch();
     g_assert_cmpint(test->m_webPageURIs.size(), ==, 2);
     ASSERT_CMP_CSTRING(test->m_webPageURIs[0], ==, kServer->getURIForPath("/redirect"));
     ASSERT_CMP_CSTRING(test->m_webPageURIs[1], ==, kServer->getURIForPath("/normal"));
 
+    // Normal load, URL changed by WebKitPage::send-request.
+    test->loadURI(kServer->getURIForPath("/normal-change-request").data());
+    test->waitUntilLoadFinished();
+    test->checkViewAndPageURIsMatch();
+    g_assert_cmpint(test->m_webPageURIs.size(), ==, 2);
+    ASSERT_CMP_CSTRING(test->m_webPageURIs[0], ==, kServer->getURIForPath("/normal-change-request"));
+    ASSERT_CMP_CSTRING(test->m_webPageURIs[1], ==, kServer->getURIForPath("/request-changed"));
+
+    // Redirect, URL changed by WebKitPage::send-request.
+    test->loadURI(kServer->getURIForPath("/redirect-to-change-request").data());
+    test->waitUntilLoadFinished();
+    test->checkViewAndPageURIsMatch();
+    g_assert_cmpint(test->m_webPageURIs.size(), ==, 3);
+    ASSERT_CMP_CSTRING(test->m_webPageURIs[0], ==, kServer->getURIForPath("/redirect-to-change-request"));
+    ASSERT_CMP_CSTRING(test->m_webPageURIs[1], ==, kServer->getURIForPath("/normal-change-request"));
+    ASSERT_CMP_CSTRING(test->m_webPageURIs[2], ==, kServer->getURIForPath("/request-changed-on-redirect"));
 }
 
 static void testURIRequestHTTPHeaders(WebViewTest* test, gconstpointer)