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