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

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: Rebase + Replied to dcheng@ Comments 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/WebFrameTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
index 6d006afeac74cad236faf2591d3840026383ad59..e95ce77a60bbd4de2e100a26cfe6ddc0b27a76fe 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::TestWebRemoteFrameClientForVisibility* remoteFrameClient() { return &m_remoteFrameClient; }
+
+private:
+ FrameTestHelpers::TestWebRemoteFrameClientForVisibility 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