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

Unified Diff: content/browser/site_per_process_browsertest.cc

Issue 1991273003: Fire visibilityChange event on out-of-process iframes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 years, 6 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: content/browser/site_per_process_browsertest.cc
diff --git a/content/browser/site_per_process_browsertest.cc b/content/browser/site_per_process_browsertest.cc
index 242c0ecd167577af615d09c8a2b9d038e33b3dd8..2c2a4524521703b27b6a7f1c5fc4a81aa90d4fa8 100644
--- a/content/browser/site_per_process_browsertest.cc
+++ b/content/browser/site_per_process_browsertest.cc
@@ -7332,4 +7332,43 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, FileChooserInSubframe) {
EXPECT_EQ("bar", file_name);
}
+// Tests that an out-of-process iframe receives the visibilitychange event.
+IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, VisibilityChange) {
+ GURL main_url(embedded_test_server()->GetURL(
+ "a.com", "/cross_site_iframe_factory.html?a(b)"));
+ NavigateToURL(shell(), main_url);
+
+ FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
+ ->GetFrameTree()
+ ->root();
+
+ EXPECT_EQ(
+ " Site A ------------ proxies for B\n"
+ " +--Site B ------- proxies for A\n"
+ "Where A = http://a.com/\n"
+ " B = http://b.com/",
+ DepictFrameTree(root));
+
+ EXPECT_TRUE(ExecuteScript(
+ root->child_at(0)->current_frame_host(),
+ "var event_fired = 0;\n"
+ "document.addEventListener('visibilitychange',\n"
+ " function() { event_fired++; });\n"));
+
+ shell()->web_contents()->WasHidden();
+
+ int event_fired = 0;
+ EXPECT_TRUE(ExecuteScriptAndExtractInt(
+ root->child_at(0)->current_frame_host(),
+ "window.domAutomationController.send(event_fired);", &event_fired));
+ EXPECT_EQ(1, event_fired);
+
+ shell()->web_contents()->WasShown();
+
+ EXPECT_TRUE(ExecuteScriptAndExtractInt(
+ root->child_at(0)->current_frame_host(),
+ "window.domAutomationController.send(event_fired);", &event_fired));
+ EXPECT_EQ(2, event_fired);
+}
+
} // namespace content
« no previous file with comments | « content/browser/frame_host/render_frame_host_manager.cc ('k') | content/browser/web_contents/web_contents_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698