예제 #1
0
TEST(WebKit2, Find)
{
    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
    WKRetainPtr<WKPageNamespaceRef> pageNamespace(AdoptWK, WKPageNamespaceCreate(context.get()));
    
    PlatformWebView webView(pageNamespace.get());
    
    WKPageLoaderClient loaderClient;
    memset(&loaderClient, 0, sizeof(loaderClient));
    
    loaderClient.version = 0;
    loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
    WKPageSetPageLoaderClient(webView.page(), &loaderClient);

    WKPageFindClient findClient;
    memset(&findClient, 0, sizeof(findClient));

    findClient.version = 0;
    findClient.didCountStringMatches = didCountStringMatches;
    WKPageSetPageFindClient(webView.page(), &findClient);

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

    Util::run(&didFinishLoad);

    WKRetainPtr<WKStringRef> findString(AdoptWK, WKStringCreateWithUTF8CString("Hello"));
    WKPageCountStringMatches(webView.page(), findString.get(), true, 100);

    Util::run(&didCallCountStringMatches);
}
예제 #2
0
TEST(WebKit2, SpacebarScrolling)
{
    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
    WKRetainPtr<WKPageNamespaceRef> pageNamespace(AdoptWK, WKPageNamespaceCreate(context.get()));

    PlatformWebView webView(pageNamespace.get());

    WKPageLoaderClient loaderClient;
    memset(&loaderClient, 0, sizeof(loaderClient));
    
    loaderClient.version = 0;
    loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
    WKPageSetPageLoaderClient(webView.page(), &loaderClient);

    WKPageUIClient uiClient;
    memset(&uiClient, 0, sizeof(uiClient));

    uiClient.didNotHandleKeyEvent = didNotHandleKeyEventCallback;
    WKPageSetPageUIClient(webView.page(), &uiClient);

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

    TEST_ASSERT(runJSTest(webView.page(), "isDocumentScrolled()", "false"));
    TEST_ASSERT(runJSTest(webView.page(), "textFieldContainsSpace()", "false"));

    webView.simulateSpacebarKeyPress();

    TEST_ASSERT(runJSTest(webView.page(), "isDocumentScrolled()", "false"));
    TEST_ASSERT(runJSTest(webView.page(), "textFieldContainsSpace()", "true"));

    // On Mac, a key down event represents both a raw key down and a key press. On Windows, a key
    // down event only represents a raw key down. We expect the key press to be handled (because it
    // inserts text into the text field). But the raw key down should not be handled.
#if PLATFORM(MAC)
    TEST_ASSERT(!didNotHandleKeyDownEvent);
#elif PLATFORM(WIN)
    TEST_ASSERT(didNotHandleKeyDownEvent);
#endif

    TEST_ASSERT(runJSTest(webView.page(), "blurTextField()", "undefined"));

    didNotHandleKeyDownEvent = false;
    webView.simulateSpacebarKeyPress();

    TEST_ASSERT(runJSTest(webView.page(), "isDocumentScrolled()", "true"));
    TEST_ASSERT(runJSTest(webView.page(), "textFieldContainsSpace()", "true"));
#if PLATFORM(MAC)
    TEST_ASSERT(!didNotHandleKeyDownEvent);
#elif PLATFORM(WIN)
    TEST_ASSERT(didNotHandleKeyDownEvent);
#endif
}
예제 #3
0
TEST(WebKit2, FailedLoad)
{
    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
    WKRetainPtr<WKPageNamespaceRef> pageNamespace(AdoptWK, WKPageNamespaceCreate(context.get()));
    PlatformWebView webView(pageNamespace.get());

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

    loaderClient.version = 0;
    loaderClient.clientInfo = 0;
    loaderClient.didFailProvisionalLoadWithErrorForFrame = didFailProvisionalLoadWithErrorForFrame;
    WKPageSetPageLoaderClient(webView.page(), &loaderClient);

    WKRetainPtr<WKURLRef> url(AdoptWK, Util::URLForNonExistentResource());
    WKPageLoadURL(webView.page(), url.get());

    Util::run(&testDone);
}
예제 #4
0
TEST(WebKit2, FrameMIMETypePNG)
{
    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
    WKRetainPtr<WKPageNamespaceRef> pageNamespace(AdoptWK, WKPageNamespaceCreate(context.get()));
    PlatformWebView webView(pageNamespace.get());

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

    loaderClient.version = 0;
    loaderClient.clientInfo = 0;
    loaderClient.didStartProvisionalLoadForFrame = didStartProvisionalLoadForFrame;
    loaderClient.didCommitLoadForFrame = didCommitLoadForFrame;
    loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
    WKPageSetPageLoaderClient(webView.page(), &loaderClient);

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

    Util::run(&testDone);
}
예제 #5
0
void WebPageProxy::preferencesDidChange()
{
    if (!isValid())
        return;

    // FIXME: It probably makes more sense to send individual preference changes.
    process()->connection()->send(WebPageMessage::PreferencesDidChange, m_pageID, CoreIPC::In(pageNamespace()->context()->preferences()->store()));
}
예제 #6
0
void WebPageProxy::reinitializeWebPage(const WebCore::IntSize& size)
{
    if (!isValid())
        return;

    ASSERT(m_drawingArea);
    process()->connection()->send(WebProcessMessage::Create, m_pageID, CoreIPC::In(size, pageNamespace()->context()->preferences()->store(), *(m_drawingArea.get())));
}
예제 #7
0
void WebPageProxy::initializeWebPage(const IntSize& size, PassOwnPtr<DrawingAreaProxy> drawingArea)
{
    if (!isValid()) {
        puts("initializeWebPage called with a dead WebProcess");
        revive();
        return;
    }

    m_drawingArea = drawingArea;
    process()->connection()->send(WebProcessMessage::Create, m_pageID, CoreIPC::In(size, pageNamespace()->context()->preferences()->store(), *(m_drawingArea.get())));
}