Changeset 195288 in webkit


Ignore:
Timestamp:
Jan 19, 2016 8:49:58 AM (8 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Runtime critical warnings when loading a URL after a session restore
https://bugs.webkit.org/show_bug.cgi?id=153233

Reviewed by Michael Catanzaro.

Source/WebKit2:

This happens when doing a normal load after restoring the back
forward list from session state and the list contained forward
items. In that case the forward items are removed from the list
and we try to reference a WebBackForwardListItem wrapper that
hasn't been created. We create the wrappers on demand, and when
the back forward list is populated from session state, items are
added to the list without creating their wrappers. That was not
possible before, and that's why we assumed that any item that is
removed from the list should have a wrapper already created.

  • UIProcess/API/gtk/WebKitBackForwardList.cpp:

(webkitBackForwardListChanged): If we don't have a wrapper for the
removed item, create a new one to be passed to the signal, but
without adding it to the map.

Tools:

Add new test case.

  • TestWebKitAPI/Tests/WebKit2Gtk/TestBackForwardList.cpp:

(viewLoadChanged):
(testWebKitWebViewNavigationAfterSessionRestore):
(beforeAll):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r195264 r195288  
     12016-01-19  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Runtime critical warnings when loading a URL after a session restore
     4        https://bugs.webkit.org/show_bug.cgi?id=153233
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        This happens when doing a normal load after restoring the back
     9        forward list from session state and the list contained forward
     10        items. In that case the forward items are removed from the list
     11        and we try to reference a WebBackForwardListItem wrapper that
     12        hasn't been created. We create the wrappers on demand, and when
     13        the back forward list is populated from session state, items are
     14        added to the list without creating their wrappers. That was not
     15        possible before, and that's why we assumed that any item that is
     16        removed from the list should have a wrapper already created.
     17
     18        * UIProcess/API/gtk/WebKitBackForwardList.cpp:
     19        (webkitBackForwardListChanged): If we don't have a wrapper for the
     20        removed item, create a new one to be passed to the signal, but
     21        without adding it to the map.
     22
    1232016-01-19  Ryosuke Niwa  <rniwa@webkit.org>
    224
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardList.cpp

    r185502 r195288  
    136136    WebKitBackForwardListPrivate* priv = backForwardList->priv;
    137137    for (auto& webItem : webRemovedItems) {
    138         removedItems = g_list_prepend(removedItems, g_object_ref(priv->itemsMap.get(webItem.get()).get()));
    139         priv->itemsMap.remove(webItem.get());
     138        // After a session restore, we still don't have wrappers for the newly added items, so it would be possible that
     139        // the removed items are not in the map. In that case we create a wrapper now to pass it the changed signal, but
     140        // without adding it to the item map. See https://bugs.webkit.org/show_bug.cgi?id=153233.
     141        GRefPtr<WebKitBackForwardListItem> removedItem = priv->itemsMap.get(webItem.get());
     142        if (removedItem) {
     143            removedItems = g_list_prepend(removedItems, g_object_ref(removedItem.get()));
     144            priv->itemsMap.remove(webItem.get());
     145        } else
     146            removedItems = g_list_prepend(removedItems, webkitBackForwardListItemGetOrCreate(webItem.get()));
    140147    }
    141148
  • trunk/Tools/ChangeLog

    r195287 r195288  
     12016-01-19  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Runtime critical warnings when loading a URL after a session restore
     4        https://bugs.webkit.org/show_bug.cgi?id=153233
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        Add new test case.
     9
     10        * TestWebKitAPI/Tests/WebKit2Gtk/TestBackForwardList.cpp:
     11        (viewLoadChanged):
     12        (testWebKitWebViewNavigationAfterSessionRestore):
     13        (beforeAll):
     14
    1152016-01-19  Michael Catanzaro  <mcatanzaro@igalia.com>
    216
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestBackForwardList.cpp

    r194579 r195288  
    367367}
    368368
     369static void viewLoadChanged(WebKitWebView* webView, WebKitLoadEvent loadEvent, GMainLoop* mainLoop)
     370{
     371    if (loadEvent == WEBKIT_LOAD_FINISHED)
     372        g_main_loop_quit(mainLoop);
     373}
     374
     375static void testWebKitWebViewNavigationAfterSessionRestore(BackForwardListTest* test, gconstpointer)
     376{
     377    // This test checks that a normal load after a session restore with a BackForard list having
     378    // forward items doesn't produce any runtime critical warning. See https://bugs.webkit.org/show_bug.cgi?id=153233.
     379    GRefPtr<WebKitWebView> view = WEBKIT_WEB_VIEW(webkit_web_view_new());
     380    g_signal_connect(view.get(), "load-changed", G_CALLBACK(viewLoadChanged), test->m_mainLoop);
     381
     382    webkit_web_view_load_uri(view.get(), kServer->getURIForPath("/Page1").data());
     383    g_main_loop_run(test->m_mainLoop);
     384    webkit_web_view_load_uri(view.get(), kServer->getURIForPath("/Page2").data());
     385    g_main_loop_run(test->m_mainLoop);
     386    webkit_web_view_load_uri(view.get(), kServer->getURIForPath("/Page3").data());
     387    g_main_loop_run(test->m_mainLoop);
     388    webkit_web_view_go_back(view.get());
     389    g_main_loop_run(test->m_mainLoop);
     390
     391    WebKitWebViewSessionState* state = webkit_web_view_get_session_state(view.get());
     392    webkit_web_view_restore_session_state(test->m_webView, state);
     393    webkit_web_view_session_state_unref(state);
     394
     395    // A normal load after a session restore should remove the forward list, add the new item and update the current one.
     396    test->m_changedFlags = BackForwardListTest::CurrentItem | BackForwardListTest::AddedItem | BackForwardListTest::RemovedItems;
     397    test->loadURI(kServer->getURIForPath("/Page4").data());
     398    test->waitUntilLoadFinished();
     399}
     400
    369401void beforeAll()
    370402{
     
    376408    BackForwardListTest::add("WebKitWebView", "session-state", testWebKitWebViewSessionState);
    377409    BackForwardListTest::add("WebKitWebView", "session-state-with-form-data", testWebKitWebViewSessionStateWithFormData);
     410    BackForwardListTest::add("WebKitWebView", "navigation-after-session-restore", testWebKitWebViewNavigationAfterSessionRestore);
    378411}
    379412
Note: See TracChangeset for help on using the changeset viewer.