Chromium Code Reviews| 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..9b830e71c0f0652e89a6b7618d85d035d2fb0bad 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,51 @@ TEST_F(WebFrameTest, ShowVirtualKeyboardOnElementFocus) { |
| webViewHelper.reset(); |
| } |
| +class ContextMenuWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
| + public: |
| + // WebFrameClient methods |
| + void showContextMenu(const WebContextMenuData& data) override { |
| + m_menuData = data; |
| + } |
| + |
| + WebContextMenuData getMenuData() { return m_menuData; } |
| + |
| + private: |
| + WebContextMenuData m_menuData; |
| +}; |
|
yosin_UTC9
2017/03/16 01:21:35
nit: Could you add |DISALLOW_COPY_AND_ASSIGN(Conte
|
| + |
| +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'>")); |
| + EXPECT_TRUE(testSelectAll("<div contenteditable></div>")); |
|
yosin_UTC9
2017/03/16 01:21:35
nit: Could you add a TODO comment that we actually
|
| + EXPECT_TRUE(testSelectAll("<div contenteditable>nonempty</div>")); |
| +} |
| + |
| } // namespace blink |