TEST_F(WebSearchableFormDataTest, SearchString)
{
    URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), "search_form.html");
    WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "search_form.html");

    WebVector<WebFormElement> forms;
    webView->mainFrame()->document().forms(forms);

    EXPECT_EQ(forms.size(), 1U);

    WebSearchableFormData searchableFormData(forms[0]);
    EXPECT_EQ("http://www.mock.url/search?hl=en&q={searchTerms}&btnM=Mock+Search", searchableFormData.url().string());
}
TEST_F(WebPluginContainerTest, PluginDocumentPluginIsFocused)
{
    URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("test.pdf"), WebString::fromUTF8("application/pdf"));

    TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper.
    FrameTestHelpers::WebViewHelper webViewHelper;
    WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "test.pdf", true, &pluginWebFrameClient);
    ASSERT(webView);
    webView->updateAllLifecyclePhases();

    WebDocument document = webView->mainFrame()->document();
    EXPECT_TRUE(document.isPluginDocument());
    WebPluginContainer* pluginContainer = getWebPluginContainer(webView, "plugin");
    EXPECT_EQ(document.focusedElement(), pluginContainer->element());
}
Beispiel #3
0
void TouchActionTest::runIFrameTest(std::string file) {
  TouchActionTrackingWebViewClient client;

  WebView* webView = setupTest(file, client);
  WebFrame* curFrame = webView->mainFrame()->firstChild();
  ASSERT_TRUE(curFrame);

  for (; curFrame; curFrame = curFrame->nextSibling()) {
    // Oilpan: see runTouchActionTest() comment why these are persistent
    // references.
    Persistent<Document> contentDoc =
        static_cast<Document*>(curFrame->document());
    runTestOnTree(contentDoc.get(), webView, client);
  }

  // Explicitly reset to break dependency on locally scoped client.
  m_webViewHelper.reset();
}
Frame* WebFrameLoaderClient::dispatchCreatePage()
{
#if PLATFORM(AMIGAOS4)
    extern BalWidget *createAmigaWindow(WebView *);
    extern void closeAmigaWindow(BalWidget *);

    WebView* newWebView = WebView::createInstance();
    if (newWebView) {
        BalWidget *newowbwindow = createAmigaWindow(newWebView);
        if (newowbwindow) {
            IntRect clientRect(0, 0, amigaConfig.width, amigaConfig.height);
            newWebView->initWithFrame(clientRect, "", "");
            newWebView->setViewWindow(newowbwindow);

            WebFrame *mainFrame = newWebView->mainFrame();
            if (mainFrame && mainFrame->impl())
                return mainFrame->impl();

            closeAmigaWindow(newowbwindow);
        }
        delete newWebView;
    }

    return 0;
#else
    /*WebView* webView = m_webFrame->webView();

    COMPtr<IWebUIDelegate> ui;
    if (FAILED(webView->uiDelegate(&ui)))
        return 0;

    COMPtr<IWebView> newWebView;
    if (FAILED(ui->createWebViewWithRequest(webView, 0, &newWebView)))
        return 0;

    COMPtr<IWebFrame> mainFrame;
    if (FAILED(newWebView->mainFrame(&mainFrame)))
        return 0;

    COMPtr<WebFrame> mainFrameImpl(Query, mainFrame);
    return core(mainFrameImpl.get());*/
    return 0;
#endif
}
Beispiel #5
0
void IDBFactoryBackendProxy::openFromWorker(const String& name, IDBCallbacks* callbacks, PassRefPtr<SecurityOrigin> prpOrigin, WorkerContext* context, const String& dataDir)
{
#if ENABLE(WORKERS)
    WebSecurityOrigin origin(prpOrigin);
    if (!allowIDBFromWorkerThread(context, name, origin)) {
        callbacks->onError(WebIDBDatabaseError(0, "The user denied permission to access the database."));
        return;
    }
    WorkerLoaderProxy* workerLoaderProxy = &context->thread()->workerLoaderProxy();
    WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerLoaderProxy);
    WebView* webView = webWorker->view();
    if (!webView) {
        // Frame is closed, worker is terminaring.
        return;
    }
    WebFrame* webFrame = webView->mainFrame();
    m_webIDBFactory->open(name, new WebIDBCallbacksImpl(callbacks), origin, webFrame, dataDir);
