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

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: Removed the Call to WebRemoteFrameImpl::close() and WebViewHelper::reset() in the Destructor of the … 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..bfa31c128d1b2c97fba6345abb765bd2c734e546 100644
--- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
@@ -8357,4 +8357,73 @@ TEST_F(WebFrameTest, CallbackOrdering)
webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true, &client);
}
+class TestWebRemoteFrameClientForVisibility : public FrameTestHelpers::TestWebRemoteFrameClient {
+public:
+ TestWebRemoteFrameClientForVisibility()
+ : m_visible(true)
+ {
+ }
+ void visibilityChanged(bool visible) override { m_visible = visible; }
+
+ bool isVisible() const { return m_visible; }
+
+private:
+ bool m_visible;
+};
+
+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()
+ {
+ }
+
+ 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; }
+ TestWebRemoteFrameClientForVisibility* remoteFrameClient() { return &m_remoteFrameClient; }
+
+private:
+ 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
« no previous file with comments | « third_party/WebKit/Source/web/RemoteFrameClientImpl.cpp ('k') | third_party/WebKit/public/web/WebRemoteFrameClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698