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));
}
TEST(WebKit2, WKPageGetScaleFactorNotZero)
{
    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());

    PlatformWebView webView(context.get());
    setPageLoaderClient(webView.page());

    WKRetainPtr<WKDataRef> data = createSessionState(context.get());
    EXPECT_NOT_NULL(data);

    WKPageRestoreFromSessionState(webView.page(), data.get());
    Util::run(&didFinishLoad);

    EXPECT_TRUE(WKPageGetScaleFactor(webView.page()) == 1.0);
}
Пример #3
0
TEST(WebKit2, RestoreSessionStateContainingFormData)
{
    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());

    // FIXME: Once <rdar://problem/8708435> is fixed, we can move the creation of this
    // PlatformWebView after the call to createSessionStaetContainingFormData. Until then, it must
    // remain here to avoid a race condition between the UI and web processes.
    PlatformWebView webView(context.get());
    setPageLoaderClient(webView.page());

    WKRetainPtr<WKDataRef> data = createSessionStateContainingFormData(context.get());
    EXPECT_NOT_NULL(data);

    WKPageRestoreFromSessionState(webView.page(), data.get());
    Util::run(&didFinishLoad);

    EXPECT_TRUE(WKPageCanGoBack(webView.page()));
}