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

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

Issue 1414663011: Notifying the Out of Process Renderer about Visibility Change of a Remote Frame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased & Added Blink Unit Tests Created 5 years 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/WebFrameTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
index e184269b6ff3d3a7dc92713efd79da3282d356aa..e6146a701a22cec4f3add26273b6c3421847ad2c 100644
--- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
@@ -8357,4 +8357,61 @@ TEST_F(WebFrameTest, CallbackOrdering)
webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true, &client);
}
+class WebFrameVisibilityChangeTest : public WebFrameTest {
+public:
+ WebFrameVisibilityChangeTest()
+ {
+ registerMockedHttpURLLoad("visible_iframe.html");
+ registerMockedHttpURLLoad("single_iframe.html");
+ m_frame = m_webViewHelper.initializeAndLoad(m_baseURL + "single_iframe.html", true)->mainFrame();
+ m_webRemoteFrame = remoteFrameClient()->frame();
+ }
+
+ ~WebFrameVisibilityChangeTest()
+ {
+ m_webViewHelper.reset();
+ remoteFrame()->close();
+ }
+
+ void executeScriptOnMainFrame(const WebScriptSource& script)
+ {
+ mainFrame()->executeScript(script);
+ mainFrame()->view()->updateAllLifecyclePhases();
+ runPendingTasks();
+ }
+
+ void swapLocalFrameToRemoteFrame()
+ {
+ mainFrame()->lastChild()->swap(remoteFrame());
+ remoteFrame()->setReplicatedOrigin(SecurityOrigin::createUnique());
+ }
+
+ WebFrame* mainFrame() { return m_frame; }
+ WebRemoteFrameImpl* remoteFrame() { return m_webRemoteFrame; }
+ FrameTestHelpers::TestWebRemoteFrameClient* remoteFrameClient() { return &m_remoteFrameClient; }
+
+private:
+ FrameTestHelpers::TestWebRemoteFrameClient m_remoteFrameClient;
+ FrameTestHelpers::WebViewHelper m_webViewHelper;
+ WebFrame* m_frame;
+ WebRemoteFrameImpl* m_webRemoteFrame;
+};
+
+TEST_F(WebFrameVisibilityChangeTest, RemoteFrameVisibilityChange)
+{
+ swapLocalFrameToRemoteFrame();
+ executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').style.display = 'none';"));
+ EXPECT_FALSE(remoteFrameClient()->isVisible());
+
+ executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').style.display = 'block';"));
+ EXPECT_TRUE(remoteFrameClient()->isVisible());
+}
+
+TEST_F(WebFrameVisibilityChangeTest, RemoteFrameParentVisibilityChange)
+{
+ swapLocalFrameToRemoteFrame();
+ executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').parentElement.style.display = 'none';"));
+ EXPECT_FALSE(remoteFrameClient()->isVisible());
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698