Title: [122960] trunk/Source/WebKit2
Revision
122960
Author
carlo...@webkit.org
Date
2012-07-18 06:27:12 -0700 (Wed, 18 Jul 2012)

Log Message

[GTK] No main resource in WebView when page has been loaded from history cache
https://bugs.webkit.org/show_bug.cgi?id=91478

Reviewed by Gustavo Noronha Silva.

We are assuming that a resource loaded for the main frame that is
provisionally loading is the main resource of the web view. However
that's not true for pages loaded from history cache, so when you
go back/forward webkit_web_view_get_main_resource() always returns
NULL. We can assume that the first resource loaded for the main
frame is the main resource of the web view when
pageIsProvisionallyLoading is false.

* UIProcess/API/gtk/WebKitWebView.cpp:
(webkitWebViewResourceLoadStarted): Make sure we always have a
main resource for the web view.
* UIProcess/API/gtk/tests/TestResources.cpp:
(testWebViewResourcesHistoryCache): Test we always have a main
resource even after going back/forward.
(beforeAll): Add new test case.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (122959 => 122960)


--- trunk/Source/WebKit2/ChangeLog	2012-07-18 13:19:21 UTC (rev 122959)
+++ trunk/Source/WebKit2/ChangeLog	2012-07-18 13:27:12 UTC (rev 122960)
@@ -1,3 +1,26 @@
+2012-07-18  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        [GTK] No main resource in WebView when page has been loaded from history cache
+        https://bugs.webkit.org/show_bug.cgi?id=91478
+
+        Reviewed by Gustavo Noronha Silva.
+
+        We are assuming that a resource loaded for the main frame that is
+        provisionally loading is the main resource of the web view. However
+        that's not true for pages loaded from history cache, so when you
+        go back/forward webkit_web_view_get_main_resource() always returns
+        NULL. We can assume that the first resource loaded for the main
+        frame is the main resource of the web view when
+        pageIsProvisionallyLoading is false.
+
+        * UIProcess/API/gtk/WebKitWebView.cpp:
+        (webkitWebViewResourceLoadStarted): Make sure we always have a
+        main resource for the web view.
+        * UIProcess/API/gtk/tests/TestResources.cpp:
+        (testWebViewResourcesHistoryCache): Test we always have a main
+        resource even after going back/forward.
+        (beforeAll): Add new test case.
+
 2012-07-18  Seokju Kwon  <seokju.k...@samsung.com>
 
         [EFL] Rename WebInspectorEfl.cpp as WebInspectorProxyEfl.cpp

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp (122959 => 122960)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp	2012-07-18 13:19:21 UTC (rev 122959)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp	2012-07-18 13:27:12 UTC (rev 122960)
@@ -1250,7 +1250,7 @@
 
     WebKitWebViewPrivate* priv = webView->priv;
     WebKitWebResource* resource = webkitWebResourceCreate(wkFrame, request, isMainResource);
-    if (WKFrameIsMainFrame(wkFrame) && isMainResource)
+    if (WKFrameIsMainFrame(wkFrame) && (isMainResource || !priv->mainResource))
         priv->mainResource = resource;
     priv->loadingResourcesMap.set(resourceIdentifier, adoptGRef(resource));
     g_signal_emit(webView, signals[RESOURCE_LOAD_STARTED], 0, resource, request);

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp (122959 => 122960)


--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp	2012-07-18 13:19:21 UTC (rev 122959)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestResources.cpp	2012-07-18 13:27:12 UTC (rev 122960)
@@ -520,6 +520,25 @@
     g_assert(!webkit_web_view_get_subresources(test->m_webView));
 }
 
+static void testWebViewResourcesHistoryCache(SingleResourceLoadTest* test, gconstpointer)
+{
+    test->loadURI(kServer->getURIForPath("/").data());
+    test->waitUntilResourceLoadFinished();
+    g_assert(webkit_web_view_get_main_resource(test->m_webView));
+
+    test->loadURI(kServer->getURIForPath("/_javascript_.html").data());
+    test->waitUntilResourceLoadFinished();
+    g_assert(webkit_web_view_get_main_resource(test->m_webView));
+
+    test->goBack();
+    test->waitUntilResourceLoadFinished();
+    g_assert(webkit_web_view_get_main_resource(test->m_webView));
+
+    test->goForward();
+    test->waitUntilResourceLoadFinished();
+    g_assert(webkit_web_view_get_main_resource(test->m_webView));
+}
+
 static void addCacheHTTPHeadersToResponse(SoupMessage* message)
 {
     // The actual date doesn't really matter.
@@ -604,6 +623,7 @@
     ResourceURITrackingTest::add("WebKitWebResource", "active-uri", testWebResourceActiveURI);
     ResourcesTest::add("WebKitWebResource", "get-data", testWebResourceGetData);
     ResourcesTest::add("WebKitWebView", "replaced-content", testWebViewResourcesReplacedContent);
+    SingleResourceLoadTest::add("WebKitWebView", "history-cache", testWebViewResourcesHistoryCache);
 }
 
 void afterAll()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to