Exemplo n.º 1
0
TEST(WebKit2, ResizeWindowAfterCrash)
{
    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
    TestStatesData states(context.get());

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

    loaderClient.base.version = 0;
    loaderClient.base.clientInfo = &states;
    loaderClient.didFinishLoadForFrame = didFinishLoad;
    loaderClient.processDidCrash = didCrash;

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

    WKRetainPtr<WKURLRef> url = adoptWK(WKURLCreateWithUTF8CString("about:blank"));
    // Load a blank page and next kills WebProcess.
    WKPageLoadURL(states.webView.page(), url.get());
    Util::run(&states.firstLoad);
    WKPageTerminate(states.webView.page());

    // Let's try load a page and see what happens.
    WKPageLoadURL(states.webView.page(), url.get());
    Util::run(&states.resizeAfterCrash);
}
TEST(WebKit2, WKConnectionTest)
{
    WKRetainPtr<WKContextRef> context(AdoptWK, Util::createContextForInjectedBundleTest("WKConnectionTest"));

    // Set up the context's connection client so that we can access the connection when
    // it is created.
    WKContextConnectionClient contextConnectionClient;
    memset(&contextConnectionClient, 0, sizeof(contextConnectionClient));
    contextConnectionClient.version = kWKContextConnectionClientCurrentVersion;
    contextConnectionClient.clientInfo = 0;
    contextConnectionClient.didCreateConnection = didCreateConnection;
    WKContextSetConnectionClient(context.get(), &contextConnectionClient);
 
    // Load a simple page to start the WebProcess and establish a connection.
    PlatformWebView webView(context.get());
    WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("simple", "html"));
    WKPageLoadURL(webView.page(), url.get());

    // Wait until the connection is established.
    Util::run(&connectionEstablished);
    ASSERT_NOT_NULL(connectionToBundle);

    // Setup a client on the connection so we can listen for messages and
    // tear down notifications.
    WKConnectionClient connectionClient;
    memset(&connectionClient, 0, sizeof(connectionClient));
    connectionClient.version = WKConnectionClientCurrentVersion;
    connectionClient.clientInfo = 0;
    connectionClient.didReceiveMessage = connectionDidReceiveMessage;
    connectionClient.didClose = connectionDidClose;
    WKConnectionSetConnectionClient(connectionToBundle, &connectionClient);
    
    // Post a simple message to the bundle via the connection.
    WKConnectionPostMessage(connectionToBundle, Util::toWK("PingMessageName").get(), Util::toWK("PingMessageBody").get());

    // Wait for the reply.
    Util::run(&messageReceived);

    // Terminate the page to force the connection closed.
    WKPageTerminate(webView.page());
    
    // Wait for the connection to close.
    Util::run(&connectionTornDown);

    // This release is to balance the retain in didCreateConnection.
    WKRelease(connectionToBundle);
}
TEST(WebKit2, CloseThenTerminate)
{
    WKRetainPtr<WKContextRef> context = adoptWK(WKContextCreate());
    PlatformWebView webView(context.get());

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

    loaderClient.base.version = 0;
    loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
    
    WKPageSetPageLoaderClient(webView.page(), &loaderClient.base);

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

    Util::run(&loaded);

    WKPageClose(webView.page());
    WKPageTerminate(webView.page());
}
TEST(WebKit2, WKViewClientWebProcessCallbacks)
{
    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
    WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("simple", "html"));

    PlatformWebView view(context.get());

    TestStatesData states = TestStatesData(view.platformView(), url.get());

    setPageLoaderClient(view.page(), &states);
    setViewClient(view.platformView(), &states);

    WKPageLoadURL(view.page(), url.get());
    Util::run(&states.didFinishLoad);

    WKPageTerminate(view.page());
    Util::run(&states.didCrash);

    WKPageReload(view.page());
    Util::run(&states.didRelaunch);
}
Exemplo n.º 5
0
TEST(WebKit2, MouseMoveAfterCrash)
#endif
{
    WKRetainPtr<WKContextRef> context = adoptWK(Util::createContextForInjectedBundleTest("MouseMoveAfterCrashTest"));

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

    WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("mouse-move-listener", "html"));
    WKPageLoadURL(webView.page(), url.get());
    Util::run(&didFinishLoad);

    didFinishLoad = false;

    WKContextPostMessageToInjectedBundle(context.get(), Util::toWK("Pause").get(), 0);

    webView.simulateSpacebarKeyPress();

    // Move the mouse once we are hung.
    webView.simulateMouseMove(10, 10);
    webView.simulateMouseMove(20, 20);

    // After moving the mouse (while the web process was hung on the Pause message), kill the web process. It is restarted by reloading the page.
    WKPageTerminate(webView.page());
    WKPageReload(webView.page());

    // Wait until we load the page a second time.
    Util::run(&didFinishLoad);

    EXPECT_JS_FALSE(webView.page(), "didMoveMouse()");

    // Once the page has reloaded, try moving the mouse to verify that we get mouse move events.
    webView.simulateMouseMove(10, 10);
    webView.simulateMouseMove(20, 20);

    EXPECT_JS_TRUE(webView.page(), "didMoveMouse()");
}
Exemplo n.º 6
0
TEST(WebKit2, ReloadPageAfterCrash)
{
    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
    PlatformWebView webView(context.get());

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

    loaderClient.base.version = 0;
    loaderClient.didFinishLoadForFrame = didFinishLoad;
    loaderClient.processDidCrash = didCrash;

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

    WKRetainPtr<WKURLRef> url = adoptWK(WKURLCreateWithUTF8CString("about:blank"));
    // Load a blank page and next kills WebProcess.
    WKPageLoadURL(webView.page(), url.get());
    Util::run(&loadBeforeCrash);
    WKPageTerminate(webView.page());

    // Let's try load a page and see what happens.
    WKPageLoadURL(webView.page(), url.get());
    Util::run(&loadAfterCrash);
}