| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 ContextMenuWebFrameClient(){}; |
| 11455 // WebFrameClient methods |
| 11456 void showContextMenu(const WebContextMenuData& data) override { |
| 11457 m_menuData = data; |
| 11458 } |
| 11459 |
| 11460 WebContextMenuData getMenuData() { return m_menuData; } |
| 11461 |
| 11462 private: |
| 11463 WebContextMenuData m_menuData; |
| 11464 DISALLOW_COPY_AND_ASSIGN(ContextMenuWebFrameClient); |
| 11465 }; |
| 11466 |
| 11467 bool testSelectAll(const std::string& html) { |
| 11468 ContextMenuWebFrameClient frame; |
| 11469 FrameTestHelpers::WebViewHelper webViewHelper; |
| 11470 WebViewImpl* webView = webViewHelper.initialize(true, &frame); |
| 11471 FrameTestHelpers::loadHTMLString(webView->mainFrame(), html, |
| 11472 toKURL("about:blank")); |
| 11473 webView->resize(WebSize(500, 300)); |
| 11474 webView->updateAllLifecyclePhases(); |
| 11475 runPendingTasks(); |
| 11476 webView->setInitialFocus(false); |
| 11477 runPendingTasks(); |
| 11478 |
| 11479 WebMouseEvent mouseEvent(WebInputEvent::MouseDown, WebInputEvent::NoModifiers, |
| 11480 WebInputEvent::TimeStampForTesting); |
| 11481 |
| 11482 mouseEvent.button = WebMouseEvent::Button::Right; |
| 11483 mouseEvent.x = 10; |
| 11484 mouseEvent.y = 10; |
| 11485 mouseEvent.clickCount = 1; |
| 11486 webView->handleInputEvent(WebCoalescedInputEvent(mouseEvent)); |
| 11487 runPendingTasks(); |
| 11488 webViewHelper.reset(); |
| 11489 return frame.getMenuData().editFlags & WebContextMenuData::CanSelectAll; |
| 11490 } |
| 11491 |
| 11492 TEST_F(WebFrameTest, ContextMenuData) { |
| 11493 EXPECT_FALSE(testSelectAll("<textarea></textarea>")); |
| 11494 EXPECT_TRUE(testSelectAll("<textarea>nonempty</textarea>")); |
| 11495 EXPECT_FALSE(testSelectAll("<input>")); |
| 11496 EXPECT_TRUE(testSelectAll("<input value='nonempty'>")); |
| 11497 // TODO(amaralp): Empty contenteditable should not have select all enabled. |
| 11498 EXPECT_TRUE(testSelectAll("<div contenteditable></div>")); |
| 11499 EXPECT_TRUE(testSelectAll("<div contenteditable>nonempty</div>")); |
| 11500 } |
| 11501 |
| 11451 } // namespace blink | 11502 } // namespace blink |
| OLD | NEW |