コード例 #1
0
// Verifies |Ctrl-C| and |Ctrl-Insert| keyboard events, results in copying to
// the clipboard.
TEST_F(WebPluginContainerTest, CopyInsertKeyboardEventsTest)
{
    URLTestHelpers::registerMockedURLFromBaseURL(
        WebString::fromUTF8(m_baseURL.c_str()),
        WebString::fromUTF8("plugin_container.html"));
    TestPluginWebFrameClient 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"));
    PlatformEvent::Modifiers modifierKey = static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | PlatformEvent::NumLockOn | PlatformEvent::IsLeft);
#if OS(MACOSX)
    modifierKey = static_cast<PlatformEvent::Modifiers>(PlatformEvent::MetaKey | PlatformEvent::NumLockOn | PlatformEvent::IsLeft);
#endif
    PlatformKeyboardEvent platformKeyboardEventC(PlatformEvent::RawKeyDown, "", "", "67", "", "", 67, 0, false, modifierKey, 0.0);
    RefPtrWillBeRawPtr<KeyboardEvent> keyEventC = KeyboardEvent::create(platformKeyboardEventC, 0);
    toWebPluginContainerImpl(pluginContainerOneElement.pluginContainer())->handleEvent(keyEventC.get());
    EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(WebClipboard::Buffer()));

    // Clearing |Clipboard::Buffer()|.
    Platform::current()->clipboard()->writePlainText(WebString(""));
    EXPECT_EQ(WebString(""), Platform::current()->clipboard()->readPlainText(WebClipboard::Buffer()));

    PlatformKeyboardEvent platformKeyboardEventInsert(PlatformEvent::RawKeyDown, "", "", "45", "", "", 45, 0, false, modifierKey, 0.0);
    RefPtrWillBeRawPtr<KeyboardEvent> keyEventInsert = KeyboardEvent::create(platformKeyboardEventInsert, 0);
    toWebPluginContainerImpl(pluginContainerOneElement.pluginContainer())->handleEvent(keyEventInsert.get());
    EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(WebClipboard::Buffer()));
}
コード例 #2
0
TEST_F(WebNodeTest, QuerySelectorError)
{
    setInnerHTML("<div></div>");
    WebExceptionCode ec;
    WebElement element = root().querySelector("@invalid-selector", ec);
    EXPECT_NE(0, ec);
    EXPECT_TRUE(element.isNull());
}
コード例 #3
0
TEST_F(WebNodeTest, QuerySelectorDoesNotMatch)
{
    setInnerHTML("<div id=x><span class=a></span></div>");
    WebExceptionCode ec;
    WebElement element = root().querySelector("section", ec);
    EXPECT_EQ(0, ec);
    EXPECT_TRUE(element.isNull());
}
コード例 #4
0
void TestRunner::markerTextForListItem(const CppArgumentList& args, CppVariant* result)
{
    WebElement element;
    if (!WebBindings::getElement(args[0].value.objectValue, &element))
        result->setNull();
    else
        result->set(element.document().frame()->markerTextForListItem(element).utf8());
}
コード例 #5
0
static string dumpDocumentText(WebFrame* frame)
{
    // We use the document element's text instead of the body text here because
    // not all documents have a body, such as XML documents.
    WebElement documentElement = frame->document().documentElement();
    if (documentElement.isNull())
        return string();
    return documentElement.innerText().utf8();
}
コード例 #6
0
TEST_F(WebNodeTest, QuerySelectorMatches)
{
    setInnerHTML("<div id=x><span class=a></span></div>");
    WebExceptionCode ec;
    WebElement element = root().querySelector(".a", ec);
    EXPECT_EQ(0, ec);
    EXPECT_FALSE(element.isNull());
    EXPECT_TRUE(element.hasHTMLTagName("span"));
}
コード例 #7
0
bool TestRunner::elementDoesAutoCompleteForElementWithId(const WebString& elementId)
{
    WebFrame* webFrame = m_webView->mainFrame();
    if (!webFrame)
        return false;

    WebElement element = webFrame->document().getElementById(elementId);
    if (element.isNull() || !element.hasTagName("input"))
        return false;

    WebInputElement inputElement = element.to<WebInputElement>();
    return inputElement.autoComplete();
}
コード例 #8
0
bool TestRunner::pauseTransitionAtTimeOnElementWithId(const WebString& propertyName, double time, const WebString& elementId)
{
    WebFrame* webFrame = m_webView->mainFrame();
    if (!webFrame)
        return false;

    WebAnimationController* controller = webFrame->animationController();
    if (!controller)
        return false;

    WebElement element = webFrame->document().getElementById(elementId);
    if (element.isNull())
        return false;
    return controller->pauseTransitionAtTime(element, propertyName, time);
}
コード例 #9
0
bool LayoutTestController::pauseAnimationAtTimeOnElementWithId(const WebString& animationName, double time, const WebString& elementId)
{
    WebFrame* webFrame = m_shell->webView()->mainFrame();
    if (!webFrame)
        return false;

    WebAnimationController* controller = webFrame->animationController();
    if (!controller)
        return false;

    WebElement element = webFrame->document().getElementById(elementId);
    if (element.isNull())
        return false;
    return controller->pauseAnimationAtTime(element, animationName, time);
}
コード例 #10
0
TEST_F(WebPluginContainerTest, ClippedRectsForIframedElement)
{
    URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("plugin_container.html"));
    URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("plugin_containing_page.html"));

    TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper.
    FrameTestHelpers::WebViewHelper webViewHelper;
    WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_containing_page.html", true, &pluginWebFrameClient);
    ASSERT(webView);
    webView->settings()->setPluginsEnabled(true);
    webView->resize(WebSize(300, 300));
    webView->updateAllLifecyclePhases();
    runPendingTasks();

    WebElement pluginElement = webView->mainFrame()->firstChild()->document().getElementById("translated-plugin");
    RefPtrWillBeRawPtr<WebPluginContainerImpl> pluginContainerImpl = toWebPluginContainerImpl(pluginElement.pluginContainer());

    ASSERT(pluginContainerImpl.get());
    pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300));

    IntRect windowRect, clipRect, unobscuredRect;
    Vector<IntRect> cutOutRects;
    calculateGeometry(pluginContainerImpl.get(), windowRect, clipRect, unobscuredRect, cutOutRects);
    EXPECT_RECT_EQ(IntRect(10, 210, 300, 300), windowRect);
    EXPECT_RECT_EQ(IntRect(0, 0, 240, 90), clipRect);
    EXPECT_RECT_EQ(IntRect(0, 0, 240, 160), unobscuredRect);

    // Cause the plugin's frame to be detached.
    webViewHelper.reset();
}
コード例 #11
0
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());
}
コード例 #12
0
AccessibilityUIElement* AccessibilityController::findAccessibleElementByIdRecursive(const WebAccessibilityObject& obj, const WebString& id)
{
    if (obj.isNull() || obj.isDetached())
        return 0;

    WebNode node = obj.node();
    if (!node.isNull() && node.isElementNode()) {
        WebElement element = node.to<WebElement>();
        element.getAttribute("id");
        if (element.getAttribute("id") == id) 
            return m_elements.getOrCreate(obj);
    }

    unsigned childCount = obj.childCount();
    for (unsigned i = 0; i < childCount; i++) {
        if (AccessibilityUIElement* result = findAccessibleElementByIdRecursive(obj.childAt(i), id))
            return result;
    }

    return 0;
}
コード例 #13
0
void WebLocalFrameImpl::requestTextChecking(const WebElement& webElement)
{
    if (webElement.isNull())
        return;
    frame()->spellChecker().requestTextChecking(*webElement.constUnwrap<Element>());
}
コード例 #14
0
WebPluginContainer* getWebPluginContainer(WebView* webView, const WebString& id)
{
    WebElement element = webView->mainFrame()->document().getElementById(id);
    return element.pluginContainer();
}