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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("plugin_container.html")); 305 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("plugin_container.html"));
306 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper . 306 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper .
307 FrameTestHelpers::WebViewHelper webViewHelper; 307 FrameTestHelpers::WebViewHelper webViewHelper;
308 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta iner.html", true, &pluginWebFrameClient); 308 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta iner.html", true, &pluginWebFrameClient);
309 DCHECK(webView); 309 DCHECK(webView);
310 webView->settings()->setPluginsEnabled(true); 310 webView->settings()->setPluginsEnabled(true);
311 webView->resize(WebSize(300, 300)); 311 webView->resize(WebSize(300, 300));
312 webView->updateAllLifecyclePhases(); 312 webView->updateAllLifecyclePhases();
313 runPendingTasks(); 313 runPendingTasks();
314 314
315 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE lementById(WebString::fromUTF8("translated-plugin")); 315 webView->mainFrame()->document().unwrap<Document>()->body()->getElementById( "translated-plugin")->focus();
316 EXPECT_TRUE(webView->mainFrame()->executeCommand("Copy", pluginContainerOne Element)); 316 EXPECT_TRUE(webView->mainFrame()->executeCommand("Copy"));
317 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We bClipboard::Buffer())); 317 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We bClipboard::Buffer()));
318 } 318 }
319 319
320 TEST_F(WebPluginContainerTest, CopyFromContextMenu)
321 {
322 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("plugin_container.html"));
323 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper .
324 FrameTestHelpers::WebViewHelper webViewHelper;
325 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta iner.html", true, &pluginWebFrameClient);
326 DCHECK(webView);
327 webView->settings()->setPluginsEnabled(true);
328 webView->resize(WebSize(300, 300));
329 webView->updateAllLifecyclePhases();
330 runPendingTasks();
331
332 auto event = FrameTestHelpers::createMouseEvent(WebMouseEvent::MouseDown, We bMouseEvent::ButtonRight, WebPoint(30, 30), 0);
333 event.clickCount = 1;
334
335 // Make sure the right-click + Copy works in common scenario.
336 webView->handleInputEvent(event);
337 EXPECT_TRUE(webView->mainFrame()->executeCommand("Copy"));
338 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We bClipboard::Buffer()));
339
340 // Clear the clipboard buffer.
341 Platform::current()->clipboard()->writePlainText(WebString(""));
342 EXPECT_EQ(WebString(""), Platform::current()->clipboard()->readPlainText(Web Clipboard::Buffer()));
343
344 // Now, let's try a more complex scenario:
345 // 1) open the context menu. This will focus the plugin.
346 webView->handleInputEvent(event);
347 // 2) document blurs the plugin, because it can.
348 webView->clearFocusedElement();
349 // 3) Copy should still operate on the context node, even though the focus h ad shifted.
350 EXPECT_TRUE(webView->mainFrame()->executeCommand("Copy"));
351 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We bClipboard::Buffer()));
352 }
353
320 // Verifies |Ctrl-C| and |Ctrl-Insert| keyboard events, results in copying to 354 // Verifies |Ctrl-C| and |Ctrl-Insert| keyboard events, results in copying to
321 // the clipboard. 355 // the clipboard.
322 TEST_F(WebPluginContainerTest, CopyInsertKeyboardEventsTest) 356 TEST_F(WebPluginContainerTest, CopyInsertKeyboardEventsTest)
323 { 357 {
324 URLTestHelpers::registerMockedURLFromBaseURL( 358 URLTestHelpers::registerMockedURLFromBaseURL(
325 WebString::fromUTF8(m_baseURL.c_str()), 359 WebString::fromUTF8(m_baseURL.c_str()),
326 WebString::fromUTF8("plugin_container.html")); 360 WebString::fromUTF8("plugin_container.html"));
327 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper . 361 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper .
328 FrameTestHelpers::WebViewHelper webViewHelper; 362 FrameTestHelpers::WebViewHelper webViewHelper;
329 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta iner.html", true, &pluginWebFrameClient); 363 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta iner.html", true, &pluginWebFrameClient);
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 runPendingTasks(); 684 runPendingTasks();
651 685
652 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE lementById(WebString::fromUTF8("translated-plugin")); 686 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE lementById(WebString::fromUTF8("translated-plugin"));
653 pluginContainerOneElement.pluginContainer()->setWantsWheelEvents(true); 687 pluginContainerOneElement.pluginContainer()->setWantsWheelEvents(true);
654 688
655 runPendingTasks(); 689 runPendingTasks();
656 EXPECT_TRUE(webView->page()->frameHost().eventHandlerRegistry().hasEventHand lers(EventHandlerRegistry::WheelEventBlocking)); 690 EXPECT_TRUE(webView->page()->frameHost().eventHandlerRegistry().hasEventHand lers(EventHandlerRegistry::WheelEventBlocking));
657 } 691 }
658 692
659 } // namespace blink 693 } // namespace blink
OLDNEW
« 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