| 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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 webView->resize(WebSize(300, 300)); | 288 webView->resize(WebSize(300, 300)); |
| 289 webView->updateAllLifecyclePhases(); | 289 webView->updateAllLifecyclePhases(); |
| 290 runPendingTasks(); | 290 runPendingTasks(); |
| 291 | 291 |
| 292 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE
lementById(WebString::fromUTF8("translated-plugin")); | 292 WebElement pluginContainerOneElement = webView->mainFrame()->document().getE
lementById(WebString::fromUTF8("translated-plugin")); |
| 293 PlatformEvent::Modifiers modifierKey = static_cast<PlatformEvent::Modifiers>
(PlatformEvent::CtrlKey | PlatformEvent::NumLockOn | PlatformEvent::IsLeft); | 293 PlatformEvent::Modifiers modifierKey = static_cast<PlatformEvent::Modifiers>
(PlatformEvent::CtrlKey | PlatformEvent::NumLockOn | PlatformEvent::IsLeft); |
| 294 #if OS(MACOSX) | 294 #if OS(MACOSX) |
| 295 modifierKey = static_cast<PlatformEvent::Modifiers>(PlatformEvent::MetaKey |
PlatformEvent::NumLockOn | PlatformEvent::IsLeft); | 295 modifierKey = static_cast<PlatformEvent::Modifiers>(PlatformEvent::MetaKey |
PlatformEvent::NumLockOn | PlatformEvent::IsLeft); |
| 296 #endif | 296 #endif |
| 297 PlatformKeyboardEvent platformKeyboardEventC(PlatformEvent::RawKeyDown, "",
"", "67", "", "", 67, 0, false, modifierKey, 0.0); | 297 PlatformKeyboardEvent platformKeyboardEventC(PlatformEvent::RawKeyDown, "",
"", "67", "", "", 67, 0, false, modifierKey, 0.0); |
| 298 RefPtrWillBeRawPtr<KeyboardEvent> keyEventC = KeyboardEvent::create(platform
KeyboardEventC, 0); | 298 RawPtr<KeyboardEvent> keyEventC = KeyboardEvent::create(platformKeyboardEven
tC, 0); |
| 299 toWebPluginContainerImpl(pluginContainerOneElement.pluginContainer())->handl
eEvent(keyEventC.get()); | 299 toWebPluginContainerImpl(pluginContainerOneElement.pluginContainer())->handl
eEvent(keyEventC.get()); |
| 300 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We
bClipboard::Buffer())); | 300 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We
bClipboard::Buffer())); |
| 301 | 301 |
| 302 // Clearing |Clipboard::Buffer()|. | 302 // Clearing |Clipboard::Buffer()|. |
| 303 Platform::current()->clipboard()->writePlainText(WebString("")); | 303 Platform::current()->clipboard()->writePlainText(WebString("")); |
| 304 EXPECT_EQ(WebString(""), Platform::current()->clipboard()->readPlainText(Web
Clipboard::Buffer())); | 304 EXPECT_EQ(WebString(""), Platform::current()->clipboard()->readPlainText(Web
Clipboard::Buffer())); |
| 305 | 305 |
| 306 PlatformKeyboardEvent platformKeyboardEventInsert(PlatformEvent::RawKeyDown,
"", "", "45", "", "", 45, 0, false, modifierKey, 0.0); | 306 PlatformKeyboardEvent platformKeyboardEventInsert(PlatformEvent::RawKeyDown,
"", "", "45", "", "", 45, 0, false, modifierKey, 0.0); |
| 307 RefPtrWillBeRawPtr<KeyboardEvent> keyEventInsert = KeyboardEvent::create(pla
tformKeyboardEventInsert, 0); | 307 RawPtr<KeyboardEvent> keyEventInsert = KeyboardEvent::create(platformKeyboar
dEventInsert, 0); |
| 308 toWebPluginContainerImpl(pluginContainerOneElement.pluginContainer())->handl
eEvent(keyEventInsert.get()); | 308 toWebPluginContainerImpl(pluginContainerOneElement.pluginContainer())->handl
eEvent(keyEventInsert.get()); |
| 309 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We
bClipboard::Buffer())); | 309 EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(We
bClipboard::Buffer())); |
| 310 } | 310 } |
| 311 | 311 |
| 312 // A class to facilitate testing that events are correctly received by plugins. | 312 // A class to facilitate testing that events are correctly received by plugins. |
| 313 class EventTestPlugin : public FakeWebPlugin { | 313 class EventTestPlugin : public FakeWebPlugin { |
| 314 public: | 314 public: |
| 315 EventTestPlugin(WebFrame* frame, const WebPluginParams& params) | 315 EventTestPlugin(WebFrame* frame, const WebPluginParams& params) |
| 316 : FakeWebPlugin(frame, params) | 316 : FakeWebPlugin(frame, params) |
| 317 , m_lastEventType(WebInputEvent::Undefined) | 317 , m_lastEventType(WebInputEvent::Undefined) |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); | 387 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); |
| 388 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. | 388 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. |
| 389 FrameTestHelpers::WebViewHelper webViewHelper; | 389 FrameTestHelpers::WebViewHelper webViewHelper; |
| 390 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); | 390 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); |
| 391 ASSERT(webView); | 391 ASSERT(webView); |
| 392 webView->settings()->setPluginsEnabled(true); | 392 webView->settings()->setPluginsEnabled(true); |
| 393 webView->resize(WebSize(300, 300)); | 393 webView->resize(WebSize(300, 300)); |
| 394 webView->updateAllLifecyclePhases(); | 394 webView->updateAllLifecyclePhases(); |
| 395 runPendingTasks(); | 395 runPendingTasks(); |
| 396 | 396 |
| 397 RefPtrWillBeRawPtr<WebPluginContainerImpl> pluginContainerImpl = | 397 RawPtr<WebPluginContainerImpl> pluginContainerImpl = |
| 398 toWebPluginContainerImpl(getWebPluginContainer(webView, WebString::fromU
TF8("translated-plugin"))); | 398 toWebPluginContainerImpl(getWebPluginContainer(webView, WebString::fromU
TF8("translated-plugin"))); |
| 399 pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300)); | 399 pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300)); |
| 400 | 400 |
| 401 WebRect rect = pluginContainerImpl->element().boundsInViewport(); | 401 WebRect rect = pluginContainerImpl->element().boundsInViewport(); |
| 402 EXPECT_TRUE(pluginContainerImpl->isRectTopmost(rect)); | 402 EXPECT_TRUE(pluginContainerImpl->isRectTopmost(rect)); |
| 403 | 403 |
| 404 // Cause the plugin's frame to be detached. | 404 // Cause the plugin's frame to be detached. |
| 405 webViewHelper.reset(); | 405 webViewHelper.reset(); |
| 406 | 406 |
| 407 EXPECT_FALSE(pluginContainerImpl->isRectTopmost(rect)); | 407 EXPECT_FALSE(pluginContainerImpl->isRectTopmost(rect)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 424 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. | 424 TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper
. |
| 425 FrameTestHelpers::WebViewHelper webViewHelper; | 425 FrameTestHelpers::WebViewHelper webViewHelper; |
| 426 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
ining_page.html", true, &pluginWebFrameClient); | 426 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
ining_page.html", true, &pluginWebFrameClient); |
| 427 ASSERT(webView); | 427 ASSERT(webView); |
| 428 webView->settings()->setPluginsEnabled(true); | 428 webView->settings()->setPluginsEnabled(true); |
| 429 webView->resize(WebSize(300, 300)); | 429 webView->resize(WebSize(300, 300)); |
| 430 webView->updateAllLifecyclePhases(); | 430 webView->updateAllLifecyclePhases(); |
| 431 runPendingTasks(); | 431 runPendingTasks(); |
| 432 | 432 |
| 433 WebElement pluginElement = webView->mainFrame()->firstChild()->document().ge
tElementById("translated-plugin"); | 433 WebElement pluginElement = webView->mainFrame()->firstChild()->document().ge
tElementById("translated-plugin"); |
| 434 RefPtrWillBeRawPtr<WebPluginContainerImpl> pluginContainerImpl = toWebPlugin
ContainerImpl(pluginElement.pluginContainer()); | 434 RawPtr<WebPluginContainerImpl> pluginContainerImpl = toWebPluginContainerImp
l(pluginElement.pluginContainer()); |
| 435 | 435 |
| 436 ASSERT(pluginContainerImpl.get()); | 436 ASSERT(pluginContainerImpl.get()); |
| 437 pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300)); | 437 pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300)); |
| 438 | 438 |
| 439 IntRect windowRect, clipRect, unobscuredRect; | 439 IntRect windowRect, clipRect, unobscuredRect; |
| 440 Vector<IntRect> cutOutRects; | 440 Vector<IntRect> cutOutRects; |
| 441 calculateGeometry(pluginContainerImpl.get(), windowRect, clipRect, unobscure
dRect, cutOutRects); | 441 calculateGeometry(pluginContainerImpl.get(), windowRect, clipRect, unobscure
dRect, cutOutRects); |
| 442 EXPECT_RECT_EQ(IntRect(10, 210, 300, 300), windowRect); | 442 EXPECT_RECT_EQ(IntRect(10, 210, 300, 300), windowRect); |
| 443 EXPECT_RECT_EQ(IntRect(0, 0, 240, 90), clipRect); | 443 EXPECT_RECT_EQ(IntRect(0, 0, 240, 90), clipRect); |
| 444 EXPECT_RECT_EQ(IntRect(0, 0, 240, 160), unobscuredRect); | 444 EXPECT_RECT_EQ(IntRect(0, 0, 240, 160), unobscuredRect); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); | 480 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("plugin_container.html")); |
| 481 TopmostPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHel
per. | 481 TopmostPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHel
per. |
| 482 FrameTestHelpers::WebViewHelper webViewHelper; | 482 FrameTestHelpers::WebViewHelper webViewHelper; |
| 483 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); | 483 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_conta
iner.html", true, &pluginWebFrameClient); |
| 484 ASSERT(webView); | 484 ASSERT(webView); |
| 485 webView->settings()->setPluginsEnabled(true); | 485 webView->settings()->setPluginsEnabled(true); |
| 486 webView->resize(WebSize(300, 300)); | 486 webView->resize(WebSize(300, 300)); |
| 487 webView->updateAllLifecyclePhases(); | 487 webView->updateAllLifecyclePhases(); |
| 488 runPendingTasks(); | 488 runPendingTasks(); |
| 489 | 489 |
| 490 RefPtrWillBeRawPtr<WebPluginContainerImpl> pluginContainerImpl = | 490 RawPtr<WebPluginContainerImpl> pluginContainerImpl = |
| 491 toWebPluginContainerImpl(getWebPluginContainer(webView, WebString::fromU
TF8("translated-plugin"))); | 491 toWebPluginContainerImpl(getWebPluginContainer(webView, WebString::fromU
TF8("translated-plugin"))); |
| 492 pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300)); | 492 pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300)); |
| 493 | 493 |
| 494 EXPECT_TRUE(pluginContainerImpl->isRectTopmost(topmostRect)); | 494 EXPECT_TRUE(pluginContainerImpl->isRectTopmost(topmostRect)); |
| 495 | 495 |
| 496 TopmostPlugin* testPlugin = static_cast<TopmostPlugin*>(pluginContainerImpl-
>plugin()); | 496 TopmostPlugin* testPlugin = static_cast<TopmostPlugin*>(pluginContainerImpl-
>plugin()); |
| 497 EXPECT_TRUE(testPlugin->isRectTopmost()); | 497 EXPECT_TRUE(testPlugin->isRectTopmost()); |
| 498 | 498 |
| 499 // Cause the plugin's frame to be detached. | 499 // Cause the plugin's frame to be detached. |
| 500 webViewHelper.reset(); | 500 webViewHelper.reset(); |
| 501 | 501 |
| 502 EXPECT_FALSE(pluginContainerImpl->isRectTopmost(topmostRect)); | 502 EXPECT_FALSE(pluginContainerImpl->isRectTopmost(topmostRect)); |
| 503 } | 503 } |
| 504 | 504 |
| 505 } // namespace blink | 505 } // namespace blink |
| OLD | NEW |