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

Side by Side Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 2712603007: Select All present even all selectable text has been selected (Closed)
Patch Set: only set edit flags when document is HTML or XHTML 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/web/ContextMenuClientImpl.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 #include "public/platform/WebClipboard.h" 111 #include "public/platform/WebClipboard.h"
112 #include "public/platform/WebFloatRect.h" 112 #include "public/platform/WebFloatRect.h"
113 #include "public/platform/WebMockClipboard.h" 113 #include "public/platform/WebMockClipboard.h"
114 #include "public/platform/WebSecurityOrigin.h" 114 #include "public/platform/WebSecurityOrigin.h"
115 #include "public/platform/WebThread.h" 115 #include "public/platform/WebThread.h"
116 #include "public/platform/WebURL.h" 116 #include "public/platform/WebURL.h"
117 #include "public/platform/WebURLLoaderClient.h" 117 #include "public/platform/WebURLLoaderClient.h"
118 #include "public/platform/WebURLLoaderMockFactory.h" 118 #include "public/platform/WebURLLoaderMockFactory.h"
119 #include "public/platform/WebURLResponse.h" 119 #include "public/platform/WebURLResponse.h"
120 #include "public/web/WebConsoleMessage.h" 120 #include "public/web/WebConsoleMessage.h"
121 #include "public/web/WebContextMenuData.h"
121 #include "public/web/WebDataSource.h" 122 #include "public/web/WebDataSource.h"
122 #include "public/web/WebDeviceEmulationParams.h" 123 #include "public/web/WebDeviceEmulationParams.h"
123 #include "public/web/WebDocument.h" 124 #include "public/web/WebDocument.h"
124 #include "public/web/WebFindOptions.h" 125 #include "public/web/WebFindOptions.h"
125 #include "public/web/WebFormElement.h" 126 #include "public/web/WebFormElement.h"
126 #include "public/web/WebFrameClient.h" 127 #include "public/web/WebFrameClient.h"
127 #include "public/web/WebFrameContentDumper.h" 128 #include "public/web/WebFrameContentDumper.h"
128 #include "public/web/WebFrameWidget.h" 129 #include "public/web/WebFrameWidget.h"
129 #include "public/web/WebHistoryItem.h" 130 #include "public/web/WebHistoryItem.h"
130 #include "public/web/WebPrintParams.h" 131 #include "public/web/WebPrintParams.h"
(...skipping 11310 matching lines...) Expand 10 before | Expand all | Expand 10 after
11441 WebScriptSource("window.focus();" 11442 WebScriptSource("window.focus();"
11442 "document.querySelector('input').focus();")); 11443 "document.querySelector('input').focus();"));
11443 11444
11444 // Verify that the right WebWidgetClient has been notified. 11445 // Verify that the right WebWidgetClient has been notified.
11445 EXPECT_TRUE(webWidgetClient.didShowVirtualKeyboard()); 11446 EXPECT_TRUE(webWidgetClient.didShowVirtualKeyboard());
11446 11447
11447 remoteFrame->close(); 11448 remoteFrame->close();
11448 webViewHelper.reset(); 11449 webViewHelper.reset();
11449 } 11450 }
11450 11451
11452 class ContextMenuWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
11453 public:
11454 // WebFrameClient methods
11455 void showContextMenu(const WebContextMenuData& data) override {
11456 m_menuData = data;
11457 }
11458
11459 WebContextMenuData getMenuData() { return m_menuData; }
11460
11461 private:
11462 WebContextMenuData m_menuData;
11463 };
yosin_UTC9 2017/03/16 01:21:35 nit: Could you add |DISALLOW_COPY_AND_ASSIGN(Conte
11464
11465 bool testSelectAll(const std::string& html) {
11466 ContextMenuWebFrameClient frame;
11467 FrameTestHelpers::WebViewHelper webViewHelper;
11468 WebViewImpl* webView = webViewHelper.initialize(true, &frame);
11469 FrameTestHelpers::loadHTMLString(webView->mainFrame(), html,
11470 toKURL("about:blank"));
11471 webView->resize(WebSize(500, 300));
11472 webView->updateAllLifecyclePhases();
11473 runPendingTasks();
11474 webView->setInitialFocus(false);
11475 runPendingTasks();
11476
11477 WebMouseEvent mouseEvent(WebInputEvent::MouseDown, WebInputEvent::NoModifiers,
11478 WebInputEvent::TimeStampForTesting);
11479
11480 mouseEvent.button = WebMouseEvent::Button::Right;
11481 mouseEvent.x = 10;
11482 mouseEvent.y = 10;
11483 mouseEvent.clickCount = 1;
11484 webView->handleInputEvent(WebCoalescedInputEvent(mouseEvent));
11485 runPendingTasks();
11486 webViewHelper.reset();
11487 return frame.getMenuData().editFlags & WebContextMenuData::CanSelectAll;
11488 }
11489
11490 TEST_F(WebFrameTest, ContextMenuData) {
11491 EXPECT_FALSE(testSelectAll("<textarea></textarea>"));
11492 EXPECT_TRUE(testSelectAll("<textarea>nonempty</textarea>"));
11493 EXPECT_FALSE(testSelectAll("<input>"));
11494 EXPECT_TRUE(testSelectAll("<input value='nonempty'>"));
11495 EXPECT_TRUE(testSelectAll("<div contenteditable></div>"));
yosin_UTC9 2017/03/16 01:21:35 nit: Could you add a TODO comment that we actually
11496 EXPECT_TRUE(testSelectAll("<div contenteditable>nonempty</div>"));
11497 }
11498
11451 } // namespace blink 11499 } // namespace blink
OLDNEW
« 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