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

    WKContextHistoryClient historyClient;
    memset(&historyClient, 0, sizeof(historyClient));

    historyClient.version = 0;
    historyClient.clientInfo = 0;
    historyClient.didNavigateWithNavigationData = didNavigateWithNavigationData;
    WKContextSetHistoryClient(context.get(), &historyClient);

    PlatformWebView webView(context.get());

    WKPageLoaderClient pageLoaderClient;
    memset(&pageLoaderClient, 0, sizeof(pageLoaderClient));

    pageLoaderClient.version = 0;
    pageLoaderClient.clientInfo = 0;
    pageLoaderClient.didSameDocumentNavigationForFrame = didSameDocumentNavigationForFrame;
    WKPageSetPageLoaderClient(webView.page(), &pageLoaderClient);

    WKRetainPtr<WKPreferencesRef> preferences(AdoptWK, WKPreferencesCreate());
    WKPreferencesSetPrivateBrowsingEnabled(preferences.get(), true);

    WKPageGroupRef pageGroup = WKPageGetPageGroup(webView.page());
    WKPageGroupSetPreferences(pageGroup, preferences.get());

    WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("push-state", "html"));
    WKPageLoadURL(webView.page(), url.get());

    Util::run(&testDone);
}
TEST(WebKit2, ResizeReversePaginatedWebView)
{
    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
    PlatformWebView webView(context.get());

    WKPageLoaderClientV3 loaderClient;
    memset(&loaderClient, 0, sizeof(loaderClient));

    loaderClient.base.version = 3;
    loaderClient.base.clientInfo = &webView;
    loaderClient.didLayout = didLayout;

    WKPageSetPageLoaderClient(webView.page(), &loaderClient.base);

    WKPageListenForLayoutMilestones(webView.page(), kWKDidFirstLayoutAfterSuppressedIncrementalRendering);

    WKPageGroupRef pageGroup =  WKPageGetPageGroup(webView.page());
    WKPreferencesRef preferences = WKPageGroupGetPreferences(pageGroup);
    WKPreferencesSetSuppressesIncrementalRendering(preferences, true);

    WKPageSetPaginationMode(webView.page(), kWKPaginationModeRightToLeft);
    WKPageSetPageLength(webView.page(), pageLength);
    WKPageSetGapBetweenPages(webView.page(), pageGap);
    WKPageSetPaginationBehavesLikeColumns(webView.page(), true);

    WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("lots-of-text-vertical-lr", "html")).get());

    Util::run(&testDone);
    EXPECT_TRUE(testDone);
}
WKPageRef TestController::createOtherPage(WKPageRef oldPage, WKURLRequestRef, WKDictionaryRef, WKEventModifiers, WKEventMouseButton, const void*)
{
    PlatformWebView* view = new PlatformWebView(WKPageGetContext(oldPage), WKPageGetPageGroup(oldPage));
    WKPageRef newPage = view->page();

    view->resizeTo(800, 600);

    WKPageUIClient otherPageUIClient = {
        kWKPageUIClientCurrentVersion,
        view,
        0, // createNewPage_deprecatedForUseWithV0
        0, // showPage
        closeOtherPage,
        0, // takeFocus
        focus,
        unfocus,
        0, // runJavaScriptAlert        
        0, // runJavaScriptConfirm
        0, // runJavaScriptPrompt
        0, // setStatusText
        0, // mouseDidMoveOverElement_deprecatedForUseWithV0
        0, // missingPluginButtonClicked
        0, // didNotHandleKeyEvent
        0, // didNotHandleWheelEvent
        0, // toolbarsAreVisible
        0, // setToolbarsAreVisible
        0, // menuBarIsVisible
        0, // setMenuBarIsVisible
        0, // statusBarIsVisible
        0, // setStatusBarIsVisible
        0, // isResizable
        0, // setIsResizable
        getWindowFrameOtherPage,
        setWindowFrameOtherPage,
        runBeforeUnloadConfirmPanel,
        0, // didDraw
        0, // pageDidScroll
        exceededDatabaseQuota,
        0, // runOpenPanel
        0, // decidePolicyForGeolocationPermissionRequest
        0, // headerHeight
        0, // footerHeight
        0, // drawHeader
        0, // drawFooter
        0, // printFrame
        runModal,
        0, // didCompleteRubberBandForMainFrame
        0, // saveDataToFileInDownloadsFolder
        0, // shouldInterruptJavaScript
        createOtherPage,
        0, // mouseDidMoveOverElement
        0, // decidePolicyForNotificationPermissionRequest
    };
    WKPageSetPageUIClient(newPage, &otherPageUIClient);

    WKRetain(newPage);
    return newPage;
}
Esempio n. 4
0
TEST(WebKit2, WebWorker)
{
    // This test cover the binding between functions of JavaScript Workers and
    // functions defined at a previously loaded bundle. It verifies the two
    // types of Workers, dedicated and shared.

    WKRetainPtr<WKContextRef> context = adoptWK(Util::createContextForInjectedBundleTest("WebWorkerTest"));
    PlatformWebView view(context.get());

    WKPageLoaderClientV3 pageLoaderClient;
    memset(&pageLoaderClient, 0, sizeof(pageLoaderClient));
    pageLoaderClient.base.version = 3;
    pageLoaderClient.didReceiveTitleForFrame = didReceiveTitleForFrame;
    WKPageSetPageLoaderClient(WKViewGetPage(view.platformView()), &pageLoaderClient.base);

    WKContextInjectedBundleClientV1 injectedBundleClient;
    memset(&injectedBundleClient, 0, sizeof(injectedBundleClient));
    injectedBundleClient.base.version = 1;
    injectedBundleClient.didReceiveMessageFromInjectedBundle = didReceiveMessageFromInjectedBundle;
    WKContextSetInjectedBundleClient(context.get(), &injectedBundleClient.base);

    WKPageGroupRef pageGroup = WKPageGetPageGroup(WKViewGetPage(view.platformView()));
    WKPreferencesRef preferences = WKPageGroupGetPreferences(pageGroup);
    WKPreferencesSetFileAccessFromFileURLsAllowed(preferences, true);

    WKRetainPtr<WKURLRef> url = adoptWK(Util::createURLForResource("../WebKit2/WebWorkerTest", "html"));
    WKPageLoadURL(WKViewGetPage(view.platformView()), url.get());
    Util::run(&initialized);
    Util::run(&terminated);
    Util::run(&changedTitle);

    url = adoptWK(Util::createURLForResource("../WebKit2/WebWorkerSharedTest", "html"));
    WKPageLoadURL(WKViewGetPage(view.platformView()), url.get());
    Util::run(&initializedShared);
    Util::run(&terminatedShared);
    Util::run(&changedTitleShared);
}
Esempio n. 5
0
WKPreferencesRef QWebPreferencesPrivate::preferencesRef() const
{
    WKPageGroupRef pageGroupRef = WKPageGetPageGroup(qtWebPageProxy->pageRef());
    return WKPageGroupGetPreferences(pageGroupRef);
}