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

Unified Diff: third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp

Issue 1567623007: Traverse into subdocuments when mapping plugin rects from absolute to local space. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp b/third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp
index 29aff42298915527e30d3d5a3dfe03607b0b85c1..4a8440ff47e6d0e4c930cc83ca1ada1b9d817f81 100644
--- a/third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp
@@ -72,6 +72,11 @@ public:
Platform::current()->unitTestSupport()->unregisterAllMockedURLs();
}
+ void calculateGeometry(WebPluginContainerImpl* pluginContainerImpl, IntRect& windowRect, IntRect& clipRect, IntRect& unobscuredRect, Vector<IntRect>& cutOutRects)
+ {
+ pluginContainerImpl->calculateGeometry(windowRect, clipRect, unobscuredRect, cutOutRects);
+ }
+
protected:
std::string m_baseURL;
};
@@ -402,6 +407,46 @@ TEST_F(WebPluginContainerTest, IsRectTopmostTest)
EXPECT_FALSE(pluginContainerImpl->isRectTopmost(rect));
}
+#define EXPECT_RECT_EQ(expected, actual) \
+ do { \
+ const IntRect& actualRect = actual; \
+ EXPECT_EQ(expected.x(), actualRect.x()); \
+ EXPECT_EQ(expected.y(), actualRect.y()); \
+ EXPECT_EQ(expected.width(), actualRect.width()); \
+ EXPECT_EQ(expected.height(), actualRect.height()); \
+ } while (false)
+
+TEST_F(WebPluginContainerTest, ClippedRectsForIframedElement)
+{
+ URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("plugin_container.html"));
+ URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("plugin_containing_page.html"));
+
+ TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper.
+ FrameTestHelpers::WebViewHelper webViewHelper;
+ WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_containing_page.html", true, &pluginWebFrameClient);
+ ASSERT(webView);
+ webView->settings()->setPluginsEnabled(true);
+ webView->resize(WebSize(300, 300));
+ webView->updateAllLifecyclePhases();
+ runPendingTasks();
+
+ WebElement pluginElement = webView->mainFrame()->firstChild()->document().getElementById("translated-plugin");
+ RefPtrWillBeRawPtr<WebPluginContainerImpl> pluginContainerImpl = toWebPluginContainerImpl(pluginElement.pluginContainer());
+
+ ASSERT(pluginContainerImpl.get());
+ pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300));
+
+ IntRect windowRect, clipRect, unobscuredRect;
+ Vector<IntRect> cutOutRects;
+ calculateGeometry(pluginContainerImpl.get(), windowRect, clipRect, unobscuredRect, cutOutRects);
+ EXPECT_RECT_EQ(IntRect(10, 210, 300, 300), windowRect);
+ EXPECT_RECT_EQ(IntRect(0, 0, 240, 90), clipRect);
+ EXPECT_RECT_EQ(IntRect(0, 0, 240, 160), unobscuredRect);
+
+ // Cause the plugin's frame to be detached.
+ webViewHelper.reset();
+}
+
TEST_F(WebPluginContainerTest, TopmostAfterDetachTest)
{
static WebRect topmostRect(10, 10, 40, 40);

Powered by Google App Engine
This is Rietveld 408576698