#endif
}
TEST_F(WebPluginContainerTest, GestureLongPressReachesPlugin)
{
    URLTestHelpers::registerMockedURLFromBaseURL(
        WebString::fromUTF8(m_baseURL.c_str()),
        WebString::fromUTF8("plugin_container.html"));
    EventTestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper.
    FrameTestHelpers::WebViewHelper webViewHelper;
    WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_container.html", true, &pluginWebFrameClient);
    ASSERT(webView);
    webView->settings()->setPluginsEnabled(true);
    webView->resize(WebSize(300, 300));
    webView->updateAllLifecyclePhases();
    runPendingTasks();

    WebElement pluginContainerOneElement = webView->mainFrame()->document().getElementById(WebString::fromUTF8("translated-plugin"));
    WebPlugin* plugin = static_cast<WebPluginContainerImpl*>(pluginContainerOneElement.pluginContainer())->plugin();
    EventTestPlugin* testPlugin = static_cast<EventTestPlugin*>(plugin);

    WebGestureEvent event;
    event.type = WebInputEvent::GestureLongPress;
    event.sourceDevice = WebGestureDeviceTouchscreen;

    // First, send an event that doesn't hit the plugin to verify that the
    // plugin doesn't receive it.
    event.x = 0;
    event.y = 0;

    webView->handleInputEvent(event);
    runPendingTasks();

    EXPECT_EQ(WebInputEvent::Undefined, testPlugin->getLastInputEventType());

    // Next, send an event that does hit the plugin, and verify it does receive it.
    WebRect rect = pluginContainerOneElement.boundsInViewportSpace();
    event.x = rect.x + rect.width / 2;
    event.y = rect.y + rect.height / 2;

    webView->handleInputEvent(event);
    runPendingTasks();

    EXPECT_EQ(WebInputEvent::GestureLongPress, testPlugin->getLastInputEventType());
}
Beispiel #7
0
WebView* TouchActionTest::setupTest(std::string file,
                                    TouchActionTrackingWebViewClient& client) {
  URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL),
                                               WebString::fromUTF8(file));
  // Note that JavaScript must be enabled for shadow DOM tests.
  WebView* webView =
      m_webViewHelper.initializeAndLoad(m_baseURL + file, true, 0, &client);

  // Set size to enable hit testing, and avoid line wrapping for consistency
  // with browser.
  webView->resize(WebSize(800, 1200));

  // Scroll to verify the code properly transforms windows to client co-ords.
  const int kScrollOffset = 100;
  Document* document = static_cast<Document*>(webView->mainFrame()->document());
  document->frame()->view()->layoutViewportScrollableArea()->setScrollOffset(
      ScrollOffset(0, kScrollOffset), ProgrammaticScroll);

  return webView;
}
Beispiel #8
0
void TouchActionTest::runTouchActionTest(std::string file) {
  TouchActionTrackingWebViewClient client;

  // runTouchActionTest() loads a document in a frame, setting up a
  // nested message loop. Should any Oilpan GC happen while it is in
  // effect, the implicit assumption that we're outside any event
  // loop (=> there being no pointers on the stack needing scanning)
  // when that GC strikes will no longer hold.
  //
  // To ensure that the references on the stack are also traced, we
  // turn them into persistent, stack allocated references. This
  // workaround is sufficient to handle this artificial test
  // scenario.
  WebView* webView = setupTest(file, client);

  Persistent<Document> document =
      static_cast<Document*>(webView->mainFrame()->document());
  runTestOnTree(document.get(), webView, client);

  // Explicitly reset to break dependency on locally scoped client.
  m_webViewHelper.reset();
}
TEST_F(WebPluginContainerTest, PrintAllPages)
{
    URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("test.pdf"), WebString::fromUTF8("application/pdf"));

    TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper.
    FrameTestHelpers::WebViewHelper webViewHelper;
    WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "test.pdf", true, &pluginWebFrameClient);
    ASSERT(webView);
    webView->updateAllLifecyclePhases();
    runPendingTasks();
    WebFrame* frame = webView->mainFrame();

    WebPrintParams printParams;
    printParams.printContentArea.width = 500;
    printParams.printContentArea.height = 500;

    frame->printBegin(printParams);
    SkPictureRecorder recorder;
    frame->printPagesWithBoundaries(recorder.beginRecording(IntRect()), WebSize());
    frame->printEnd();
    ASSERT(pluginWebFrameClient.printedAtLeastOnePage());
}