TEST(WebKit2, WKPageCopySessionStateWithFiltering)
{
    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());

    createSessionStates(context.get());

    EXPECT_NOT_NULL(sessionStateWithFirstItemRemoved);
    PlatformWebView webView1(context.get());
    setPageLoaderClient(webView1.page());
    WKPageRestoreFromSessionState(webView1.page(), sessionStateWithFirstItemRemoved.get());
    Util::run(&didFinishLoad);
    didFinishLoad = false;

    WKBackForwardListRef backForwardList1 = WKPageGetBackForwardList(webView1.page());
    EXPECT_EQ(0u, WKBackForwardListGetBackListCount(backForwardList1));
    EXPECT_EQ(1u, WKBackForwardListGetForwardListCount(backForwardList1));

    EXPECT_NOT_NULL(sessionStateWithAllItemsRemoved);
    PlatformWebView webView2(context.get());
    setPageLoaderClient(webView2.page());
    WKPageRestoreFromSessionState(webView2.page(), sessionStateWithAllItemsRemoved.get());
    // Because the session state ends up being empty, nothing is actually loaded.

    WKBackForwardListRef backForwardList2 = WKPageGetBackForwardList(webView2.page());
    EXPECT_EQ(0u, WKBackForwardListGetBackListCount(backForwardList2));
    EXPECT_EQ(0u, WKBackForwardListGetForwardListCount(backForwardList2));
}
Ejemplo n.º 2
0
static inline bool goToItemAtIndex(int index)
{
    WKBackForwardListRef backForwardList = WKPageGetBackForwardList(mainPage());
    ASSERT(backForwardList);

    WKBackForwardListItemRef listItem = WKBackForwardListGetItemAtIndex(backForwardList, index);
    if (!listItem)
        return false;

    WKPageGoToBackForwardListItem(mainPage(), listItem);

    return true;
}