Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(807)

Unified Diff: third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp

Issue 1977633003: Remove RenderFrameImpl::GetFocusedElement. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes the right click + blur + copy case. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.cpp ('k') | third_party/WebKit/public/web/WebFrame.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp b/third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp
index 24474b76fef397c6c7d706125fa33d1606667a24..b69327a7f52ea1a6b76107a139bfb1c659756156 100644
--- a/third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp
@@ -312,8 +312,42 @@ TEST_F(WebPluginContainerTest, Copy)
webView->updateAllLifecyclePhases();
runPendingTasks();
- WebElement pluginContainerOneElement = webView->mainFrame()->document().getElementById(WebString::fromUTF8("translated-plugin"));
- EXPECT_TRUE(webView->mainFrame()->executeCommand("Copy", pluginContainerOneElement));
+ webView->mainFrame()->document().unwrap<Document>()->body()->getElementById("translated-plugin")->focus();
+ EXPECT_TRUE(webView->mainFrame()->executeCommand("Copy"));
+ EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(WebClipboard::Buffer()));
+}
+
+TEST_F(WebPluginContainerTest, CopyFromContextMenu)
+{
+ 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);
+ DCHECK(webView);
+ webView->settings()->setPluginsEnabled(true);
+ webView->resize(WebSize(300, 300));
+ webView->updateAllLifecyclePhases();
+ runPendingTasks();
+
+ auto event = FrameTestHelpers::createMouseEvent(WebMouseEvent::MouseDown, WebMouseEvent::ButtonRight, WebPoint(30, 30), 0);
+ event.clickCount = 1;
+
+ // Make sure the right-click + Copy works in common scenario.
+ webView->handleInputEvent(event);
+ EXPECT_TRUE(webView->mainFrame()->executeCommand("Copy"));
+ EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(WebClipboard::Buffer()));
+
+ // Clear the clipboard buffer.
+ Platform::current()->clipboard()->writePlainText(WebString(""));
+ EXPECT_EQ(WebString(""), Platform::current()->clipboard()->readPlainText(WebClipboard::Buffer()));
+
+ // Now, let's try a more complex scenario:
+ // 1) open the context menu. This will focus the plugin.
+ webView->handleInputEvent(event);
+ // 2) document blurs the plugin, because it can.
+ webView->clearFocusedElement();
+ // 3) Copy should still operate on the context node, even though the focus had shifted.
+ EXPECT_TRUE(webView->mainFrame()->executeCommand("Copy"));
EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(WebClipboard::Buffer()));
}
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.cpp ('k') | third_party/WebKit/public/web/WebFrame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698