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

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

Issue 2712603007: Select All present even all selectable text has been selected (Closed)
Patch Set: yosin's nits Created 3 years, 9 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/ContextMenuClientImpl.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/tests/WebFrameTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
index e4c8df9640211892d556ce0e1292500a8fcacc1a..b569a675a4400a9458741405d109d4e247beae39 100644
--- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
@@ -118,6 +118,7 @@
#include "public/platform/WebURLLoaderMockFactory.h"
#include "public/platform/WebURLResponse.h"
#include "public/web/WebConsoleMessage.h"
+#include "public/web/WebContextMenuData.h"
#include "public/web/WebDataSource.h"
#include "public/web/WebDeviceEmulationParams.h"
#include "public/web/WebDocument.h"
@@ -11448,4 +11449,54 @@ TEST_F(WebFrameTest, ShowVirtualKeyboardOnElementFocus) {
webViewHelper.reset();
}
+class ContextMenuWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
+ public:
+ ContextMenuWebFrameClient(){};
+ // WebFrameClient methods
+ void showContextMenu(const WebContextMenuData& data) override {
+ m_menuData = data;
+ }
+
+ WebContextMenuData getMenuData() { return m_menuData; }
+
+ private:
+ WebContextMenuData m_menuData;
+ DISALLOW_COPY_AND_ASSIGN(ContextMenuWebFrameClient);
+};
+
+bool testSelectAll(const std::string& html) {
+ ContextMenuWebFrameClient frame;
+ FrameTestHelpers::WebViewHelper webViewHelper;
+ WebViewImpl* webView = webViewHelper.initialize(true, &frame);
+ FrameTestHelpers::loadHTMLString(webView->mainFrame(), html,
+ toKURL("about:blank"));
+ webView->resize(WebSize(500, 300));
+ webView->updateAllLifecyclePhases();
+ runPendingTasks();
+ webView->setInitialFocus(false);
+ runPendingTasks();
+
+ WebMouseEvent mouseEvent(WebInputEvent::MouseDown, WebInputEvent::NoModifiers,
+ WebInputEvent::TimeStampForTesting);
+
+ mouseEvent.button = WebMouseEvent::Button::Right;
+ mouseEvent.x = 10;
+ mouseEvent.y = 10;
+ mouseEvent.clickCount = 1;
+ webView->handleInputEvent(WebCoalescedInputEvent(mouseEvent));
+ runPendingTasks();
+ webViewHelper.reset();
+ return frame.getMenuData().editFlags & WebContextMenuData::CanSelectAll;
+}
+
+TEST_F(WebFrameTest, ContextMenuData) {
+ EXPECT_FALSE(testSelectAll("<textarea></textarea>"));
+ EXPECT_TRUE(testSelectAll("<textarea>nonempty</textarea>"));
+ EXPECT_FALSE(testSelectAll("<input>"));
+ EXPECT_TRUE(testSelectAll("<input value='nonempty'>"));
+ // TODO(amaralp): Empty contenteditable should not have select all enabled.
+ EXPECT_TRUE(testSelectAll("<div contenteditable></div>"));
+ EXPECT_TRUE(testSelectAll("<div contenteditable>nonempty</div>"));
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/web/ContextMenuClientImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698