| OLD | NEW |
| 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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 webView->mainFrame()->document().unwrap<Document>()->body()->getElementById(
"translated-plugin")->focus(); | 315 webView->mainFrame()->document().unwrap<Document>()->body()->getElementById(
"translated-plugin")->focus(); |
| 316 EXPECT_TRUE(webView->mainFrame()->executeCommand("Copy")); | 316 EXPECT_TRUE(webView->mainFrame()->toWebLocalFrame()->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) | 320 TEST_F(WebPluginContainerTest, CopyFromContextMenu) |
| 321 { | 321 { |
| 322 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); | 322 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); |
| 323 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. | 323 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. |
| 324 FrameTestHelpers::WebViewHelper webViewHelper; | 324 FrameTestHelpers::WebViewHelper webViewHelper; |
| 325 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); | 325 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); |
| 326 DCHECK(webView); | 326 DCHECK(webView); |
| 327 webView->settings()->setPluginsEnabled(true); | 327 webView->settings()->setPluginsEnabled(true); |
| 328 webView->resize(WebSize(300, 300)); | 328 webView->resize(WebSize(300, 300)); |
| 329 webView->updateAllLifecyclePhases(); | 329 webView->updateAllLifecyclePhases(); |
| 330 runPendingTasks(); | 330 runPendingTasks(); |
| 331 | 331 |
| 332 auto event = FrameTestHelpers::createMouseEvent(WebMouseEvent::MouseDown, We
bMouseEvent::ButtonRight, WebPoint(30, 30), 0); | 332 auto event = FrameTestHelpers::createMouseEvent(WebMouseEvent::MouseDown, We
bMouseEvent::ButtonRight, WebPoint(30, 30), 0); |
| 333 event.clickCount = 1; | 333 event.clickCount = 1; |
| 334 | 334 |
| 335 // Make sure the right-click + Copy works in common scenario. | 335 // Make sure the right-click + Copy works in common scenario. |
| 336 webView->handleInputEvent(event); | 336 webView->handleInputEvent(event); |
| 337 EXPECT_TRUE(webView->mainFrame()->executeCommand("Copy")); | 337 EXPECT_TRUE(webView->mainFrame()->toWebLocalFrame()->executeCommand("Copy"))
; |
| 338 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We
bClipboard::Buffer())); | 338 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We
bClipboard::Buffer())); |
| 339 | 339 |
| 340 // Clear the clipboard buffer. | 340 // Clear the clipboard buffer. |
| 341 Platform::current()->clipboard()->writePlainText(WebString("")); | 341 Platform::current()->clipboard()->writePlainText(WebString("")); |
| 342 EXPECT_EQ(WebString(""), Platform::current()->clipboard()->readPlainText(Web
Clipboard::Buffer())); | 342 EXPECT_EQ(WebString(""), Platform::current()->clipboard()->readPlainText(Web
Clipboard::Buffer())); |
| 343 | 343 |
| 344 // Now, let's try a more complex scenario: | 344 // Now, let's try a more complex scenario: |
| 345 // 1) open the context menu. This will focus the plugin. | 345 // 1) open the context menu. This will focus the plugin. |
| 346 webView->handleInputEvent(event); | 346 webView->handleInputEvent(event); |
| 347 // 2) document blurs the plugin, because it can. | 347 // 2) document blurs the plugin, because it can. |
| 348 webView->clearFocusedElement(); | 348 webView->clearFocusedElement(); |
| 349 // 3) Copy should still operate on the context node, even though the focus h
ad shifted. | 349 // 3) Copy should still operate on the context node, even though the focus h
ad shifted. |
| 350 EXPECT_TRUE(webView->mainFrame()->executeCommand("Copy")); | 350 EXPECT_TRUE(webView->mainFrame()->toWebLocalFrame()->executeCommand("Copy"))
; |
| 351 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We
bClipboard::Buffer())); | 351 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We
bClipboard::Buffer())); |
| 352 } | 352 } |
| 353 | 353 |
| 354 // 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 |
| 355 // the clipboard. | 355 // the clipboard. |
| 356 TEST_F(WebPluginContainerTest, CopyInsertKeyboardEventsTest) | 356 TEST_F(WebPluginContainerTest, CopyInsertKeyboardEventsTest) |
| 357 { | 357 { |
| 358 URLTestHelpers::registerMockedURLFromBaseURL( | 358 URLTestHelpers::registerMockedURLFromBaseURL( |
| 359 WebString::fromUTF8(m_baseURL.c_str()), | 359 WebString::fromUTF8(m_baseURL.c_str()), |
| 360 WebString::fromUTF8("plugin_container.html")); | 360 WebString::fromUTF8("plugin_container.html")); |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 runPendingTasks(); | 684 runPendingTasks(); |
| 685 | 685 |
| 686 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE
lementById(WebString::fromUTF8("translated-plugin")); | 686 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE
lementById(WebString::fromUTF8("translated-plugin")); |
| 687 pluginContainerOneElement.pluginContainer()->setWantsWheelEvents(true); | 687 pluginContainerOneElement.pluginContainer()->setWantsWheelEvents(true); |
| 688 | 688 |
| 689 runPendingTasks(); | 689 runPendingTasks(); |
| 690 EXPECT_TRUE(webView->page()->frameHost().eventHandlerRegistry().hasEventHand
lers(EventHandlerRegistry::WheelEventBlocking)); | 690 EXPECT_TRUE(webView->page()->frameHost().eventHandlerRegistry().hasEventHand
lers(EventHandlerRegistry::WheelEventBlocking)); |
| 691 } | 691 } |
| 692 | 692 |
| 693 } // namespace blink | 693 } // namespace blink |
| OLD | NEW |